Esempio n. 1
0
        public List <OrganizationsStructuresBLL> GetParentOrganizationsManagers(int OrganizationID)
        {
            try
            {
                OrganizationsStructures    OrganizationStructure    = new OrganizationsStructuresDAL().GetByOrganizationID(OrganizationID);
                OrganizationsStructuresBLL OrganizationStructureBLL = new OrganizationsStructuresBLL();
                OrganizationStructureBLL.OrganizationName     = OrganizationStructure.OrganizationName;
                OrganizationStructureBLL.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(OrganizationID);
                OrganizationStructureBLL.OrganizationManager  = OrganizationStructure.EmployeesCodes != null ? new EmployeesCodesBLL()
                {
                    EmployeeCodeID = OrganizationStructure.EmployeesCodes.EmployeeCodeID,
                    EmployeeCodeNo = OrganizationStructure.EmployeesCodes.EmployeeCodeNo,
                    Employee       = new EmployeesBLL().MapEmployee(OrganizationStructure.EmployeesCodes.Employees)
                } : new EmployeesCodesBLL()
                {
                    Employee = new EmployeesBLL()
                };
                _OrganizationsStructuresList.Add(OrganizationStructureBLL);
                if (OrganizationStructure.ParentOrganization != null)
                {
                    GetParentOrganizationsManagers(OrganizationStructure.ParentOrganization.OrganizationID);
                }

                return(_OrganizationsStructuresList);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 2
0
        private void AddChildren(OrganizationsStructuresBLL OrgList, OrganizationsStructuresBLL Parent)
        {
            try
            {
                if (_OrgList == null)
                {
                    _OrgList = this.GetOrganizationStructure();
                }

                Parent.ChildOrganization = _OrgList.Where(x => x.ParentOrganization != null && x.ParentOrganization.OrganizationID.Equals(Parent.OrganizationID)).ToList();
                if (Parent.ChildOrganization != null)
                {
                    for (int i = 0; i < Parent.ChildOrganization.Count; i++)
                    {
                        AddChildren(OrgList, Parent.ChildOrganization[i]);
                    }
                }
                else
                {
                    Parent.ChildOrganization = new List <OrganizationsStructuresBLL>();
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 3
0
        public IQueryable <AssigngingsDTO> GetActualEmployeesBasedOnAssigningsAsRanksCategories(int OrganizationID)
        {
            try
            {
                List <int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID);

                // Get actual employees Based On Assignings by date
                List <vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList();

                var query = ActualEmployeesBasedOnAssignings.Select(y => new AssigngingsDTO(y.EmployeeCodeNo,
                                                                                            y.EmployeeNameAr,
                                                                                            y.OrganizationName,
                                                                                            y.JobName,
                                                                                            y.RankCategoryName,
                                                                                            y.RankName,
                                                                                            y.Sorting
                                                                                            ));


                return(query.AsQueryable());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
 internal OrganizationsStructuresBLL MapOrganizationWithoutManager(OrganizationsStructures OrganizationStructure)
 {
     try
     {
         OrganizationsStructuresBLL OrganizationStructuresBLL = null;
         if (OrganizationStructure != null)
         {
             OrganizationStructuresBLL = new OrganizationsStructuresBLL()
             {
                 CreatedDate        = OrganizationStructure.CreatedDate,
                 LastUpdatedDate    = OrganizationStructure.LastUpdatedDate,
                 OrganizationID     = OrganizationStructure.OrganizationID,
                 OrganizationCode   = OrganizationStructure.OrganizationCode,
                 OrganizationName   = OrganizationStructure.OrganizationName, //+ " - " + new BranchesBLL().MapBranch(OrganizationStructure.Branches).BranchName,
                 ShowInECM          = OrganizationStructure.ShowInECM.HasValue ? OrganizationStructure.ShowInECM.Value : false,
                 ParentOrganization = OrganizationStructure.ParentOrganization != null ? new OrganizationsStructuresBLL()
                 {
                     OrganizationID   = OrganizationStructure.ParentOrganization.OrganizationID,
                     OrganizationCode = OrganizationStructure.ParentOrganization.OrganizationCode,
                     OrganizationName = OrganizationStructure.ParentOrganization.OrganizationName,
                     Branch           = new BranchesBLL()
                     {
                         BranchName = OrganizationStructure.ParentOrganization.Branches.BranchName
                     }
                 } : null,
                 Branch = new BranchesBLL().MapBranch(OrganizationStructure.Branches),
             };
         }
         return(OrganizationStructuresBLL);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
        public List <EVacationsRequestsBLL> GetPendingEVacationsRequestsByAuthorizedPerson(string AuthorizedPersonCodeNo)
        {
            try
            {
                List <EServicesAuthorizationsBLL> OrganizationsList = new EServicesAuthorizationsBLL().GetBasedOnAuthorizedPerson(AuthorizedPersonCodeNo, EServicesTypesEnum.Vacation);
                List <int> OrganizationsIDs = new List <int>();
                OrganizationsList.ForEach(x => OrganizationsIDs.Add(x.Organization.OrganizationID));

                #region Get evacations requests of normal employees
                List <EVacationsRequests>    EVacationsRequestsList    = new EVacationsRequestsDAL().GetEVacationsRequestsByOrganizations(OrganizationsIDs).Where(x => x.EVacationRequestStatusID == (int)EVacationRequestStatusEnum.Pending).ToList();
                List <EVacationsRequestsBLL> EVacationsRequestsBLLList = new List <EVacationsRequestsBLL>();
                EVacationsRequestsList.ForEach(x => EVacationsRequestsBLLList.Add(MapEVacationRequest(x)));
                #endregion

                #region Get evacations requests of managers under him
                List <int> OrganizationIDList = new List <int>();
                new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(AuthorizedPersonCodeNo).ForEach(x => OrganizationIDList.Add(x.OrganizationID));
                //int? OrganizationID = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(AuthorizedPersonCodeNo).FirstOrDefault()?.OrganizationID;
                foreach (var OrganizationID in OrganizationIDList)
                {
                    List <int> ChildOrganizationIDs = new OrganizationsStructuresBLL().GetOrganizationFirstLevelByID(OrganizationID);
                    List <EVacationsRequests> ChildOrganizationIDEVacationsRequestsList = new EVacationsRequestsDAL().GetEVacationsRequestsByOrganizations(ChildOrganizationIDs).Where(x => x.EVacationRequestStatusID == (int)EVacationRequestStatusEnum.Pending &&
                                                                                                                                                                                       !x.ActualJobID.HasValue) // thats mean is manager
                                                                                          .ToList();
                    ChildOrganizationIDEVacationsRequestsList.ForEach(x => EVacationsRequestsBLLList.Add(MapEVacationRequest(x)));
                }
                #endregion

                return(EVacationsRequestsBLLList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
        public List <EServicesAuthorizationsBLL> GetFirstLevel(int OrganizationID, EServicesTypesEnum EServiceTypeID)
        {
            try
            {
                List <int> ChildOrganizationIDs = new OrganizationsStructuresBLL().GetOrganizationFirstLevelByID(OrganizationID); //new List<int>(); ChildOrganizationIDs.Add(1803); //
                List <EServicesAuthorizations>    EServiceAuthorizationList     = new EServicesAuthorizationsDAL().GetOrganizationsByOrganizationIDs(ChildOrganizationIDs, (int)EServiceTypeID);
                List <EServicesAuthorizationsBLL> EServicesAuthorizationBLLList = new List <EServicesAuthorizationsBLL>();

                foreach (var item in EServiceAuthorizationList)
                {
                    EServicesAuthorizationBLLList.Add(new EServicesAuthorizationsBLL()
                    {
                        EServiceAuthorizationID = item.EServiceAuthorizationID,
                        //AuthorizedPerson = new EmployeesCodesBLL()
                        //{
                        //    EmployeeCodeNo = item.AuthorizedPersonNav.EmployeeCodeNo,
                        //    Employee = new EmployeesBLL()
                        //    {
                        //        FirstNameAr = item.AuthorizedPersonNav.Employees.FirstNameAr,
                        //        MiddleNameAr = item.AuthorizedPersonNav.Employees.MiddleNameAr,
                        //        GrandFatherNameAr = item.AuthorizedPersonNav.Employees.GrandFatherNameAr,
                        //        LastNameAr = item.AuthorizedPersonNav.Employees.LastNameAr,
                        //    }
                        //},
                        //Organization = new OrganizationsStructuresBLL()
                        //{
                        //    OrganizationID = item.OrganizationsStructures.OrganizationID,
                        //    ParentOrganization = item.OrganizationsStructures.ParentOrganization == null ? null : new OrganizationsStructuresBLL()
                        //    {
                        //        OrganizationID = item.OrganizationsStructures.ParentOrganization.OrganizationID
                        //    },
                        //    OrganizationName = item.OrganizationsStructures.OrganizationName,
                        //    Branch = new BranchesBLL().MapBranch(item.OrganizationsStructures.Branches),
                        //    OrganizationManager = item.OrganizationsStructures.EmployeesCodes != null ? new EmployeesCodesBLL()
                        //    {
                        //        EmployeeCodeID = item.OrganizationsStructures.EmployeesCodes.EmployeeCodeID,
                        //        EmployeeCodeNo = item.OrganizationsStructures.EmployeesCodes.EmployeeCodeNo,
                        //        Employee = new EmployeesBLL()
                        //        {
                        //            FirstNameAr = item.OrganizationsStructures.EmployeesCodes.Employees.FirstNameAr,
                        //            MiddleNameAr = item.OrganizationsStructures.EmployeesCodes.Employees.MiddleNameAr,
                        //            GrandFatherNameAr = item.OrganizationsStructures.EmployeesCodes.Employees.GrandFatherNameAr,
                        //            LastNameAr = item.OrganizationsStructures.EmployeesCodes.Employees.LastNameAr,
                        //        },
                        //    } : null,
                        //},
                        AuthorizedPerson = new EmployeesCodesBLL().MapEmployeeCode(item.AuthorizedPersonNav),
                        Organization     = new OrganizationsStructuresBLL().MapOrganization(item.OrganizationsStructures),
                        EServiceType     = new EServicesTypesBLL().MapEServicesTypes(item.EServicesTypes)
                    });
                }

                return(EServicesAuthorizationBLLList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Task # 255: Changing the manager of any organization must affect on e services authorization module
        /// </summary>
        /// <param name="OrganizationID"></param>
        /// <param name="OldAuthorizedPersonCodeID"></param>
        /// <param name="NewAuthorizedPersonCodeID"></param>
        /// <returns></returns>
        internal Result ChangeAuthorizedPersonForAllChildByOrganizationID(int OrganizationID, int OldAuthorizedPersonCodeID, int NewAuthorizedPersonCodeID)
        {
            Result     result = null;
            List <int> ChildOrganizationIDs = new OrganizationsStructuresBLL().GetAllChildernByOrganizationID(OrganizationID);
            int        LastUpdatedBy        = this.LoginIdentity.EmployeeCodeID;

            new EServicesAuthorizationsDAL().ChangeAuthorizedPersonForAllChildByOrganizationID(ChildOrganizationIDs, OldAuthorizedPersonCodeID, NewAuthorizedPersonCodeID, LastUpdatedBy);

            result            = new Result();
            result.Entity     = null;
            result.EnumType   = typeof(EServicesAuthorizationsEnum);
            result.EnumMember = EServicesAuthorizationsEnum.Done.ToString();

            return(result);
        }
Esempio n. 8
0
        public Result SetAuthorizations(int EServiceTypeID, int LoginOrganizationID, int OrganizationID, int AuthorizedPersonCodeID)
        {
            Result result = null;

            // validate Login and Authority Organization
            if (LoginOrganizationID == OrganizationID)
            {
                result            = new Result();
                result.Entity     = null;
                result.EnumType   = typeof(EServicesAuthorizationsEnum);
                result.EnumMember = EServicesAuthorizationsEnum.RejectedBecauseLoginOrganizationIsSameAsAuthorization.ToString();

                return(result);
            }
            else if (AuthorizedPersonCodeID == 0)
            {
                result            = new Result();
                result.Entity     = null;
                result.EnumType   = typeof(EServicesAuthorizationsEnum);
                result.EnumMember = EServicesAuthorizationsEnum.RejectedBecauseThereIsNoManagerForThisOrganization.ToString();

                return(result);
            }

            EServicesAuthorizations LoginOrganizationAuth = new EServicesAuthorizationsDAL().GetByOrganizationID(LoginOrganizationID, EServiceTypeID);

            if (LoginOrganizationAuth.AuthorizedPersonCodeID != this.LoginIdentity.EmployeeCodeID)
            {
                result            = new Result();
                result.Entity     = null;
                result.EnumType   = typeof(EServicesAuthorizationsEnum);
                result.EnumMember = EServicesAuthorizationsEnum.RejectedBecauseOrganizationManagerIsNotAuthorized.ToString();

                return(result);
            }

            List <int> ChildOrganizationIDs = new OrganizationsStructuresBLL().GetAllChildernByOrganizationID(OrganizationID);
            int        LastUpdatedBy        = this.LoginIdentity.EmployeeCodeID;

            new EServicesAuthorizationsDAL().SetAuthorizations(EServiceTypeID, ChildOrganizationIDs, AuthorizedPersonCodeID, LastUpdatedBy);

            result            = new Result();
            result.Entity     = null;
            result.EnumType   = typeof(EServicesAuthorizationsEnum);
            result.EnumMember = EServicesAuthorizationsEnum.Done.ToString();

            return(result);
        }
Esempio n. 9
0
 public virtual List <OrganizationsStructuresBLL> GetByOrganizationIDWithhAllChilds(int OrganizationID)
 {
     try
     {
         List <OrganizationsStructuresBLL> AllOrgs = new OrganizationsStructuresBLL().GetOrganizationStructureWithFullName();
         List <OrganizationsStructuresBLL> orgs    = new List <OrganizationsStructuresBLL>();
         OrganizationsStructuresBLL        MainOrg = AllOrgs.FirstOrDefault(x => x.OrganizationID == OrganizationID);
         orgs.Add(MainOrg);
         AddChildren(AllOrgs, orgs, MainOrg.OrganizationID);
         return(orgs);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 10
0
        public IQueryable <EmployeesDelegationsBasedOnAssigngingsDTO> GetEmployeesDelegationsBasedOnAssigningsAsRanksCategories(int DelegationTypeID, DateTime FromDate, DateTime ToDate, int OrganizationID)
        {
            try
            {
                List <int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID);
                DateTime   FromDateGr          = Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(string.Format("{0}/{1}/{2}", FromDate.Day, FromDate.Month, FromDate.Year)), new CultureInfo("en-US"));
                DateTime   ToDateGr            = Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(string.Format("{0}/{1}/{2}", ToDate.Day, ToDate.Month, ToDate.Year)), new CultureInfo("en-US"));
                List <vwActualEmployeesBasedOnAssignings> ActualEmployeesHaveDelegations = new List <vwActualEmployeesBasedOnAssignings>();

                // Get actual employees Based On Assignings by date
                List <vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x =>
                                                                                                                                                            // (FromDateGr.Date >= x.AssigningStartDate.Date && FromDateGr.Date <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date))
                                                                                                                                                            (
                                                                                                                                                                (FromDateGr >= x.AssigningStartDate && FromDateGr <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) ||
                                                                                                                                                                (ToDate >= x.AssigningStartDate && ToDate <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) ||
                                                                                                                                                                (FromDateGr >= x.AssigningStartDate && ToDate <= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date)) ||
                                                                                                                                                                (FromDateGr <= x.AssigningStartDate && ToDate >= (!x.AssigningEndDate.HasValue ? DateTime.Now.Date : x.AssigningEndDate.Value.Date))
                                                                                                                                                            ) &&
                                                                                                                                                            OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList();
                List <int> EmployeeCareerHistoryIDs = new List <int>();
                ActualEmployeesBasedOnAssignings.ForEach(x => EmployeeCareerHistoryIDs.Add(x.EmployeeCareerHistoryID.Value));

                List <DelegationsDetails> EmployeesDelegationsOfActualEmployeesList = new DelegationsDetailsDAL().GetEmployeesDelegationsByDate(FromDateGr, DelegationTypeID, EmployeeCareerHistoryIDs);

                var query = EmployeesDelegationsOfActualEmployeesList.Select(y => new EmployeesDelegationsBasedOnAssigngingsDTO(y.EmployeesCareersHistory.EmployeesCodes.EmployeeCodeNo,
                                                                                                                                ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).EmployeeNameAr,
                                                                                                                                ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).OrganizationName,
                                                                                                                                ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).JobName,
                                                                                                                                ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).RankCategoryName,
                                                                                                                                ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).RankName,
                                                                                                                                y.Delegations.DelegationStartDate,
                                                                                                                                y.Delegations.DelegationEndDate,
                                                                                                                                y.Delegations.DelegationsTypes.DelegationTypeName,
                                                                                                                                ActualEmployeesBasedOnAssignings.FirstOrDefault(x => x.EmployeeCodeID == y.EmployeesCareersHistory.EmployeeCodeID).Sorting
                                                                                                                                ));

                return(query.AsQueryable());
            }
            catch
            {
                throw;
            }
        }
Esempio n. 11
0
 public virtual List <OrganizationsStructuresBLL> GetOrganizationStructureWithManagers()
 {
     try
     {
         List <OrganizationsStructures>    OrganizationsStructuresList   = new OrganizationsStructuresDAL().GetOrganizationStructure();
         List <OrganizationsStructuresBLL> OrganizationsStructureBLLList = new List <OrganizationsStructuresBLL>();
         foreach (var item in OrganizationsStructuresList)
         {
             OrganizationsStructuresBLL Org = new OrganizationsStructuresBLL();
             Org = MapOrganization(item);
             OrganizationsStructureBLLList.Add(Org);
         }
         return(OrganizationsStructureBLLList);
     }
     catch
     {
         throw;
     }
 }
Esempio n. 12
0
        //public List<ChartsAxis> GetQualificationsBasedOnAssigningsAsRanksCategories(int QualificationDegreeID, int QualificationID, int GeneralSpecializationID, int OrganizationID)
        //{
        //    try
        //    {
        //        List<int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID);

        //        // Get actual employees Based On Assignings by date
        //        List<vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList();

        //        List<int> EmployeesCodesIDs = new List<int>();
        //        ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesCodesIDs.Add(x.EmployeeCodeID));

        //        List<EmployeesQualificationsBLL> EmployeesQualificationsList = new EmployeesQualificationsBLL().GetEmployeesQualifications(EmployeesCodesIDs);

        //        List<EmployeesQualificationsBLL> EmployeesQualificationsOfActualEmployeesList = new List<EmployeesQualificationsBLL>();

        //        ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesQualificationsOfActualEmployeesList.Add(new EmployeesQualificationsBLL().GetLastEmployeeQualification(EmployeesQualificationsList, x.EmployeeCodeID)));

        //        EmployeesQualificationsOfActualEmployeesList = EmployeesQualificationsOfActualEmployeesList.Where(x => x.QualificationDegree.QualificationDegreeID == QualificationDegreeID
        //                                                                                                            && (QualificationID != 0 ? x.Qualification.QualificationID == QualificationID : x.Qualification.QualificationID == x.Qualification.QualificationID)
        //                                                                                                            && (GeneralSpecializationID != 0 ? x.GeneralSpecialization.GeneralSpecializationID == GeneralSpecializationID : x.GeneralSpecialization.GeneralSpecializationID == x.GeneralSpecialization.GeneralSpecializationID)).ToList();

        //        ActualEmployeesBasedOnAssignings.RemoveAll(x => !EmployeesQualificationsOfActualEmployeesList.Any(y => y.EmployeeCode.EmployeeCodeID == x.EmployeeCodeID));

        //        var query = ActualEmployeesBasedOnAssignings.GroupBy(x => x.RankCategoryName)
        //                                                    .Select(y => new
        //                                                    {
        //                                                        RankCategoryName = y.Key,
        //                                                        RecordCount = y.Count()
        //                                                    }).ToList();

        //        List<ChartsAxis> ChartAxisList = new List<ChartsAxis>();
        //        foreach (var item in query)
        //            ChartAxisList.Add(new ChartsAxis { KeyName = item.RankCategoryName, Value = item.RecordCount });

        //        return ChartAxisList;
        //    }
        //    catch
        //    {
        //        throw;
        //    }
        //}

        public IQueryable <EmployeesQualificationBasedOnAssigngingsDTO> GetQualificationsBasedOnAssigningsAsRanksCategoriesDetails(int QualificationDegreeID, int QualificationID, int GeneralSpecializationID, int OrganizationID)
        {
            try
            {
                List <int> OrganizationIDsList = new OrganizationsStructuresBLL().GetByOrganizationIDsWithhAllChilds(OrganizationID);

                // Get actual employees Based On Assignings by date
                List <vwActualEmployeesBasedOnAssignings> ActualEmployeesBasedOnAssignings = new AssigningsDAL().GetActualEmployeeBasedOnAssignings().Where(x => OrganizationIDsList.Contains(x.OrganizationID.Value)).ToList();

                List <int> EmployeesCodesIDs = new List <int>();
                ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesCodesIDs.Add(x.EmployeeCodeID));

                List <EmployeesQualificationsBLL> EmployeesQualificationsList = new EmployeesQualificationsBLL().GetEmployeesQualifications(EmployeesCodesIDs);

                List <EmployeesQualificationsBLL> EmployeesQualificationsOfActualEmployeesList = new List <EmployeesQualificationsBLL>();

                ActualEmployeesBasedOnAssignings.ForEach(x => EmployeesQualificationsOfActualEmployeesList.Add(new EmployeesQualificationsBLL().GetLastEmployeeQualification(EmployeesQualificationsList, x.EmployeeCodeID)));

                EmployeesQualificationsOfActualEmployeesList = EmployeesQualificationsOfActualEmployeesList.Where(x => x.QualificationDegree.QualificationDegreeID == QualificationDegreeID &&
                                                                                                                  (QualificationID != 0 ? x.Qualification.QualificationID == QualificationID : x.Qualification.QualificationID == x.Qualification.QualificationID) &&
                                                                                                                  (GeneralSpecializationID != 0 ? x.GeneralSpecialization.GeneralSpecializationID == GeneralSpecializationID : x.GeneralSpecialization.GeneralSpecializationID == x.GeneralSpecialization.GeneralSpecializationID)).ToList();

                ActualEmployeesBasedOnAssignings.RemoveAll(x => !EmployeesQualificationsOfActualEmployeesList.Any(y => y.EmployeeCode.EmployeeCodeID == x.EmployeeCodeID));

                var query = ActualEmployeesBasedOnAssignings.Select(y => new EmployeesQualificationBasedOnAssigngingsDTO(y.EmployeeCodeNo,
                                                                                                                         y.EmployeeNameAr,
                                                                                                                         y.OrganizationName,
                                                                                                                         y.JobName,
                                                                                                                         y.RankCategoryName,
                                                                                                                         y.RankName,
                                                                                                                         EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).QualificationDegree.QualificationDegreeName,
                                                                                                                         EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).Qualification.QualificationName,
                                                                                                                         EmployeesQualificationsOfActualEmployeesList.FirstOrDefault(x => x.EmployeeCode.EmployeeCodeID == y.EmployeeCodeID).GeneralSpecialization.GeneralSpecializationName,
                                                                                                                         y.Sorting
                                                                                                                         ));

                return(query.AsQueryable());
            }
            catch
            {
                throw;
            }
        }
Esempio n. 13
0
 public List <OrganizationsStructuresBLL> GetOrganizationStructureWithFullName()
 {
     try
     {
         List <OrganizationsStructures>    OrganizationsStructuresList   = new OrganizationsStructuresDAL().GetOrganizationStructure().ToList();
         List <OrganizationsStructuresBLL> OrganizationsStructureBLLList = new List <OrganizationsStructuresBLL>();
         foreach (var item in OrganizationsStructuresList)
         {
             OrganizationsStructuresBLL Org = new OrganizationsStructuresBLL();
             Org = MapOrganization(item);
             Org.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(OrganizationsStructuresList, item);
             OrganizationsStructureBLLList.Add(Org);
         }
         return(OrganizationsStructureBLLList);
     }
     catch
     {
         throw;
     }
 }
Esempio n. 14
0
        public virtual OrganizationsStructuresBLL GetOrganizationStructureAsTree()
        {
            try
            {
                OrganizationsStructuresBLL OrgList = new OrganizationsStructuresBLL();
                var FirstLevelList = this.GetFirstLevel();

                foreach (var item in FirstLevelList)
                {
                    OrgList = item;
                    AddChildren(OrgList, item);
                }

                return(OrgList);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 15
0
 public virtual OrganizationsStructuresBLL GetCurrentManagerOfEmployee(int EmployeeCareerHistoryID)
 {
     try
     {
         BaseAssigningsBLL ActiveAssigning = new BaseAssigningsBLL().GetEmployeeActiveAssigning(EmployeeCareerHistoryID);
         if (ActiveAssigning != null)
         {
             return(((InternalAssigningBLL)ActiveAssigning).Organization);
         }
         else
         {
             string ManagerCodeNo = new EmployeesCareersHistoryBLL().GetByEmployeeCareerHistoryID(EmployeeCareerHistoryID).EmployeeCode.EmployeeCodeNo;
             List <OrganizationsStructuresBLL> AllOrganizationsForManager = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(ManagerCodeNo);
             return(AllOrganizationsForManager.FirstOrDefault().ParentOrganization);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 16
0
 public List <PlacementBLL> GetOrganizationsPlacement(int OrgnizationID)
 {
     try
     {
         List <PlacementBLL>               PlacementBLLList     = new List <PlacementBLL>();
         List <InternalAssigningBLL>       AssigningBLLList     = new InternalAssigningBLL().Get();
         List <OrganizationsStructuresBLL> OrganizationsBLLList = new OrganizationsStructuresBLL().GetByOrganizationIDWithhAllChilds(OrgnizationID);
         foreach (var item in OrganizationsBLLList)
         {
             PlacementBLLList.Add(new PlacementBLL()
             {
                 Organization         = item,
                 EmployeesPlacedCount = AssigningBLLList.Where(x => x.Organization.OrganizationID == item.OrganizationID).Count()
             });
         }
         return(PlacementBLLList);
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 17
0
        public virtual List <OrganizationsStructuresBLL> GetManagerOrganizationsWithChildsAsTree(string ManagerCodeNo)
        {
            try
            {
                OrganizationsStructuresBLL OrgList = new OrganizationsStructuresBLL();
                //var FirstLevelList = this.GetFirstLevel();

                List <OrganizationsStructuresBLL> ManagerOrgList       = this.GetOrganizationStructureWithManagers().Where(x => x.OrganizationManager != null && x.OrganizationManager.EmployeeCodeNo == ManagerCodeNo).ToList();
                List <OrganizationsStructuresBLL> ManagerOrgListAsTree = new List <OrganizationsStructuresBLL>();
                foreach (var item in ManagerOrgList)
                {
                    OrgList = item;
                    AddChildren(OrgList, item);
                    ManagerOrgListAsTree.Add(OrgList);
                }

                return(ManagerOrgListAsTree);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// get Actual Org and Actual Job from organization structure module if he is a manager, but if he is a normal employee, get from internal assignings module
        /// </summary>
        /// <param name="EmployeeCodeNo"></param>
        /// <returns></returns>
        public PlacementBLL GetCurrentActualOrgAndActualJob(string EmployeeCodeNo)
        {
            try
            {
                PlacementBLL CurrentOrgAndJob = null;
                OrganizationsStructuresBLL OrganizationsStructureBasedOnManagement = new OrganizationsStructuresBLL().GetAllOrganizationsForManagerByManagerCodeNo(EmployeeCodeNo)?.FirstOrDefault();
                if (OrganizationsStructureBasedOnManagement != null)
                {
                    OrganizationsStructureBasedOnManagement.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(OrganizationsStructureBasedOnManagement.OrganizationID);
                    CurrentOrgAndJob = new PlacementBLL()
                    {
                        Organization = OrganizationsStructureBasedOnManagement, Job = new JobsBLL()
                        {
                            JobName = Globalization.ManagerText + " " + OrganizationsStructureBasedOnManagement.OrganizationName
                        }
                    };
                }
                else
                {
                    BaseAssigningsBLL CurrentAssigningRecord = new InternalAssigningBLL().GetEmployeeActiveAssigning(EmployeeCodeNo);
                    if (CurrentAssigningRecord != null)
                    {
                        CurrentOrgAndJob = new PlacementBLL()
                        {
                            Organization = ((InternalAssigningBLL)CurrentAssigningRecord).Organization, Job = ((InternalAssigningBLL)CurrentAssigningRecord).Job
                        }
                    }
                    ;
                }

                return(CurrentOrgAndJob);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 19
0
        internal OrganizationsStructuresBLL MapOrganization(OrganizationsStructures OrganizationStructure)
        {
            try
            {
                OrganizationsStructuresBLL OrganizationStructuresBLL = null;
                if (OrganizationStructure != null)
                {
                    OrganizationStructuresBLL = new OrganizationsStructuresBLL()
                    {
                        CreatedDate      = OrganizationStructure.CreatedDate,
                        LastUpdatedDate  = OrganizationStructure.LastUpdatedDate,
                        OrganizationID   = OrganizationStructure.OrganizationID,
                        OrganizationCode = OrganizationStructure.OrganizationCode,
                        OrganizationName = OrganizationStructure.OrganizationName, //+ " - " + new BranchesBLL().MapBranch(OrganizationStructure.Branches).BranchName,
                        ShowInECM        = OrganizationStructure.ShowInECM.HasValue ? OrganizationStructure.ShowInECM.Value : false,
                        WorkingWithDigitalDecisionInECM = OrganizationStructure.WorkingWithDigitalDecisionInECM.HasValue ? OrganizationStructure.WorkingWithDigitalDecisionInECM.Value : false,
                        ParentOrganization = OrganizationStructure.ParentOrganization != null ? new OrganizationsStructuresBLL()
                        {
                            OrganizationID   = OrganizationStructure.ParentOrganization.OrganizationID,
                            OrganizationCode = OrganizationStructure.ParentOrganization.OrganizationCode,
                            OrganizationName = OrganizationStructure.ParentOrganization.OrganizationName,
                            Branch           = new BranchesBLL()
                            {
                                BranchName = OrganizationStructure.ParentOrganization.Branches.BranchName
                            },
                            OrganizationManager = new EmployeesCodesBLL()
                            {
                                EmployeeCodeID = OrganizationStructure.ParentOrganization.ManagerCodeID.HasValue ? OrganizationStructure.ParentOrganization.ManagerCodeID.Value : 0
                            }
                        } : null,
                        Branch = new BranchesBLL().MapBranch(OrganizationStructure.Branches),
                        OrganizationManager = OrganizationStructure.EmployeesCodes != null ? new EmployeesCodesBLL()
                        {
                            EmployeeCodeID = OrganizationStructure.EmployeesCodes.EmployeeCodeID,
                            EmployeeCodeNo = OrganizationStructure.EmployeesCodes.EmployeeCodeNo,
                            Employee       = new EmployeesBLL().MapEmployee(OrganizationStructure.EmployeesCodes.Employees),
                            HiringRecord   = new EmployeesCareersHistoryBLL()
                            {
                                JoinDate = new EmployeesCareersHistoryBLL().GetHiringDate(OrganizationStructure.EmployeesCodes.EmployeeCodeID)
                            },
                        } : null,
                    };

                    // comment out because there is json error on Organization structure page. Dated : 19-07-2020
                    //if (OrganizationStructure.EmployeesCodes != null)
                    //{
                    //    if (OrganizationStructure.EmployeesCodes.EmployeesCareersHistory != null)
                    //    {
                    //        if (OrganizationStructure.EmployeesCodes.EmployeesCareersHistory.Count > 0)
                    //        {
                    //            EmployeesCareersHistory CurrentEmplyeeJob = OrganizationStructure.EmployeesCodes.EmployeesCareersHistory.FirstOrDefault(x => x.IsActive == true); // to get current organization of his job
                    //            OrganizationStructuresBLL.OrganizationManager.EmployeeCurrentJob = new EmployeesCareersHistoryBLL()
                    //            {
                    //                OrganizationJob = new OrganizationsJobsBLL()
                    //                {
                    //                    OrganizationStructure = new OrganizationsStructuresBLL()
                    //                    {
                    //                        OrganizationName = CurrentEmplyeeJob != null ? CurrentEmplyeeJob.OrganizationsJobs.OrganizationsStructures.OrganizationName : string.Empty
                    //                        //OrganizationName =  OrganizationStructure.EmployeesCodes.EmployeesCareersHistory.FirstOrDefault(x => x.IsActive == true).OrganizationsJobs.OrganizationsStructures.OrganizationName
                    //                    }
                    //                }
                    //            };
                    //        }

                    //    }
                    //}
                }
                return(OrganizationStructuresBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Task # 255: Changing the manager of any organization must affect on e services authorization module
        ///  - removed validation of Is Placement period finished or not?
        ///
        /// </summary>
        /// <param name="Organization"></param>
        /// <returns></returns>
        public Result ChangeOrganizationManager(OrganizationsStructuresBLL Organization)
        {
            try
            {
                Result result = null;

                // Now there is no need for this condition, placement is open for all times.

                //#region Validate if the Placement period finished or not
                //result = CommonHelper.IsValidToCompleteEmployeesPlacement();
                //if (result != null)
                //    return result;
                //#endregion

                // TASK 255 (related) Changing the manager of any organization must affect on e services authorization module
                OrganizationsStructures OldOrganization = new OrganizationsStructuresDAL().GetByOrganizationID(Organization.OrganizationID);

                // TASK 330 (related) Checking the manager organization is going to be changed or not .. if the manager is not going to be changed, no need to do any action
                if (OldOrganization.ManagerCodeID.HasValue)
                {
                    if (Organization.OrganizationManager.EmployeeCodeID == OldOrganization.ManagerCodeID.Value) // thats mean the manager is not going to be changed
                    {
                        return(result);
                    }
                }

                OrganizationsStructures OrganizationStructure = new OrganizationsStructures()
                {
                    OrganizationID  = Organization.OrganizationID,
                    ManagerCodeID   = Organization.OrganizationManager != null ? Organization.OrganizationManager.EmployeeCodeID : (int?)null,
                    LastUpdatedDate = DateTime.Now,
                    LastUpdatedBy   = Organization.LoginIdentity.EmployeeCodeID
                };

                Assignings Assigning = new Assignings()
                {
                    OrganizationID  = Organization.OrganizationID,
                    ManagerCodeID   = Organization.OrganizationManager != null ? Organization.OrganizationManager.EmployeeCodeID : (int?)null,
                    LastUpdatedDate = DateTime.Now,
                    LastUpdatedBy   = Organization.LoginIdentity.EmployeeCodeID
                };

                new OrganizationsStructuresDAL().UpdateManager(OrganizationStructure);
                new AssigningsDAL().UpdateOrganizationManager(Assigning); // if the manager of organization has been changed, the manager of the same organization in Assigning must be changed (for all unfinished assignings)

                // Old and New Organization must have ManagerCodeID
                // Update AuthorizedPerson in EServices Authorization table (related to task 255)
                if (OldOrganization.ManagerCodeID.HasValue && OldOrganization.ManagerCodeID.Value > 0 &&
                    Organization.OrganizationManager != null && Organization.OrganizationManager.EmployeeCodeID > 0)
                {
                    new EServicesAuthorizationsBLL()
                    {
                        LoginIdentity = Organization.LoginIdentity
                    }.ChangeAuthorizedPersonForAllChildByOrganizationID(Organization.OrganizationID, OldOrganization.ManagerCodeID.Value, Organization.OrganizationManager.EmployeeCodeID);
                }

                #region Task 318: Service to Cancel EServicesProxies By System
                try
                {
                    result = new EServicesProxiesBLL()
                    {
                        LoginIdentity = Organization.LoginIdentity
                    }
                    .RevokeEServiceProxyByEmployeeCodeID(Organization.OrganizationManager.EmployeeCodeID, EServicesProxiesStatusEnum.CancelledBySystem, Globalization.EServiceProxyCancelledBySystemBecauseOfChangeManagerText);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion


                // this to get mobile no of manager
                EmployeesCodesBLL ManagerCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(Organization.OrganizationManager != null ? Organization.OrganizationManager.EmployeeCodeID : 0);
                if (ManagerCodeBLL != null)
                {
                    SMSLogsBLL SMSLogBLL = new SMSLogsBLL()
                    {
                        BusinssSubCategory = BusinessSubCategoriesEnum.OrganizationStructure,
                        MobileNo           = ManagerCodeBLL.Employee.EmployeeMobileNo,
                        DetailID           = 0,
                        Message            = string.Format(Globalization.SMSManagerAlreadyAssignedToOrganizationMessageText, ManagerCodeBLL.Employee.FirstNameAr + " " + ManagerCodeBLL.Employee.LastNameAr, Organization.GetOrganizationNameTillLastParentExceptPresident(Organization.OrganizationID)),
                        CreatedBy          = Organization.LoginIdentity,
                        CreatedDate        = DateTime.Now,
                    };
                    new SMSBLL().SendSMS(SMSLogBLL);
                }

                result            = new Result();
                result.Entity     = this;
                result.EnumType   = typeof(OrganizationStructureValidationEnum);
                result.EnumMember = OrganizationStructureValidationEnum.Done.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }