Exemplo n.º 1
0
        public async Task <PriorityResponse> HandleRequest(PriorityRequest request)
        {
            await Task.Delay(30);

            return(new PriorityResponse {
                Priority = request.Priority
            });
        }
Exemplo n.º 2
0
        public void initializeRequestsList()
        {
            outstandingHolidaysListView.Items.Clear();
            try
            {
                messageLabel.Visible = false;
                using (HBSModel _entity = new HBSModel())
                {
                    var prioritiseReqs = (from el in _entity.HolidayRequests
                                          where el.StatusRequest.Status == GeneralUtils.PENDING
                                          select new PriorityRequest()
                    {
                        Constraints = new BreakingConstraints()
                        {
                            AtLeastPercentage = el.ConstraintsBroken.AtLeastPercentage,
                            ExceedsHolidayEntitlement = el.ConstraintsBroken.ExceedsHolidayEntitlement,
                            HeadOrDeputy = el.ConstraintsBroken.HeadOrDeputy,
                            ManagerOrSenior = el.ConstraintsBroken.ManagerOrSenior
                        },
                        WorkingDays = el.NumberOfDays,
                        DaysPeakTime = el.DaysPeakTime,
                        EndDate = el.EndDate,
                        ID = el.ID,
                        RemainingDays = el.User.RemainingDays,
                        StartDate = el.StartDate,
                        InitialHolidayEntitlement = el.User.InitialHolidayEntitlement,
                        TotalPeakDaysHoliday = el.User.TotalPeakDaysHoliday
                    }).ToList();
                    var ordered = new PrioritiseRequests(prioritiseReqs).getPrioritisedRequests();
                    foreach (var request in ordered)
                    {
                        string[] arr = new string[4];
                        arr[0] = request.ID.ToString();
                        arr[1] = request.StartDate.ToShortDateString();
                        arr[2] = request.EndDate.ToShortDateString();
                        arr[3] = request.WorkingDays.ToString();
                        ListViewItem item = new ListViewItem(arr);
                        if (PriorityRequest.isAnyConstraintBroken(request.Constraints))
                        {
                            item.BackColor = Color.SandyBrown;
                        }
                        else
                        {
                            item.BackColor = Color.Lime;
                        }

                        outstandingHolidaysListView.Items.Add(item);
                    }
                }
            }
            catch (Exception err)
            {
                DesktopAppUtils.popDefaultErrorMessageBox("Could not retrieve Item from DB \n" + err.Message);
            }
        }
Exemplo n.º 3
0
        private IEnumerator Coro_ExecutePriorityRequest(PriorityRequest newReq)
        {
            priorityRequests.Push(newReq);

            while (priorityRequests.Count > 0)
            {
                var req = priorityRequests.Pop();

                request = CreateReq(req.reqData);

                yield return(request.Send());

                if (priorityRequestForStatusCode != null)
                {
                    var pReq = priorityRequestForStatusCode(request.ResponseCode);

                    if (pReq != null && pReq.reqData != null)
                    {
                        if (request != null)
                        {
                            request.Destroy();
                            request = null;
                        }

                        priorityRequests.Push(pReq);
                        priorityRequests.Push(req);

                        continue;
                    }
                }

                if (request.IsError)
                {
                    if (req.onError != null)
                    {
                        req.onError(request);
                    }
                }
                else
                {
                    if (request.IsSuccess)
                    {
                        if (req.onSuccess != null)
                        {
                            req.onSuccess(request);
                        }
                    }
                    else
                    {
                        if (req.onFailure != null)
                        {
                            req.onFailure(request);
                        }
                    }
                }

                if (request != null)
                {
                    request.Destroy();
                    request = null;
                }
            }
        }