Example #1
0
        public ActionResult GetReportPayHDTJob([DataSourceRequest] DataSourceRequest request, Hre_ReportPayHDTJobModel Model)
        {
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = Model.DateFrom };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = Model.DateTo };
            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_ReportPayHDTJobModel(),
                    FileName = "Hre_ReportPayHDTJob",
                    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_ReportPayHDTJobModel>(Model, "Hre_ReportPayHDTJob", ref message);
            if (!checkValidate)
            {
                // var ls = new object[] { "error", message };
                return Json(message, JsonRequestBehavior.AllowGet);
            }
            #endregion
            var ReportServices = new Hre_ReportServices();
            var result = ReportServices.GetPayHDTJob(Model.DateFrom, Model.DateTo, Model.OrgStructureIDs, UserLogin).Translate<Hre_ReportPayHDTJobModel>();

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

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