public async void RunUDS(UserDefinedSelectionViewModel udsvm) { if (NotNetOrConnection) { return; } try { udsvm.State = ModelState.Loading; List <UserDefinedSelectionResult> list = await NAV.RunUDS(Zone.LocationCode, Zone.Code, udsvm.ID, ACD.Default).ConfigureAwait(true); if (list is List <UserDefinedSelectionResult> ) { foreach (RackViewModel rvm in RackViewModels) { rvm.UDSSelects.RemoveAll(x => x.FunctionID == udsvm.ID); } foreach (UserDefinedSelectionResult udsr in list) { RackViewModel rvm = RackViewModels.ToList().Find(x => x.No == udsr.RackNo); if (rvm is RackViewModel) { SubSchemeSelect sss = new SubSchemeSelect() { FunctionID = udsr.FunctionID, Section = udsr.Section, Level = udsr.Level, Depth = udsr.Depth, Value = udsr.Value, HexColor = udsr.HexColor }; rvm.UDSSelects.Add(sss); } } } MessagingCenter.Send(this, "UDSRunIsDone"); } catch (OperationCanceledException e) { System.Diagnostics.Debug.WriteLine(e.Message); ErrorText = e.Message; LoadAnimation = false; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } udsvm.State = ModelState.Normal; }
public async void RunUDS(UserDefinedSelectionViewModel udsvm) { if (NotNetOrConnection) { return; } try { if (udsvm.UDSIsRan) { UDSLastResults.RemoveAll(x => x.FunctionID == udsvm.ID); foreach (RackViewModel rvm in RackViewModels) { rvm.UDSSelects.RemoveAll(x => x.FunctionID == udsvm.ID); } MessagingCenter.Send(this, "UDSRunIsDone"); udsvm.UDSIsRan = false; } else { udsvm.State = ModelState.Loading; List <UserDefinedSelectionResult> list = await NAV.RunUDS(Zone.LocationCode, Zone.Code, udsvm.ID, ACD.Default).ConfigureAwait(true); if ((NotDisposed) && (list is List <UserDefinedSelectionResult>)) { UDSLastResults.RemoveAll(x => x.FunctionID == udsvm.ID); foreach (UserDefinedSelectionResult udsr in list) { UDSLastResults.Add(udsr); } FillRackUDSR(udsvm.ID); MessagingCenter.Send(this, "UDSRunIsDone"); } udsvm.UDSIsRan = true; } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); udsvm.UDSIsRan = false; } finally { LoadAnimation = false; } udsvm.State = ModelState.Normal; }