Esempio n. 1
0
        private void ActionTask(string status)
        {
            try
            {
                if (status == "0")
                {
                    if (AppSession.BulkPickByQty)
                    {
                        totalQty = CurrentTask.Quantity;
                    }

                    if (totalQty > 0)
                    {
                        this.CurrentTask.Quantity = Quantity;
                    }
                    else
                    {
                        _navigationService.DisplayAlert("Task Error", "Quantity cannot be 0", "Ok");
                        return;
                    }


                    this.CurrentTask.TaskWasWIP = false;
                }

                Result result = null;
                if (String.IsNullOrEmpty(CurrentTask.FromLocationCode))
                {
                    _navigationService.DisplayAlert("Task Error", "From Location Code cannot be empty!", "Ok");
                    return;
                }


                if (String.IsNullOrEmpty(CurrentTask.ToLocationCode))
                {
                    _navigationService.DisplayAlert("Task Error", "To Location Code cannot be empty!", "Ok");
                }

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

                result = ConnectionService.CompleteBulkPickTask(CurrentTask, AppSession.UserId,
                                                                status,
                                                                this.CurrentTask.TaskDetailID);

                if (result.Status)
                {
                    this.CurrentTask           = JsonConvert.DeserializeObject <GetNextTaskModel>(result.Data.ToString());
                    AppSession.ExecutingTaskId = CurrentTask.TaskDetailID;
                    AppSession.LastRoleId      = CurrentTask.LastRoleID;
                    AppSession.CurrentWaveId   = CurrentTask.WaveID;
                    AppSession.IsHireWave      = CurrentTask.IsHire;
                    switch (status)
                    {
                    default:
                        _navigationService.DisplayAlert("Task Complete", "Task has been completed!", "Ok");
                        break;
                    }

                    if (!AppSession.BulkPickByQty)
                    {
                        totalQty = 0;
                        SkuCode  = String.Empty;
                        Quantity = 0;
                    }
                    else
                    {
                        if (AppSession.CompanyId == "FTS")
                        {
                            totalQty = 0;
                            SkuCode  = String.Empty;
                            Quantity = 0;
                        }
                        else
                        {
                            Quantity = 0;
                        }
                    }
                }
                else
                {
                    AppSession.ExecutingTaskId = 0;
                    AppSession.LastRoleId      = 0;
                    AppSession.CurrentWaveId   = 0;


                    if (result.Message.Contains("No more tasks for") || result.Message.ToLower().Contains("no bulk picks available."))
                    {
                        _navigationService.DisplayAlert("No Tasks", result.Message, "Ok");
                        _navigationService.PushAsync(new BulkPickSearchPage());
                    }
                    else
                    {
                        _navigationService.DisplayAlert("Task Error", result.Message, "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                _navigationService.DisplayAlert("Task Error", ex.Message, "Ok");
            }
        }