コード例 #1
0
            public static bool Create(MySQLConnector conn)
            {
                using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableCreate(TableName, Columns);

                    return ((IDataConnector)conn).ExecuteNonQuery(bl) > 0;
                }
            }
コード例 #2
0
            public static bool Exists(MySQLConnector conn)
            {
                using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableExists(TableName);

                    return ((IDataConnector)conn).Execute(bl);
                }
            }
コード例 #3
0
            public static bool Exists(MySQLConnector conn)
            {
                using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableExists(TableName);

                    return(((IDataConnector)conn).Execute(bl));
                }
            }
コード例 #4
0
            public static bool Create(MySQLConnector conn)
            {
                using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableCreate(TableName, Columns);

                    return(((IDataConnector)conn).ExecuteNonQuery(bl) > 0);
                }
            }
コード例 #5
0
        public static long Insert(MySQLConnector conn, string node, bool deny)
        {
            using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                bl.InsertInto(TableDefinition.TableName,
                              new DataParameter(TableDefinition.ColumnNames.Node, node),
                              new DataParameter(TableDefinition.ColumnNames.Deny, deny)
                              );

                return(((IDataConnector)conn).ExecuteInsert(bl));
            }
        }
コード例 #6
0
        public static long Insert(MySQLConnector conn, string node, bool deny)
        {
            using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                bl.InsertInto(TableDefinition.TableName,
                    new DataParameter(TableDefinition.ColumnNames.Node, node),
                    new DataParameter(TableDefinition.ColumnNames.Deny, deny)
                );

                return ((IDataConnector)conn).ExecuteInsert(bl);
            }
        }
コード例 #7
0
        public static long Insert(MySQLConnector conn, long groupId, long permissionId)
        {
            using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                bl.InsertInto(TableDefinition.TableName,
                    new DataParameter(TableDefinition.ColumnNames.GroupId, groupId),
                    new DataParameter(TableDefinition.ColumnNames.PermissionId, permissionId)
                );

                return ((IDataConnector)conn).ExecuteInsert(bl);
            }
        }
コード例 #8
0
        bool IPermissionHandler.AddNodeToUser(string username, string node, bool deny)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.AddNodeToUser, "prm",
                    new DataParameter("UserName", username),
                    new DataParameter("Node", node),
                    new DataParameter("Deny", deny)
                );

                return Storage.ExecuteScalar<Int64>(sb) > 0;
            }
        }
コード例 #9
0
        private Permission IsPermitted(string node, bool isGuest, string authentication = null)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure("SqlPermissions_IsPermitted", "prm",
                    new DataParameter("Node", node),
                    new DataParameter("IsGuest", isGuest),
                    new DataParameter("Authentication", authentication)
                );

                return (Permission)Storage.ExecuteScalar<Int32>(sb);
            }
        }
コード例 #10
0
        bool IPermissionHandler.AddOrUpdateGroup(string name, bool applyToGuests, string parent, byte r, byte g, byte b, string prefix, string suffix)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.AddOrUpdateGroup, "prm",
                    new DataParameter("Name", name),
                    new DataParameter("ApplyToGuests", applyToGuests),
                    new DataParameter("Parent", parent),
                    new DataParameter("R", r),
                    new DataParameter("G", g),
                    new DataParameter("B", b),
                    new DataParameter("Prefix", prefix),
                    new DataParameter("Suffix", suffix)
                );

                return Storage.ExecuteScalar<Int64>(sb) > 0;
            }
        }
