Exemple #1
0
        public ActionResult GetReportSumaryHDTProfile([DataSourceRequest] DataSourceRequest request, Hre_ReportSumaryHDTProfileModel Model)
        {
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateStart", Value = Model.DateFrom ?? DateTime.Now };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateEnd", Value = 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_ReportSumaryHDTProfileModel(),
                    FileName = "Hre_ReportSumaryHDTProfile",
                    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_ReportSumaryHDTProfileModel>(Model, "Hre_ReportSumaryHDTProfile", ref message);
            if (!checkValidate)
            {
                var ls = new object[] { "error", message };
                return Json(ls);
            }
            #endregion
            var ReportServices = new Hre_ReportServices();
            var result = ReportServices.GetReportSumaryHDTProfile(
                Model.DateFrom,
                Model.DateTo,
                Model.HDTJobGroupID,
                Model.CodeEmp, UserLogin).Translate<Hre_ReportSumaryHDTProfileModel>();

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

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