Пример #1
0
 public ActionResult ExportDisciplineList([DataSourceRequest] DataSourceRequest request, Hre_DisciplineSearchModel model)
 {
     return ExportAllAndReturn<Hre_DisciplineEntity, Hre_DisciplineModel, Hre_DisciplineSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_Discipline);
 }
Пример #2
0
        public ActionResult ExportProfileDisciplineListByTemplate([DataSourceRequest] DataSourceRequest request, Hre_DisciplineSearchModel model)
        {
            var ActionService = new ActionService(UserLogin);
            string status = string.Empty;
            var isDataTable = false;
            object obj = new Hre_ProfileModel();
            var result = GetListData<Hre_DisciplineModel, Hre_DisciplineEntity, Hre_DisciplineSearchModel>(request, model, ConstantSql.hrm_hr_sp_get_Discipline, ref status);
            if (result != null && result.Count > 0)
            {
                #region lấy Org và OrgType

                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 = ActionService.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 = ActionService.GetData<Cat_OrgStructureTypeEntity>(lstObjOrgType, ConstantSql.hrm_cat_sp_get_OrgStructureType, ref status).ToList();
                #endregion

                foreach (var item in result)
                {
                    Guid? orgId = item.OrgStructureID1;
                    var org = lstOrg.FirstOrDefault(s => s.ID == item.OrgStructureID1);
                    var orgBranch = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_BRANCH, lstOrg, lstOrgType);
                    var orgGroup = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_GROUP, lstOrg, lstOrgType);
                    var orgOrg = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DEPARTMENT, lstOrg, lstOrgType);
                    var orgTeam = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_TEAM, lstOrg, lstOrgType);
                    var orgSection = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_SECTION, lstOrg, lstOrgType);
                    var orgDivision = LibraryService.GetNearestParentEntity(orgId, OrgUnit.E_DIVISION, lstOrg, lstOrgType);

                    item.BranchName = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
                    item.GroupName = orgGroup != null ? orgGroup.OrgStructureName : string.Empty;
                    item.DepartmentName = orgOrg != null ? orgOrg.OrgStructureName : string.Empty;
                    item.TeamName = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
                    item.SectionName = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                    item.DivisionName = orgDivision != null ? orgDivision.OrgStructureName : string.Empty;

                    item.DisciplineCount = result.Where(s => s.ProfileID == item.ProfileID).Count();
                }

            }
            //if (model.IsCreateTemplateForDynamicGrid)
            //{
            //    obj = result;
            //    isDataTable = false;
            //}
            if (model != null && model.IsCreateTemplate)
            {

                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Hre_DisciplineModel(),
                    FileName = "Hre_Discipline",
                    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, result, null, model.ExportType);
                return Json(fullPath);
            }

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