コード例 #1
0
ファイル: DBM.cs プロジェクト: 65001/DBM-CSharp
        static void LogMessage(string Message, string Type, string Caller)
        {
#if DEBUG
            Console.WriteLine("Log : Caller was : {0}; Type: {1}; Message: {2} ;", Caller, Type, Message);
#endif
            if (string.IsNullOrWhiteSpace(Type))
            {
                Type = "Unknown";
            }

            if (Type == "Debug" && GlobalStatic.DebugMode == false)
            {
                return;
            }

            if (Type == "PopUp")
            {
                GraphicsWindow.ShowMessage(Message, Caller);
            }
            else if (Message.Contains("LDDataBase.Query") == true || Message.Contains("LDDataBase.Command") == true)
            {
                if (Message.Contains("logic error"))
                {
                    Type = "SQL Error";
                    GraphicsWindow.ShowMessage(Message, Type);
                }
            }
            else if (Message.Contains("Shape not found"))
            {
                Type = "Shape";
            }

            int StackPointer = Stack.Add($"Events.LogMessage({Message},{Type},{Caller})");

            string LogCMD = "INSERT INTO LOG ([UTC DATE],[UTC TIME],DATE,TIME,USER,ProductID,ProductVersion,Event,Type) VALUES(DATE(),TIME(),DATE('now','localtime'),TIME('now','localtime'),'" + GlobalStatic.UserName + "','" + GlobalStatic.ProductID + "','" + GlobalStatic.VersionID + "','" + Message.Replace("\n", "") + "','" + Type + "');";;
            var    CS     = new Engines.CommandSettings()
            {
                Database    = GlobalStatic.LogDB,
                SQL         = LogCMD,
                User        = Language.Localization["App"],
                Explanation = Language.Localization["Auto Log"]
            };

            Engines.Command(CS);
            Stack.Exit(StackPointer);
        }
コード例 #2
0
ファイル: Settings.cs プロジェクト: 65001/DBM-CSharp
        /// <summary>
        /// Connects to and creates Log and Transaction databases with default tables.
        /// </summary>
        public static void IniateDatabases()
        {
            int StackPointer = Stack.Add("Settings.IniateDatabases()");

            if (string.IsNullOrWhiteSpace(GlobalStatic.TransactionDBPath) || string.IsNullOrWhiteSpace(GlobalStatic.LogDBpath))
            {
                throw new ArgumentNullException("Transaction or Log Path is null");
            }

            GlobalStatic.TransactionDB = Engines.Load.Sqlite(GlobalStatic.TransactionDBPath, "Transaction Log");
            GlobalStatic.LogDB         = Engines.Load.Sqlite(GlobalStatic.LogDBpath, "Master Log");

            var LogCS = new Engines.CommandSettings()
            {
                Database    = GlobalStatic.LogDB,
                SQL         = GlobalStatic.LOGSQL,
                User        = GlobalStatic.UserName,
                Explanation = "Auto Creation Statements"
            };

            var LogView = new Engines.CommandSettings()
            {
                Database    = GlobalStatic.LogDB,
                SQL         = GlobalStatic.LOGSQLVIEW,
                User        = GlobalStatic.UserName,
                Explanation = "Auto Creation Statements"
            };

            var Transactions = new Engines.CommandSettings()
            {
                Database    = GlobalStatic.TransactionDB,
                SQL         = GlobalStatic.TransactionsSQL,
                User        = GlobalStatic.UserName,
                Explanation = "Auto Creation Statements"
            };

            Engines.Command(LogCS);
            Engines.Command(LogView);
            Engines.Command(Transactions);
            Stack.Exit(StackPointer);
        }
