Ejemplo n.º 1
0
        public override Result Add()
        {
            try
            {
                Result result = base.Add();
                if (result != null)
                {
                    return(result);
                }

                result = CommonHelper.IsNoConflictWithOtherProcess(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, this.AssigningStartDate, this.AssigningEndDate ?? DateTime.Now);
                if (result != null)
                {
                    return(result);
                }

                result = new Result();
                Assignings assigning = DALInstance;
                assigning.ExternalOrganization = this.ExternalOrganization;
                assigning.ExternalKSACityID    = this.ExternalKSACity.KSACityID;
                assigning.CreatedBy            = this.LoginIdentity.EmployeeCodeID;
                this.AssigningID = new AssigningsDAL().Insert(assigning);
                if (this.AssigningID != 0)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
                return(result);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public override Result Update()
        {
            try
            {
                Result result = base.Update();
                if (result != null)
                {
                    return(result);
                }

                result = new Result();
                Assignings assigning = DALInstance;
                assigning.ExternalOrganization = this.ExternalOrganization;
                assigning.ExternalKSACityID    = this.ExternalKSACity.KSACityID;
                assigning.LastUpdatedBy        = this.LoginIdentity.EmployeeCodeID;
                this.AssigningID = new AssigningsDAL().Update(assigning);
                if (this.AssigningID != 0)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
                return(result);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public override Result Update()
        {
            try
            {
                Result result = base.Update();
                if (result != null)
                {
                    return(result);
                }

                result = new Result();
                Assignings assigning = DALInstance;
                assigning.JobID          = this.Job.JobID;
                assigning.OrganizationID = this.Organization.OrganizationID;
                assigning.ManagerCodeID  = this.Manager != null ? this.Manager.EmployeeCodeID : (int?)null;
                assigning.LastUpdatedBy  = this.LoginIdentity.EmployeeCodeID;
                this.AssigningID         = new AssigningsDAL().Update(assigning);
                if (this.AssigningID != 0)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        internal BaseAssigningsBLL MapAssigning(Assignings Assigning)
        {
            try
            {
                BaseAssigningsBLL AssigningBLL = null;
                if (Assigning != null)
                {
                    if (Assigning.AssigningTypID == (Int32)AssigningsTypesEnum.Internal)
                    {
                        AssigningBLL = new InternalAssigningBLL()
                        {
                            Job          = new JobsBLL().MapJob(Assigning.Jobs),
                            Organization = new OrganizationsStructuresBLL().MapOrganization(Assigning.OrganizationsStructures),
                            Manager      = new EmployeesCodesBLL().MapEmployeeCode(Assigning.ManagerCode)
                        };

                        ((InternalAssigningBLL)AssigningBLL).Organization.FullOrganizationName = new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(((InternalAssigningBLL)AssigningBLL).Organization.OrganizationID);
                    }
                    else if (Assigning.AssigningTypID == (Int32)AssigningsTypesEnum.External)
                    {
                        AssigningBLL = new ExternalAssigningBLL()
                        {
                            ExternalKSACity      = new KSACitiesBLL().MapKSACity(Assigning.KSACities),
                            ExternalOrganization = Assigning.ExternalOrganization,
                        };
                    }
                    AssigningBLL.AssigningID           = Assigning.AssigningID;
                    AssigningBLL.AssigningStartDate    = Assigning.AssigningStartDate;
                    AssigningBLL.AssigningEndDate      = Assigning.AssigningEndDate;
                    AssigningBLL.AssigningType         = new AssigningsTypesBLL().MapAssigningType(Assigning.AssigningsTypes);
                    AssigningBLL.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().MapEmployeeCareerHistory(Assigning.EmployeesCareersHistory);
                    AssigningBLL.IsFinished            = Assigning.IsFinished;
                    AssigningBLL.AssigningReason       = new AssigningsReasonsBLL().MapAssigningReason(Assigning.AssigningsReasons);
                    AssigningBLL.AssigningReasonOther  = "" + Assigning.AssigningReasonOther;
                    AssigningBLL.CreatedDate           = Assigning.CreatedDate;
                    AssigningBLL.CreatedBy             = new EmployeesCodesBLL().MapEmployeeCode(Assigning.CreatedByNav);
                }
                return(AssigningBLL);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 5
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;
            }
        }
Ejemplo n.º 6
0
        public override Result Add()
        {
            try
            {
                Result result = base.Add();
                if (result != null)
                {
                    return(result);
                }

                int      EmployeeCodeID = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID;
                DateTime StartDate      = this.AssigningStartDate;
                DateTime EndDate        = this.AssigningEndDate ?? DateTime.Now.Date;

                #region Validaion for conflict with lender
                EmployeesCareersHistoryBLL EmployeesCareersHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(this.EmployeeCareerHistory.EmployeeCareerHistoryID);
                //if (EmployeesCareersHistory != null && EmployeesCareersHistory.EmployeeCareerHistoryID > 0)
                //    EmployeeCodeID = EmployeesCareersHistory.EmployeeCode.EmployeeCodeID;

                List <LendersBLL> LendersBLLList = new LendersBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (LendersBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithLender.ToString();
                    return(result);
                }
                #endregion

                #region Validaion for conflict with StopWorks
                List <StopWorksBLL> StopWorksBLLList = new StopWorksBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (StopWorksBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithStopWork.ToString();
                    return(result);
                }
                #endregion

                #region Validaion for conflict with scholarship
                List <BaseScholarshipsBLL> BaseScholarshipsBLLList = new BaseScholarshipsBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (BaseScholarshipsBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithScholarship.ToString();
                    return(result);
                }
                #endregion

                #region Validaion for conflict with External Assigning
                List <ExternalAssigningBLL> ExternalAssigningBLLList = new ExternalAssigningBLL().GetByEmployeeCodeID(EmployeeCodeID, StartDate, EndDate);
                if (ExternalAssigningBLLList.Count() != 0)
                {
                    result            = new Result();
                    result.EnumType   = typeof(NoConflictWithOtherProcessValidationEnum);
                    result.EnumMember = NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithExternalAssigning.ToString();
                    return(result);
                }
                #endregion

                result = new Result();
                Assignings assigning = DALInstance;
                assigning.JobID          = this.Job.JobID;
                assigning.ManagerCodeID  = this.Manager != null ? this.Manager.EmployeeCodeID : (int?)null;
                assigning.OrganizationID = this.Organization.OrganizationID;
                assigning.CreatedBy      = this.LoginIdentity.EmployeeCodeID;
                this.AssigningID         = new AssigningsDAL().Insert(assigning);
                if (this.AssigningID != 0)
                {
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
        public Result AssignEmployeeUnderManager()
        {
            try
            {
                Result result;
                //Result result = base.Add();
                //if (result != null)
                //    return result;

                //int EmployeeCodeID = this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID;
                //DateTime StartDate = this.AssigningStartDate;
                //DateTime EndDate = this.AssigningEndDate ?? DateTime.Now.Date;

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

                #region Validate if the employee has active Assigning or not
                BaseAssigningsBLL ActiveEmployeeAssigning = new EmployeesCodesBLL().GetAssigningsByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID).FirstOrDefault(x => x.IsFinished == false);
                if (ActiveEmployeeAssigning != null)
                {
                    result            = new Result();
                    result.Entity     = ActiveEmployeeAssigning;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString();
                    return(result);
                }
                #endregion


                AssigningsReasonsBLL AssigningReason = GetLastAssigningEndReasonsByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID);
                Assignings           assigning       = new Assignings();
                assigning.AssigningTypID     = (int)AssigningsTypesEnum.Internal;
                assigning.AssigningReasonID  = AssigningReason != null ? AssigningReason.AssigningReasonID : (int)AssigningsReasonsEnum.BasedOnWorkNeeds;
                assigning.AssigningStartDate = DateTime.Now.Date;
                assigning.ManagerCodeID      = this.Manager.EmployeeCodeID;
                assigning.OrganizationID     = this.Organization.OrganizationID;
                assigning.JobID = this.Job.JobID;
                assigning.EmployeeCareerHistoryID = this.EmployeeCareerHistory?.EmployeeCareerHistoryID;
                assigning.CreatedBy   = this.LoginIdentity.EmployeeCodeID;
                assigning.CreatedDate = DateTime.Now;
                this.AssigningID      = new AssigningsDAL().Insert(assigning);

                if (this.AssigningID != 0)
                {
                    // this to get info of employee
                    EmployeesCodesBLL EmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.EmployeeCareerHistory.EmployeeCode != null ? this.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID : 0);

                    // this to get info of manager
                    EmployeesCodesBLL ManagerCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.Manager.EmployeeCodeID);

                    if (EmployeeCodeBLL != null)
                    {
                        SMSLogsBLL SMSLogBLL = new SMSLogsBLL()
                        {
                            BusinssSubCategory = BusinessSubCategoriesEnum.OrganizationStructure,
                            MobileNo           = EmployeeCodeBLL.Employee.EmployeeMobileNo,
                            DetailID           = 0,
                            Message            = string.Format(Globalization.SMSEmployeeAlreadyAssignedUnderManagerMessageText, EmployeeCodeBLL.Employee.FirstNameAr + " " + EmployeeCodeBLL.Employee.LastNameAr, new OrganizationsStructuresBLL().GetOrganizationNameTillLastParentExceptPresident(this.Organization.OrganizationID), ManagerCodeBLL.Employee.EmployeeNameAr),
                            CreatedBy          = this.LoginIdentity,
                            CreatedDate        = DateTime.Now,
                        };
                        new SMSBLL().SendSMS(SMSLogBLL);
                    }

                    result            = new Result();
                    result.Entity     = this;
                    result.EnumType   = typeof(AssigningsValidationEnum);
                    result.EnumMember = AssigningsValidationEnum.Done.ToString();
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }