private void UpdateSystemState() { Test runningTest = _entityQuery.FirstOrDefault <Test>(x => x.ID == _testStatus.RunningTests.Last().RunningTestID); Vehicle runningVehicle = _entityQuery.FirstOrDefault <Vehicle>(x => x.Name == runningTest.VehicleName); try { Main._testType.SetByString(runningTest.Properties.FirstOrDefault(x => x.Key == "TestProcedureName").Value.ToString()); } catch { Main._testType.SetByString(String.Empty); } try { Main._operatorID.SetByString(runningTest.CustomFieldValues.FirstOrDefault(x => x.CustomFieldID == "OperatorID").Value); } catch { Main._operatorID.SetByString(String.Empty); } try { Main._driverID.SetByString(runningTest.CustomFieldValues.FirstOrDefault(x => x.CustomFieldID == "DriverID").Value); } catch { Main._driverID.SetByString(String.Empty); } try { Main._vehicleType.SetByString(runningVehicle.CustomFieldValues.FirstOrDefault(x => x.CustomFieldID == "ModelType").Value); } catch { Main._vehicleType.SetByString(String.Empty); } try { Main._vehicleManufacturer.SetByString(runningVehicle.CustomFieldValues.FirstOrDefault(x => x.CustomFieldID == "ManufacturerName").Value.ToString()); } catch { Main._vehicleManufacturer.SetByString(String.Empty); } Main._systemState.SetCurrentStateRunningTest(); Main._isInit = false; _monitorRunningTestThread = new Thread(_ => MonitorRunningTest()); _monitorRunningTestThread.IsBackground = true; _monitorRunningTestThread.Start(); }
private Test GetVetsTest(string resourceName) { var test = _entityQuery.FirstOrDefault <Test>( x => x.Name == resourceName); if (test == null) { throw new NullReferenceException(string.Format("Test {0} does not exist", resourceName)); } return(test); }
/// <summary> /// Do all test stand updating and re-activate if there have been any changes /// </summary> /// <param name="runContext">The context to use to run the activity</param> /// <param name="activityStatus">Call methods on this object to indicate state and progress of activity</param> public void Run(IActivityRunContext <IEmissionTestRunContext> runContext, IActivityStatus activityStatus) { _runContext = runContext; _activityStatus = activityStatus; try { Test runningTest = EntityQuery.FirstOrDefault <Test>(x => x.ID == TestStatus.RunningTests.Last().RunningTestID); if (Config.ShowPopupOnTestStart && runningTest != null) { List <PropertyInfo> properties = runningTest.GetType().GetProperties().ToList(); if (properties.Any(x => x.Name == "CycleRepeat")) { if (properties.FirstOrDefault(x => x.Name == "CycleRepeat").GetValue(runningTest, null).ToString() == "OperatorControlled") { ShowMessage(Config.PopupTitle, Config.PopupMessage); } } } _activityStatus.Completed(); } catch (Exception e) { if (!_aborted) { _activityStatus.Failed(e); } } }
/// <summary> /// Do all test stand updating and re-activate if there have been any changes /// </summary> /// <param name="runContext">The context to use to run the activity</param> /// <param name="activityStatus">Call methods on this object to indicate state and progress of activity</param> public void Run(IActivityRunContext <IEmissionTestRunContext> runContext, IActivityStatus activityStatus) { _runContext = runContext; _activityStatus = activityStatus; try { Test runningTest = EntityQuery.FirstOrDefault <Test>(x => x.ID == TestStatus.RunningTests.Last().RunningTestID); Program.GetSocDataInParallel(runContext.TestRunContext.TestRunID, runningTest); activityStatus.Completed(); } catch (Exception e) { if (!_aborted) { activityStatus.Failed(e); } } }