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 HandleUpdatesForTestStations(ProgressResponse response, string[] stationIds) { MainThreadUtility.InvokeOnMain(() => { if (response != null) { DataCache.AddCommandProgress(new CommandProgress(CommandType.TestStations, response.Body, stationIds)); if (response.IsFinal) { Action resetStations = () => { foreach (string id in stationIds) { var station = this.Device?.Device?.Stations.Values.Where((d) => d.Id == id).FirstOrDefault(); if (station != null) { station.Selected = false; station.Starting = false; } } }; if (response.IsSuccessful) { //AlertUtility.ShowAlert("Testing Stations", "Testing Stations"); this.RegisterForAsyncUpdate(resetStations, 5000); } else { this.RegisterForAsyncUpdate(resetStations); if ((bool)!response?.IsReconnectResponse && (bool)!response?.IsServerDownResponse) { AlertUtility.ShowAppError(response?.ErrorBody); } } DataCache.TriggerDeviceUpdate(this.DeviceId); int countSelected = Device.Stations.Where((s) => s.Selected).Count(); this._buttonFooterView.PermaDisabled = false; this.ShowHideButtonFooter(countSelected); this._selectionHeaderView.Enabled = true; /* * this.LoadData(); */ } } }); }
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); }); }
private void HandleUpdatesForStartStations(ProgressResponse response, IEnumerable <PumpViewModel> pumps, int durationMinutes, string[] stationIds) { MainThreadUtility.InvokeOnMain(() => { if (response != null) { DataCache.AddCommandProgress(new CommandProgress(CommandType.StartStations, response.Body, stationIds)); if (response.IsFinal) { Action resetStations = () => { foreach (string id in stationIds) { var station = this.Device?.Device?.Stations.Values.Where((d) => d.Id == id).FirstOrDefault(); if (station != null) { station.Selected = false; station.Starting = false; } } }; if (response.IsSuccessful) { //AlertUtility.ShowAlert("Starting Stations", "Starting Stations"); this.RegisterForAsyncUpdate(resetStations, 5000); } else { this.RegisterForAsyncUpdate(resetStations); if ((bool)!response?.IsReconnectResponse && (bool)!response?.IsServerDownResponse) { AlertUtility.ShowAppError(response?.ErrorBody); } } DataCache.TriggerDeviceUpdate(this.DeviceId); } } }); }