Пример #1
0
        public void InsertPermit(Request request)
        {
            Permit            permit     = new Permit();
            PermitPair        permitPair = new PermitPair();
            string            name       = request.Precard.PrecardGroup.LookupKey;
            PrecardGroupsName groupName  = (PrecardGroupsName)Enum.Parse(typeof(PrecardGroupsName), name);
            IList <Permit>    list       = permitRep.GetExistingPermit(request.Person.ID, request.Precard.ID, request.FromDate, request.ToDate);

            if (list.Count > 0 && (groupName == PrecardGroupsName.overwork || request.Precard.IsHourly))
            {
                permit = list.First();
                if (permit.Pairs == null)
                {
                    permit.Pairs = new List <PermitPair>();
                }
                permitPair.Permit    = permit;
                permitPair.RequestID = request.ID;
                permitPair.From      = request.FromTime;
                permitPair.To        = request.ToTime;
                permitPair.Value     = request.TimeDuration;
                permitPair.PreCardID = request.Precard.ID;
                permitPair.IsFilled  = true;
                permit.Pairs.Add(permitPair);

                EntityRepository <PermitPair> rep = new EntityRepository <PermitPair>(false);
                this.SaveChanges(permit, UIActionType.EDIT);
            }
            else
            {
                if (groupName == PrecardGroupsName.overwork)
                {
                    permit.IsPairly = false;
                    if (request.TimeDuration == -1000)
                    {
                        permit.IsPairly = true;
                    }
                }
                else if (request.Precard.IsHourly)
                {
                    permit.IsPairly = true;
                }
                else if (request.Precard.IsDaily)
                {
                    permit.IsPairly = false;
                }

                permit.FromDate = request.FromDate;
                permit.ToDate   = request.ToDate;
                permit.Pairs    = new List <PermitPair>()
                {
                    permitPair
                };
                permit.Person = request.Person;

                permitPair.Permit    = permit;
                permitPair.RequestID = request.ID;
                permitPair.From      = request.FromTime;
                permitPair.To        = request.ToTime;
                permitPair.Value     = request.TimeDuration;
                permitPair.PreCardID = request.Precard.ID;
                permitPair.IsFilled  = true;

                this.SaveChanges(permit, UIActionType.ADD);
            }
        }
Пример #2
0
        private bool CheckRequestValueAppliedFlowConditionValue(ManagerFlowCondition managerFlowCondition, Request request)
        {
            bool isAppliedFlowConditionValue = false;

            if (managerFlowCondition != null)
            {
                ConditionOperators conditionOperator = (ConditionOperators)managerFlowCondition.Operator;
                Precard            precard           = managerFlowCondition.PrecardAccessGroupDetail.Precard;
                PrecardGroupsName  precardGroupsName = (PrecardGroupsName)managerFlowCondition.PrecardAccessGroupDetail.Precard.PrecardGroup.IntLookupKey;
                int requestValue = 0;
                switch (precardGroupsName)
                {
                case PrecardGroupsName.leave:
                case PrecardGroupsName.leaveestelajy:
                case PrecardGroupsName.duty:
                    if (precard.IsHourly)
                    {
                        requestValue = request.TimeDuration;
                    }
                    else
                    if (precard.IsDaily)
                    {
                        requestValue = (int)(request.ToDate - request.FromDate).TotalDays + 1;
                    }
                    if (this.CheckRequestValueIsInRangeConditionValue(conditionOperator, managerFlowCondition.Value, requestValue))
                    {
                        isAppliedFlowConditionValue = true;
                    }
                    break;

                case PrecardGroupsName.overwork:
                    requestValue = ((int)(request.ToDate - request.FromDate).TotalDays + 1) * request.TimeDuration;
                    if (this.CheckRequestValueIsInRangeConditionValue(conditionOperator, managerFlowCondition.Value, requestValue))
                    {
                        isAppliedFlowConditionValue = true;
                    }
                    break;

                case PrecardGroupsName.traffic:
                    if (request.FromTime != -1000 && request.ToTime != 1000 && request.TimeDuration != 1000)
                    {
                        if (this.CheckRequestValueIsInRangeConditionValue(conditionOperator, managerFlowCondition.Value, request.TimeDuration))
                        {
                            isAppliedFlowConditionValue = true;
                        }
                    }
                    break;

                case PrecardGroupsName.imperative:
                    if (this.CheckRequestValueIsInRangeConditionValue(conditionOperator, managerFlowCondition.Value, request.TimeDuration))
                    {
                        isAppliedFlowConditionValue = true;
                    }
                    break;

                default:
                    break;
                }
            }
            return(isAppliedFlowConditionValue);
        }