コード例 #3
0
ファイル: Emulator.cs プロジェクト: 65001/DBM-CSharp
        public static void Emulator(EnginesMode Mode, string Database, string SQL, string Username, string Listview) //TODO Implement Emulator atleast for sqlite for DBM
        {
            //Attempts to emulate some if not all commands of a database engine by aliasing it to SQL
            int           StackPointer  = Stack.Add($"Engines.Emulator({Mode},{Database},{SQL}");
            StringBuilder Emulator_Sql  = new StringBuilder();
            string        EmulatorTable = null;

            StringComparison Comparison = StringComparison.InvariantCultureIgnoreCase;

            switch (Mode)
            {
            case EnginesMode.SQLITE:
                if (SQL.StartsWith(".help", Comparison))
                {
                    //EmulatorTable = "DBM_SQLITE_Help";
                    List <string> Arguments = new List <string>()
                    {
                        ".help", ".databases", ".tables", ".index", ".pragma", ".querytimes", ".filesystem $Path", ".stacktrace", ".localizations", ".functions"
                    };
                    Dictionary <string, string> Description = new Dictionary <string, string>
                    {
                        { ".help", "Displays this table.Note: The following commands are being interpreted by the DBM CLI Emulator not the SQLITE CLI." },
                        { ".databases", "Displays a list of connected databases." },
                        { ".tables", "Lists all tables and views in the current database." },
                        { ".index", "Lists all the indexes in the current database." },
                        { ".pragma", "Lists most pragma settings for sqlite db." },
                        { ".querytimes", "Lists all queries executed by the program and the time in miliseconds." },
                        { ".filesystem $Path", "Lists all the folders and files in the argumented path. Defaults to MyDocuments if no argument is given." },
                        { ".stacktrace", "Lists the functions and methods and the like and the order they were called in." },
                        { ".localizations", "List of the key value pairs of the current languages localization" },
                        { ".functions", "List of all custom functions." },
                        { ".charts", "A List of all charts currentley implemented" }
                    };
                    Arguments.Sort();

                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (Arguments TEXT,Description TEXT);", EmulatorTable);
                    for (int i = 0; i < Arguments.Count; i++)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} VALUES ('{1}','{2}');", EmulatorTable, Arguments[i], Description[Arguments[i]]);
                    }
                    break;
                }
                else if (SQL.StartsWith(".databases", Comparison))
                {
                    EmulatorTable = "DBM_SQLITE_Databases";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,NAME TEXT,\"DBM NAME\" TEXT,FILE TEXT);", EmulatorTable);
                    for (int i = 0; i < DB_Name.Count; i++)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} (NAME,\"DBM NAME\",FILE) VALUES ('{1}','{2}','{3}');", EmulatorTable, DB_Name[i].Replace("'", "''"), DB_ShortName[i].Replace("'", "''"), DB_Path[i].Replace("'", "''"));
                    }
                }
                else if (SQL.StartsWith(".tables", Comparison) || SQL.StartsWith(".views", Comparison))
                {
                    EmulatorTable = "DBM_SQLITE_Tables";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,NAME TEXT,Type TEXT);", EmulatorTable);
                    for (int i = 0; i < Tables.Count; i++)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} (Name,Type) VALUES ('{1}','table');", EmulatorTable, Tables[i].Replace("'", "''"));
                    }
                    for (int i = 0; i < Views.Count; i++)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} (Name,Type) VALUES ('{1}','view');", EmulatorTable, Views[i].Replace("'", "''"));
                    }
                }
                else if (SQL.StartsWith(".index", Comparison))
                {
                    EmulatorTable = "DBM_SQLITE_Index";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,NAME TEXT,Type TEXT);", EmulatorTable);
                    for (int i = 0; i < Indexes.Count; i++)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} (Name,Type) VALUES ('{1}','index');", EmulatorTable, Indexes[i].Replace("'", "''"));
                    }
                }
                else if (SQL.StartsWith(".pragma", Comparison))
                {
                    EmulatorTable = "DBM_SQLITE_PRAGMA";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (\"PRAGMA\" TEXT,VALUE TEXT);", EmulatorTable);
                    List <string> PRAGMA = new List <string>()
                    {
                        "Application_ID", "Auto_Vacuum", "Automatic_Index", "Busy_TimeOut", "Cache_Size", "Cache_Spill", "Case_Sensitive_Like", "Cell_Size_Check", "Checkpoint_fullfsync", "data_version", "defer_foreign_keys", "Encoding", "Foreign_Keys", "Freelist_count", "fullfsync", "ignore_check_constraints",
                        "incremental_vacuum", "integrity_check", "journal_mode", "journal_size_limit", "legacy_file_format", "locking_mode", "max_page_count", "mmap_size", "page_count", "page_size", "query_only", "read_uncommitted", "recursive_triggers", "reverse_unordered_selects", "secure_delete", "soft_heap_limit", "synchronous", "temp_store", "threads", "user_version",
                        "wal_autocheckpoint", "writable_schema"
                    };

                    PRAGMA.Sort();

                    /*The following were removed due to them displaying 1+ rows of data
                     * Collation_List
                     * Compile_Options
                     * database_list
                     * wal_checkpoint
                     * Foreign_Key_Check
                     */
                    for (int i = 0; i < PRAGMA.Count; i++)
                    {
                        var QS = new QuerySettings
                        {
                            Database     = CurrentDatabase,
                            SQL          = $"PRAGMA {PRAGMA[i]};",
                            ListView     = null,
                            FetchRecords = true,
                            User         = Username,
                            Explanation  = "Emulator"
                        };

                        Emulator_Sql.AppendFormat("INSERT INTO {0} VALUES ('{1}','{2}');",
                                                  EmulatorTable,
                                                  PRAGMA[i].Replace("_", " "),
                                                  Query(QS)[1][PRAGMA[i]]);
                    }
                }
                else if (SQL.StartsWith(".filesystem", Comparison))
                {
                    try
                    {
                        string _Path = SQL.Substring(".filesystem".Length);
                        if (string.IsNullOrWhiteSpace(_Path))
                        {
                            _Path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                        }
                        List <string> DirectoryList = new List <string>(System.IO.Directory.EnumerateDirectories(_Path));
                        List <string> FileList      = new List <string>(System.IO.Directory.EnumerateFiles(_Path));

                        EmulatorTable = "DBM_SQLITE_Filesystem";
                        Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (Name TEXT,\"Date Modified\" TEXT,TYPE TEXT,SIZE INT);", EmulatorTable);

                        for (int i = 0; i < DirectoryList.Count; i++)
                        {
                            string        Directory = DirectoryList[i];
                            DirectoryInfo DI        = new DirectoryInfo(Directory);
                            Emulator_Sql.AppendFormat("INSERT INTO {0} VALUES ('{1}','{2}','File Folder',NULL);", EmulatorTable, Directory.Replace("'", "''"), DI.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));
                        }

                        for (int i = 0; i < FileList.Count; i++)
                        {
                            string   File = FileList[i];
                            FileInfo FI   = new FileInfo(File);

                            Emulator_Sql.AppendFormat("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}');", EmulatorTable, File.Replace("'", "''"), FI.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"), FI.Extension, FI.Length);
                        }
                    }
                    catch (Exception ex)
                    {
                        Events.LogMessage(ex.Message, Language.Localization["System"]);
                    }
                }
                else if (SQL.StartsWith(".querytimes", Comparison))
                {
                    EmulatorTable = "DBM_SQLITE_QueryTimes";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,SQL TEXT,\"Execution Time (ms)\" INTEGER,Explanation TEXT,User TEXT,\"Start Time (UTC)\" TEXT,Cache TEXT);", EmulatorTable);

                    int ii = 0;
                    for (int i = 0; i < _Type_Referer.Count; i++)
                    {
                        if (_Type_Referer[i] == Type.Query)
                        {
                            Emulator_Sql.AppendFormat("INSERT INTO {0} VALUES('{1}','{2}','{3}','{4}','{5}','{6}','{7}');", EmulatorTable, ii, LastQuery[ii].Replace("'", "''"), _Timer[i], _Explanation[i], _User[i], _UTC_Start[i], _CacheStatus[ii]);
                            ii++;
                        }
                        #if DEBUG
                        else
                        {
                            Console.WriteLine("#{0} is a {1} with a time of {2}(ms)", i, _Type_Referer[i], _Timer[i]);
                        }
                        #endif
                    }
                }
                else if (SQL.StartsWith(".stacktrace", Comparison))
                {
                    //"hh:mm:ss ffffff"
                    EmulatorTable = "DBM_SQLITE_StackTrace";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,Item TEXT,\"Start Time (UTC)\" TEXT,\"Exit Time (UTC)\" TEXT,\"Duration (ms)\" TEXT);", EmulatorTable);
                    for (int i = 0; i < Stack.StackEntries.Count; i++)
                    {
                        var SE = Stack.StackEntries[i];
                        Emulator_Sql.AppendFormat("INSERT INTO {0} VALUES('{1}','{2}','{3}','{4}','{5}');", EmulatorTable, i,
                                                  SE.Trace,
                                                  SE.StartTime.ToString("hh:mm:ss ffffff"),
                                                  SE.ExitTime.ToString("hh:mm:ss ffffff"),
                                                  SE.Duration.TotalMilliseconds
                                                  );
                    }
                }
                else if (SQL.StartsWith(".localization", Comparison))
                {
                    EmulatorTable = "DBM_SQLITE_Localizations";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,KEY TEXT,VALUE TEXT);", EmulatorTable);
                    foreach (KeyValuePair <string, string> entry in Language.Localization)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} (Key,Value) VALUES('{1}','{2}');", EmulatorTable, entry.Key, entry.Value);
                    }
                }
                else if (SQL.StartsWith(".function", Comparison))
                {
                    EmulatorTable = "DBM_Sqlite_Functions";
                    Emulator_Sql.AppendFormat("CREATE TEMP TABLE {0} (ID INTEGER PRIMARY KEY,Function TEXT,Description TEXT);", EmulatorTable);
                    Dictionary <string, string> Functions = new Dictionary <string, string>()
                    {
                        { "REGEXP(input,pattern)", "Pattern matching" },
                        { "POWER(b,x)", "b^x" },
                        { "Sqrt(x)", "x^(1/2)" },
                        { "Sin(x)", "" },
                        { "Sinh(x)", "" },
                        { "Cos(x)", "" },
                        { "Cosh(x)", "" },
                        { "Tan(x)", "" },
                        { "Tanh(x)", "" },
                        { "e()", "" },
                        { "pi()", "" },
                        { "log(x)", "" },
                        { "encrypt(text,password)", "Encrypts the text given the password using AES encryption." },
                        { "decrypt(text,password)", "Decrypts the text given the password using AES encryption." },
                        { "hash(text)", "Hashes an item using SHA512." },
                    };

                    foreach (KeyValuePair <string, string> entry in Functions)
                    {
                        Emulator_Sql.AppendFormat("INSERT INTO {0} (Function,Description) VALUES('{1}','{2}');", EmulatorTable, entry.Key, entry.Value);
                    }
                }
                break;

            default:
                throw new NotImplementedException();
            }

            if (EmulatorTable != null)
            {
                string _SQL = Emulator_Sql.ToString();
                var    CS   = new Engines.CommandSettings()
                {
                    Database    = Database,
                    SQL         = $"DROP TABLE IF EXISTS {EmulatorTable};" + _SQL,
                    User        = GlobalStatic.UserName,
                    Explanation = Language.Localization["User Requested"] + ": CLI EMULATOR"
                };
                Command(CS);

                QuerySettings QS = new QuerySettings
                {
                    Database     = Database,
                    SQL          = $"SELECT * FROM {EmulatorTable};",
                    ListView     = Listview,
                    FetchRecords = false,
                    User         = Username,
                    Explanation  = Language.Localization["User Requested"] + ": CLI EMULATOR"
                };
                Query(QS);

                GetSchema(Database);
                SetDefaultTable(EmulatorTable);
                GetColumnsofTable(Database, EmulatorTable);
            }
            Stack.Exit(StackPointer);
        }
