sources/src/Monetco.Host/Controllers/SimulatorController.cs
/// <summary>
/// Export responses for current ID as json file
/// </summary>
/// <remarks>File name "export_"{id}".json". Encoding UTF-8.</remarks>
/// <param name="id">User ID from path</param>
/// <returns>Sheduled responses in json format</returns>
Export responses for current ID as json file
Export responses for current ID as json file
[HttpGet("{id}/export")]
        public FileResult Export([FromRoute]string id)
        {
            var list = _service.GetResponsesById(id);
            HttpContext.Response.ContentType = "application/json";
            List<byte> byteList = new List<byte>();
            var begin = Encoding.UTF8.GetBytes("[");
            byteList.AddRange(begin);
            if (list != null)
            {
                for (var i = 0; i < list.Count; i++)
                {
                    list[i].Content = null;
                    var bytes = Encoding.UTF8.GetBytes(list[i].ToJson());
                    byteList.AddRange(bytes);
                    if (i != list.Count - 1)
                    {
                        byteList.AddRange(Encoding.UTF8.GetBytes(","));
                    }
                }
            }
            var end = Encoding.UTF8.GetBytes("]");
            byteList.AddRange(end);
            FileContentResult results = new FileContentResult(byteList.ToArray(), "application/json")
            {
                FileDownloadName = "export_" + id + ".json"
            };
            return results;
        }
[ HttpGet ( " " ) ] public FileResult Export ( [ FromRoute ] string id ) { var list = _service . GetResponsesById ( id ) ; HttpContext . Response . ContentType = " " ; List < byte > byteList = new List < byte > ( ) ; var begin = Encoding . UTF8 . GetBytes ( " " ) ; byteList . AddRange ( begin ) ; if ( list != null ) { for ( var i = 0 ; i < list . Count ; i ++ ) { list [ i ] . Content = null ; var bytes = Encoding . UTF8 . GetBytes ( list [ i ] . ToJson ( ) ) ; byteList . AddRange ( bytes ) ; if ( i != list . Count - 1 ) { byteList . AddRange ( Encoding . UTF8 . GetBytes ( " " ) ) ; } } } var end = Encoding . UTF8 . GetBytes ( " " ) ; byteList . AddRange ( end ) ; FileContentResult results = new FileContentResult ( byteList . ToArray ( ) , " " ) { FileDownloadName = " " + id + " " } ; return results ; }
Export responses for current ID as json file
Export responses for current ID as json file
Sheduled responses in json format
Sheduled responses in json format
string
[FromRoute]
id
User ID from path
User ID from path
remarks
File name "export_"{id}".json". Encoding UTF-8.
File name " export_ " { id } " . json " . Encoding UTF - 8 .