示例#1
0
        public async Task <StatusBasePayload> UpdateStatus(UpdateStatusInput input,
                                                           [ScopedService] ApplicationDbContext context, CancellationToken cancellationToken)
        {
            var status = await context.Status.DeferredFirst(x => x.Id == input.Id).FromCacheAsync(cancellationToken);

            if (status is null)
            {
                return(new StatusBasePayload(
                           new UserError("Status with that id not found.", "STATUS_NOT_FOUND")));
            }

            if (input.Description.HasValue)
            {
                status.Description = input.Description;
            }

            if (input.Color.HasValue)
            {
                status.Color = input.Color;
            }

            if (input.Name.HasValue)
            {
                status.Name = input.Name;
            }
            if (input.Severity.HasValue)
            {
                status.Severity = input.Severity;
            }
            QueryCacheManager.ExpireType <Status>();
            return(new StatusBasePayload(status));
        }
        }        //end method

        protected async Task PerformStatusChange(int selectedStatusID)
        {
            StatusResult result;

            try {
                //Update server
                //
                UpdateUI(true);
                MobRegService     service = new MobRegService(ProgramVars.URL);
                UpdateStatusInput input   = new UpdateStatusInput()
                {
                    newStatus      = selectedStatusID,
                    userID         = App.appSettings.loginVars.userID.ToString(),
                    installationID = App.appSettings.installationID,
                    planningID     = planning.ID,
                    resources      = Common.GetResourcesForPlanningID(planning.ID)
                };
                result = await service.UpdateStatusForGroupAsync(input);

                if (result.statusCode != 0)
                {
                    throw new Exception(result.status);
                }
                //Update client
                //
                Common.ChangeStatus(planning, selectedStatusID);


                // Do post status change processing
                //
                if (selectedStatusID == StatusTypes.FinishedOK || selectedStatusID == StatusTypes.FinishedNOK)
                {
                    planning.ExecEndDateTime = time;
                    // Send ExecXXXDateTimes to server
                    //
                    SavePlanningInput saveInput = new SavePlanningInput()
                    {
                        userIDin                 = App.appSettings.loginVars.userID.ToString(),
                        installationID           = App.appSettings.installationID,
                        dataIn                   = planning.TOrsPlanning(),
                        overWriteExecEndDateTime = true,
                        includeSignatureData     = false,
                        sendReport               = true,
                        resources                = Common.GetResourcesForPlanningID(planning.ID)
                    };
                    result = await service.SavePlanningAsync(saveInput);

                    if (result.statusCode != 0)
                    {
                        throw new Exception(result.status);
                    }

                    // Delete all planning related data from client
                    //
                    Common.DeletePlanningByPlanningID(planning.ID);
                }
                else
                {
                    // Update PlanningHistory table
                    //
                    planning.StatusID = selectedStatusID;
                    App.dbHandler.db.Update(planning);
                    PlanningHistory his = new PlanningHistory()
                    {
                        PlanningID = planning.ID,
                        StatusID   = planning.StatusID,
                        StartTime  = time,
                        EndTime    = time
                    };
                    App.dbHandler.db.Insert(his);
                }
                //activityIndicator.IsRunning = activityIndicator.IsVisible = false;
                UpdateUI(false);
                await App.Current.MainPage.Navigation.PopAsync(true);
            } catch (Exception ex) {
                UpdateUI(false);
                //activityIndicator.IsRunning = activityIndicator.IsVisible = false;
                await DisplayAlert(AppResources.Error, ex.Message, AppResources.Cancel);
            }
        }
示例#3
0
 public void UpdateStatusForGroup(UpdateStatusInput input, Action <StatusResult> whenCompleted)
 {
     ProcessRestRequest <UpdateStatusInput, StatusResult> ("UpdateStatusForGroup", input, whenCompleted);
 }
示例#4
0
 public async Task <StatusResult> UpdateStatusForGroupAsync(UpdateStatusInput input)
 {
     return(await ProcessAsync <UpdateStatusInput, StatusResult> ("UpdateStatusForGroup", input, new StatusResult()));
 }