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

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_ReportEducationChartListModel(),
                    FileName = "Hre_ReportEducationChartList",
                    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_ReportEducationChartListModel>(Model, "Hre_ReportProfileNew", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }
            DateTime From = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            DateTime To = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);

            #endregion

            if (Model.DateFrom != null)
            {
                From = Model.DateFrom.Value;
            }
            if (Model.DateTo != null)
            {
                To = Model.DateTo.Value;
            }
            var service = new Hre_ReportServices();
            var actionServices = new ActionService(UserLogin);
            List<object> strOrgIDs = new List<object>();
            strOrgIDs.AddRange(new object[3]);
            strOrgIDs[0] = (object)Model.OrgStructureID;

            string status = string.Empty;
            List<Guid> lstProfileIDs = actionServices.GetData<Hre_ProfileIdEntity>(strOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).Select(s => s.ID).ToList();
            var result = service.GetReportEducationCharList(From, To, lstProfileIDs, Model.AppliedForThisPeriod).ToList().Translate<Hre_ReportEducationChartListModel>();

            if (Model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(Model.ExportID, result, Model.ExportType);

                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));
        }