示例#1
0
        /// <summary>
        /// Convert SimulationStore into necessary tables entries for RoadCare
        /// </summary>
        /// <param name="simulationID"></param>
        public static void Simulation(string simulationID)
        {
            SimulationStore             simulation = SelectScenario.GetSimulationStore(simulationID);
            OMSAssetConditionIndexStore oci        = OMS.GetAssetConditionIndex(simulation.Asset);

            PrepareAnalysis.Priorities(simulation);
            //PrepareAnalysis.TargetAndDeficients(simulation);
            PrepareAnalysis.ConditionCategoryWeights(simulation);
            //PrepareAnalysis.Performance(simulation);
            //PrepareAnalysis.RepeatedActivities(simulation);
            //PrepareAnalysis.ActivityFeasibilityCostConsequences(simulation);
            List <AttributeStore>    attributes   = PrepareAnalysis.Attributes(simulation);
            AssetRequestOMSDataStore assetRequest = new AssetRequestOMSDataStore(DateTime.Now, attributes, oci);
            Dictionary <string, AssetReplyOMSLookupTable> assetLookups = OMS.GetAssetLookupData(assetRequest);
            List <AssetReplyOMSDataStore> assets = OMS.GetAssetData(assetRequest);
            List <AssetReplyOMSDataStore> assetsWithCondition = assets.FindAll(delegate(AssetReplyOMSDataStore arods) { return(arods.ConditionIndices != null); });

            PrepareAnalysis.Assets(simulation, assetsWithCondition, attributes, assetRequest, assetLookups);
        }
