Example #1
0
        public List<Hre_ReportProfileWorkingEntity> GetReportProfileWorking(DateTime? DateFrom, DateTime? DateTo, string lstOrgOrderNumber, string codeEmp, string userLogin)
        {
            string status = string.Empty;
            List<Hre_ReportProfileWorkingEntity> lstReportProfileWorkingEntity = new List<Hre_ReportProfileWorkingEntity>();

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));

                var orgsService = new Cat_OrgStructureServices();
                var orgs = orgsService.GetDataNotParam<Cat_OrgStructure>(ConstantSql.hrm_cat_sp_get_AllOrg, userLogin, ref status).ToList();

                var empoyeeTypesServices = new Cat_EmployeeTypeServices();
                var empoyeeTypes = empoyeeTypesServices.GetDataNotParam<Cat_EmployeeTypeEntity>(ConstantSql.hrm_cat_sp_get_AllEmpType, userLogin, ref status).ToList();

                var postionsServices = new Cat_PositionServices();
                var postions = postionsServices.GetDataNotParam<Cat_PositionEntity>(ConstantSql.hrm_cat_sp_get_AllPosition, userLogin, ref status).ToList();

                var orgTypesServices = new Cat_OrgStructureTypeServices();
                var orgTypes = orgTypesServices.GetDataNotParam<Cat_OrgStructureType>(ConstantSql.hrm_cat_sp_get_AllOrgType, userLogin, ref status).ToList();

                var hrService = new Hre_ProfileServices();
                List<object> listObjHr = new List<object>();
                listObjHr.Add(lstOrgOrderNumber);
                listObjHr.Add(DateFrom);
                listObjHr.Add(DateTo);
                listObjHr.Add(codeEmp);
                var profiles = hrService.GetData<Hre_ProfileEntity>(listObjHr, ConstantSql.hrm_hr_sp_get_RptWorkingProfile, userLogin,ref status).ToList();

                foreach (var profile in profiles)
                {
                    Hre_ReportProfileWorkingEntity ReportProfileWorkingEntity = new Hre_ReportProfileWorkingEntity();
                    Guid? orgId = profile.OrgStructureID;
                    var org = orgs.FirstOrDefault(s => s.ID == profile.OrgStructureID);
                    var orgBranch = LibraryService.GetNearestParent(orgId, OrgUnit.E_BRANCH, orgs, orgTypes);
                    var orgOrg = LibraryService.GetNearestParent(orgId, OrgUnit.E_DEPARTMENT, orgs, orgTypes);
                    var orgTeam = LibraryService.GetNearestParent(orgId, OrgUnit.E_TEAM, orgs, orgTypes);
                    var orgSection = LibraryService.GetNearestParent(orgId, OrgUnit.E_SECTION, orgs, orgTypes);
                    ReportProfileWorkingEntity.CodeBranch = orgBranch != null ? orgBranch.Code : string.Empty;
                    ReportProfileWorkingEntity.CodeOrg = orgOrg != null ? orgOrg.Code : string.Empty;
                    ReportProfileWorkingEntity.CodeTeam = orgTeam != null ? orgTeam.Code : string.Empty;
                    ReportProfileWorkingEntity.CodeSection = orgSection != null ? orgSection.Code : string.Empty;
                    ReportProfileWorkingEntity.BranchName = orgBranch != null ? orgBranch.OrgStructureName : string.Empty;
                    ReportProfileWorkingEntity.OrgName = orgOrg != null ? orgOrg.OrgStructureName : string.Empty;
                    ReportProfileWorkingEntity.TeamName = orgTeam != null ? orgTeam.OrgStructureName : string.Empty;
                    ReportProfileWorkingEntity.SectionName = orgSection != null ? orgSection.OrgStructureName : string.Empty;
                    ReportProfileWorkingEntity.CodeEmp = profile.CodeEmp;
                    ReportProfileWorkingEntity.ProfileName = profile.ProfileName;
                    ReportProfileWorkingEntity.IDNo = profile.IDNo;
                    ReportProfileWorkingEntity.Gender = profile.Gender;
                    ReportProfileWorkingEntity.CodeAttendance = profile.CodeAttendance;
                    ReportProfileWorkingEntity.PAStreet = profile.PAddress;
                    ReportProfileWorkingEntity.DateHire = profile.DateHire;
                    var employeeType = empoyeeTypes.Where(s => profile.EmpTypeID == s.ID).FirstOrDefault();
                    if (employeeType != null)
                    {
                        ReportProfileWorkingEntity.EmployeeTypeName = employeeType.EmployeeTypeName;
                    }
                    var position = postions.Where(s => profile.PositionID == s.ID).FirstOrDefault();
                    if (position != null)
                    {
                        ReportProfileWorkingEntity.PositionName = position.PositionName;
                    }
                    lstReportProfileWorkingEntity.Add(ReportProfileWorkingEntity);
                }
                return lstReportProfileWorkingEntity;
            }
        }
Example #2
0
        public ActionResult GetReportProfileWorking([DataSourceRequest] DataSourceRequest request, Hre_ReportProfileWorkingModel Model)
        {
            #region Validate

            string message = string.Empty;
            var checkValidate = ValidatorService.OnValidateData<Hre_ReportProfileWorkingModel>(Model, "Hre_ReportProfileWorking", ref message);
            if (!checkValidate)
            {
                return Json(message);
            }

            #endregion

            var service = new Hre_ReportServices();
            var actionServices = new ActionService(UserLogin);

            DateTime From = SqlDateTime.MinValue.Value;
            DateTime To = SqlDateTime.MaxValue.Value;
            if (Model.DateFrom != null)
            {
                From = Model.DateFrom.Value;
            }
            if (Model.DateTo != null)
            {
                To = Model.DateTo.Value;
            }
            var isDataTable = false;
            object obj = new Hre_ReportProfileWorkingEntity();
            List<object> listObj = new List<object>();
            listObj.Add(Model.OrgStructureID);
            listObj.Add(Model.DateFrom);
            listObj.Add(Model.DateTo);
            listObj.Add(Model.CodeEmp);
            string status = string.Empty;
            var result = actionServices.GetData<Hre_ReportProfileWorkingEntity>(listObj, ConstantSql.hrm_hr_sp_get_RptWorkingProfile, ref status);

            if (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 = obj,
                    FileName = "Hre_ReportProfileWorkingEntity",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (Model.ExportID != Guid.Empty)
            {

                string[] valueField = null;
                if (Model.ValueFields != null)
                {
                    valueField = Model.ValueFields.Split(',');
                }
                var fullPath = ExportService.Export(Model.ExportID, result, null, Model.ExportType);

                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }