Ejemplo n.º 1
0
        public static IWorkPermit Get_NewWorkPermit(IPersonInApplication personInApp)


        {
            if (personInApp.Employee != null)
            {
                if (personInApp != null && personInApp.Employee.IsEmployee && personInApp.Application != null && personInApp.Employee.WorkPermits.Count > 0 && personInApp.Application.ForEmployee)
                {
                    IWorkPermit workpermit = null;

                    foreach (var employeeInWP in personInApp.Employee.WorkPermits)
                    {
                        if (employeeInWP.ProcessNumber != null && employeeInWP.ProcessNumber.Application == personInApp.Application)
                        {
                            workpermit = employeeInWP;

                            break;
                        }
                    }


                    return(workpermit);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static void AfterConstruction(IWorkPermit workPermit, IObjectSpace obspace)
        {
            var appConf = obspace.FindObject <AppConf>(new BinaryOperator("ID", 1));

            if (appConf != null)
            {
                workPermit.AppConf = obspace.FindObject <AppConf>(new BinaryOperator("ID", 1));
            }
        }
Ejemplo n.º 3
0
        public static void AfterChange_Employee(IWorkPermit wp)
        {
            wp.Passport = Helper.GetLastPassport(wp.Employee);
            wp.Position = Helper.GetLastPosition(wp.Employee);

            if (wp.WorkPermitLetter != null && wp.WorkPermitLetter.Date != null)
            {
                wp.ProcessNumber = Helper.Get_ApplicationFoWorkPermit(wp.Employee, wp.WorkPermitLetter.Date);
            }
        }
Ejemplo n.º 4
0
        /*
         * public static void OnSaving(IWorkPermit wp, IObjectSpace obspace)
         * {
         *
         *  // Imp wp letter
         *
         *
         *
         *
         *  IWorkPermitLetter wpLetter = obspace.FindObject<IWorkPermitLetter>(new BinaryOperator("Number", wp.ImpLetter));
         *  if (wpLetter == null)
         *  {
         *
         *      wpLetter = obspace.CreateObject<IWorkPermitLetter>();
         *      wpLetter.Date = wp.ImpWpIssuedDate;
         *
         *
         *  }
         *
         *
         *  if (wpLetter != null)
         *  {
         *      wp.WorkPermitLetter = wpLetter;
         *  }
         *
         *  // Imp Passport
         *  if (!String.IsNullOrEmpty(wp.ImpPassport))
         *  {
         *
         *
         *      IPassport pasport = obspace.FindObject<IPassport>(new BinaryOperator("PassportNumber", wp.ImpPassport));
         *
         *      wp.Passport = pasport;
         *
         *  }
         *
         *  // Imp Position
         *
         *  if (!String.IsNullOrEmpty(wp.ImpPosition))
         *  {
         *
         *
         *      IWorkHistory position = obspace.FindObject<IWorkHistory>(new BinaryOperator("Position", wp.ImpPosition));
         *
         *      wp.Position = position;
         *
         *
         *  }
         *
         *
         *  // Imp ID Number
         *
         *
         *  if (!String.IsNullOrEmpty(wp.ImpIDNumber))
         *  {
         *
         *
         *      IEmployee employee = obspace.FindObject<IEmployee>(new BinaryOperator("IDNumber", wp.ImpIDNumber));
         *
         *      wp.Employee = employee;
         *
         *
         *  }
         *
         *
         *
         *
         *
         *
         * }
         */

        public static IPersonInApplication Get_AppForWorkPermitCancelling(IWorkPermit workPermit)
        {
            if (workPermit.Employee != null && workPermit.Employee.EmployeeInApplications.Count > 0)
            {
                IPersonInApplication temp = null;
                foreach (var empInApp in workPermit.Employee.EmployeeInApplications)
                {
                    if (empInApp.Application.ForEmployee && empInApp.Application.ApplicationTypeForEmployee.TypeOfApplicationForEmployee == SubType.ApplicationForCancellingVisaAndWorkpermit && empInApp.WorkPermit == workPermit)
                    {
                        temp = empInApp;
                    }
                }

                return(temp);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        public static IPersonInApplication Get_PersonInApplication(IWorkPermit workpermit)
        {
            if (workpermit.Employee != null && workpermit.Employee.EmployeeInApplications.Count > 0)
            {
                IPersonInApplication appForWP = null;

                foreach (var personInApp in workpermit.Employee.EmployeeInApplications)
                {
                    SubType st = personInApp.ApplicationType;

                    switch (st)
                    {
                    case SubType.ApplicationForVisaExtention:

                        if (personInApp.WorkPermit == workpermit)
                        {
                            appForWP = personInApp;
                        }
                        break;

                    case SubType.ApplicationForCancellingVisaAndWorkpermit:

                        if (personInApp.WorkPermit == workpermit)
                        {
                            appForWP = personInApp;
                        }
                        break;
                    }
                }
                return(appForWP);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        public static WorkPermitStateEnum Get_WorkPermitState(IWorkPermit workPermit, IObjectSpace os)
        {
            try
            {
                if (workPermit.PersonInApplications.Count == 0 && workPermit.RemainingDays <= 0)
                {
                    return(WorkPermitStateEnum.EXPIRED);
                }

                if (workPermit.Employee.LastWorkPermit != workPermit && workPermit.RemainingDays >= 1)
                {
                    return(WorkPermitStateEnum.Extended);
                }

                if (workPermit.PersonInApplications.Count == 0 && workPermit.RemainingDays >= 1)
                {
                    return(WorkPermitStateEnum.VALID);
                }



                if (workPermit.PersonInApplications != null && workPermit.PersonInApplications.Count == 1)
                {
                    IPersonInApplication personInApp = workPermit.PersonInApplications.First();


                    return(WorkPermitStateHelper.GetWorkPermitState(personInApp, workPermit, WorkPermitStateEnum.UNKNOWN));
                }

                if (workPermit.PersonInApplications != null && workPermit.PersonInApplications.Count >= 2)
                {
                    IList <IPersonInApplication> personInApps = workPermit.PersonInApplications.Where(c => !c.Cancelled).Where(g => !g.Application.Cancelled).Where(t => t.Application.SubType == SubType.ApplicationForCancellingVisaAndWorkpermit ||
                                                                                                                                                                    t.Application.SubType == SubType.ApplicationForCancellingWorkPermit ||
                                                                                                                                                                    t.Application.SubType == SubType.ApplicationForCancellingWorkPermitAndInvitation ||
                                                                                                                                                                    t.Application.SubType == SubType.ApplicationForExtendingWorkPermitLocation ||
                                                                                                                                                                    t.Application.SubType == SubType.ApplicationForVisaExtention

                                                                                                                                                                    ).OrderBy(b => b.Cancelled).OrderByDescending(t => t.Application.ManualApplicationDate).ToList();

                    if (personInApps.Count > 0)
                    {
                        IPersonInApplication pInApp = personInApps.First();

                        return(WorkPermitStateHelper.GetWorkPermitState(pInApp, workPermit, WorkPermitStateEnum.UNKNOWN));
                    }

                    if (workPermit.RemainingDays <= 0)
                    {
                        return(WorkPermitStateEnum.EXPIRED);
                    }

                    if (workPermit.RemainingDays >= 1)
                    {
                        return(WorkPermitStateEnum.VALID);
                    }
                    //  return WorkPermitStateEnum.NONE_0;
                }

                return(WorkPermitStateEnum.UNKNOWN);
            }
            catch (Exception)
            {
                return(WorkPermitStateEnum.UNKNOWN);
            }
        }
Ejemplo n.º 7
0
 public static string Get_ASNumberForLine(IWorkPermit wp)
 {
     return(wp.ASNumber);
 }
Ejemplo n.º 8
0
 public int Get_RemainingDays(IWorkPermit wp)
 {
     {
         return(Helper.GetRemainingDaysBeforeExpire(wp.ExpiringDateOfWorkPermit));
     }
 }
Ejemplo n.º 9
0
 public static IList <DevExpress.Persistent.BaseImpl.AuditDataItemPersistent> Get_ChangeHistory(IWorkPermit workpermit, IObjectSpace os)
 {
     return(DevExpress.Persistent.BaseImpl.AuditedObjectWeakReference.GetAuditTrail(((XPObjectSpace)os).Session, workpermit));
 }
Ejemplo n.º 10
0
        public static WorkPermitStateEnum GetWorkPermitState(IPersonInApplication personInApp, IWorkPermit workPermit, WorkPermitStateEnum unknown)
        {
            //REJECTED
            if (personInApp.Rejected
                | personInApp.Application.Rejected
                | personInApp.Application.ApplicationState == ApplicationStateEnum.Rejected)
            {
                return(WorkPermitStateEnum.VE_REJECTED);
            }



            if (workPermit.RemainingDays >= 1 && personInApp.Cancelled | personInApp.Application.Cancelled)
            {
                return(WorkPermitStateEnum.VALID);
            }
            //CANCELLED BY PERSON IN APP
            if ((personInApp.IsComplete ||
                 personInApp.Application.ApplicationState == ApplicationStateEnum.Processed) &&
                personInApp.Application.BaseApplicationType.TypeOfBaseApplication == AppType.Cancelling)
            {
                return(WorkPermitStateEnum.CANCELLED);
            }

            //EXTENDED BY PERSON IN APP
            if (workPermit.RemainingDays >= 1 && (personInApp.IsComplete | personInApp.Application.ApplicationState == ApplicationStateEnum.Processed) && personInApp.Application.SubType == SubType.ApplicationForVisaExtention)
            {
                return(WorkPermitStateEnum.Extended);
            }
            //EXTENDED BY APPICATION
            if (workPermit.RemainingDays >= 1 && personInApp.Application.SubType == SubType.ApplicationForVisaExtention &&
                (personInApp.Application.ApplicationState == ApplicationStateEnum.Processed
                 | personInApp.Application.IsComplete))
            {
                return(WorkPermitStateEnum.Extended);
            }

            if (personInApp.Application.SubType == SubType.ApplicationForVisaExtention &&
                !personInApp.IsComplete &&
                !personInApp.Cancelled &&
                !personInApp.Rejected &&
                personInApp.Application.ApplicationState == ApplicationStateEnum.OnProcess)
            //EXTENTION VE_ONPROCESS
            {
                return(WorkPermitStateEnum.VE_ONPROCESS);
            }


            // FROM MINISTERY
            if (personInApp.Application.ApplicationState == ApplicationStateEnum.FromMinistery &&
                !personInApp.Cancelled &&
                !personInApp.Rejected &&
                !personInApp.IsComplete)
            {
                return(WorkPermitStateEnum.FROM_MINISTERY);
            }

            // TO MINISTERY
            if (personInApp.Application.ApplicationState == ApplicationStateEnum.ToMinistery &&
                !personInApp.Cancelled &&
                !personInApp.Rejected &&
                !personInApp.IsComplete)
            {
                return(WorkPermitStateEnum.TO_MINISTERY);
            }
            //ADD PLACE TO WP ON PROCESS
            if (workPermit.RemainingDays >= 1 && (personInApp.Application.ApplicationState == ApplicationStateEnum.Processed ||
                                                  personInApp.IsComplete) &&
                personInApp.Application.SubType == SubType.ApplicationForExtendingWorkPermitLocation)
            {
                return(WorkPermitStateEnum.AP_COMPLETE);
            }
            //ADD PLACE TO WP ON PROCESS
            if (personInApp.Application.SubType == SubType.ApplicationForExtendingWorkPermitLocation &&
                (personInApp.Application.ApplicationState == ApplicationStateEnum.Office &&
                 !personInApp.Cancelled &&
                 !personInApp.Rejected) &&
                !personInApp.IsComplete)
            {
                return(WorkPermitStateEnum.AP_OFFICE);
            }
            //ADD PLACE TO WP COMPLETE
            if (personInApp.Application.SubType == SubType.ApplicationForExtendingWorkPermitLocation &&
                (personInApp.Application.ApplicationState == ApplicationStateEnum.OnProcess &&
                 !personInApp.Rejected &&
                 !personInApp.Cancelled &&
                 !personInApp.IsComplete)
                )
            {
                return(WorkPermitStateEnum.AP_ONPROCESS);
            }


            //CANCELLED office
            if ((personInApp.Application.BaseApplicationType.TypeOfBaseApplication == AppType.Cancelling) &&
                (personInApp.Application.ApplicationState == ApplicationStateEnum.Office &&
                 !personInApp.IsComplete &&
                 !personInApp.Rejected &&
                 !personInApp.Cancelled))
            {
                return(WorkPermitStateEnum.VC_OFFICE);
            }

            //CANCELLED CANCELLED
            if ((personInApp.Application.BaseApplicationType.TypeOfBaseApplication == AppType.Cancelling) &&
                (personInApp.Application.ApplicationState == ApplicationStateEnum.Processed ||
                 personInApp.IsComplete))
            {
                return(WorkPermitStateEnum.CANCELLED);
            }

            //EXTENTION ON OFFICE
            if (personInApp.Application.SubType == SubType.ApplicationForVisaExtention &&
                personInApp.Application.ApplicationState == ApplicationStateEnum.Office &&
                !personInApp.IsComplete && !personInApp.Rejected && !personInApp.Cancelled)
            {
                return(WorkPermitStateEnum.VE_OFFICE);
            }

            if (workPermit.RemainingDays <= 0)
            {
                return(WorkPermitStateEnum.EXPIRED);
            }



            else
            {
                return(unknown);
            }
        }