Ejemplo n.º 1
0
 public void Initialise(MSSQLConnector conn)
 {
     if (!TableDefinition.Exists(conn))
     {
         ProgramLog.Admin.Log("Permission node table does not exist and will now be created");
         TableDefinition.Create(conn);
     }
 }
Ejemplo n.º 2
0
 public void Initialise(MSSQLConnector conn)
 {
     if (!TableDefinition.Exists(conn))
     {
         ProgramLog.Admin.Log("Group table does not exist and will now be created");
         TableDefinition.Create(conn);
     }
 }
Ejemplo n.º 3
0
            public static bool Exists(MSSQLConnector conn)
            {
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableExists(TableName);

                    return(((IDataConnector)conn).Execute(bl));
                }
            }
Ejemplo n.º 4
0
            public static bool Create(MSSQLConnector conn)
            {
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableCreate(TableName, Columns);

                    return(((IDataConnector)conn).ExecuteNonQuery(bl) > 0);
                }
            }
Ejemplo n.º 5
0
            public static bool Exists(MSSQLConnector conn)
            {
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableExists(TableName);

                    return ((IDataConnector)conn).Execute(bl);
                }
            }
Ejemplo n.º 6
0
            public static bool Create(MSSQLConnector conn)
            {
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableCreate(TableName, Columns);

                    return ((IDataConnector)conn).ExecuteNonQuery(bl) > 0;
                }
            }
Ejemplo n.º 7
0
        public static long Insert(MSSQLConnector conn, string node, Permission permission)
        {
            using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                bl.InsertInto(TableDefinition.TableName,
                              new DataParameter(TableDefinition.ColumnNames.Node, node),
                              new DataParameter(TableDefinition.ColumnNames.Permission, permission)
                              );

                return(((IDataConnector)conn).ExecuteInsert(bl));
            }
        }
Ejemplo n.º 8
0
        public static long Insert(MSSQLConnector conn, string node, Permission permission)
        {
            using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                bl.InsertInto(TableDefinition.TableName,
                    new DataParameter(TableDefinition.ColumnNames.Node, node),
                    new DataParameter(TableDefinition.ColumnNames.Permission, permission)
                );

                return ((IDataConnector)conn).ExecuteInsert(bl);
            }
        }
Ejemplo n.º 9
0
        public void InsertinDB()
        {
            MSSQLConnector connector = new MSSQLConnector();

            connector.OpenConnect();

            string     rqst     = "INSERT INTO Регионы (Название) VALUES ('" + this.Name + "')";
            SqlCommand command2 = new SqlCommand(rqst, connector.conn);

            command2.ExecuteNonQuery();

            connector.CloseConnect();
        }
Ejemplo n.º 10
0
        //ISQLUPDATE Interface Implementation
        public void UpdateRecord()
        {
            MSSQLConnector connector = new MSSQLConnector();

            connector.OpenConnect();

            string rqst = @"UPDATE Страны SET Название = '" + this.Name + "', [Код страны]= '" + this.Code + "', Площадь=" + this.Area +
                          ",Население=" + this.Population + ", Регион =" + this.Reg.Id + ", Столица = " + this.Cap.Id + " WHERE id=" + this.Id;;

            SqlCommand command = new SqlCommand(rqst, connector.conn);

            command.ExecuteNonQuery();
            System.Windows.Forms.MessageBox.Show(this.Name + " data was updated");

            connector.CloseConnect();
        }
Ejemplo n.º 11
0
        public void InsertinDB()
        {
            MSSQLConnector connector = new MSSQLConnector();

            connector.OpenConnect();

            string rqst = @"INSERT INTO Страны (Название, [Код страны], Площадь, Население, Регион, Столица) VALUES "
                          + "('" + this.Name + "','" + this.Code + "'," + this.Area + "," + this.Population + "," + this.Reg.Id + "," + this.Cap.Id + ")";

            this.Show();
            SqlCommand command2 = new SqlCommand(rqst, connector.conn);

            command2.ExecuteNonQuery();

            connector.CloseConnect();
        }
Ejemplo n.º 12
0
        public ArrayList FindIfExist()
        {
            MSSQLConnector connector = new MSSQLConnector();

            connector.OpenConnect();

            string        rqst     = "Select * from Города Where Название = '" + this.Name + "'";
            SqlCommand    command1 = new SqlCommand(rqst, connector.conn);
            SqlDataReader dr       = command1.ExecuteReader();
            ArrayList     tempArr  = TransformResult(dr);

            connector.CloseConnect();
            if (tempArr.Count == 0)
            {
                tempArr.Add(new Models.Capital());
            }
            return(tempArr);
        }
