Ejemplo n.º 1
0
        public ActionResult GetReportKaizenAccumulate([DataSourceRequest] DataSourceRequest request, Kai_ReportKaizenDetailModel model)
        {
            string status = string.Empty;
            var service = new Hre_ReportServices();
            var actionService = new ActionService(UserLogin);
            #region Validate
            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 };
            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Kai_ReportKaizenDetailModel>(model, "Kai_ReportKaizenDetail", ref message);
            if (!checkValidate)
            {
                var ls = new object[] { "error", message };
                return Json(ls);
            }

            #endregion
            List<object> listObj = new List<object>();
            listObj.Add(model.OrgStructureID);
            listObj.Add(model.DateFrom);
            listObj.Add(model.DateTo);
            List<Kai_ReportKaizenDetailEntity> lstKaizenDetailEntity = actionService.GetData<Kai_ReportKaizenDetailEntity>(listObj, ConstantSql.hrm_sal_sp_get_RptKaizenDataAccumulate, ref status);
            var result = service.GetReportKaizenAccumulate(lstKaizenDetailEntity, model.DateFrom, model.DateTo, model.RateDetail, model.IsCreateTemplate);
            var isDataTable = false;
            object obj = new DataTable();
            if (model.IsCreateTemplateForDynamicGrid)
            {
                var col = result.Columns.Count;
                result.Columns.RemoveAt(col - 1);
                obj = result;
                isDataTable = true;
            }
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Kai_ReportKaizenDetailEntity",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable,
                    HeaderInfo = listHeaderInfo,
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, result, listHeaderInfo, model.ExportType);
                return Json(fullPath);
            }
            return new JsonResult() { Data = result.ToDataSourceResult(request), MaxJsonLength = int.MaxValue };
        }
Ejemplo n.º 2
0
        public ActionResult GetReportKaizenMonthly([DataSourceRequest] DataSourceRequest request, Kai_ReportKaizenDetailModel Model)
        {
            string status = string.Empty;
            var actionService = new ActionService(UserLogin);
            var isDataTable = false;
            object obj = new Kai_ReportKaizenDetailModel();

            #region Validate
            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Kai_ReportKaizenDetailModel>(Model, "Kai_ReportCTKaizenDataMonthly", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }

            #endregion
            List<object> listObj = new List<object>();
            listObj.Add(Model.OrgStructureID);
            listObj.Add(null);
            listObj.Add(null);
            listObj.Add(null);
            listObj.Add(null);
            var result = actionService.GetData<Kai_ReportKaizenDetailEntity>(listObj, ConstantSql.hrm_sal_sp_get_RptKaizenDataDetail, ref status).Where(s => s.MonthReport != null && s.YearReport != null && s.MonthReport == Model.DateFrom.Value.Month && s.YearReport == Model.DateFrom.Value.Year && (s.IsPaymentOut == false || s.IsPaymentOut == null)).ToList().Translate<Kai_ReportKaizenDetailModel>();

            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.IsCreateTemplateForDynamicGrid)
            {
                obj = result;
                isDataTable = true;
            }
            if (Model != null && Model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Kai_ReportKaizenDetailModel(),
                    FileName = "Kai_ReportKaizenDetail",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            if (Model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(Model.ExportID, result, listHeaderInfo, Model.ExportType);

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