/// <summary> /// Add checklist data /// </summary> /// <param name="_group"></param> /// <param name="_devID"></param> /// <param name="_dbconn"></param> /// <param name="_context"></param> /// <param name="_table1"></param> /// <param name="_field1"></param> /// <param name="_type1"></param> /// <param name="_postfix1"></param> /// <param name="_text1"></param> /// <param name="_table2"></param> /// <param name="_field2"></param> /// <param name="_type2"></param> /// <param name="_postfix2"></param> /// <param name="_text2"></param> private void addCheckListData(int _group, int _devID, SqlConnection _dbconn, string _context, string _table1, string _field1, Type _type1, string _postfix1, string _text1, string _table2, string _field2, Type _type2, string _postfix2, string _text2) { string person; bool ok = (db.GetTreeStatus(_devID, _context, _dbconn, out person) >= 2); checklistdata data = new checklistdata(); data.group = _group; data.ok = ok; data.person = person; data.value = readFromDB(_devID, _dbconn, _table1, _field1, _type1); data.text = _text1; data.context = _context + _postfix1; varCheckList.Add(_context + _postfix1, data); data = new checklistdata(); data.group = _group; data.ok = ok; data.person = person; data.value = readFromDB(_devID, _dbconn, _table2, _field2, _type2); data.text = _text2; data.context = _context + _postfix1; varCheckList.Add(_context + _postfix2, data); }
internal checklistdata(checklistdata _other) { text = _other.text; person = _other.person; ok = _other.ok; value = _other.value; group = _other.group; context = _other.context; }
/// <summary> /// Add checklist data /// </summary> /// <param name="_group"></param> /// <param name="_devID"></param> /// <param name="_dbconn"></param> /// <param name="_context"></param> /// <param name="_table1"></param> /// <param name="_field1"></param> /// <param name="_type1"></param> /// <param name="_postfix1"></param> /// <param name="_text1"></param> /// <param name="_table2"></param> /// <param name="_field2"></param> /// <param name="_type2"></param> /// <param name="_postfix2"></param> /// <param name="_text2"></param> private void addCheckListData(int _group, int _devID, SqlConnection _dbconn, string _context, string _table1, string _field1, Type _type1, string _postfix1, string _text1, string _table2, string _field2, Type _type2, string _postfix2, string _text2) { string person; bool ok = (db.GetTreeStatus(_devID, _context, _dbconn, out person) >= 2); checklistdata data; if (_context.StartsWith("kric")) { // This is a Kr-Rico device. So it certainly has a new // introduced firmware version descriptor. This item is // added now. var queryLib = new QueryLibraryCommon(devID); string fwVersion = queryLib.SelectFirmwareVersion(); if (string.IsNullOrEmpty(fwVersion)) { fwVersion = "unbekannt"; } string postfix = ".firmware"; data = new checklistdata(); data.group = _group; data.ok = ok; data.person = person; data.value = fwVersion; data.text = "Firmware Version"; data.context = _context + postfix; varCheckList.Add(_context + postfix, data); // At the moment Kr-Rico devices always have these boards _text1 = "Version CUPID"; _text2 = "Version KMU"; } data = new checklistdata(); data.group = _group; data.ok = ok; data.person = person; data.value = readFromDB(_devID, _dbconn, _table1, _field1, _type1); data.text = _text1; data.context = _context + _postfix1; varCheckList.Add(_context + _postfix1, data); data = new checklistdata(); data.group = _group; data.ok = ok; data.person = person; data.value = readFromDB(_devID, _dbconn, _table2, _field2, _type2); data.text = _text2; data.context = _context + _postfix1; varCheckList.Add(_context + _postfix2, data); }
/// <summary> /// Add checklist data with value /// </summary> /// <param name="_group"></param> /// <param name="_devID"></param> /// <param name="_dbconn"></param> /// <param name="_context"></param> /// <param name="_table"></param> /// <param name="_field"></param> /// <param name="_type"></param> private void addCheckListData(int _group, int _devID, SqlConnection _dbconn, string _context, string _value) { checklistdata data = new checklistdata(); data.group = _group; data.ok = (db.GetTreeStatus(_devID, _context, _dbconn, out data.person) >= 2); data.value = _value; if (contextDescription.ContainsKey(_context)) { data.text = contextDescription[_context]; } varCheckList.Add(_context, data); }
/// <summary> /// Add checklist data with value /// </summary> /// <param name="_group"></param> /// <param name="_devID"></param> /// <param name="_dbconn"></param> /// <param name="_context"></param> /// <param name="_table"></param> /// <param name="_field1"></param> /// <param name="_field2"></param> /// <param name="_type"></param> private void addCheckListData(int _group, int _devID, SqlConnection _dbconn, string _context, string _table, string _field1, string _field2, Type _type) { checklistdata data = new checklistdata(); data.group = _group; data.ok = (db.GetTreeStatus(_devID, _context, _dbconn, out data.person) >= 2); data.value = readFromDB(_devID, _dbconn, _table, _field1, _type) + " - " + readFromDB(_devID, _dbconn, _table, _field2, _type); if (contextDescription.ContainsKey(_context)) { data.text = contextDescription[_context]; } varCheckList.Add(_context, data); }
/// <summary>uu /// Vorbereiten der Daten zum Druck /// </summary> /// <param name="_devSerial"></param> private bool prepareData(string _devSerial, string _devFileName) { varDevSerial = _devSerial; varDevFilename = _devFileName; string prefixKrRico = ""; if (isKrRico) { prefixKrRico = "kric."; } SqlConnection dbconn = new SqlConnection(db.ConnectionString); dbconn.Open(); string sql = "SELECT id," + db.TAB_DEVICE_USERID + " FROM " + db.TAB_DEVICE + " " + "WHERE " + db.TAB_DEVICE_SERIAL + "='" + varDevSerial + "'" + "AND " + db.TAB_DEVICE_FILENAME + "='" + varDevFilename + "'"; DbDataReader dr = db.QueryDataReader(new SqlCommand(sql, dbconn)); if (dr == null) { return(false); } if (!dr.Read()) { dr.Close(); dbconn.Close(); return(false); } devID = (int)dr["id"]; int uid = (int)dr[db.TAB_DEVICE_USERID]; dr.Close(); sql = "select " + db.TAB_USER_NACHNAME + "," + db.TAB_USER_VORNAME + " from " + db.TAB_USER + " " + "where id=" + uid; dr = db.QueryDataReader(new SqlCommand(sql, dbconn)); if (dr == null) { dbconn.Close(); return(false); } if (!dr.Read()) { dr.Close(); dbconn.Close(); return(false); } varUser = (string)dr[db.TAB_USER_NACHNAME] + ", " + (string)dr[db.TAB_USER_VORNAME]; dr.Close(); sql = "select * from " + db.TAB_PARAMS + " " + "where id=" + devID; dr = db.QueryDataReader(new SqlCommand(sql, dbconn)); if (dr == null) { dbconn.Close(); return(false); } if (!dr.Read()) { dr.Close(); dbconn.Close(); return(false); } devBits = (int)dr[db.TAB_PARAMS_TYP]; devType = (devBits & 0x7F000000) >> 24; deviceType = DeviceBits.Type(devBits); dr.Close(); if (deviceType == CustomDeviceType.DR6000) { QueryLibraryRefracto queryLibRefracto = new QueryLibraryRefracto(devID); queryLibRefracto = new QueryLibraryRefracto(devID); TargetTable type; refractoAdjustment = queryLibRefracto .SelectLatestMeasAdjustment(out refractoAdjustmentDate, out type); } varDevType = DeviceBits.DeviceName(devBits); if (varDevType.Length == 0) { varDevType = DeviceBits.GroupNameShort(devBits); } varDate = DateTime.Now.ToShortDateString(); //---Gruppe "1" Checklistedatenliste vorbereiten--- int groupIdGeneral = Array.FindIndex(groupName, item => item.EndsWith("general")); addCheckListData(groupIdGeneral, devID, dbconn, prefixKrRico + "general.ipa", db.TAB_PARAMS, db.TAB_PARAMS_IPA, typeof(string)); //addCheckListData(1, devID, dbconn, prefixKrRico + "general.serial", db.TAB_DEVICE, db.TAB_DEVICE_SERIAL, typeof(string)); //addCheckListData(1, devID, dbconn, prefixKrRico + "general.typ", varDevType); addCheckListData(groupIdGeneral, devID, dbconn, prefixKrRico + "general.version", db.TAB_PARAMS, db.TAB_PARAMS_VERSION_AUCKLAND, typeof(string), ".auckland", "Firmware Version Auckland", db.TAB_PARAMS, db.TAB_PARAMS_VERSION_ECO, typeof(string), ".eco", "Firmware Version Eco"); addCheckListData(groupIdGeneral, devID, dbconn, prefixKrRico + "general.date", db.TAB_PARAMS, db.TAB_PARAMS_TIMESYNC, typeof(DateTime)); if (devType == 2) { addCheckListData(groupIdGeneral, devID, dbconn, prefixKrRico + "general.measurement.range", db.TAB_PARAMS, db.TAB_PARAMS_MEAS_RANGE_MIN, db.TAB_PARAMS_MEAS_RANGE_MAX, typeof(double)); } //---für alle anderen Gruppen außer "1" Checklistedatenliste vorbereiten--- foreach (KeyValuePair <string, string> pair in contextDescription) { if (contextGroup.ContainsKey(pair.Key)) { if (contextGroup[pair.Key] != 1) { //if (pair.Key != prefixKrRico + "general.typ" && pair.Key != prefixKrRico + "general.serial") //{ // ==> mit Ulf nach Vereinfachung suchen checklistdata cld = new checklistdata(pair.Key, contextGroup[pair.Key], pair.Value, false, ""); varCheckList.Add(pair.Key, cld); //} } } } //---Checklistedaten aus DB lesen--- sql = "select * from " + db.TAB_TREE + " where id=" + devID; dr = db.QueryDataReader(new SqlCommand(sql, dbconn)); if (dr == null) { dbconn.Close(); return(false); } while (dr.Read()) { string ctx = (string)dr[db.TAB_TREE_CONTEXT]; if (isKrRico && !ctx.StartsWith(prefixKrRico)) { ctx = prefixKrRico + ctx; } string person; int sta = db.GetTreeStatus(devID, ctx, dbconn, out person); if (!varCheckList.ContainsKey(ctx)) { string txt = ""; int grp = -1; if (contextDescription.ContainsKey(ctx)) { txt = contextDescription[ctx]; } if (contextGroup.ContainsKey(ctx)) { grp = contextGroup[ctx]; } varCheckList.Add(ctx, new checklistdata(ctx, grp, txt, sta == 2, person)); } else { varCheckList[ctx].ok = (sta == 2); varCheckList[ctx].person = person; } } dr.Close(); //---weitere parameter aus DB auslesen--- if (varCheckList.ContainsKey("finalize.params")) { checklistdata d = varCheckList["finalize.params"]; if (d.ok) { sql = "select " + db.TAB_CONFIG_TIMESTAMP + " from " + db.TAB_CONFIG + " " + "where (id=" + devID + ")and(" + db.TAB_CONFIG_TYP + "=" + (int)db.ConfigType.DeviceParametersBinary + ")"; dr = db.QueryDataReader(new SqlCommand(sql, dbconn)); if (dr != null) { if (dr.Read()) { d.value = ((DateTime)dr[db.TAB_CONFIG_TIMESTAMP]).ToString(); } dr.Close(); } } } if (varCheckList.ContainsKey(prefixKrRico + "finalize.db")) { checklistdata d = varCheckList[prefixKrRico + "finalize.db"]; if (d.ok) { sql = "select " + db.TAB_CONFIG_TIMESTAMP + " from " + db.TAB_CONFIG + " " + "where (id=" + devID + ")and(" + db.TAB_CONFIG_TYP + "=" + (int)db.ConfigType.DeviceDatabaseBinary + ")"; dr = db.QueryDataReader(new SqlCommand(sql, dbconn)); if (dr != null) { if (dr.Read()) { d.value = ((DateTime)dr[db.TAB_CONFIG_TIMESTAMP]).ToString(); } dr.Close(); } } } //---prepare group 0 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 0) { varCheckList0.Add(new checklistdata(pair.Value)); } } //---prepare group 1 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 1) { if (pair.Key != "general.version") { varCheckList1.Add(new checklistdata(pair.Value)); } } } //---prepare group 2 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 2) { varCheckList2.Add(new checklistdata(pair.Value)); } } //---prepare group 3 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 3) { varCheckList3.Add(new checklistdata(pair.Value)); } } //---prepare group 4 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 4) { varCheckList4.Add(new checklistdata(pair.Value)); } } //---prepare group 5 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 5) { varCheckList5.Add(new checklistdata(pair.Value)); } } //---prepare group 6 data--- foreach (KeyValuePair <string, checklistdata> pair in varCheckList) { if (pair.Value.group == 6) { varCheckList6.Add(new checklistdata(pair.Value)); } } dbconn.Close(); return(true); }