Beispiel #1
0
        /// <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
            {
                if (Config.CrossReferencePreconditionOnTestRun)
                {
                    Test vtsTest = GetVetsTest();
                    if (vtsTest.ID != TestStatus.RunningTests.Last().RunningTestID)
                    {
                        return;
                    }

                    Vehicle vtsVehicle = GetVetsVehicle();
                    string  vin        = vtsVehicle.CustomFieldValues.FirstOrDefault(p => p.CustomFieldID == "VIN").Value;

                    List <TestResult> testResults = GetTestResults();
                    if (testResults != null && testResults.Count > 0)
                    {
                        SelectPrecondition selectPrecondition = new SelectPrecondition(testResults, vin);
                        selectPrecondition.ShowDialog();
                        TestResult selectedTestRecord = selectPrecondition.SelectedTestRecord;
                        selectPrecondition.Dispose();
                        if (selectedTestRecord != null)
                        {
                            //vtsTest.CustomFieldValues.FirstOrDefault(x => x.CustomFieldID == "PreconditionTest").Value = selectedTestRecord.Name;
                            EntityManagerView.Lookup(Interfaces.Constants.ResourceType.Test).Value.Update(vtsTest.ID, vtsTest.Properties);
                        }
                    }
                }
                _activityStatus.Completed();
            }
            catch (Exception e)
            {
                if (!_aborted)
                {
                    _activityStatus.Failed(e);
                }
            }
        }
Beispiel #2
0
        public PropertyBag ShowTestProperties(string resourceName)
        {
            /// <summary>
            /// To be invoked by UI.dll upon "Get test details" button press.
            /// Test, Fuel, & Vehicle properties are parsed from vtsRepository.xml
            /// for the VTS resource having "resourceName". Properties are written
            /// to VETS resources and returned in PropertyBag for display
            /// in Enterprise UI.
            /// </summary>

            string[] propertyBagFilter = { "ProjectID", "VehicleID", "ManufacturerName", "ModelType", "Priority" };

            _logger.AddLogEntry(TraceEventType.Information, SystemLogSources.DataAccess, String.Format(Properties.Resources.TestImportStarted, resourceName));

            Test    vetsTest    = GetVetsTest(Config.TestResourceName);
            Fuel    vetsFuel    = GetVetsFuel(Config.FuelResourceName);
            Vehicle vetsVehicle = GetVetsVehicle(Config.VehicleResourceName);
            SamplingConfiguration vetsSamplingConfiguration = GetVetsSamplingConfiguration(Config.SamplingConfigurationResourceName);

            //From vtsRepository.xml
            XElement testProperties    = GetProperties(resourceName, Resources.Tests);
            XElement fuelProperties    = GetProperties(resourceName, Resources.Fuels);
            XElement vehicleProperties = GetProperties(resourceName, Resources.Vehicles);
            XElement samplingConfigurationProperties = GetProperties(resourceName, Resources.SamplingConfiguration);

            //Shown in Enterprise UI
            CommonPropertyBag masterPropertyBag  = new CommonPropertyBag("All Properties");
            CommonPropertyBag testPropertyBag    = new CommonPropertyBag(Resources.Tests);
            CommonPropertyBag fuelPropertyBag    = new CommonPropertyBag(Resources.Fuels);
            CommonPropertyBag vehiclePropertyBag = new CommonPropertyBag(Resources.Vehicles);
            CommonPropertyBag samplingConfigurationPropertyBag = new CommonPropertyBag(Resources.SamplingConfiguration);

            masterPropertyBag.SetProperty(Constants.Type, "");
            testPropertyBag.SetProperty(Constants.Type, Resources.Tests);
            fuelPropertyBag.SetProperty(Constants.Type, Resources.Fuels);
            vehiclePropertyBag.SetProperty(Constants.Type, Resources.Vehicles);
            samplingConfigurationPropertyBag.SetProperty(Constants.Type, Resources.SamplingConfiguration);

            //Set all custom fields to empty string and doubles to '0'
            //ClearResourceProperties(vetsTest);
            //ClearResourceProperties(vetsFuel);
            //ClearResourceProperties(vetsVehicle);

            //Write VTS properties to VETS resources & enterprise UI
            foreach (XElement property in testProperties.Descendants())
            {
                SetResourceProperty(vetsTest, property.Name.LocalName, property.Value);
                if (propertyBagFilter.Contains(property.Name.LocalName))
                {
                    testPropertyBag.SetProperty(property.Name.LocalName, property.Value);
                }
            }

            foreach (XElement property in fuelProperties.Descendants())
            {
                SetResourceProperty(vetsFuel, property.Name.LocalName, property.Value);
                if (propertyBagFilter.Contains(property.Name.LocalName))
                {
                    fuelPropertyBag.SetProperty(property.Name.LocalName, property.Value);
                }
            }

            foreach (XElement property in vehicleProperties.Descendants())
            {
                SetResourceProperty(vetsVehicle, property.Name.LocalName, property.Value);
                if (propertyBagFilter.Contains(property.Name.LocalName))
                {
                    vehiclePropertyBag.SetProperty(property.Name.LocalName, property.Value);
                }
            }

            foreach (XElement property in samplingConfigurationProperties.Descendants())
            {
                SetResourceProperty(vetsSamplingConfiguration, property.Name.LocalName, property.Value);
                if (propertyBagFilter.Contains(property.Name.LocalName))
                {
                    samplingConfigurationPropertyBag.SetProperty(property.Name.LocalName, property.Value);
                }
            }

            vetsTest.Modified    = DateTime.Now;
            vetsFuel.Modified    = DateTime.Now;
            vetsVehicle.Modified = DateTime.Now;
            vetsSamplingConfiguration.Modified = DateTime.Now;

            //Refresh to update fields in VETS UI
            _entityManagerView.Lookup(ResourceType.Test).Value.Update(vetsTest.ID, vetsTest.Properties);
            _entityManagerView.Lookup(ResourceType.Fuel).Value.Update(vetsFuel.ID, vetsFuel.Properties);
            _entityManagerView.Lookup(ResourceType.Vehicle).Value.Update(vetsVehicle.ID, vetsVehicle.Properties);
            _entityManagerView.Lookup(ResourceType.SamplingConfiguration).Value.Update(vetsSamplingConfiguration.ID, vetsSamplingConfiguration.Properties);

            masterPropertyBag.SetProperty("Test Properties", testPropertyBag);
            masterPropertyBag.SetProperty("Fuel Properties", fuelPropertyBag);
            masterPropertyBag.SetProperty("Vehicle Properties", vehiclePropertyBag);
            masterPropertyBag.SetProperty("Sampling Configuration Properties", samplingConfigurationPropertyBag);

            _logger.AddLogEntry(TraceEventType.Information, SystemLogSources.DataAccess, String.Format(Properties.Resources.TestImportFinished, resourceName));

            return(masterPropertyBag);
        }