Ejemplo n.º 1
0
        public IActionResult EvaluateImportEntityRecordsFromCsv(string entityName, [FromBody]JObject postObject)
        {
            ImportExportManager ieManager = new ImportExportManager(this.hooksService);
            ResponseModel response = ieManager.EvaluateImportEntityRecordsFromCsv(entityName, postObject, controller: this);

            return DoResponse(response);
        }
Ejemplo n.º 2
0
        public IActionResult ExportListRecordsToCsv(string entityName, string listName, int count = 10)
        {
            var random = new Random().Next(10, 99);
            DateTime dt = DateTime.Now;
            string time = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Second.ToString() + dt.Millisecond.ToString();
            string fileName = $"{entityName.Replace('_', '-').Trim().ToLowerInvariant()}-{time}{random}.csv"; //"goro-test-report.csv";

            Response.ContentType = "application/octet-stream;charset=utf-8";
            Response.Headers.Add("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
            //Response.Headers.Add("Content-Length", fileResp.ContentLength.ToString());

            Dictionary<string, string> urlQueries = new Dictionary<string, string>();
            if (Request.Query.Count > 0)
            {
                foreach (var query in Request.Query)
                {
                    if (query.Key != "count")
                        urlQueries.Add(query.Key, query.Value);
                }
            }

            ImportExportManager ieManager = new ImportExportManager(this.hooksService);
            ResponseModel response = ieManager.ExportListRecordsToCsv(entityName, listName, Response.Body, urlQueries, count);

            Response.Body.Close();

            if (!response.Success)
                return DoResponse(response);

            return new EmptyResult();
        }
Ejemplo n.º 3
0
        public IActionResult ImportEntityRecordsFromCsv(string entityName, [FromBody]JObject postObject)
        {
            string fileTempPath = "";

            if (!postObject.IsNullOrEmpty() && postObject.Properties().Any(p => p.Name == "fileTempPath"))
            {
                fileTempPath = postObject["fileTempPath"].ToString();
            }

            ImportExportManager ieManager = new ImportExportManager(this.hooksService);
            ResponseModel response = ieManager.ImportEntityRecordsFromCsv(entityName, fileTempPath);

            return DoResponse(response);
        }