Exemplo 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;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  to get all organizations that the employee was assigned to these organization as manager
        /// </summary>
        /// <param name="ManagerCodeNo"></param>
        /// <returns></returns>
        public List <OrganizationsStructuresBLL> GetAllOrganizationsForManagerByManagerCodeNo(string ManagerCodeNo)
        {
            try
            {
                EmployeesCodesBLL EmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeNo(ManagerCodeNo);
                if (EmployeeCodeBLL != null)
                {
                    List <OrganizationsStructures> OrganizationsStructuresList = new OrganizationsStructuresDAL().GetOrganizationsUnderManagerByManagerCodeID(EmployeeCodeBLL.EmployeeCodeID);
                    if (OrganizationsStructuresList.Count() > 0)
                    {
                        List <OrganizationsStructuresBLL> OrganizationsStructureBLLList = new List <OrganizationsStructuresBLL>();
                        foreach (var item in OrganizationsStructuresList)
                        {
                            OrganizationsStructureBLLList.Add(MapOrganization(item));
                        }

                        return(OrganizationsStructureBLLList);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public virtual List <PlacementBLL> GetEmployeesInPlaced()
        {
            try
            {
                List <PlacementBLL>            EmployeesInPlacedBLLList = new List <PlacementBLL>();
                List <EmployeesCareersHistory> Employees = new EmployeesCareersHistoryDAL().GetActiveEmployeesCareersHistory();
                List <Assignings> Assignings             = new AssigningsDAL().GetAssignings();
                List <OrganizationsStructures> OrganizationsStructures = new OrganizationsStructuresDAL().GetOrganizationStructure();
                int[] EmployeeCareerHistoryIDs = Assignings.Select(c => (int)c.EmployeeCareerHistoryID).ToArray();
                int[] ManagerCodeIDs           = OrganizationsStructures.Where(p => p.ManagerCodeID.HasValue == true).Select(c => c.ManagerCodeID.Value).ToArray(); //.Select(c => (int)c.ManagerCodeID).ToArray();
                Employees.RemoveAll(x => EmployeeCareerHistoryIDs.Contains(x.EmployeeCareerHistoryID));
                Employees.RemoveAll(o => ManagerCodeIDs.Contains(o.EmployeeCodeID));

                foreach (var item in Employees)
                {
                    EmployeesInPlacedBLLList.Add(new PlacementBLL()
                    {
                        EmployeeCareerHistory = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(item)
                    });
                    //new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(((InternalAssigningBLL)AssigningBLL).Organization.OrganizationID);
                    EmployeesInPlacedBLLList.ForEach(x => x.EmployeeCareerHistory.OrganizationJob.OrganizationStructure.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(x.EmployeeCareerHistory.OrganizationJob.OrganizationStructure.OrganizationID));
                }
                return(EmployeesInPlacedBLLList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public string GetOrganizationNameTillLastParentExceptPresident(int OrganizationID)
        {
            OrganizationsStructures OrganizationStructure = new OrganizationsStructuresDAL().GetByOrganizationID(OrganizationID);

            if (OrganizationStructure != null && !OrganizationStructure.OrganizationParentID.HasValue)
            {
                return(OrganizationStructure.OrganizationName);
            }
            else if (OrganizationStructure != null && OrganizationStructure.OrganizationParentID.HasValue && OrganizationStructure.OrganizationParentID == 1)
            {
                return(OrganizationStructure.OrganizationName);
            }
            else
            {
                return(GetOrganizationNameTillLastParentExceptPresident(OrganizationStructure.OrganizationParentID.Value) + " / " + OrganizationStructure.OrganizationName);
            }
        }
Exemplo n.º 5
0
        private List <OrganizationsStructuresBLL> GetFirstLevel()
        {
            try
            {
                List <OrganizationsStructures>    OrganizationsStructuresList   = new OrganizationsStructuresDAL().GetFirstLevel();
                List <OrganizationsStructuresBLL> OrganizationsStructureBLLList = new List <OrganizationsStructuresBLL>();

                foreach (var item in OrganizationsStructuresList)
                {
                    OrganizationsStructureBLLList.Add(new OrganizationsStructuresBLL().MapOrganizationWithoutManager(item));
                }

                return(OrganizationsStructureBLLList);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 6
0
        public virtual List <int> GetAllChildernByOrganizationID(int OrganizationID)
        {
            List <int> OrganizationIDsList = new List <int>();
            //List<OrganizationsStructuresBLL> OrganizationsStructuresBLLList = this.GetByOrganizationIDWithhAllChilds(OrganizationID).ToList();

            List <OrganizationsStructures> AllOrgs = new OrganizationsStructuresDAL().GetOrganizationStructure();
            List <OrganizationsStructures> orgs    = new List <OrganizationsStructures>();
            OrganizationsStructures        MainOrg = AllOrgs.FirstOrDefault(x => x.OrganizationID == OrganizationID);

            orgs.Add(MainOrg);
            AddChildrenID(AllOrgs, orgs, MainOrg.OrganizationID);

            foreach (var item in orgs)
            {
                OrganizationIDsList.Add(item.OrganizationID);
            }

            return(OrganizationIDsList);
        }
Exemplo n.º 7
0
 public virtual OrganizationsStructuresBLL GetByOrganizationID(int OrganizationID)
 {
     try
     {
         OrganizationsStructures organizationStructure = new OrganizationsStructuresDAL().GetByOrganizationID(OrganizationID);
         if (organizationStructure != null)
         {
             return(new OrganizationsStructuresBLL().MapOrganization(organizationStructure));
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 8
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;
     }
 }
Exemplo n.º 9
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;
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Task 256: Adding records in e service authorization after adding new organization node in organizations structure
        /// Set Manager as Parent_Manager_Code_ID if manager is null
        /// </summary>
        /// <returns></returns>
        public virtual Result Add()
        {
            try
            {
                Result result = new Result();

                // TASK 256 (related) if manager is null, we set "parent manage" is also manager of newly created organization
                if (this.OrganizationManager == null)
                {
                    OrganizationsStructures ParentOrg = new OrganizationsStructuresDAL().GetByOrganizationID(this.ParentOrganization.OrganizationID);
                    if (ParentOrg != null && ParentOrg.ManagerCodeID.HasValue && ParentOrg.ManagerCodeID.Value > 0)
                    {
                        this.OrganizationManager = new EmployeesCodesBLL()
                        {
                            EmployeeCodeID = ParentOrg.ManagerCodeID.Value
                        };
                    }
                }

                OrganizationsStructures OrganizationsStructures = new OrganizationsStructures()
                {
                    BranchID             = this.Branch.BranchID,
                    OrganizationParentID = this.ParentOrganization.OrganizationID,
                    OrganizationName     = this.OrganizationName,
                    OrganizationCode     = this.OrganizationCode,
                    ManagerCodeID        = this.OrganizationManager != null && this.OrganizationManager.EmployeeCodeID != 0 ? (int)this.OrganizationManager.EmployeeCodeID : (int?)null,
                    CreatedDate          = DateTime.Now,
                    CreatedBy            = this.LoginIdentity.EmployeeCodeID
                };
                this.OrganizationID = new OrganizationsStructuresDAL().Insert(OrganizationsStructures);

                #region EService Authorization: Create EServiceAuthorization records of the Organization based on EServiceTypes
                if (this.OrganizationManager != null && this.OrganizationManager.EmployeeCodeID > 0)
                {
                    EServicesAuthorizationsBLL EServiceAuthorizationBLL;
                    foreach (var item in new EServicesTypesBLL().GetEServicesTypes())
                    {
                        EServiceAuthorizationBLL = new EServicesAuthorizationsBLL();
                        EServiceAuthorizationBLL.Organization = new OrganizationsStructuresBLL()
                        {
                            OrganizationID = this.OrganizationID
                        };
                        EServiceAuthorizationBLL.AuthorizedPerson = new EmployeesCodesBLL()
                        {
                            EmployeeCodeID = this.OrganizationManager.EmployeeCodeID
                        };
                        EServiceAuthorizationBLL.EServiceType  = item;
                        EServiceAuthorizationBLL.CreatedDate   = DateTime.Now;
                        EServiceAuthorizationBLL.LoginIdentity = this.LoginIdentity;
                        EServiceAuthorizationBLL.Add();
                    }
                }
                #endregion

                result.Entity     = this;
                result.EnumType   = typeof(OrganizationStructureValidationEnum);
                result.EnumMember = OrganizationStructureValidationEnum.Done.ToString();
                return(result);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 11
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;
            }
        }