Ejemplo n.º 1
0
        public ActionResult GetReportProfileInformationMoment([DataSourceRequest] DataSourceRequest request, Hre_ReportGeneralSearchModel model)
        {
            #region Validate
            string message = string.Empty;
            //Do BC chỉ sd tìm kiếm 1 ngày
            model.DateEnd = DateTime.Now;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ReportGeneralSearchModel>(model, "Hre_ReportGeneral", ref message);
            if (!checkValidate)
            {
                var ls = new object[] { "error", message };
                return Json(ls);
            }
            #endregion

            var Services = new Hre_ReportServices();
            var actionService = new ActionService(UserLogin);

            #region Getdata
            string status = string.Empty;
            List<Hre_ProfileEntity> listProfileByOrg = new List<Hre_ProfileEntity>();
            if (!model.IsCreateTemplate)
            {
                //Lọc theo phòng ban
                List<object> listObj = new List<object>();
                listObj.Add(model.OrgStructureID);
                listObj.Add(model.ProfileName);
                listObj.Add(model.CodeEmp);
                listProfileByOrg = actionService.GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status);
            }
            #endregion

            string NameTable = "ReportProfileInformationMoment";
            DataTable Table = Services.GetReportProfileInformationMoment(listProfileByOrg, (DateTime)model.DateStart, model.IsCreateTemplate, NameTable, model.WorkPlaceID, model.SalaryClassID);

            #region Xử lý cách export mới
            var isDataTable = false;
            DataTable obj = null;
            if (model.IsCreateTemplateForDynamicGrid)
            {
                var col = Table.Columns.Count;
                Table.Columns.RemoveAt(col - 1);
                obj = Table;
                isDataTable = true;
            }
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateStart", Value = model.DateStart };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateEnd", Value = model.DateEnd };
            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 = obj,
                    FileName = NameTable,
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, Table, listHeaderInfo, ExportFileType.Excel);
                return Json(fullPath);
            }
            #endregion

            return new JsonResult() { Data = Table.ToDataSourceResult(request), MaxJsonLength = Int32.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
Ejemplo n.º 2
0
        public ActionResult GetReportProfileInformation([DataSourceRequest] DataSourceRequest request, Hre_ReportGeneralSearchModel model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ReportGeneralSearchModel>(model, "Hre_ReportGeneral", ref message);
            if (!checkValidate)
            {
                var ls = new object[] { "error", message };
                return Json(ls);
            }
            #endregion

            Hre_ReportServices Services = new Hre_ReportServices();
            string NameTable = "ReportProfileInformation";
            List<Guid> listOrgID = new List<Guid>();

            if (model.OrgStructureID != null)
            {
                listOrgID = model.OrgStructureID.StringToList();
            }

            DataTable Table = Services.GetReportProfileInformation(listOrgID, (DateTime)model.DateStart,
                (DateTime)model.DateEnd, model.CodeEmp, model.ProfileName, model.IsCreateTemplate, NameTable, UserLogin);



            #region Xử lý cách export mới
            var isDataTable = false;
            DataTable obj = null;
            if (model.IsCreateTemplateForDynamicGrid)
            {
                var col = Table.Columns.Count;
                Table.Columns.RemoveAt(col - 1);
                obj = Table;
                isDataTable = true;
            }
            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateStart", Value = model.DateStart };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateEnd", Value = model.DateEnd };
            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 = obj,
                    FileName = NameTable,
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportID != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportID, Table, listHeaderInfo, ExportFileType.Excel);
                return Json(fullPath);
            }
            #endregion

            return new JsonResult() { Data = Table.ToDataSourceResult(request), MaxJsonLength = Int32.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }