private void Fill_GridRequestRefrence_RequestRefrence(decimal RequestID, string RefrenceType) { string[] retMessage = new string[4]; try { IList <KartablProxy> requestList = new List <KartablProxy>(); GTS.Clock.Model.RequestFlow.Request request = null; switch (RefrenceType.ToLower()) { case "ischild": request = this.RequestBusiness.GetByID(RequestID).RequestChildList.FirstOrDefault(); break; case "isparent": request = this.RequestBusiness.GetByID(RequestID); break; } KartablProxy proxy = this.KartableBusiness.ConvertRegisterRequestToProxy(request); requestList.Add(proxy); this.GridRequestRefrence_RequestRefrence.DataSource = requestList; this.GridRequestRefrence_RequestRefrence.DataBind(); } catch (UIValidationExceptions ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage); this.ErrorHiddenField_Refrence_RequestRefrence.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } catch (UIBaseException ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage); this.ErrorHiddenField_Refrence_RequestRefrence.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } catch (Exception ex) { retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage); this.ErrorHiddenField_Refrence_RequestRefrence.Value = this.exceptionHandler.CreateErrorMessage(retMessage); } }
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; } }
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; } }