Esempio n. 1
0
        public ActionResult Create(CatImportModel model)
        {

            var service = new RestServiceClient<CatImportModel>(UserLogin);
            service.SetCookies(this.Request.Cookies, _hrm_Hr_Service);
            var result = service.Post(_hrm_Hr_Service, "api/CatImport/", model);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
 /// <summary>
 /// [Tin.Nguyen] - Lấy dữ liệu Nhập Dữ Liệu(Cat_ImportItem) theo Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public CatImportModel GetById(Guid id)
 {
     string status = string.Empty;
     var model = new CatImportModel();
     ActionService service = new ActionService(UserLogin);
     var entity = service.GetByIdUseStore<Cat_ImportEntity>(id,ConstantSql.hrm_cat_sp_get_ImportById ,ref status);
     if (entity != null)
     {
         model = entity.CopyData<CatImportModel>();
     }
     model.ActionStatus = status;
     return model;
 }
Esempio n. 3
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());
            }
        }
Esempio n. 4
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;
        }
Esempio n. 5
0
        public ActionResult SaveImport([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            try
            {
                if (model.UserID != Guid.Empty && ListImportDataTemp != null
                    && ListImportDataTemp.ContainsKey(model.UserID))
                {
                    ImportService importService = new ImportService
                    {
                        UserID = model.UserID,
                        ImportTemplateID = model.ID,
                        DateTimeFormat = model.FormatDate,
                        ImportMode = model.ProcessDuplicateData == HRM.Infrastructure.Utilities.EnumDropDown.DuplicateData.E_INSERT.ToString() ?
                        ImportDataMode.Insert : model.ProcessDuplicateData == HRM.Infrastructure.Utilities.EnumDropDown.DuplicateData.E_UPDATE.ToString() ?
                        ImportDataMode.Update : ImportDataMode.Skip
                    };

                    importService.ProgressChanged += importService_ProgressChanged;

                    if (importService.Save(model.UserID, ListImportDataTemp[model.UserID], UserLogin))
                    {
                        ListImportDataTemp[model.UserID] = null;
                        ListImportDataTemp.Remove(model.UserID);
                        return Json(NotificationType.Success.ToString());
                    }
                    else
                    {
                        return Json(NotificationType.Error.ToString());
                    }
                }
                else
                {
                    return Json(NotificationType.Error.ToString());
                }
            }
            catch (Exception ex)
            {
                return Json(NotificationType.Error + "," + ex.GetExceptionMessage());
            }
        }
Esempio n. 6
0
        public ContentResult ProgessChanged([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            if (ListComputePercent != null && ListComputePercent.ContainsKey(model.UserID))
            {
                var arg = ListComputePercent[model.UserID];
                model.Percent = arg.Percent.ToString();
                model.ProcessName = arg.Name;
                model.ProcessNameView = arg.Value;
            }

            var serializer = new JavaScriptSerializer();
            serializer.MaxJsonLength = Int32.MaxValue - 1;
            var result = new ContentResult();
            result.Content = serializer.Serialize(model);
            result.ContentType = "text/json";
            return result;
        }
Esempio n. 7
0
        public ContentResult Import([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            var _fileName = Common.GetPath(Common.TemplateURL) + model.TemplateFile;
            _fileName = _fileName.Replace("/", "\\");

            ImportService importService = new ImportService
            {
                FileName = _fileName,
                UserID = model.UserID,
                ImportTemplateID = model.ID,
                DateTimeFormat = model.FormatDate,
                ImportMode = model.ProcessDuplicateData == HRM.Infrastructure.Utilities.EnumDropDown.DuplicateData.E_INSERT.ToString() ?
                ImportDataMode.Insert : model.ProcessDuplicateData == HRM.Infrastructure.Utilities.EnumDropDown.DuplicateData.E_UPDATE.ToString() ?
                ImportDataMode.Update : ImportDataMode.Skip
            };

            importService.ProgressChanged += importService_ProgressChanged;
            DataTable dataTableInvalid = new DataTable("InvalidData");
            DataTable dataTable = new DataTable("ImportData");

            string[] lstFieldInvalid = new string[] 
            { 
                "DataField", 
                "InvalidValue",
                "ExcelField", 
                "ExcelValue", 
                "ValueType", 
                "Desciption" 
            };

            try
            {
                importService.Import();
                dataTable = importService.ListImportData.Translate(importService.ListValueField.ToArray());
                dataTableInvalid = importService.ListInvalidData.Translate(lstFieldInvalid);

                if (model.UserID != Guid.Empty)
                {
                    if (ListImportDataTemp == null)
                    {
                        ListImportDataTemp = new Dictionary<Guid, IList>();
                    }

                    if (ListImportDataTemp.ContainsKey(model.UserID))
                    {
                        ListImportDataTemp[model.UserID] = importService.ListImportData;
                    }
                    else
                    {
                        ListImportDataTemp.Add(model.UserID, importService.ListImportData);
                    }

                    if (ListInvalidDataTemp == null)
                    {
                        ListInvalidDataTemp = new Dictionary<Guid, IList>();
                    }

                    if (ListInvalidDataTemp.ContainsKey(model.UserID))
                    {
                        ListInvalidDataTemp[model.UserID] = importService.ListInvalidData.Select(d => d.ImportData).Distinct().ToList();
                    }
                    else
                    {
                        ListInvalidDataTemp.Add(model.UserID, importService.ListInvalidData.Select(d => d.ImportData).Distinct().ToList());
                    }
                }
                else
                {
                    model.Description = "Người dùng ảo";
                }

                if (model.IsImportAndSave)
                {
                    if (importService.Save(model.UserID, importService.ListImportData, UserLogin))
                    {
                        model.Description = NotificationType.Success.ToString();
                    }
                    else
                    {
                        model.Description = NotificationType.Error.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                model.Description = ex.Message;
            }

            model.ListImportData = dataTable.ConfigTable().ToDataSourceResult(request);
            model.ListInvalidData = dataTableInvalid.ConfigTable().ToDataSourceResult(request);
            model.UrlInvalidFileName = ExportInvalidData(model.UserID, model.ID, importService);

            model.ListValueField = importService.ListValueField;
            model.ListDisplayField = lstFieldInvalid.ToList();

            var serializer = new JavaScriptSerializer();
            serializer.MaxJsonLength = Int32.MaxValue - 1;
            var result = new ContentResult();
            result.Content = serializer.Serialize(model);
            result.ContentType = "text/json";
            return result;
        }
Esempio n. 8
0
        public ActionResult ImportResultInterviewValidate(CatImportModel Model)
        {
            //if (ListComputePercent != null && ListComputePercent.ContainsKey(Model.UserID))
            //{
            //    ListComputePercent.Remove(Model.UserID);
            //}

            //#region Validate
            string message = string.Empty;
            //var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<CatImportModel>(Model, "Cat_Import_List", ref message);
            //if (!checkValidate)
            //{
            //    var ls = new object[] { "error", message };
            //    return Json(ls);
            //}
            //#endregion

            return Json(message);
        }
Esempio n. 9
0
        public JsonResult SaveChangeClass([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            var services = new Tra_TraineeServices();
            List<ImportTraineeEntity> lstTrainee = new List<ImportTraineeEntity>();
            List<Tra_TraineeChangeClassEntity> lstTraineeTranslate = new List<Tra_TraineeChangeClassEntity>();
            List<Tra_TraineeScoreImport> DataError = new List<Tra_TraineeScoreImport>();
            var _fileName = Common.GetPath(Common.TemplateURL) + model.TemplateFile;
            _fileName = _fileName.Replace("/", "\\");
            ImportService = new ImportService
            {
                FileName = _fileName,
                DateTimeFormat = model.FormatDate,
                ImportTemplateID = model.ID,
            };
            try
            {

                var table = ImportService.ImportNew(_fileName, model.TemplateFile, model.ID);

                lstTrainee = table.Translate<ImportTraineeEntity>();
                foreach (var item in lstTrainee)
                {
                    var entity = new Tra_TraineeChangeClassEntity
                    {
                        CodeEmp = item.Column2,
                        ClassOldCode = item.Column3,
                        ClassNewCode = item.Column4
                    };
                    lstTraineeTranslate.Add(entity);
                }
                var message = services.ImportChangeClass(lstTraineeTranslate,UserLogin);
                if (message == NotificationType.Success.ToString())
                {
                    return Json(message, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                model.Description = ex.Message;
            }
            return Json(DataError.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
Esempio n. 10
0
        public JsonResult ImportTrainee([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            var services = new Tra_TraineeServices();
            List<Tra_TraineeScoreImport> lstTraineeScore = new List<Tra_TraineeScoreImport>();
            List<Tra_TraineeScoreImport> DataError = new List<Tra_TraineeScoreImport>();
            List<ImportTraineeEntity> lstTrainee = new List<ImportTraineeEntity>();
            List<ImportTraineeEntity> lstTraineeTranslate = new List<ImportTraineeEntity>();

            var _fileName = Common.GetPath(Common.TemplateURL) + model.TemplateFile;
            _fileName = _fileName.Replace("/", "\\");
            ImportService = new ImportService
            {
                //FileName = Common.GetPath(model.TemplateFile),
                FileName = _fileName,
                DateTimeFormat = model.FormatDate,
                ImportTemplateID = model.ID,

            };

            try
            {

                var table = ImportService.ImportNew(_fileName, model.TemplateFile, model.ID);

                lstTrainee = table.Translate<ImportTraineeEntity>();

                foreach (var item in lstTrainee)
                {
                    var entity = new ImportTraineeEntity
                    {
                        CodeEmp = item.Column2,
                        ClassCode = item.Column3,
                        RequirementCode = item.Column4,
                        Status = item.Column5
                    };
                    lstTraineeTranslate.Add(entity);
                }

                var lstEntity = services.GetListTrainee(lstTraineeTranslate,UserLogin);
                if (lstEntity.Count > 0)
                {
                    return Json(lstEntity.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                model.Description = ex.Message;
            }
            return Json(DataError.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
Esempio n. 11
0
        public JsonResult SaveImortScore([DataSourceRequest] DataSourceRequest request, CatImportModel model)
        {
            var services = new Tra_TraineeScoreServices();
            List<Tra_TraineeScoreImport> lstTraineeScore = new List<Tra_TraineeScoreImport>();
            List<Tra_TraineeScoreImport> lstTraineeScoreTranslate = new List<Tra_TraineeScoreImport>();
            List<Tra_TraineeScoreImport> DataError = new List<Tra_TraineeScoreImport>();
            var _fileName = Common.GetPath(Common.TemplateURL) + model.TemplateFile;
            _fileName = _fileName.Replace("/", "\\");
            ImportService = new ImportService
            {
                //FileName = Common.GetPath(model.TemplateFile),
                FileName = _fileName,
                DateTimeFormat = model.FormatDate,
                ImportTemplateID = model.ID,

            };

            try
            {

                var table = ImportService.ImportNew(_fileName, model.TemplateFile, model.ID);

                lstTraineeScore = table.Translate<Tra_TraineeScoreImport>();

                foreach (var item in lstTraineeScore)
                {
                    var entity = new Tra_TraineeScoreImport
                    {
                        ClassCode = item.Column2,
                        CodeEmp = item.Column3,
                        TopicCode = item.Column4,
                        TypeScore = item.Column5,
                        Score = item.Column6,
                        TypeError = item.Column7,
                    };
                    lstTraineeScoreTranslate.Add(entity);
                }

                var message = services.SaveListTraineeScore(lstTraineeScoreTranslate, out DataError);
                if (message == NotificationType.Success.ToString())
                {
                    return Json(message, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                model.Description = ex.Message;
            }
            return Json(DataError.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
Esempio n. 12
0
 public ActionResult ImportValidate(CatImportModel Model)
 {
     #region Validate
     string message = string.Empty;
     var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<CatImportModel>(Model, "Tra_Import_List", ref message);
     if (!checkValidate)
     {
         var ls = new object[] { "error", message };
         return Json(ls);
     }
     #endregion
     return Json(message);
 }