Exemplo n.º 1
0
        public TokenBoxGump(PlayerMobile from, Item item) : base(0, 0)
        {
            m_From = from;
            if (!(item is TokenBox))
            {
                return;
            }
            TokenBox box = item as TokenBox;

            m_Box = box;

            m_From.CloseGump(typeof(TokenBoxGump));

            Closable   = true;
            Disposable = false;
            Dragable   = true;
            Resizable  = false;
            AddPage(0);
            AddImage(112, 135, 75);
            AddLabel(143, 280, 1160, @"Karmageddon's Tokens");
            AddButton(125, 265, 1209, 1210, 1, GumpButtonType.Reply, 0);
            AddButton(125, 245, 1209, 1210, 2, GumpButtonType.Reply, 0);
            AddButton(125, 225, 1209, 1210, 3, GumpButtonType.Reply, 0);
            AddLabel(145, 260, 37, @"Add Tokens");
            AddLabel(145, 240, 67, @"Extract Tokens");
            AddLabel(145, 220, 67, @"Write Check");
            AddBackground(132, 200, 165, 20, 9300);
            AddTextEntry(135, 200, 155, 25, 1265, 1, "0");
            AddLabel(125, 160, 1160, @"Current Tokens:");
            AddLabel(240, 160, 1160, box.Token.ToString());
            AddLabel(180, 140, 187, @"Token Box");
            AddButton(285, 145, 2708, 2709, 4, GumpButtonType.Reply, 0);
            AddLabel(140, 180, 67, @"Tokens to be Extracted");
        }
Exemplo n.º 2
0
 public Lexer(string filePath)
 {
     this.filePath = filePath;
     buffer        = new StringBuilder(128);
     wordBox       = new TokenBox();
     tokens        = new List <Token>();
     wordBox.AddDFA(new ConstantDFA(), TokenType.Constant);
 }
