Ejemplo n.º 1
0
        public ActionResult SaveResultInterviewImport([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            try
            {
                Rec_ImportInterviewResultService importService = new Rec_ImportInterviewResultService
                {
                    UserID = model.UserID,
                };

                if (importService.SaveInterviewResult())
                {
                    return Json(NotificationType.Success.ToString());
                }
                else
                {
                    return Json(NotificationType.Error.ToString());
                }
            }
            catch (Exception ex)
            {
                return Json(NotificationType.Error + "," + ex.GetBaseException());
            }
        }
Ejemplo n.º 2
0
        public ContentResult ImportResultInterview([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            var _fileName = Common.GetPath(Common.TemplateURL) + model.TemplateFile;
            _fileName = _fileName.Replace("/", "\\");

            Rec_ImportInterviewResultService importService = new Rec_ImportInterviewResultService
            {
                FileName = _fileName,
                UserID = model.UserID,

            };

            DataTable dataTableInvalid = new DataTable("InvalidData");
            DataTable dataTable = new DataTable("ImportData");

            try
            {
                importService.ImportInterviewResult();
                dataTable = importService.GetImportObject();
                dataTableInvalid = importService.GetInvalidObject();
            }
            catch (Exception ex)
            {
                model.Description = ex.Message;
            }

            var importConfigs = new Dictionary<string, Dictionary<string, object>>();

            foreach (DataColumn item in dataTable.Columns)
            {
                var displayField = importService.FieldMappings.Where(d => d.Value == item.ColumnName).Select(d => d.Key).FirstOrDefault();

                if (string.IsNullOrWhiteSpace(displayField) || importService.ListInvisibleField.Contains(item.ColumnName))
                {
                    var config = new Dictionary<string, object>();
                    config.Add("hidden", true);
                    importConfigs.Add(item.ColumnName, config);
                }
                else
                {
                    var config = new Dictionary<string, object>();
                    config.Add("title", displayField);
                    importConfigs.Add(item.ColumnName, config);
                }
            }

            model.ListImportData = dataTable.ConfigTable(importConfigs).ToDataSourceResult(request);
            model.ListInvalidData = dataTableInvalid.ConfigTable().ToDataSourceResult(request);

            var serializer = new JavaScriptSerializer();
            serializer.MaxJsonLength = Int32.MaxValue - 1;
            var result = new ContentResult();
            result.Content = serializer.Serialize(model);
            result.ContentType = "text/json";
            return result;
        }