/// <summary> /// Initializes a new instance of the <see cref="TierManager"/> class using a custom connection string. /// Manages and caches <see cref="Tier"/> instances loaded from a database. /// </summary> /// <param name="main">The parent CTRSystem instance.</param> /// <param name="connectionString">The connection string to use when connecting to the database.</param> public TierManager(CTRS main, string connectionString) : base(main, connectionString) { Task.Run(CreateTablesAsync); // Load all tiers to the cache Task.Run(async () => Tiers = await GetAllAsync()); }
public ContributorManager(CTRS main) : base(main) { Task.Run(CreateTablesAsync); #region old code //var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite // ? (IQueryBuilder)new SqliteQueryCreator() // : new MysqlQueryCreator()); //if (creator.EnsureTableStructure(new SqlTable(_main.Config.ContributorTableName, // new SqlColumn("ID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true }, // new SqlColumn("XenforoID", MySqlDbType.Int32) { Unique = true, DefaultValue = null }, // new SqlColumn("TotalCredits", MySqlDbType.Float) { NotNull = true, DefaultValue = "0" }, // new SqlColumn("LastDonation", MySqlDbType.Int64) { DefaultValue = null }, // new SqlColumn("LastAmount", MySqlDbType.Float) { NotNull = true, DefaultValue = "0" }, // new SqlColumn("Tier", MySqlDbType.Int32) { NotNull = true, DefaultValue = "1" }, // new SqlColumn("ChatColor", MySqlDbType.VarChar) { Length = 11, DefaultValue = null }, // new SqlColumn("Notifications", MySqlDbType.Int32) { NotNull = true, DefaultValue = "0" }, // new SqlColumn("Settings", MySqlDbType.Int32) { NotNull = true, DefaultValue = "0" }))) //{ // TShock.Log.ConsoleInfo($"CTRS: created table '{_main.Config.ContributorTableName}'"); //} //if (creator.EnsureTableStructure(new SqlTable(_main.Config.ContributorAccountsTableName, // new SqlColumn("UserID", MySqlDbType.Int32) { Primary = true }, // new SqlColumn("ContributorID", MySqlDbType.Int32) { NotNull = true }))) //{ // // This needs to be included in the table creation query // db.Query($@"ALTER TABLE {_main.Config.ContributorAccountsTableName} // ADD FOREIGN KEY (ContributorID) // REFERENCES {_main.Config.ContributorTableName} (ID);"); // TShock.Log.ConsoleInfo($"CTRS: created table '{_main.Config.ContributorAccountsTableName}'"); //} #endregion }
/// <summary> /// Initializes a new instance of the <see cref="TierManager"/> class using a custom connection string. /// Manages and caches <see cref="Tier"/> instances loaded from a database. /// </summary> /// <param name="main">The parent CTRSystem instance.</param> /// <param name="connectionString">The connection string to use when connecting to the database.</param> public TierManager(CTRS main, string connectionString) : base(main, connectionString) { Task.Run(CreateTablesAsync); // Load all tiers to the cache Task.Run(async() => Tiers = await GetAllAsync()); }
/// <summary> /// Initializes a new instance of the <see cref="TierManager"/> class. /// Manages and caches <see cref="Tier"/> instances loaded from a database. /// </summary> /// <param name="main">The parent CTRSystem instance.</param> public TierManager(CTRS main) : base(main) { Task.Run(CreateTablesAsync); #region old code //var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite // ? (IQueryBuilder)new SqliteQueryCreator() // : new MysqlQueryCreator()); //if (creator.EnsureTableStructure(new SqlTable(_main.Config.TierTableName, // new SqlColumn("ID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true }, // new SqlColumn("Name", MySqlDbType.VarChar) { Length = 12, Unique = true }, // new SqlColumn("CreditsRequired", MySqlDbType.Float) { NotNull = true, DefaultValue = "0" }, // new SqlColumn("ShortName", MySqlDbType.VarChar) { NotNull = true, DefaultValue = "", Length = 6 }, // new SqlColumn("ChatColor", MySqlDbType.Text) { NotNull = true, DefaultValue = "" }, // new SqlColumn("Permissions", MySqlDbType.Text) { NotNull = true, DefaultValue = "" }, // new SqlColumn("ExperienceMultiplier", MySqlDbType.Float) { NotNull = true, DefaultValue = "1" }))) //{ // TShock.Log.ConsoleInfo($"CTRS: created table '{_main.Config.TierTableName}'"); //} #endregion // Load all tiers to the cache Task.Run(async() => Tiers = await GetAllAsync()); }
/// <summary> /// Initializes a new instance of the <see cref="TierManager"/> class. /// Manages and caches <see cref="Tier"/> instances loaded from a database. /// </summary> /// <param name="main">The parent CTRSystem instance.</param> public TierManager(CTRS main) : base(main) { Task.Run(CreateTablesAsync); #region old code //var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite // ? (IQueryBuilder)new SqliteQueryCreator() // : new MysqlQueryCreator()); //if (creator.EnsureTableStructure(new SqlTable(_main.Config.TierTableName, // new SqlColumn("ID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true }, // new SqlColumn("Name", MySqlDbType.VarChar) { Length = 12, Unique = true }, // new SqlColumn("CreditsRequired", MySqlDbType.Float) { NotNull = true, DefaultValue = "0" }, // new SqlColumn("ShortName", MySqlDbType.VarChar) { NotNull = true, DefaultValue = "", Length = 6 }, // new SqlColumn("ChatColor", MySqlDbType.Text) { NotNull = true, DefaultValue = "" }, // new SqlColumn("Permissions", MySqlDbType.Text) { NotNull = true, DefaultValue = "" }, // new SqlColumn("ExperienceMultiplier", MySqlDbType.Float) { NotNull = true, DefaultValue = "1" }))) //{ // TShock.Log.ConsoleInfo($"CTRS: created table '{_main.Config.TierTableName}'"); //} #endregion // Load all tiers to the cache Task.Run(async () => Tiers = await GetAllAsync()); }
/// <summary> /// Start listening to contributor related events fired by various contribution modules. /// </summary> /// <param name="main">The CTRSystem instance scope.</param> /// <param name="player">If set, will send notification messages to a player whenever possible.</param> public void Listen(CTRS scope, TSPlayer player = null) { _receiver = player; _scope = scope; _scope.Rests.ContributorUpdate += OnUpdate; _scope.Rests.Transaction += OnTransaction; }
public XenforoManager(CTRS main) : base(main) { // Make sure the tshock_id column exists try { using (var db = OpenConnection()) { db.Execute("ALTER TABLE xf_user ADD tshock_id INT UNIQUE"); } } catch (MySqlException) { // A duplicate column error is thrown if it already exists. Disregard. } }
public ContributorManager(CTRS main, string connectionString) : base(main, connectionString) { Task.Run(CreateTablesAsync); }
public TextFormatter(CTRS main, ConfigFile config) { _main = main; _config = config; }
public DbManager(CTRS main, string connectionString) : this(main) { ConnectionString = connectionString; }
public DbManager(CTRS main) { Main = main; }