Exemplo n.º 3
0
        public string GetConfigurationTemplate(string template, IDictionary <string, string> parameters)
        {
            var settings = Settings.Parse(template);

            new Populator(parameters).Populate(settings);
            CheckBox UseConnectionVariables = (CheckBox)settings.Find("UseConnectionVariables");
            TextBox  SQLServer = settings.Find("SQLServer") as TextBox;

            SQLServer.HelpText = string.Empty;
            TextBox SQLUser = settings.Find("SQLUser") as TextBox;

            SQLServer.Visible = SQLUser.Visible = (UseConnectionVariables.Value == false);
            CheckBox SQLUseSQLAuth = settings.Find("SQLUseSQLAuth") as CheckBox;
            TextBox  SQLPassword   = settings.Find("SQLPassword") as TextBox;

            SQLPassword.Visible = !UseConnectionVariables.Value && SQLUseSQLAuth.Value;
            VariableBox vSQLServer = settings.Find("vSQLServer") as VariableBox;

            vSQLServer.HelpText = string.Empty;
            VariableBox vSQLUser = settings.Find("vSQLUser") as VariableBox;

            vSQLServer.Visible = vSQLUser.Visible = (UseConnectionVariables.Value == true);
            VariableBox vSQLPassword = settings.Find("vSQLPassword") as VariableBox;

            vSQLPassword.Visible = UseConnectionVariables.Value && SQLUseSQLAuth.Value;
            string errorMessage = "";

            TextBox sqlServer   = SQLServer;
            TextBox sqlUser     = SQLUser;
            TextBox sqlPassword = SQLPassword;

            if (UseConnectionVariables.Value)
            {
                sqlServer = new TextBox()
                {
                    Value = GetVariableValue(vSQLServer.Value)
                };
                sqlUser = new TextBox()
                {
                    Value = GetVariableValue(vSQLUser.Value)
                };
                if (SQLUseSQLAuth.Value)
                {
                    sqlPassword = new TextBox()
                    {
                        Value = GetVariableValue(vSQLPassword.Value)
                    }
                }
                ;
            }

            IList <string> databases   = SQLHelpers.GetDatabases(sqlServer, sqlUser, SQLUseSQLAuth, this.decrypt(sqlPassword.Value), out errorMessage);
            DropDown       SQLDatabase = settings.Find("SQLDatabase") as DropDown;

            SQLDatabase.Options = databases.Select(i => new Option()
            {
                DisplayMemeber = i, ValueMemeber = i
            }).ToList();

            if (!String.IsNullOrWhiteSpace(SQLDatabase.Value))
            {
                IList <string> tables   = SQLHelpers.GetTables(sqlServer, sqlUser, SQLUseSQLAuth, this.decrypt(sqlPassword.Value), SQLDatabase, out errorMessage);
                DropDown       SQLTable = settings.Find("SQLTable") as DropDown;
                SQLTable.Options = tables.Select(i => new Option()
                {
                    DisplayMemeber = i, ValueMemeber = i
                }).ToList();
                if (tables.Contains(SQLTable.Value) == false)
                {
                    SQLTable.Value = "";
                }

                if (!String.IsNullOrWhiteSpace(SQLTable.Value))
                {
                    IList <DataColumn> columns            = SQLHelpers.GetColumns(sqlServer.Value, sqlUser.Value, SQLUseSQLAuth.Value, this.decrypt(sqlPassword.Value), SQLDatabase.Value, SQLTable.Value);
                    DropDown           SQLTimestampColumn = settings.Find("SQLTimestampColumn") as DropDown;
                    SQLTimestampColumn.Options = columns.Select(i => new Option()
                    {
                        DisplayMemeber = i.ColumnName, ValueMemeber = i.ColumnName
                    }).ToList();
                    if (columns.Any(c => c.ColumnName == SQLTimestampColumn.Value) == false)
                    {
                        SQLTimestampColumn.Value = "";
                    }

                    TokenBox SQLColumns = settings.Find("SQLColumns") as TokenBox;
                    SQLColumns.Options = columns.Select(c => new Option()
                    {
                        DisplayMemeber = c.ColumnName, ValueMemeber = c.ColumnName
                    }).ToList();
                    if (columns.Count > 0 && !String.IsNullOrEmpty(SQLColumns.Value))
                    {
                        SQLColumns.Value = String.Join(",", SQLColumns.Value.Split(',').Where(c => columns.Any(col => c == col.ColumnName)));
                    }
                }
            }

            if (!String.IsNullOrWhiteSpace(errorMessage))
            {
                SQLServer.HelpText = vSQLServer.HelpText = errorMessage;
            }

            return(settings.ToString());
        }
