private static ObjectBaseHash _GetServerCollection(string Ident_Domain, string UID_Profile, NodeType nodeType)
        {
            ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter;
            SqlExecutor   cSQL = clsMain.Instance.CurrentConnection.Connection.CreateSqlExecutor(clsMain.Instance.CurrentConnection.PublicKey);

            ObjectBaseHash colServers = new ObjectBaseHash();
            ObjectServer   oServer    = null;

            string strSQL = "";

            switch (nodeType)
            {
            case NodeType.AppProfile:
                strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ApplicationProfileServer"];
                break;

            case NodeType.DrvProfile:
                strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["DriverProfileServer"];
                break;

            case NodeType.MacType:
                strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["MachineTypeServer"];
                break;
            }

            // replace the Domain-Variable
            strSQL = strSQL.Replace("@Ident_Domain", isql.FormatValue(Ident_Domain, ValType.String, true));

            // replace UID_Profile
            strSQL = strSQL.Replace("@UID_Profile", isql.FormatValue(UID_Profile, ValType.String, true));

            // and now do it...
            using (IDataReader rData = new CachedDataReader(cSQL.SqlExecute(strSQL)))
            {
                while (rData.Read())
                {
                    // create a server-object
                    oServer = new ObjectServer(rData);

                    // and add to our Hash
                    colServers.Add(oServer, "UID_ApplicationServer");
                }
            }

            return(colServers);
        }
예제 #2
0
        private ObjectBaseHash _GetServerOfDomin(string parentDomain)
        {
            ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter;
            SqlExecutor   cSQL = clsMain.Instance.CurrentConnection.Connection.CreateSqlExecutor(clsMain.Instance.CurrentConnection.PublicKey);
            string        strSQL;

            ObjectBaseHash colServers = new ObjectBaseHash();
            ObjectServer2  objServer;

            try
            {
                // get the gigantic SQL-Statement
                strSQL = clsMain.Instance.CurrentConnection.Connection.SqlStrings["ApplicationServer"];

                // replace the Domain-Variable
                strSQL = strSQL.Replace("@Ident_DomainRD", isql.FormatValue(parentDomain, ValType.String));

                using (IDataReader rData = new CachedDataReader(cSQL.SqlExecute(strSQL)))
                {
                    while (rData.Read())
                    {
                        // create a new Serverobject
                        objServer = new ObjectServer2(rData);

                        // appand to our list
                        colServers.Add(objServer, "UID_ApplicationServer");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionDialog.Show(this.ParentForm, ex);
            }

            return(colServers);
        }
예제 #3
0
        public T QueryObject <T>(string key, object value, bool checkExist = false) where T : DbObject, new()
        {
            ISqlFormatter sqlFormatter = this.DbObjectOperator.SqlFormatter;
            string        condition    = string.Format("{0} = {1}", sqlFormatter.FormatFieldName(key), sqlFormatter.FormatValue(value, false));

            return(this.QueryObject <T>(condition, checkExist));
        }
        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;
            }
        }
예제 #5
0
        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);
            }
        }