Пример #1
0
        private void ActionTask(string status)
        {
            try
            {
                if (Quantity == 0 && status != "2" && status != "3")
                {
                    _navigationService.DisplayAlert("Task Error", @"Quantity is not valid!", "Ok");
                    return;
                }

                DataContext.Quantity = Quantity;
                string qty = Quantity.ToString();

                if (String.IsNullOrEmpty(DataContext.BoxNo) && status == "0")
                {
                    _navigationService.DisplayAlert("Task Error", @"Box Number is not valid!", "Ok");
                    return;
                }

                if (status == "0")
                {
                    DataContext.TaskWasWIP = false;
                }

                Result result;

                string lastPigeonHole = "";
                if (DataContext.BoxNo.Length > 4)
                {
                    lastPigeonHole = DataContext.BoxNo.Substring(DataContext.BoxNo.Length - 4, 4);
                }


                string fromLocationCode = DataContext.FromLocationCode;

                //Result validUser = ConnectionService.ValidateUsertask(AppSession.UserId, DataContext.TaskDetailID);
                //if (!validUser.Status)
                //{
                //    _navigationService.DisplayAlert("Task User Error", "User is not connected to backend system.You will be logged off", "Ok");
                //    ReSetTaskDetail();
                //    _navigationService.PushAsync(new LoginPage());
                //    return;
                //}

                result = ConnectionService.CompleteFinePickTask(DataContext, AppSession.UserId,
                                                                status,
                                                                DataContext.TaskDetailID, false);

                if (result.Status)
                {
                    DataContext = JsonConvert.DeserializeObject <GetNextTaskModel>(result.Data.ToString());

                    switch (status)
                    {
                    case "2":
                        _navigationService.DisplayAlert("Skip Complete", $"{qty} units has been skipped!", "Ok");

                        break;

                    case "3":
                        _navigationService.DisplayAlert("On Hold Complete", $"{qty} units has been put on hold!", "Ok");
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    AppSession.ExecutingTaskId = 0;
                    AppSession.LastRoleId      = 0;


                    if (result.Message.Contains("No more tasks for"))
                    {
                        _navigationService.DisplayAlert("No Tasks", result.Message, "Ok");
                        _navigationService.PushAsync(new FinePickSearchPage());
                    }

                    else
                    {
                        if (result.Message.Contains("This order was already place in a PigeonHole"))
                        {
                            //ViewController.ShowMessage(this, "Task Error", result.Message, true);
                            //isNewPigeonHole = true;
                            //dataContext.BoxNo = fromLocationCode + result.Data.ToString();
                            //lbPigHoleDisplay.Text = result.Data.ToString();
                            //totalQty--;
                            //txtBoxNo.Text = totalQty.ToString();
                            //txtBoxNo.Text = string.Empty;
                            //txtBoxNo.Focus();

                            _navigationService.DisplayAlert("Task Error", result.Message, "Ok");
                            _dataContext.BoxNo = fromLocationCode + result.Data.ToString();
                        }
                        else
                        {
                            _navigationService.DisplayAlert("Task Error", result.Message, "Ok");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _navigationService.DisplayAlert("Task Error", ex.Message, "Ok");
            }
        }