/// <summary> /// Gets the OMS asset.properties data in a form desired by the DecisionEngine /// </summary> /// <returns>A list of AttribueValueDE containing OMS ObjectUserID Hierarchy, Values and LastEntry date</returns> public List <AttributeValueDEStore> GetDecisionEngineAttributes(List <AttributeStore> attributes, AssetRequestOMSDataStore assetRequest, Dictionary <string, AssetReplyOMSLookupTable> assetLookups) { List <AttributeValueDEStore> deAttributes = new List <AttributeValueDEStore>(); foreach (AssetReplyOMSTableStore table in _tables) { AssetRequestOMSTableStore requestedLookupTables = assetRequest.Tables.Find(delegate(AssetRequestOMSTableStore a) { return(a.ForeignKeyTable == table.OmsTable); }); string key = ""; foreach (AssetReplyOMSColumnStore column in table.Columns) { deAttributes.Add(new AttributeValueDEStore(column.OmsObjectUserIDHierarchy, column.Value, table.DateLastEntry, column.AttributeField)); if (requestedLookupTables != null && column.OmsObjectUserIDHierarchy == requestedLookupTables.ForeignKeyColumn) { key = column.Value; } } if (requestedLookupTables != null) { string primaryKey = requestedLookupTables.PrimaryKeyColumn; if (assetLookups.ContainsKey(requestedLookupTables.TableName)) { AssetReplyOMSLookupTable lookup = assetLookups[requestedLookupTables.TableName]; if (key != null && lookup.LookupData.ContainsKey(key)) { Dictionary <string, string> values = lookup.LookupData[key]; foreach (AssetRequestOMSColumnStore column in requestedLookupTables.Columns) { if (column.OmsObjectUserIDHierarchy != null) { deAttributes.Add(new AttributeValueDEStore(column.OmsObjectUserIDHierarchy, values[column.ColumnName], table.DateLastEntry, column.AttributeField)); } } } else if (key == null) { foreach (AssetRequestOMSColumnStore column in requestedLookupTables.Columns) { if (column.OmsObjectUserIDHierarchy != null) { deAttributes.Add(new AttributeValueDEStore(column.OmsObjectUserIDHierarchy, null, table.DateLastEntry, column.AttributeField)); } } } } } } foreach (AssetReplyOMSConditionIndex aroci in this.ConditionIndices) { deAttributes.Add(new AttributeValueDEStore("__" + aroci.ConditionIndex.Replace(" ", "").Replace("/", ""), aroci.Value.ToString(), aroci.InspectionDate)); } return(deAttributes); }
/// <summary> /// This object is passed to the OMS class to request data for the contained tables. /// </summary> /// <param name="beforeDate">The date on of before which the data is desired.</param> /// <param name="attributes">A unique list of Attribute Stores required to perform the simulation</param> public AssetRequestOMSDataStore(DateTime beforeDate, List <AttributeStore> attributes, OMSAssetConditionIndexStore conditionIndex) { _beforeDate = beforeDate; _conditionIndex = conditionIndex; _tables = new List <AssetRequestOMSTableStore>(); if (attributes != null && attributes.Count > 0) { _assetTypeName = attributes[0].AssetType; foreach (AttributeStore attribute in attributes) { if (!attribute.IsConditionCategory && attribute.AttributeField != "AGE")//Ignore AGE which is calculated in DecisionEngine and ConditionIndices which are got with different. { int index = Tables.FindIndex(delegate(AssetRequestOMSTableStore art) { return(art.TableName == attribute.OmsTable); }); if (index < 0) { string foreignKey = null; string primaryKey = null; string foreignKeyTable = null; AssetRequestOMSTableStore table = new AssetRequestOMSTableStore(attribute.OmsTable); table.Columns.Add(new AssetRequestOMSColumnStore(attribute.AttributeField.ToString(), attribute.OmsObjectUserIDHierarchy.ToString(), attribute.AttributeField)); OMS.GetPrimaryKeyForLookups(attribute.OmsOIDHierarchy, out primaryKey, out foreignKey, out foreignKeyTable); table.PrimaryKeyColumn = primaryKey; table.ForeignKeyColumn = foreignKey; table.ForeignKeyTable = foreignKeyTable; _tables.Add(table); } else { Tables[index].Columns.Add(new AssetRequestOMSColumnStore(attribute.AttributeField.ToString(), attribute.OmsObjectUserIDHierarchy.ToString(), attribute.AttributeField)); } } } } }