public bool GetCharlieCodeFromDelta( string symbolSetString, string entityString, string mod1String, string mod2String, out string charlieCode) { Initialize(); charlieCode = string.Empty; var results = from row in LegacyCodeMappingTable.AsEnumerable() where (row.Field <string>("2525DeltaSymbolSet") == symbolSetString) & (row.Field <string>("2525DeltaEntity") == entityString) & (row.Field <string>("2525DeltaMod1") == mod1String) & (row.Field <string>("2525DeltaMod2") == mod2String) select row; int resultCount = results.Count(); if (resultCount < 1) { // Try one more time without modifiers // (TODO: this is a bit inefficient - if performance is a problem - refactor) results = from row in LegacyCodeMappingTable.AsEnumerable() where (row.Field <string>("2525DeltaSymbolSet") == symbolSetString) & (row.Field <string>("2525DeltaEntity") == entityString) select row; } resultCount = results.Count(); if (resultCount < 1) { // Uncomment if you want this info, but this is a normal result for many symbols // System.Diagnostics.Trace.WriteLine("Charlie Code not found: " + symbolSetString // + " : " + entityString + " : " + mod1String + " : " + mod2String); return(false); } else if (resultCount > 1) { System.Diagnostics.Trace.WriteLine("Warning Mutiple, Charlie Codes found, may not be correct or require modifiers: " + symbolSetString + " : " + entityString + " : " + mod1String + " : " + mod2String); } foreach (DataRow row in results) { charlieCode = row["2525Charlie"] as string; if (!string.IsNullOrEmpty(charlieCode)) { // may be muliple results with this table (some that do not have 2525C set) break; } } return(!string.IsNullOrEmpty(charlieCode)); }
/// <summary> /// Search the Charlie table and create a list of all of these symbols that can be /// created/mapped to Delta /// </summary> public List <MilitarySymbol> GetMilitarySymbolsFromCharlie() { Initialize(); List <MilitarySymbol> symbolList = new List <MilitarySymbol>(); var results = from row in LegacyCodeMappingTable.AsEnumerable() select row; // Check that search returned something int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("WARNING: Empty result of LegacyCodeMappingTable search"); // TODO: add search params to the debug output return(symbolList); // empty list } foreach (DataRow row in results) { string legacyCode = row["2525Charlie"] as string; if (!string.IsNullOrWhiteSpace(legacyCode)) { MilitarySymbol milSymbol = new MilitarySymbol(); milSymbol.Legacy2525Code = legacyCode; // TODO: set MilitarySymbol.Shape from SymbolId symbolList.Add(milSymbol); } } return(symbolList); }
public bool GetDeltaCodeFromCharlie(string charlieCode, out string symbolSetString, out string entityString, out string mod1String, out string mod2String) { Initialize(); symbolSetString = string.Empty; entityString = string.Empty; mod1String = string.Empty; mod2String = string.Empty; if ((LegacyCodeMappingTable == null) || string.IsNullOrEmpty(charlieCode) || (charlieCode.Length < 10)) { return(false); } bool isWeather = (charlieCode[0] == 'W'); char replaceAffilChar = '*'; if (isWeather) { replaceAffilChar = charlieCode[1]; } StringBuilder sbLookupCharlieCode = new StringBuilder(); sbLookupCharlieCode.Append(charlieCode[0]); sbLookupCharlieCode.Append(replaceAffilChar); sbLookupCharlieCode.Append(charlieCode[2]); if (isWeather) { sbLookupCharlieCode.Append(charlieCode[3]); } else { sbLookupCharlieCode.Append('P'); } sbLookupCharlieCode.Append(charlieCode.Substring(4, 6)); string lookupCharlieCode = sbLookupCharlieCode.ToString(); var results = from row in LegacyCodeMappingTable.AsEnumerable() where (row.Field <string>("2525Charlie1stTen") == lookupCharlieCode) select row; int resultCount = results.Count(); if (resultCount < 1) { System.Diagnostics.Trace.WriteLine("Charlie Code not found: " + lookupCharlieCode); return(false); } foreach (DataRow row in results) { symbolSetString = row["2525DeltaSymbolSet"] as string; entityString = row["2525DeltaEntity"] as string; mod1String = row["2525DeltaMod1"] as string; mod2String = row["2525DeltaMod2"] as string; break; // should only be 1 result } return(true); }