コード例 #4
0
ファイル: DBM.cs プロジェクト: 65001/DBM-CSharp
        public static void CreateTableHandler()
        {
            int    StackPointer = Stack.Add("UI.CreateTableHandler()");
            string LastButton   = Controls.LastClickedButton;
            string Name         = Controls.GetTextBoxText(_TextBox["Table_Name"]);

            if (LastButton == _Buttons["Commit"])
            {
                if (!string.IsNullOrWhiteSpace(Name))
                {
                    Name = Name.Replace("[", "").Replace("]", "").Replace("\"", "");
                    int Max = LDControls.DataViewRowCount(GlobalStatic.Dataview);

                    StringBuilder Define_SQL = new StringBuilder();
                    Define_SQL.Append("CREATE TABLE \"" + Name + "\"(");
                    for (int i = 1; i <= Max; i++)
                    {
                        Primitive _Data = LDControls.DataViewGetRow(GlobalStatic.Dataview, i);
                        if (!string.IsNullOrWhiteSpace(_Data[1]))
                        {
                            if (_Data[4] == true)
                            {
                                _Data[3] = true;
                            }
                            string Field = ((string)_Data[1]).Replace("[", "").Replace("]", "").Replace("\"", "");
                            Define_SQL.AppendFormat("\"{0}\" {1}", Field, (string)_Data[2]);

                            if (_Data[6] == true)
                            {
                                Define_SQL.Append(" NOT NULL");
                            }
                            if (_Data[3] == true)
                            {
                                Define_SQL.Append(" PRIMARY KEY");
                            }
                            if (_Data[4] == true)
                            {
                                Define_SQL.Append(" AUTOINCREMENT");
                            }
                            if (_Data[5] == true)
                            {
                                Define_SQL.Append(" UNIQUE");
                            }
                            if (i != Max)
                            {
                                Define_SQL.Append(",");
                            }
                            else
                            {
                                Define_SQL.Append(");");
                            }
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(Engines.CurrentDatabase))
                    {
                        string Confirmation = LDDialogs.Confirm("Do you wish to commit the following SQL:\n" + Define_SQL.ToString() + "\n to " + Engines.DB_ShortName[Engines.DB_Name.IndexOf(Engines.CurrentDatabase)], "Commit SQL");
                        if (Confirmation == "Yes")
                        {
                            Engines.CommandSettings CS = new Engines.CommandSettings()
                            {
                                Database    = Engines.CurrentDatabase,
                                SQL         = Define_SQL.ToString(),
                                User        = GlobalStatic.UserName,
                                Explanation = "User Defining a Table" //Localize
                            };
                            Engines.Command(CS);
                        }
                    }
                }
                else
                {
                    GraphicsWindow.ShowMessage("Table Name is not empty, please fill it!", "NAME");
                }
                Stack.Exit(StackPointer);
                return;
            }

            if (LastButton == _Buttons["Exit"])
            {
                Controls.ButtonClicked -= CreateTableHandler;
                Controls.ButtonClicked += Events.BC;
                ClearWindow();
                DisplayResults();
                ShowDisplayResults();
                MainMenu();
                //Events.MC("View");
                Stack.Exit(StackPointer);
                return;
            }


            Stack.Exit(StackPointer);
        }
コード例 #5
0
ファイル: Handlers.cs プロジェクト: 65001/DBM-CSharp
        public static void Buttons(string LastButton)
        {
            int StackPointer = Stack.Add($"Handlers.Buttons({LastButton})");

            try
            {
                if (LastButton == UI.Buttons["Search"] || LastButton == UI.Buttons["Sort"] || LastButton == UI.Buttons["RunFunction"])
                {
                    Primitive ASCDESC_Sorts = "1=ASC;2=DESC;3=RANDOM();";
                    bool      Search = false, Sort = true, Function = false;

                    bool.TryParse(LDControls.CheckBoxGetState(GlobalStatic.CheckBox["StrictSearch"]), out bool StrictSearch);
                    bool.TryParse(LDControls.CheckBoxGetState(GlobalStatic.CheckBox["InvertSearch"]), out bool InvertSearch);

                    string SearchIn       = "\"" + Engines.Schema[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["Search"])] + "\"";
                    string SearchText     = Controls.GetTextBoxText(UI.TextBox["Search"]).ToString().Replace("'", "''");
                    string FunctionIn     = "\"" + Engines.Schema[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["ColumnList"])] + "\"";
                    string FunctionCalled = Engines.Functions(Engines.CurrentEngine)[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["FunctionList"]) - 1];

                    string SortBy  = "\"" + Engines.Schema[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["Sort"])] + "\"";
                    string ASCDESC = ASCDESC_Sorts[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["ASCDESC"])];

                    if (LastButton == UI.Buttons["Search"])
                    {
                        Search = true;
                    }
                    else if (LastButton == UI.Buttons["RunFunction"])
                    {
                        Function = true;
                    }

                    /*
                     * Console.WriteLine();
                     * Console.WriteLine("Search: {0} Sort : {1} Function :{2}", Search, Sort, Function);
                     * Console.WriteLine("Strict Search : {0} Invert Search : {1}", StrictSearch, InvertSearch);
                     * Console.WriteLine("SearchIn : {0} Search Text : {1} FunctionIn : {2} FunctionCalled : {3} SortBy : {4} ASCDESC : {5} LastButton : {6}", SearchIn, SearchText, FunctionIn, FunctionCalled, SortBy, ASCDESC, Controls.GetButtonCaption(LastButton));
                     */
                    var GQS = new Engines.GenerateQuerySettings
                    {
                        //bool
                        Search      = Search,
                        Sort        = Sort,
                        RunFunction = Function,

                        SearchBy = SearchIn,
                        OrderBy  = SortBy,

                        StrictSearch     = StrictSearch,
                        InvertSearch     = InvertSearch,
                        FunctionSelected = FunctionCalled,
                        FunctionColumn   = FunctionIn,
                        SearchText       = SearchText
                    };
                    switch (ASCDESC)
                    {
                    case "ASC":
                        GQS.Order = Engines.GenerateQuerySettings.SortOrder.Ascending;
                        break;

                    case "DESC":
                        GQS.Order = Engines.GenerateQuerySettings.SortOrder.Descding;
                        break;

                    case "RANDOM()":
                        GQS.Order = Engines.GenerateQuerySettings.SortOrder.Random;
                        break;
                    }
                    string Query             = Engines.GenerateQuery(GQS, Engines.CurrentTable.SanitizeFieldName());
                    Engines.QuerySettings QS = new Engines.QuerySettings
                    {
                        Database    = Engines.CurrentDatabase,
                        SQL         = Query,
                        ListView    = GlobalStatic.ListView,
                        User        = GlobalStatic.UserName,
                        Explanation = "Auto Generated Query on behalf of " + GlobalStatic.UserName
                    };

                    Engines.Query(QS);
                }
                else if (LastButton == UI.Buttons["Query"])
                {
                    Engines.Cache.Clear();
                    Engines.QuerySettings QS = new Engines.QuerySettings
                    {
                        Database    = Engines.CurrentDatabase,
                        SQL         = Controls.GetTextBoxText(UI.TextBox["CustomQuery"]),
                        ListView    = GlobalStatic.ListView,
                        User        = GlobalStatic.UserName,
                        Explanation = Language.Localization["User Requested"]
                    };
                    Engines.Query(QS);
                }
                else if (LastButton == UI.Buttons["Command"]) //Custom Command
                {
                    Engines.Cache.Clear();
                    var CS = new Engines.CommandSettings()
                    {
                        Database    = Engines.CurrentDatabase,
                        SQL         = Controls.GetTextBoxText(UI.TextBox["CustomQuery"]),
                        User        = GlobalStatic.UserName,
                        Explanation = Language.Localization["User Requested"]
                    };
                    Engines.Command(CS);
                }
            }
            catch (KeyNotFoundException)
            {
                string Message = Controls.GetButtonCaption(LastButton) + "(" + LastButton + ") |" + UI.Buttons.ContainsKey(LastButton) + "|" + Controls.GetButtonCaption(LastButton) == Language.Localization["Query"].ToUpper() + "| does not exist in context or has not yet implemented.";
                Events.LogMessage(Message, "System");
            }
            Stack.Exit(StackPointer);
        }