Ejemplo n.º 1
0
 public ActionResult ReportWorkHistoryDeptValidate(Hre_ReportWorkHistoryDeptModel model)
 {
     string message = string.Empty;
     var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Hre_ReportWorkHistoryDeptModel>(model, "Hre_ReportWorkHistoryDeptValidate", ref message);
     if (!checkValidate)
     {
         var ls = new object[] { "error", message };
         return Json(ls);
     }
     return Json(message);
 }
Ejemplo n.º 2
0
        public ActionResult ExportWordReportWorkHistoryDeptByTemplate(List<Guid> selectedIds, string valueFields, Hre_ReportWorkHistoryDeptModel model)
        {
            DateTime DateStart = DateTime.Now;
            string messages = string.Empty;
            string dirpath = Common.GetPath(Common.DownloadURL); ;
            if (!Directory.Exists(dirpath))
                Directory.CreateDirectory(dirpath);

            var contractServices = new Hre_ReportWorkHistoryDeptModel();
            var baseService = new BaseService();
            var objs = new List<object>();
            string strIDs = string.Empty;
            foreach (var item in selectedIds)
            {
                strIDs += Common.DotNetToOracle(item.ToString()) + ",";
            }
            if (strIDs.IndexOf(",") > 0)
                strIDs = strIDs.Substring(0, strIDs.Length - 1);

            var actionServices = new ActionService(UserLogin);
            List<object> listObj = new List<object>();
            listObj.Add(strIDs);
            listObj.Add(model.DateFrom);
            listObj.Add(model.DateTo);
            string status = string.Empty;
            var lstReportWorkHistory = actionServices.GetData<Hre_ReportWorkHistoryDeptEntity>(listObj, ConstantSql.hrm_hr_sp_get_RptWorkHistoryDeptByids, ref status).ToList();
            if (lstReportWorkHistory == null)
                return null;
            int i = 0;
            var lstReportWorkHistoryID = lstReportWorkHistory.Select(s => s.ID).Distinct().ToList();
            String suffix = DateStart.ToString("_ddMMyyyyHHmmss");
            string folferPath = string.Empty;
            string folderName = "ExportHre_Contract" + suffix;
            if (lstReportWorkHistory.Count > 1)
            {
                folferPath = dirpath + "/" + folderName;
                Directory.CreateDirectory(folferPath);
            }
            else
            {
                folferPath = dirpath;
            }
            var fileDoc = string.Empty;
            foreach (var ReportWorkHistory in lstReportWorkHistory)
            {
                ActionService service = new ActionService(UserLogin);
                var exportService = new Cat_ExportServices();
                Cat_ExportEntity template = null;
                string outputPath = string.Empty;
                List<object> lstObjExport = new List<object>();
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(null);
                lstObjExport.Add(1);
                lstObjExport.Add(10000000);
                template = actionServices.GetData<Cat_ExportEntity>(lstObjExport, ConstantSql.hrm_cat_sp_get_ExportWord, ref status).Where(s => s.ScreenName == valueFields).FirstOrDefault();
                if (template == null)
                {
                    messages = "Error";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }

                string templatepath = Common.GetPath(Common.TemplateURL + template.TemplateFile);

                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                outputPath = folferPath + "/" + Common.ChuyenTVKhongDau(ReportWorkHistory.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                fileDoc = NotificationType.Success.ToString() + "," + Common.DownloadURL + "/" + Common.ChuyenTVKhongDau(ReportWorkHistory.ProfileName) + suffix + i.ToString() + "_" + template.TemplateFile;
                if (!System.IO.File.Exists(templatepath))
                {
                    messages = "NotTemplate";
                    return Json(messages, JsonRequestBehavior.AllowGet);
                }
                var lst = new List<Hre_ReportWorkHistoryDeptEntity>();
                lst.Add(ReportWorkHistory);
                ExportService.ExportWord(outputPath, templatepath, lst);
            }
            if (lstReportWorkHistory.Count > 1)
            {
                var fileZip = Common.MultiExport("", true, folderName);
                return Json(fileZip);
            }
            return Json(fileDoc);
        }
Ejemplo n.º 3
0
        public ActionResult GetReportWorkHistoryDept([DataSourceRequest] DataSourceRequest request, Hre_ReportWorkHistoryDeptModel Model)
        {
            #region Validate
            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Hre_ReportWorkHistoryDeptModel>(Model, "Hre_ReportWorkHistoryDept", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }

            #endregion

            var actionServices = new ActionService(UserLogin);
            var profileServices = new Hre_ProfileServices();
            var rptServices = new Hre_ReportServices();
            List<object> listObj = new List<object>();
            listObj.Add(Model.DateFrom);
            listObj.Add(Model.DateTo);
            listObj.Add(Model.ProfileName);
            listObj.Add(Model.CodeEmp);
            listObj.Add(Model.JobTitleID);
            listObj.Add(Model.PositionID);
            listObj.Add(Model.OrgStructureIDs);
            listObj.Add(Model.TypeOfTransferID);
            listObj.Add(Model.SalaryClassID);
            listObj.Add(Model.WorkPlaceID);
            listObj.Add(Model.Status);
            listObj.Add(1);
            listObj.Add(int.MaxValue - 1);
            string status = string.Empty;
            var result = actionServices.GetData<Hre_ReportWorkHistoryDeptEntity>(listObj, ConstantSql.hrm_hr_sp_get_RptWorkHistoryDept, ref status).ToList().Translate<Hre_ReportWorkHistoryDeptModel>();
            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 };
            HeaderInfo headerInfo3 = new HeaderInfo() { Name = "WorkPlaceName", Value = ((result != null && result.FirstOrDefault() != null) && result.FirstOrDefault().WorkPlaceName != null) ? result.FirstOrDefault().WorkPlaceName : "" };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2, headerInfo3 };
            if (Model != null && Model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_ReportWorkHistoryDeptModel(),
                    FileName = "Hre_ReportWorkHistoryDept",
                    OutPutPath = path,
                    HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = false
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }
            bool isgroup = profileServices.IsGroupByOrgProfileQuit();
            if (isgroup == true)
            {
                List<Hre_ReportWorkHistoryDeptModel> resultNew = new List<Hre_ReportWorkHistoryDeptModel>();
                if (result.Count > 0)
                {
                    var orgServices = new Cat_OrgStructureServices();
                    var lstObjOrg = new List<object>();
                    lstObjOrg.Add(null);
                    lstObjOrg.Add(null);
                    lstObjOrg.Add(null);
                    lstObjOrg.Add(1);
                    lstObjOrg.Add(int.MaxValue - 1);
                    var lstOrg = actionServices.GetData<Cat_OrgStructureEntity>(lstObjOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, ref status).ToList();

                    var orgTypeService = new Cat_OrgStructureTypeServices();
                    var lstObjOrgType = new List<object>();
                    lstObjOrgType.Add(null);
                    lstObjOrgType.Add(null);
                    lstObjOrgType.Add(1);
                    lstObjOrgType.Add(int.MaxValue - 1);
                    var lstOrgType = actionServices.GetData<Cat_OrgStructureTypeEntity>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, ref status).ToList();

                    foreach (var item in result)
                    {
                        var orgName = new List<string>();
                        if (item.OrgStructureID != null)
                        {
                            orgName = rptServices.GetParentOrgName(lstOrg, lstOrgType, item.OrgStructureID);
                            if (orgName.Count < 3)
                            {
                                orgName.Insert(0, string.Empty);
                                if (orgName.Count < 3)
                                {
                                    orgName.Insert(0, string.Empty);
                                }
                            }
                        }
                        if (orgName.Count > 0)
                        {
                            item.Channel = orgName[2];
                            item.Region = orgName[1];
                            item.Area = orgName[0];
                        }
                        resultNew.Add(item);
                    }
                }
                if (Model.ExportID != Guid.Empty)
                {
                    var fullPath = ExportService.Export(Model.ExportID, resultNew, listHeaderInfo, Model.ExportType);

                    return Json(fullPath);
                }

                return Json(resultNew.ToDataSourceResult(request));
            }

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

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