Ejemplo n.º 13
0
        public static void InitializeConnections(string db)
        {
            switch (db)
            {
            case "MSSQL":
                MSSQLConnector mssql = new MSSQLConnector();
                Connection = mssql;
                break;

            case "Entity":
                EntityConnector entity = new EntityConnector();
                Connection = entity;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 14
0
            public static bool Create(MSSQLConnector conn)
            {
                try
                {
                    using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                    {
                        bl.TableCreate(TableName, Columns);

                        ((IDataConnector)conn).ExecuteNonQuery(bl);
                    }

                    //Set defaults
                    var pc = CommandParser.GetAvailableCommands(AccessLevel.PLAYER);
                    var ad = CommandParser.GetAvailableCommands(AccessLevel.OP);
                    var op = CommandParser.GetAvailableCommands(AccessLevel.CONSOLE); //Funny how these have now changed

                    CreateGroup("Guest", true, null, 255, 255, 255, pc
                                .Where(x => !String.IsNullOrEmpty(x.Value.Node))
                                .Select(x => x.Value.Node)
                                .Distinct()
                                .ToArray(), conn);
                    CreateGroup("Admin", false, "Guest", 240, 131, 77, ad
                                .Where(x => !String.IsNullOrEmpty(x.Value.Node))
                                .Select(x => x.Value.Node)
                                .Distinct()
                                .ToArray(), conn);
                    CreateGroup("Operator", false, "Admin", 77, 166, 240, op
                                .Where(x => !String.IsNullOrEmpty(x.Value.Node))
                                .Select(x => x.Value.Node)
                                .Distinct()
                                .ToArray(), conn);

                    return(true);
                }
                catch (Exception e)
                {
                    ProgramLog.Log(e);
                    return(false);
                }
            }
Ejemplo n.º 15
0
            public static bool Create(MSSQLConnector conn)
            {
                try
                {
                    using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                    {
                        bl.TableCreate(TableName, Columns);

                        ((IDataConnector)conn).ExecuteNonQuery(bl);
                    }

                    //Set defaults
                    var pc = CommandParser.GetAvailableCommands(AccessLevel.PLAYER);
                    var ad = CommandParser.GetAvailableCommands(AccessLevel.OP);
                    var op = CommandParser.GetAvailableCommands(AccessLevel.CONSOLE); //Funny how these have now changed

                    CreateGroup("Guest", true, null, 255, 255, 255, pc
                        .Where(x => !String.IsNullOrEmpty(x.Value.Node))
                        .Select(x => x.Value.Node)
                        .Distinct()
                        .ToArray(), conn);
                    CreateGroup("Admin", false, "Guest", 240, 131, 77, ad
                        .Where(x => !String.IsNullOrEmpty(x.Value.Node))
                        .Select(x => x.Value.Node)
                        .Distinct()
                        .ToArray(), conn);
                    CreateGroup("Operator", false, "Admin", 77, 166, 240, op
                        .Where(x => !String.IsNullOrEmpty(x.Value.Node))
                        .Select(x => x.Value.Node)
                        .Distinct()
                        .ToArray(), conn);

                    return true;
                }
                catch (Exception e)
                {
                    ProgramLog.Log(e);
                    return false;
                }
            }
Ejemplo n.º 16
0
 public SQLContextStudent(MSSQLConnector connector)
 {
     this.connector = connector;
 }
Ejemplo n.º 17
0
 public SQLContextUser(MSSQLConnector connector)
 {
     this._connector = connector;
 }
Ejemplo n.º 18
0
 public SQLContextOuder(MSSQLConnector Connector)
 {
     this.Connector = Connector;
 }
Ejemplo n.º 19
0
            static void CreateGroup(string name, bool guest, string parent, byte r, byte g, byte b, string[] nodes, MSSQLConnector conn)
            {
                long id;

                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.InsertInto(TableName,
                                  new DataParameter(ColumnNames.Name, name),
                                  new DataParameter(ColumnNames.ApplyToGuests, guest),
                                  new DataParameter(ColumnNames.Parent, parent),
                                  new DataParameter(ColumnNames.Chat_Red, r),
                                  new DataParameter(ColumnNames.Chat_Green, g),
                                  new DataParameter(ColumnNames.Chat_Blue, b)
                                  );

                    id = ((IDataConnector)conn).ExecuteInsert(bl);
                }

                foreach (var nd in nodes)
                {
                    var nodeId = PermissionTable.Insert(conn, nd, Permission.Permitted);
                    GroupPermissions.Insert(conn, id, nodeId);
                }
            }
Ejemplo n.º 20
0
            static void CreateGroup(string name, bool guest, string parent, byte r, byte g, byte b, string[] nodes, MSSQLConnector conn)
            {
                long id;
                using (var bl = new MSSQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.InsertInto(TableName,
                        new DataParameter(ColumnNames.Name, name),
                        new DataParameter(ColumnNames.ApplyToGuests, guest),
                        new DataParameter(ColumnNames.Parent, parent),
                        new DataParameter(ColumnNames.Chat_Red, r),
                        new DataParameter(ColumnNames.Chat_Green, g),
                        new DataParameter(ColumnNames.Chat_Blue, b)
                    );

                    id = ((IDataConnector)conn).ExecuteInsert(bl);
                }

                foreach (var nd in nodes)
                {
                    var nodeId = PermissionTable.Insert(conn, nd, Permission.Permitted);
                    GroupPermissions.Insert(conn, id, nodeId);
                }
            }