Exemplo n.º 4
0
        public string GetConfigurationTemplate(string template, IDictionary <string, string> parameters)
        {
            var settings = Settings.Parse(template);

            new Populator(parameters).Populate(settings);
            CheckBox UseConnectionVariables = (CheckBox)settings.Find("UseConnectionVariables");
            TextBox  SQLServer = settings.Find("SQLServer") as TextBox;

            SQLServer.HelpText = string.Empty;
            TextBox SQLUser = settings.Find("SQLUser") as TextBox;

            SQLServer.Visible = SQLUser.Visible = (UseConnectionVariables.Value == false);
            CheckBox SQLUseSQLAuth = settings.Find("SQLUseSQLAuth") as CheckBox;
            TextBox  SQLPassword   = settings.Find("SQLPassword") as TextBox;

            SQLPassword.Visible = !UseConnectionVariables.Value && SQLUseSQLAuth.Value;
            VariableBox vSQLServer = settings.Find("vSQLServer") as VariableBox;

            vSQLServer.HelpText = string.Empty;
            VariableBox vSQLUser = settings.Find("vSQLUser") as VariableBox;

            vSQLServer.Visible = vSQLUser.Visible = (UseConnectionVariables.Value == true);
            VariableBox vSQLPassword = settings.Find("vSQLPassword") as VariableBox;

            vSQLPassword.Visible = UseConnectionVariables.Value && SQLUseSQLAuth.Value;
            string errorMessage = "";

            TextBox sqlServer   = SQLServer;
            TextBox sqlUser     = SQLUser;
            TextBox sqlPassword = SQLPassword;

            if (UseConnectionVariables.Value)
            {
                sqlServer = new TextBox()
                {
                    Value = GetVariableValue(vSQLServer.Value)
                };
                sqlUser = new TextBox()
                {
                    Value = GetVariableValue(vSQLUser.Value)
                };
                if (SQLUseSQLAuth.Value)
                {
                    sqlPassword = new TextBox()
                    {
                        Value = GetVariableValue(vSQLPassword.Value)
                    }
                }
                ;
            }

            IList <string> databases   = SQLHelpers.GetDatabases(sqlServer, sqlUser, SQLUseSQLAuth, this.decrypt(sqlPassword.Value), out errorMessage);
            DropDown       SQLDatabase = settings.Find("SQLDatabase") as DropDown;

            SQLDatabase.Options = databases.Select(i => new Option()
            {
                DisplayMemeber = i, ValueMemeber = i
            }).ToList();

            if (!String.IsNullOrWhiteSpace(SQLDatabase.Value))
            {
                IList <string> tables   = SQLHelpers.GetTables(sqlServer, sqlUser, SQLUseSQLAuth, this.decrypt(sqlPassword.Value), SQLDatabase, out errorMessage);
                DropDown       SQLTable = settings.Find("SQLTable") as DropDown;
                SQLTable.Options = tables.Select(i => new Option()
                {
                    DisplayMemeber = i, ValueMemeber = i
                }).ToList();
                if (tables.Contains(SQLTable.Value) == false)
                {
                    SQLTable.Value = "";
                }

                if (!String.IsNullOrWhiteSpace(SQLTable.Value))
                {
                    IList <DataColumn> columns    = SQLHelpers.GetColumns(sqlServer.Value, sqlUser.Value, SQLUseSQLAuth.Value, this.decrypt(sqlPassword.Value), SQLDatabase.Value, SQLTable.Value);
                    TokenBox           SQLColumns = settings.Find("SQLColumns") as TokenBox;
                    SQLColumns.Options = columns.Select(c => new Option()
                    {
                        DisplayMemeber = c.ColumnName, ValueMemeber = c.ColumnName
                    }).ToList();
                    if (columns.Count > 0 && !String.IsNullOrEmpty(SQLColumns.Value))
                    {
                        SQLColumns.Value = String.Join(",", SQLColumns.Value.Split(',').Where(c => columns.Any(col => c == col.ColumnName)));
                    }

                    XMIoT.Framework.Settings.Filter Filters = settings.Find("Filters") as XMIoT.Framework.Settings.Filter;
                    Filters.Fields = columns.Select(i => new TypedOption()
                    {
                        Type = i.DataType.GetIoTType(), DisplayMemeber = i.ColumnName, ValueMemeber = i.ColumnName
                    }).ToList();

                    Grid     SortGrid   = settings.Find("SortGrid") as Grid;
                    DropDown SortColumn = SortGrid.Columns.First(s => s.Key == "SortColumn") as DropDown;
                    SortColumn.Options = columns.Select(i => new Option()
                    {
                        DisplayMemeber = i.ColumnName, ValueMemeber = i.ColumnName
                    }).ToList();

                    var newRows = new JArray();
                    var rows    = SortGrid.Rows?.ToList() ?? new List <IDictionary <string, object> >();
                    foreach (var row in rows)
                    {
                        if (columns.Select(c => c.ColumnName).Contains(row["SortColumn"].ToString()) == true)
                        {
                            newRows.Add(JObject.FromObject(row));
                        }
                    }
                    SortGrid.Value = newRows.ToString();
                }
            }

            if (!String.IsNullOrWhiteSpace(errorMessage))
            {
                SQLServer.HelpText = vSQLServer.HelpText = errorMessage;
            }

            return(settings.ToString());
        }