void OnReadConfig(ref HookContext ctx, ref HookArgs.ConfigurationLine args)
        {
            switch (args.Key)
            {
                case "mysql":
                    if (!Storage.IsAvailable)
                    {
                        MySQLConnector cn = null;

                        try
                        {
                            cn = new MySQLConnector(args.Value);
                            cn.Open();
                        }
                        catch (Exception e)
                        {
                            ProgramLog.Error.Log("Exception connecting to MySQL database: {0}", e);
                            return;
                        }
                        Storage.SetConnector(cn);

                        _connector = cn;
                    }
                    break;
            }
        }
 public void Initialise(MySQLConnector conn)
 {
     if (!TableDefinition.Exists(conn))
     {
         ProgramLog.Admin.Log("Group permissions table does not exist and will now be created");
         TableDefinition.Create(conn);
     }
 }
Example #3
0
 public void Initialise(MySQLConnector conn)
 {
     if (!TableDefinition.Exists(conn))
     {
         ProgramLog.Admin.Log("Group permissions table does not exist and will now be created");
         TableDefinition.Create(conn);
     }
 }
Example #4
0
            public static bool Exists(MySQLConnector conn)
            {
                using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableExists(TableName);

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

                    return(((IDataConnector)conn).ExecuteNonQuery(bl) > 0);
                }
            }
            public static bool Create(MySQLConnector conn)
            {
                using (var bl = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    bl.TableCreate(TableName, Columns);

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

                    return ((IDataConnector)conn).Execute(bl);
                }
            }
Example #8
0
            public static bool Exists(MySQLConnector conn)
            {
                using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
                {
                    sb.ProcedureExists("SqlPermissions_IsPermitted");

                    return(((IDataConnector)conn).Execute(sb));
                }
            }
        public bool Drop(MySQLConnector conn)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ProcedureDrop(Name);

                return(((IDataConnector)conn).Execute(sb));
            }
        }
        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));
            }
        }
Example #11
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));
            }
        }
        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);
            }
        }
 public static void Init(MySQLConnector conn)
 {
     foreach (var proc in _procedures)
     {
         #if TESTING
         if (proc.Exists(conn))
             proc.Drop(conn);
         #endif
         if (!proc.Exists(conn))
         {
             ProgramLog.Admin.Log("{0} procedure does not exist and will now be created", proc.Name);
             proc.Create(conn);
         }
     }
     _procedures = null;
 }
Example #14
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));
                }
            }
 public static void Init(MySQLConnector conn)
 {
     foreach (var proc in _procedures)
     {
         #if TESTING
         if (proc.Exists(conn))
         {
             proc.Drop(conn);
         }
         #endif
         if (!proc.Exists(conn))
         {
             ProgramLog.Admin.Log("{0} procedure does not exist and will now be created", proc.Name);
             proc.Create(conn);
         }
     }
     _procedures = null;
 }
Example #16
0
        void OnReadConfig(ref HookContext ctx, ref HookArgs.ConfigurationLine args)
        {
            switch (args.Key)
            {
            case "mysql":
                if (!Storage.IsAvailable)
                {
                    MySQLConnector cn = null;

                    try
                    {
                        cn = new MySQLConnector(args.Value);
                        cn.Open();
                    }
                    catch (Exception e)
                    {
                        ProgramLog.Error.Log("Exception connecting to MySQL database: {0}", e);
                        return;
                    }
                    Storage.SetConnector(_connector = cn);
                }
                break;
            }
        }
        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);
            }
        }
        public bool Exists(MySQLConnector conn)
        {
            using (var sb = new MySQLQueryBuilder(SqlPermissions.SQLSafeName))
            {
                sb.ProcedureExists(Name);

                return ((IDataConnector)conn).Execute(sb);
            }
        }
            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);
                }
            }