Пример #1
0
        private void RecursionOrgGetName(List<Cat_OrgStructure> lstOrgAll, Guid OrgCurrentID, Guid TypeDeparmentID, Guid TypeSectionID, Guid TypeBrandID, Guid TypeTeamID, OrgNameClass result)
        {

            var currentOrg = lstOrgAll.Where(m => m.ID == OrgCurrentID).FirstOrDefault();
            if (currentOrg == null)
                return;


            if (TypeDeparmentID != null && TypeDeparmentID != Guid.Empty && currentOrg.TypeID == TypeDeparmentID && result.DepartmentName == null)
            {
                result.DepartmentCode = currentOrg.Code;
                result.DepartmentName = currentOrg.OrgStructureName;
            }
            if (TypeSectionID != null && TypeSectionID != Guid.Empty && currentOrg.TypeID == TypeSectionID && result.SectionName == null)
            {
                result.SectionCode = currentOrg.Code;
                result.SectionName = currentOrg.OrgStructureName;
            }
            if (TypeBrandID != null && TypeBrandID != Guid.Empty && currentOrg.TypeID == TypeBrandID && result.BrandName == null)
            {
                result.BrandCode = currentOrg.Code;
                result.BrandName = currentOrg.OrgStructureName;
            }
            if (TypeTeamID != null && TypeTeamID != Guid.Empty && currentOrg.TypeID == TypeTeamID && result.TeamName == null)
            {
                result.TeamCode = currentOrg.Code;
                result.TeamName = currentOrg.OrgStructureName;
            }
            if (currentOrg.ParentID == null || currentOrg.ParentID == Guid.Empty)
            {
                return;
            }
            else
            {
                Guid ParentID = currentOrg.ParentID ?? Guid.Empty;
                RecursionOrgGetName(lstOrgAll, ParentID, TypeDeparmentID, TypeSectionID, TypeBrandID, TypeTeamID, result);
            }
        }
Пример #2
0
        public Dictionary<Guid, OrgNameClass> GetOrgFullLink(List<Guid> lstOrgIDs, List<Cat_OrgStructure> lstOrgStructure)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCat_NameEntity = new CustomBaseRepository<Cat_NameEntity>(unitOfWork);

                Dictionary<Guid, OrgNameClass> OrgNameAllLevel = new Dictionary<Guid, OrgNameClass>();
                string E_BRANCH = OrgUnit.E_BRANCH.ToString();
                string E_DEPARTMENT = OrgUnit.E_DEPARTMENT.ToString();
                string E_SECTION = OrgUnit.E_SECTION.ToString();
                string E_TEAM = OrgUnit.E_TEAM.ToString();
                var lstAllTypeStructure = repoCat_NameEntity.FindBy(m => m.EnumType == E_BRANCH
                    || m.EnumType == E_DEPARTMENT
                    || m.EnumType == E_SECTION
                    || m.EnumType == E_TEAM).Select(m => new { m.ID, m.EnumType }).ToList();
                Guid Type_BRANCH_ID = lstAllTypeStructure.Where(m => m.EnumType == E_BRANCH).Select(m => m.ID).FirstOrDefault();
                Guid Type_DEPARTMENT_ID = lstAllTypeStructure.Where(m => m.EnumType == E_DEPARTMENT).Select(m => m.ID).FirstOrDefault();
                Guid Type_SECTION_ID = lstAllTypeStructure.Where(m => m.EnumType == E_SECTION).Select(m => m.ID).FirstOrDefault();
                Guid Type_TEAM_ID = lstAllTypeStructure.Where(m => m.EnumType == E_TEAM).Select(m => m.ID).FirstOrDefault();


                foreach (var item in lstOrgIDs)
                {
                    OrgNameClass OrgNameLevel = new OrgNameClass();
                    RecursionOrgGetName(lstOrgStructure, item, Type_DEPARTMENT_ID, Type_SECTION_ID, Type_BRANCH_ID, Type_TEAM_ID, OrgNameLevel);
                    if (!OrgNameAllLevel.ContainsKey(item))
                        OrgNameAllLevel.Add(item, OrgNameLevel);
                }
                return OrgNameAllLevel;
            }
        }