示例#1
0
        public ActionResult GetReportSeniority([DataSourceRequest] DataSourceRequest request, Hre_ReportSeniorityModel Model)
        {
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = Model.DateSeniority != null ? Model.DateSeniority.Value : DateTime.Now };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1 };
            if (Model != null && Model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_ReportSeniorityModel(),
                    FileName = "Hre_ReportSeniority",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            #region Validate

            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Hre_ReportSeniorityModel>(Model, "Hre_ReportSeniority", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }

            #endregion
            var service = new Hre_ReportServices();
            var actionServices = new ActionService(UserLogin);

            DateTime DateSeniority = DateTime.Now;
            List<Guid?> OrgIds = new List<Guid?>();
            if (Model.DateSeniority != null)
            {
                DateSeniority = Model.DateSeniority.Value;
            }

            string strOrgIDs = null;
            if (!string.IsNullOrEmpty(Model.OrgStructureID))
            {
                strOrgIDs = Model.OrgStructureID;
            }
            List<object> listObj = new List<object>();
            listObj.Add(strOrgIDs);
            listObj.Add(string.Empty);
            listObj.Add(string.Empty);

            string status = string.Empty;
            var listEntity = actionServices.GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, ref status).ToList();
            if (listEntity.Count == 0)
            {
                return Json(null);
            }
            var result = service.GetReportSeniority(DateSeniority, listEntity).ToList().Translate<Hre_ReportSeniorityModel>();

            if (Model.ExportID != Guid.Empty)
            {
                string[] valueField = null;
                if (Model.ValueFields != null)
                {
                    valueField = Model.ValueFields.Split(',');
                }
                var fullPath = ExportService.Export(Model.ExportID, result, listHeaderInfo, Model.ExportType);

                return Json(fullPath);
            }


            return Json(result.ToDataSourceResult(request));

        }