public Dictionary<string, inverter> loadInverters(String siteName) { Dictionary<String, inverter> allInvs = new Dictionary<string, inverter>(); inverter oneInv; String serialNo, company, otherName, model, sensorSN; long sitePower, inverterPower; int type; invType invTp; using(SqlCommand cde = new SqlCommand( "select company, sitePower, serialNo, otherName, inverterPower, model, type, sensorSN "+ " from inverter join site on siteName = name " + "where siteName = '"+ siteName+"';", con)) { SqlDataReader myRdr = cde.ExecuteReader(); while (myRdr.Read()) { company = myRdr.GetString(0); sitePower = myRdr.GetInt64(1); serialNo = myRdr.GetString(2); otherName = myRdr.GetString(3); inverterPower = myRdr.GetInt64(4); model = myRdr.GetString(5); type = (int)myRdr.GetByte(6); sensorSN = myRdr.GetString(7); switch(type){ case 1: invTp = invType.WEBBOX; break; case 2: invTp = invType.SENSOR; break; default: invTp = invType.INVERTER; break; } oneInv = new inverter(company, siteName, sitePower, serialNo, otherName, inverterPower, model, invTp, sensorSN, true); allInvs.Add(oneInv.serialNo, oneInv); } myRdr.Close(); } return allInvs; }
void dumpANode(String siteName, XmlNode xnd) { string[] strInfo; DateTime dtMeasure; String strUnit; int measurePeriod; String[] measureNamesSplitted; inverter inv; String internalName; measureDef mDef; try { switch (xnd.Name) { case "Info": return; case "CurrentPublic": case "MeanPublic": strInfo = getNodeInfo(xnd); measureNamesSplitted = glob.decodeName(strInfo[2]); dtMeasure = getNodeDate(xnd); strUnit = getNodeValueString(xnd, "Unit"); measurePeriod = getNodeValInt(xnd, "Period"); if (!glob.inverters.ContainsKey(strInfo[1])) { inv = new inverter("???", siteName, 0, strInfo[1], strInfo[0], 0, "???"); glob.inverters.Add(inv.serialNo, inv); } else inv = glob.inverters[strInfo[1]]; if (glob.allMNames.ContainsKey(strInfo[2])) { internalName = glob.allMNames[strInfo[2]]; } else { Console.WriteLine("Measure: " + strInfo[2] + " not found in allMNames"); return; } if (internalName == null) return; if (!glob.allM.ContainsKey(internalName)) { MessageBox.Show ("No measure definition for " + strInfo[2] + "("+internalName+")"); return; } mDef = glob.allM[internalName]; switch (mDef.valueDataType) { case valueDTP.INT: inv.setValue(dtMeasure, measureNamesSplitted[3], strInfo[2], getNodeValInt(xnd, "Mean")); break; case valueDTP.DOUBLE: inv.setValue(dtMeasure, measureNamesSplitted[3], strInfo[2], getNodeValDouble(xnd, "Mean")); break; case valueDTP.STRING: inv.setValue(dtMeasure, measureNamesSplitted[3], strInfo[2], getNodeValueString(xnd, "Mean")); break; case valueDTP.M3INT: int[] valIntArray = new int[3]; valIntArray[0] = getNodeValInt(xnd, "Mean"); valIntArray[1] = getNodeValInt(xnd, "Min"); valIntArray[2] = getNodeValInt(xnd, "Max"); inv.setValue(dtMeasure, measureNamesSplitted[3], strInfo[2], valIntArray); break; case valueDTP.M3DOUBLE: double[] valDoubleArray = new Double[3]; valDoubleArray[0] = getNodeValDouble(xnd, "Mean"); valDoubleArray[1] = getNodeValDouble(xnd, "Min"); valDoubleArray[2] = getNodeValDouble(xnd, "Max"); inv.setValue(dtMeasure, measureNamesSplitted[3], strInfo[2], valDoubleArray); break; } break; default: MessageBox.Show("Site: " + siteName + ", Name of node unknown: " + xnd.Name + ": " + xnd.InnerText); break; } } catch (Exception ex) { throw ex; } }