private void _InsertProfiles(NodeType nodeType, TreeListNode tlnParent) { ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter; SqlExecutor cSQL = clsMain.Instance.CurrentConnection.Connection.CreateSqlExecutor(clsMain.Instance.CurrentConnection.PublicKey); TreeListNode tlnProfile = null; string strSQL = ""; NodeData nd = tlnParent.Tag as NodeData; try { Cursor.Current = Cursors.WaitCursor; tlcProfile.BeginUpdate(); // remove old childs tlnParent.Nodes.Clear(); switch (nodeType) { case NodeType.AppProfiles: strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ApplicationProfile"]; break; case NodeType.DrvProfiles: strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["DriverProfile"]; break; case NodeType.MacTypes: strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["MachineType"]; break; } // replace the Domain-Variable strSQL = strSQL.Replace("@Ident_DomainRD", isql.FormatValue(nd.Data1, ValType.String)); if (clsMain.Instance.ErrorOnly) { strSQL = strSQL.Replace("@ErrorOnly", " and x.fehler > 0" + Environment.NewLine); } else { strSQL = strSQL.Replace("@ErrorOnly", Environment.NewLine); } // and now do it... using (IDataReader rData = new CachedDataReader(cSQL.SqlExecute(strSQL))) { while (rData.Read()) { bool bFehler = rData.GetBoolean(0); switch (nodeType) { case NodeType.AppProfiles: tlnProfile = tlnParent.Nodes.Add(rData.GetString(1), bFehler ? 5 : 2); tlnProfile.Tag = new NodeData(NodeType.AppProfile, nd.Data1, rData.GetString(2)); break; case NodeType.DrvProfiles: tlnProfile = tlnParent.Nodes.Add(rData.GetString(1), bFehler ? 6 : 3); tlnProfile.Tag = new NodeData(NodeType.DrvProfile, nd.Data1, rData.GetString(2)); break; case NodeType.MacTypes: tlnProfile = tlnParent.Nodes.Add(rData.GetString(1), bFehler ? 7 : 4); tlnProfile.Tag = new NodeData(NodeType.MacType, nd.Data1, rData.GetString(2)); break; } tlnProfile.SubItems.Add(rData.GetInt32(3).ToString()); } } // no profiles --> remove + from Parent-Node if (tlnParent.Nodes.Count == 0) { tlnParent.ShowExpansionIndicator = false; } } catch (Exception ex) { ExceptionDialog.Show(this.ParentForm, ex); } finally { tlcProfile.EndUpdate(); Cursor.Current = Cursors.Default; } }
private void _InsertProfiles(NodeType nodeType, string Ident_DomainRD, string UID_ApplicationServer) { ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter; SqlExecutor cSQL = clsMain.Instance.CurrentConnection.Connection.CreateSqlExecutor(clsMain.Instance.CurrentConnection.PublicKey); string strSQL = ""; string strSQLEO = ""; TreeListNode tlnProfile; try { // SQL depents on ProfileType switch (nodeType) { case NodeType.AppProfile: strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ServerAppProfile"]; strSQLEO = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ServerAppProfileErrorsOnly"]; break; case NodeType.DrvProfile: strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ServerDrvProfile"]; strSQLEO = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ServerDrvProfileErrorsOnly"]; break; case NodeType.MacType: strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ServerMacType"]; strSQLEO = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ServerMacTypeErrorsOnly"]; break; } // replace the Variables if (clsMain.Instance.ErrorOnly) { strSQL = strSQL.Replace("@ErrorsOnly", strSQLEO); // insert the ErrorOnly part } else { strSQL = strSQL.Replace("@ErrorsOnly", ""); // remove the ErrorOnly part } strSQL = strSQL.Replace("@Ident_DomainRD", isql.FormatValue(Ident_DomainRD, ValType.String)); strSQL = strSQL.Replace("@UID_ApplicationServer", isql.FormatValue(UID_ApplicationServer, ValType.String)); using (IDataReader rData = new CachedDataReader(cSQL.SqlExecute(strSQL))) { while (rData.Read()) { // create a new Node tlnProfile = tlcProfile.Nodes.Add(rData.GetString(1), 0); tlnProfile.Tag = new NodeData(nodeType, rData.GetString(0), ""); tlnProfile.SubItems.Add(rData.GetInt32(2).ToString()); // Nr Ist tlnProfile.SubItems.Add(rData.GetInt32(3).ToString()); // Nr Soll tlnProfile.SubItems.Add(rData.GetString(4).ToString()); // State P tlnProfile.SubItems.Add(rData.GetString(5).ToString()); // State S tlnProfile.SubItems.Add(rData.GetDateTime(6).ToString()); // XDateUpdated tlnProfile.SubItems.Add(""); } } } catch (Exception ex) { ExceptionDialog.Show(this.ParentForm, ex); } }