public void UpdateMethods() { LookupFileReader xlsReader = new LookupFileReader(_log); Dictionary <string, MethodInfo> methodLookup = xlsReader.ReadMethodsFromExcel(); foreach (string productCode in methodLookup.Keys) { var productInfo = _apiReader.ReadProductFromApi(productCode); var productDesc = productInfo.productDescription; methodLookup[productCode].MethodDescription = productDesc; } _log.LogWrite(String.Format("Found {0} distinct methods.", methodLookup.Count)); string connString = ConfigurationManager.ConnectionStrings["OdmConnection"].ConnectionString; using (SqlConnection connection = new SqlConnection(connString)) { foreach (MethodInfo meth in methodLookup.Values) { try { object methodID = SaveOrUpdateMethod(meth, connection); } catch (Exception ex) { _log.LogWrite("error updating method: " + meth.MethodDescription + " " + ex.Message); } } } _log.LogWrite("UpdateMethods OK: " + methodLookup.Count.ToString() + " methods."); }
public void UpdateVariables() { try { LookupFileReader xlsReader = new LookupFileReader(_log); var variables = xlsReader.ReadVariablesFromExcel(); _log.LogWrite(String.Format("Found {0} distinct variables.", variables.Count)); string connString = ConfigurationManager.ConnectionStrings["OdmConnection"].ConnectionString; using (SqlConnection connection = new SqlConnection(connString)) { // to remove any old ("unused") variables DeleteOldVariables(connection); foreach (Variable variable in variables) { try { object variableID = SaveOrUpdateVariable(variable, connection); } catch (Exception ex) { _log.LogWrite("error updating variable: " + variable.VariableCode + " " + ex.Message); } } } _log.LogWrite("UpdateVariables OK: " + variables.Count.ToString() + " variables."); } catch (Exception ex) { _log.LogWrite("UpdateVariables ERROR on row: " + " " + ex.Message); } }
public Dictionary <string, NeonSensorPosition> GetSensorPositions() { var siteInfoList = _apiReader.ReadSitesFromApi().data; var siteInfoLookup = new Dictionary <string, NeonSite>(); foreach (NeonSite neonSite in siteInfoList) { siteInfoLookup.Add(neonSite.siteCode, neonSite); } var sensorSiteLookup = new Dictionary <string, NeonSensorPosition>(); var senPosReader = new SensorPositionReader(_log); List <string> supportedProductCodes = new List <string>(); var lookupReader = new LookupFileReader(_log); supportedProductCodes = lookupReader.ReadProductCodesFromExcel(); foreach (string productCode in supportedProductCodes) { var siteDataUrls = new Dictionary <string, string>(); siteDataUrls = GetSitesForProduct(productCode); foreach (var siteCode in siteDataUrls.Keys) { var dataUrl = siteDataUrls[siteCode]; var dataFiles = _apiReader.ReadNeonFilesFromApi(dataUrl); foreach (var dataFile in dataFiles.files) { if (dataFile.name.Contains("sensor_positions")) { Console.WriteLine(dataFile.name); var sensorPositionUrl = dataFile.url; var sensorPositions = senPosReader.ReadSensorPositionsFromUrl(sensorPositionUrl); foreach (var senPos in sensorPositions) { string fullSiteCode = siteCode + "_" + senPos.HorVerCode; if (!sensorSiteLookup.ContainsKey(fullSiteCode)) { senPos.ParentSite = siteInfoLookup[siteCode]; sensorSiteLookup.Add(fullSiteCode, senPos); } } } } } } return(sensorSiteLookup); }