示例#2
0
        private static void Assets(String simulationID, List <AssetReplyOMSDataStore> assets, List <AttributeStore> attributes, AssetRequestOMSDataStore assetRequest, Dictionary <string, AssetReplyOMSLookupTable> assetLookups, Boolean isDelete)
        {
            if (isDelete)
            {
                DeleteScenario.DeleteAssets(simulationID);
            }
            string path = Path.GetTempPath() + "DecisionEngine";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            path += "\\oms_assets_" + simulationID + ".txt";
            TextWriter tw = null;

            try
            {
                tw = new StreamWriter(path);
                foreach (AssetReplyOMSDataStore asset in assets)
                {
                    List <AttributeValueDEStore> values = asset.GetDecisionEngineAttributes(attributes, assetRequest, assetLookups);

                    //JWC_PROJECT
                    //Only include non-retired projects. If retired is non-null (ie has date), don't import it.
                    AttributeValueDEStore retired = values.Find(delegate(AttributeValueDEStore a) { return(a.AttributeField == "Retired"); });
                    if (retired != null && retired.Value == null)
                    {
                        foreach (AttributeValueDEStore value in values)
                        {
                            string row;
                            if (value.AttributeField != null)
                            {
                                row = "\t" + simulationID + "\t" + asset.OID + "\t" + value.AttributeField + "\t" + value.LastEntry.ToString() + "\t";
                            }
                            else
                            {
                                row = "\t" + simulationID + "\t" + asset.OID + "\t" + value.OmsObjectUserIDHierarchy + "\t" + value.LastEntry.ToString() + "\t";
                            }

                            if (value.Value != null)
                            {
                                row += value.Value.ToString();
                            }
                            tw.WriteLine(row);

                            if (value.OmsObjectUserIDHierarchy == "ID")
                            {
                                row = "\t" + simulationID + "\t" + asset.OID + "\tAssetType\t" + value.LastEntry.ToString() + "\t" + attributes[0].AssetType;
                                tw.WriteLine(row);
                            }

                            //JWC_PROJECT
                            //Import for case where user has entered an estimated OCI of 0.
                            //Need to add virtual condition indexes with all zeros so model works properly.
                            if (value.OmsObjectUserIDHierarchy == "EstimatedOCI")
                            {
                                if (value.Value != null)
                                {
                                    double estimatedOCI = Convert.ToDouble(value.Value);
                                    if (estimatedOCI == 0)
                                    {
                                        foreach (AssetReplyOMSConditionIndex conditionIndex in asset.ConditionIndices)
                                        {
                                            string ci = "__" + conditionIndex.ConditionIndex.Replace(" ", "").Replace("/", "");
                                            row = "\t" + simulationID + "\t" + asset.OID + "\t" + ci + "\t" + DateTime.Now.ToString() + "\t0";
                                            tw.WriteLine(row);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                tw.Close();
            }
            catch (Exception e)
            {
            }
            finally
            {
                if (tw != null)
                {
                    tw.Close();
                }
            }

            DB.SQLBulkLoad(DB.TablePrefix + "OMS_ASSETS", path, '\t');
        }
示例#3
0
 private static void Assets(SimulationStore simulation, List <AssetReplyOMSDataStore> assets, List <AttributeStore> attributes, AssetRequestOMSDataStore assetRequest, Dictionary <string, AssetReplyOMSLookupTable> assetLookups)
 {
     PrepareAnalysis.Assets(simulation.SimulationID, assets, attributes, assetRequest, assetLookups, true);
 }
示例#4
0
        public static List <AttributeStore> InitializeRoadCareAttributes(List <String> assets, List <String> additionalAttributes)
        {
            DeleteScenario.DeleteAssets("0");
            List <AttributeStore> crossAssets = new List <AttributeStore>();

            foreach (String asset in assets)
            {
                List <AttributeStore>       attributes = new List <AttributeStore>();
                OMSAssetConditionIndexStore oci        = OMS.GetAssetConditionIndex(asset);
                for (int i = 0; i < oci.ConditionIndexes.Count; i++)
                {
                    string criteria = oci.Weights[i].Criteria;
                    if (criteria != null)
                    {
                        List <AttributeStore> ociCriteriaAttributes = OMS.ParseAttributes(asset, criteria);
                        foreach (AttributeStore attribute in ociCriteriaAttributes)
                        {
                            if (!attributes.Contains(attribute))
                            {
                                attributes.Add(attribute);
                            }
                        }
                    }
                }



                //Get additional data requested.
                List <AttributeStore> attributeAsset = OMS.GetAssetAttributes(asset);
                foreach (String additionalAttribute in additionalAttributes)
                {
                    AttributeStore additional = attributeAsset.Find(delegate(AttributeStore a) { return(a.AttributeField == additionalAttribute); });
                    if (!attributes.Contains(additional))
                    {
                        if (additional != null)
                        {
                            attributes.Add(additional);
                        }
                    }

                    AttributeStore crossAsset = crossAssets.Find(delegate(AttributeStore a) { return(a.AttributeField == additionalAttribute); });
                    if (crossAsset == null)
                    {
                        if (additional != null)
                        {
                            crossAssets.Add(additional);
                        }
                    }
                }


                AssetRequestOMSDataStore assetRequest = new AssetRequestOMSDataStore(DateTime.Now, attributes, oci);
                Dictionary <string, AssetReplyOMSLookupTable> assetLookups = OMS.GetAssetLookupData(assetRequest);
                List <AssetReplyOMSDataStore> assetsFromRequest            = OMS.GetAssetData(assetRequest);
                List <AssetReplyOMSDataStore> assetsWithCondition          = assetsFromRequest.FindAll(delegate(AssetReplyOMSDataStore arods) { return(arods.ConditionIndices != null); });

                PrepareAnalysis.Assets("0", assetsWithCondition, attributes, assetRequest, assetLookups, false);
            }

            //Do something with cross attributes.
            AttributeStore assetType = new AttributeStore(null, "AssetType", "AssetType", null);

            assetType.FieldType = "Text";
            crossAssets.Add(assetType);

            AttributeStore overallConditionIndex = new AttributeStore(null, "OverallConditionIndex", "OverallConditionIndex", null);

            overallConditionIndex.FieldType    = "Number";
            overallConditionIndex.Minimum      = 0;
            overallConditionIndex.Maximum      = 100;
            overallConditionIndex.Format       = "f1";
            overallConditionIndex.InitialValue = "100";
            overallConditionIndex.Ascending    = true;
            crossAssets.Add(overallConditionIndex);


            foreach (String asset in assets)
            {
                OMSAssetConditionIndexStore oci = OMS.GetAssetConditionIndex(asset);

                foreach (OMSConditionIndexStore ci  in oci.ConditionIndexes)
                {
                    String         conditionIndex          = "__" + ci.ConditionCategory.Replace(" ", "").Replace("/", "");
                    AttributeStore attributeConditionIndex = crossAssets.Find(delegate(AttributeStore a) { return(a.OmsObjectUserIDHierarchy == conditionIndex); });
                    if (attributeConditionIndex == null)
                    {
                        attributeConditionIndex           = new AttributeStore(null, conditionIndex, conditionIndex, null);
                        attributeConditionIndex.FieldType = "Number";
                        crossAssets.Add(attributeConditionIndex);
                    }
                }
            }
            return(crossAssets);
        }