Пример #3
0
        private IList <KartablProxy> GetAllPermits(string searchKey, RequestType requestType, string theDate, int pageIndex, int pageSize, SentryPermitsOrderBy orderby)
        {
            try
            {
                DateTime date;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    date = Utility.ToMildiDate(theDate);
                }
                else
                {
                    date = Utility.ToMildiDateTime(theDate);
                }

                IList <decimal> controlStationIds = accessPort.GetAccessibleControlStations();
                List <decimal>  prsIds            = new List <decimal>();
                IList <decimal> precardIds        = accessPort.GetAccessiblePrecards();

                if (searchKey != null)
                {
                    IList <Person> quciSearchInUnderManagment = searchTool.QuickSearch(searchKey, PersonCategory.Sentry_UnderManagment);
                    var            ids = from o in quciSearchInUnderManagment
                                         select o.ID;
                    prsIds.AddRange(ids.ToList <decimal>());
                }
                else
                {
                    IList <Person> quciSearchInUnderManagment = searchTool.QuickSearch("", PersonCategory.Sentry_UnderManagment);
                    var            ids = from o in quciSearchInUnderManagment
                                         select o.ID;
                    prsIds = ids.ToList <decimal>();
                }

                IList <Permit> result = busPermit.GetExistingPermit(prsIds, precardIds, date, orderby, pageIndex, pageSize);

                IList <Permit> permitList = new List <Permit>();


                var permits = from o in result
                              group o by o.ID;


                foreach (var permit in permits)
                {
                    foreach (Permit item in permit)
                    {
                        permitList.Add(item);
                        break;
                    }
                }

                IList <KartablProxy> kartablResult = new List <KartablProxy>();
                int counter = 0;
                foreach (Permit permit in permitList)
                {
                    IList <PermitPair> permitPairs = permit.Pairs;
                    permitPairs = permitPairs.Where(x => precardIds.Contains(x.PreCardID)).ToList();
                    switch (requestType)
                    {
                    case RequestType.Daily:
                        permitPairs = permitPairs.Where(x => x.Precard.IsDaily).ToList();
                        break;

                    case RequestType.Hourly:
                        permitPairs = permitPairs.Where(x => x.Precard.IsHourly).ToList();
                        break;
                    }
                    foreach (PermitPair permitPair in permitPairs)
                    {
                        counter++;
                        KartablProxy proxy = new KartablProxy();
                        if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                        {
                            proxy.TheFromDate = Utility.ToPersianDate(permit.FromDate);
                            proxy.TheToDate   = Utility.ToPersianDate(permit.ToDate);
                        }
                        else
                        {
                            proxy.TheFromDate = Utility.ToString(permit.FromDate);
                            proxy.TheToDate   = Utility.ToString(permit.ToDate);
                        }
                        proxy.ID           = permitPair.ID;
                        proxy.RequestID    = permitPair.ID;
                        proxy.TheFromTime  = Utility.IntTimeToRealTime(permitPair.From);
                        proxy.TheToTime    = Utility.IntTimeToRealTime(permitPair.To);
                        proxy.Row          = counter;
                        proxy.RequestTitle = permitPair.Precard.Name;
                        proxy.Applicant    = permit.Person.Name;
                        proxy.PersonImage  = permit.Person.PersonDetail.Image;
                        proxy.Barcode      = permit.Person.PersonCode;
                        proxy.PersonId     = permit.Person.ID;
                        string            name      = permitPair.Precard.PrecardGroup.LookupKey;
                        PrecardGroupsName groupName = (PrecardGroupsName)Enum.Parse(typeof(PrecardGroupsName), name);
                        if (groupName == PrecardGroupsName.overwork)
                        {
                            proxy.RequestType = RequestType.OverWork;
                        }
                        else if (permitPair.Precard.IsHourly)
                        {
                            proxy.RequestType = RequestType.Hourly;
                        }
                        else if (permitPair.Precard.IsDaily)
                        {
                            proxy.RequestType = RequestType.Daily;
                        }
                        else
                        {
                            proxy.RequestType = RequestType.None;
                        }

                        kartablResult.Add(proxy);
                    }
                }
                return(kartablResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        private IList <KartablProxy> GetAllPermits(string searchKey, RequestType requestType, string theDate, bool isEndFlowRequestsView, int pageIndex, int pageSize, SentryPermitsOrderBy orderby, out int count)
        {
            try
            {
                DateTime date;
                if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                {
                    date = Utility.ToMildiDate(theDate);
                }
                else
                {
                    date = Utility.ToMildiDateTime(theDate);
                }

                //IList<decimal> controlStationIds = accessPort.GetAccessibleControlStations();
                List <decimal>  prsIds     = new List <decimal>();
                IList <decimal> precardIds = accessPort.GetAccessiblePrecards();

                if (searchKey != null)
                {
                    IList <Person> quciSearchInUnderManagment = searchTool.QuickSearch(searchKey, PersonCategory.Sentry_UnderManagment);
                    var            ids = from o in quciSearchInUnderManagment
                                         select o.ID;
                    prsIds.AddRange(ids.ToList <decimal>());
                }
                else
                {
                    IList <Person> quciSearchInUnderManagment = searchTool.QuickSearch("", PersonCategory.Sentry_UnderManagment);
                    var            ids = from o in quciSearchInUnderManagment
                                         select o.ID;
                    prsIds = ids.ToList <decimal>();
                }

                IList <InfoRequest> requestList = new RequestRepository(false).GetAllRequestMinOneLevelConfirm(prsIds, precardIds, date, orderby);
                if (requestList == null)
                {
                    requestList = new List <InfoRequest>();
                }
                IList <Precard> precardList = new BPrecard().GetAll();
                switch (requestType)
                {
                case RequestType.Daily:
                    requestList = requestList.Where(x => precardList.Any(y => y.IsDaily && y.ID == x.PrecardID) && x.LookupKey != PrecardGroupsName.terminate.ToString() && ((x.ChildsCount != 0 && x.ChildsUnConfirmCount != 0 && x.ChildsCount == x.ChildsUnConfirmCount) || x.ChildsCount == 0)).ToList();
                    break;

                case RequestType.Hourly:
                    requestList = requestList.Where(x => precardList.Any(y => y.IsHourly && y.ID == x.PrecardID) && x.LookupKey != PrecardGroupsName.overwork.ToString() && x.LookupKey != PrecardGroupsName.imperative.ToString() && x.LookupKey != PrecardGroupsName.terminate.ToString() && ((x.ChildsCount != 0 && x.ChildsUnConfirmCount != 0 && x.ChildsCount == x.ChildsUnConfirmCount) || x.ChildsCount == 0)).ToList();
                    break;

                case RequestType.Monthly:
                    requestList = requestList.Where(x => precardList.Any(y => y.IsMonthly && y.ID == x.PrecardID) && x.LookupKey != PrecardGroupsName.terminate.ToString() && ((x.ChildsCount != 0 && x.ChildsUnConfirmCount != 0 && x.ChildsCount == x.ChildsUnConfirmCount) || x.ChildsCount == 0)).ToList();
                    break;

                case RequestType.OverWork:
                    requestList = requestList.Where(x => x.LookupKey == PrecardGroupsName.overwork.ToString() && ((x.ChildsCount != 0 && x.ChildsUnConfirmCount != 0 && x.ChildsCount == x.ChildsUnConfirmCount) || x.ChildsCount == 0)).ToList();
                    break;

                case RequestType.Imperative:
                    requestList = requestList.Where(x => x.LookupKey == PrecardGroupsName.imperative.ToString()).ToList();
                    break;

                case RequestType.Terminate:
                    requestList = requestList.Where(x => x.ParentID != null).ToList();
                    break;

                case RequestType.None:
                    requestList = requestList.Where(x => x.LookupKey != PrecardGroupsName.terminate.ToString() && ((x.ChildsCount != 0 && x.ChildsUnConfirmCount != 0 && x.ChildsCount == x.ChildsUnConfirmCount) || x.ChildsCount == 0)).ToList();
                    break;
                }
                if (isEndFlowRequestsView)
                {
                    requestList = requestList.Where(x => x.Confirm.HasValue && x.Confirm.Value).ToList();
                }

                count       = requestList.Count;
                requestList = requestList.Skip(pageSize * pageIndex).Take(pageSize).ToList();


                IList <KartablProxy> kartablResult = new List <KartablProxy>();
                int counter = 0;
                foreach (InfoRequest request in requestList)
                {
                    counter++;
                    KartablProxy proxy = new KartablProxy();
                    if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi)
                    {
                        proxy.TheFromDate = Utility.ToPersianDate(request.FromDate);
                        proxy.TheToDate   = Utility.ToPersianDate(request.ToDate);
                    }
                    else
                    {
                        proxy.TheFromDate = Utility.ToString(request.FromDate);
                        proxy.TheToDate   = Utility.ToString(request.ToDate);
                    }
                    proxy.ID           = request.ID;
                    proxy.RequestID    = request.ID;
                    proxy.TheFromTime  = Utility.IntTimeToRealTime(request.FromTime);
                    proxy.TheToTime    = Utility.IntTimeToRealTime(request.ToTime);
                    proxy.Row          = counter;
                    proxy.RequestTitle = request.PrecardName;
                    proxy.Applicant    = request.Applicant;
                    proxy.PersonImage  = request.PersonImage;
                    proxy.Barcode      = request.PersonCode;
                    proxy.PersonId     = request.PersonID;
                    proxy.Description  = request.Description;
                    string            name      = request.LookupKey;
                    PrecardGroupsName groupName = (PrecardGroupsName)Enum.Parse(typeof(PrecardGroupsName), name);
                    if (groupName == PrecardGroupsName.overwork)
                    {
                        proxy.RequestType = RequestType.OverWork;

                        //تنظیم زمان ابتدا و انتها
                        //درخواست بازه ای بدون انتدا و انتها
                        if (request.TimeDuration > 0 && request.FromTime == 1439 && request.ToTime == 1439)
                        {
                            proxy.TheFromTime = proxy.TheToTime = "";
                        }
                    }
                    else if (groupName == PrecardGroupsName.imperative)
                    {
                        proxy.RequestType = RequestType.Imperative;
                    }
                    else if (request.IsHourly)
                    {
                        proxy.RequestType = RequestType.Hourly;
                    }
                    else if (request.IsDaily)
                    {
                        proxy.RequestType = RequestType.Daily;
                    }
                    else if (request.IsMonthly)
                    {
                        proxy.RequestType = RequestType.Monthly;
                    }
                    else
                    {
                        proxy.RequestType = RequestType.None;
                    }
                    proxy.DepartmentId   = request.DepartmentId;
                    proxy.DepartmentName = request.DepartmentName;
                    kartablResult.Add(proxy);
                }
                return(kartablResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }