private void HandleUpdatesForPrev(ProgressResponse response) { MainThreadUtility.InvokeOnMain(() => { if (response != null) { DataCache.AddCommandProgress(new CommandProgress(CommandType.DevicePrev, response.Body)); if (response.IsFinal) { this.Device.Preving = false; this.SetButtonMode(this._prevButton, this._prevButtonSpinner, false); if (response.IsSuccessful) { } else { if ((bool)!response?.IsReconnectResponse && (bool)!response?.IsServerDownResponse) { AlertUtility.ShowAppError(response?.ErrorBody); } } } } AlertUtility.ShowProgressResponse(this._prevFeature.ProgressText, response); }); }
private void HandleUpdatesForStopStartProgram(ProgressResponse response, ProgramViewModel program, bool start) { MainThreadUtility.InvokeOnMain(() => { if (response != null) { DataCache.AddCommandProgress(new CommandProgress(CommandType.StartPrograms, response.Body, new string[] { program.Id })); if (response.IsFinal) { Action resetProgram = () => { program.Starting = false; ServiceContainer.DeviceService.RequestDevice(this.Device.Device); }; if (response.IsSuccessful) { AlertUtility.ShowProgressResponse("Stop/Start Program " + program.Id, response); this.RegisterForAsyncUpdate(resetProgram, 5000); } else { this.RegisterForAsyncUpdate(resetProgram); if ((bool)!response?.IsReconnectResponse && (bool)!response?.IsServerDownResponse) { AlertUtility.ShowAppError(response?.ErrorBody); } } } } }); }
private void HandleUpdatesForStartCircuits(ProgressResponse response, string[] circuitIds, int durationMinutes) { MainThreadUtility.InvokeOnMain(() => { if (response != null) { DataCache.AddCommandProgress(new CommandProgress(CommandType.StartCircuits, response.Body, circuitIds)); if (response.IsFinal) { Action resetCircuits = () => { foreach (string id in circuitIds) { var circuit = this.Device?.Device?.Circuits.Values.Where((d) => d.Id == id).FirstOrDefault(); if (circuit != null) { circuit.Selected = false; circuit.Starting = false; } } }; if (response.IsSuccessful) { //AlertUtility.ShowAlert("Start Circuits", "Start Circuits"); this.RegisterForAsyncUpdate(resetCircuits, 5000); } else { this.RegisterForAsyncUpdate(resetCircuits); if ((bool)!response?.IsReconnectResponse && (bool)!response?.IsServerDownResponse) { AlertUtility.ShowAppError(response?.ErrorBody); } } DataCache.TriggerDeviceUpdate(this.DeviceId); int countSelected = Device.Circuits.Where((s) => s.Selected).Count(); this._buttonFooterView.PermaDisabled = false; this.ShowHideButtonFooter(countSelected > 0); this._selectionHeaderView.Enabled = true; } } AlertUtility.ShowProgressResponse("Start Circuits", response); }); }