コード例 #11
0
            public static bool Create(MySQLConnector conn)
            {
                try
                {
                    using (var bl = new MySQLQueryBuilder(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);
                }
            }
コード例 #12
0
            public static bool Create(MySQLConnector conn)
            {
                try
                {
                    using (var bl = new MySQLQueryBuilder(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;
                }
            }
コード例 #13
0
            static void CreateGroup(string name, bool guest, string parent, byte r, byte g, byte b, string[] nodes, MySQLConnector conn)
            {
                long id;

                using (var bl = new MySQLQueryBuilder(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, false);
                    GroupPermissions.Insert(conn, id, nodeId);
                }
            }
コード例 #14
0
        string[] IPermissionHandler.UserGroupList(string username)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.UserGroupList, "prm",
                    new DataParameter("UserName", username)
                );

                var lst = Storage.ExecuteArray<UserGroupList>(sb);
                if (lst != null)
                    return lst.Select(x => x.Name).ToArray();
            }
            return null;
        }
コード例 #15
0
        public bool Create(MySQLConnector conn)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                var proc = PluginContent.GetResource("TDSM.Data.MySQL.Procedures.Files." + Name + ".sql");

                sb.CommandType = System.Data.CommandType.Text;
                sb.CommandText = proc;

                return ((IDataConnector)conn).Execute(sb);
            }
        }
コード例 #16
0
        public bool Exists(MySQLConnector conn)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ProcedureExists(Name);

                return ((IDataConnector)conn).Execute(sb);
            }
        }
コード例 #17
0
        Group IPermissionHandler.FindGroup(string name)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.FindGroup, "prm",
                    new DataParameter("Name", name)
                );

                var arr = Storage.ExecuteArray<Group>(sb);
                if (arr != null && arr.Length > 0)
                    return arr[0];
            }

            return null;
        }
コード例 #18
0
            public static bool Create(MySQLConnector conn)
            {
                using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    var proc = PluginContent.GetResource("TDSM.Data.MySQL.IsPermitted.sql");
                //                    sb.ProcedureCreate("SqlPermissions_IsPermitted", proc,
                //                        new ProcedureParameter("prmNode", typeof(String), 50),
                //                        new ProcedureParameter("prmIsGuest", typeof(Boolean)),
                //                        new ProcedureParameter("prmAuthentication", typeof(String), 50)
                //                    );

                    sb.CommandType = System.Data.CommandType.Text;
                    sb.CommandText = proc;

                    return ((IDataConnector)conn).Execute(sb);
                }
            }
コード例 #19
0
        bool IPermissionHandler.AddUserToGroup(string username, string groupName)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.AddUserToGroup, "prm",
                    new DataParameter("UserName", username),
                    new DataParameter("GroupName", groupName)
                );

                return Storage.ExecuteScalar<Int64>(sb) > 0;
            }
        }
コード例 #20
0
        string[] IPermissionHandler.GroupList()
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.GroupList);

                var lst = Storage.ExecuteArray<GroupList>(sb);
                if (lst != null)
                    return lst.Select(x => x.Name).ToArray();
            }
            return null;
        }
コード例 #21
0
        TDSM.API.Data.PermissionNode[] IPermissionHandler.UserNodes(string username)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.UserNodes, "prm",
                    new DataParameter("UserName", username)
                );

                return Storage.ExecuteArray<TDSM.API.Data.PermissionNode>(sb);
            }
        }
コード例 #22
0
            static void CreateGroup(string name, bool guest, string parent, byte r, byte g, byte b, string[] nodes, MySQLConnector conn)
            {
                long id;
                using (var bl = new MySQLQueryBuilder(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, false);
                    GroupPermissions.Insert(conn, id, nodeId);
                }
            }
コード例 #23
0
        bool IPermissionHandler.RemoveGroupNode(string groupName, string node, bool deny)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.RemoveGroupNode, "prm",
                    new DataParameter("GroupName", groupName),
                    new DataParameter("Node", node),
                    new DataParameter("Deny", deny)
                );

                return Storage.ExecuteScalar<Int64>(sb) > 0;
            }
        }
コード例 #24
0
        bool IPermissionHandler.RemoveGroup(string name)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ExecuteProcedure(Procedures.RemoveGroup, "prm",
                    new DataParameter("Name", name)
                );

                return Storage.ExecuteNonQuery(sb) > 0;
            }
        }