當前位置: 首頁>>代碼示例>>C#>>正文


C# SqlTableCreator.EnsureExists方法代碼示例

本文整理匯總了C#中TShockAPI.DB.SqlTableCreator.EnsureExists方法的典型用法代碼示例。如果您正苦於以下問題:C# SqlTableCreator.EnsureExists方法的具體用法?C# SqlTableCreator.EnsureExists怎麽用?C# SqlTableCreator.EnsureExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TShockAPI.DB.SqlTableCreator的用法示例。


在下文中一共展示了SqlTableCreator.EnsureExists方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitTerraDB

 public static void InitTerraDB()
 {
     string sql = Path.Combine(terraDB);
     if (!File.Exists(terraDB))
     {
         SqliteConnection.CreateFile(terraDB);
     }
     DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
     SQLWriter = new SqlTableCreator(DB, new SqliteQueryCreator());
     var table = new SqlTable("Clans",
     new SqlColumn("clanname", MySqlDbType.Text) { Unique = true },
     new SqlColumn("clangroup", MySqlDbType.Text),
     new SqlColumn("leaders", MySqlDbType.Text),
     new SqlColumn("members", MySqlDbType.Text),
     new SqlColumn("motd", MySqlDbType.Text),
     new SqlColumn("invites", MySqlDbType.Text)
     );
     SQLWriter.EnsureExists(table);
     table = new SqlTable("FoundQueue",
     new SqlColumn("clanname", MySqlDbType.Text) { Unique = true },
     new SqlColumn("founder", MySqlDbType.Text),
     new SqlColumn("cofounder", MySqlDbType.Text)
     );
     SQLWriter.EnsureExists(table);
 }
開發者ID:UB1AFU,項目名稱:TerraClans,代碼行數:25,代碼來源:TCdb.cs

示例2: GroupManager

        public GroupManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("GroupList",
                new SqlColumn("GroupName", MySqlDbType.VarChar, 32) { Primary = true },
                new SqlColumn("Parent", MySqlDbType.VarChar, 32),
                new SqlColumn("Commands", MySqlDbType.Text),
                new SqlColumn("ChatColor", MySqlDbType.Text)
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);

            //Add default groups
            AddGroup("default", "canwater,canlava,warp,canbuild");
            AddGroup("newadmin", "default", "kick,editspawn,reservedslot");
            AddGroup("admin", "newadmin", "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
            AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,ignoregriefdetection,usebanneditem,manageusers");
            AddGroup("vip", "default", "canwater,canlava,warp,canbuild,reservedslot");

            String file = Path.Combine(TShock.SavePath, "groups.txt");
            if (File.Exists(file))
            {
                using (StreamReader sr = new StreamReader(file))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
                        {
                            String[] info = line.Split(' ');
                            String comms = "";
                            int size = info.Length;
                            for (int i = 1; i < size; i++)
                            {
                                if (!comms.Equals(""))
                                    comms = comms + ",";
                                comms = comms + info[i].Trim();
                            }

                            string query = "";
                            if (TShock.Config.StorageType.ToLower() == "sqlite")
                                query = "INSERT OR IGNORE INTO GroupList (GroupName, Commands) VALUES (@0, @1);";
                            else if (TShock.Config.StorageType.ToLower() == "mysql")
                                query = "INSERT IGNORE INTO GroupList SET [email protected], [email protected];";

                            db.Query(query, info[0].Trim(), comms);

                        }
                    }
                }
                String path = Path.Combine(TShock.SavePath, "old_configs");
                String file2 = Path.Combine(path, "groups.txt");
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                if (File.Exists(file2))
                    File.Delete(file2);
                File.Move(file, file2);
            }
        }
開發者ID:char213,項目名稱:TShock,代碼行數:60,代碼來源:GroupManager.cs

示例3: GroupManager

        public GroupManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("GroupList",
                                     new SqlColumn("GroupName", MySqlDbType.VarChar, 32) {Primary = true},
                                     new SqlColumn("Parent", MySqlDbType.VarChar, 32),
                                     new SqlColumn("Commands", MySqlDbType.Text),
                                     new SqlColumn("ChatColor", MySqlDbType.Text),
                                     new SqlColumn("Prefix", MySqlDbType.Text),
                                     new SqlColumn("Suffix", MySqlDbType.Text)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureExists(table);

            //Add default groups
            AddGroup("guest", "canbuild,canregister,canlogin,canpartychat,cantalkinthird");
            AddGroup("default", "guest", "warp,canchangepassword");
            AddGroup("newadmin", "default", "kick,editspawn,reservedslot");
            AddGroup("admin", "newadmin",
                     "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
            AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers");
            AddGroup("vip", "default", "reservedslot");
        }
開發者ID:kmcfate,項目名稱:TShock,代碼行數:27,代碼來源:GroupManager.cs

示例4: CheckTables

 internal static void CheckTables(IDbConnection connection)
 {
     SQLWriter = new SqlTableCreator(connection, new MysqlQueryCreator());
     var table = new SqlTable("BannedIP",
     new SqlColumn("IP", MySqlDbType.Text),
     new SqlColumn("BanDate", MySqlDbType.Int32),
     new SqlColumn("UnbanDate", MySqlDbType.Int32),
     new SqlColumn("BannedBy", MySqlDbType.Text),
     new SqlColumn("Reason", MySqlDbType.Text)
     );
     SQLWriter.EnsureExists(table);
     table = new SqlTable("BannedPlayer",
     new SqlColumn("Player", MySqlDbType.Text),
     new SqlColumn("BanDate", MySqlDbType.Int32),
     new SqlColumn("UnbanDate", MySqlDbType.Int32),
     new SqlColumn("BannedBy", MySqlDbType.Text),
     new SqlColumn("Reason", MySqlDbType.Text)
     );
     SQLWriter.EnsureExists(table);
     table = new SqlTable("MutedPlayer",
     new SqlColumn("Player", MySqlDbType.Text),
     new SqlColumn("MuteDate", MySqlDbType.Int32),
     new SqlColumn("UnmuteDate", MySqlDbType.Int32),
     new SqlColumn("MutedBy", MySqlDbType.Text),
     new SqlColumn("Reason", MySqlDbType.Text)
     );
     SQLWriter.EnsureExists(table);
 }
開發者ID:CoderCow,項目名稱:ExtendedBans,代碼行數:28,代碼來源:EBData.cs

示例5: WarpplateManager

 public WarpplateManager(IDbConnection db)
 {
     this.database = db;
     string arg_ED_0 = "Warpplates";
     SqlColumn[] array = new SqlColumn[11];
     array[0] = new SqlColumn("X1", MySqlDbType.Int32);
     array[1] = new SqlColumn("Y1", MySqlDbType.Int32);
     array[2] = new SqlColumn("width", MySqlDbType.Int32);
     array[3] = new SqlColumn("height", MySqlDbType.Int32);
     SqlColumn[] arg_7E_0 = array;
     int arg_7E_1 = 4;
     SqlColumn sqlColumn = new SqlColumn("WarpplateName", MySqlDbType.VarChar, new int?(50));
     sqlColumn.Primary = true;
     arg_7E_0[arg_7E_1] = sqlColumn;
     array[5] = new SqlColumn("WorldID", MySqlDbType.Text);
     array[6] = new SqlColumn("UserIds", MySqlDbType.Text);
     array[7] = new SqlColumn("Protected", MySqlDbType.Int32);
     array[8] = new SqlColumn("WarpplateDestination", MySqlDbType.VarChar, new int?(50));
     array[9] = new SqlColumn("Delay", MySqlDbType.Int32);
     array[10] = new SqlColumn("Label", MySqlDbType.Text);
     SqlTable sqlTable = new SqlTable(arg_ED_0, array);
     IQueryBuilder arg_10D_1;
     if (DbExt.GetSqlType(db) != SqlType.Sqlite)
     {
         IQueryBuilder queryBuilder = new MysqlQueryCreator();
         arg_10D_1 = queryBuilder;
     }
     else
     {
         arg_10D_1 = new SqliteQueryCreator();
     }
     SqlTableCreator sqlTableCreator = new SqlTableCreator(db, arg_10D_1);
     sqlTableCreator.EnsureExists(sqlTable);
     this.ReloadAllWarpplates();
 }
開發者ID:Enerdy,項目名稱:AdvancedWarpplates,代碼行數:35,代碼來源:WarpplateManager.cs

示例6: InitializeTable

        public void InitializeTable()
        {
            var table = new SqlTable("RegionHelper",
                new SqlColumn("RegionName", MySql.Data.MySqlClient.MySqlDbType.Text),
                new SqlColumn("IsLocked", MySql.Data.MySqlClient.MySqlDbType.Text));

            var creator = new SqlTableCreator(_Connection, _Connection.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
開發者ID:middas,項目名稱:ExtendedAdmin,代碼行數:9,代碼來源:RegionHelper.cs

示例7: ArmorShopManager

        public ArmorShopManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Armor",
                new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true },
                new SqlColumn("Name", MySqlDbType.VarChar, 32),
                new SqlColumn("InGameName", MySqlDbType.VarChar, 128),
                new SqlColumn("Contains", MySqlDbType.VarChar, 128),
                new SqlColumn("Price", MySqlDbType.Int32));
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
開發者ID:RogerPaladin,項目名稱:TShock,代碼行數:13,代碼來源:ArmorShopManager.cs

示例8: ChatManager

        public ChatManager(IDbConnection db)
        {
            database = db;

                var table = new SqlTable("Chat",
                    new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true },
                    new SqlColumn("Username", MySqlDbType.VarChar, 32),
                    new SqlColumn("ToUsername", MySqlDbType.VarChar, 32),
                    new SqlColumn("Message", MySqlDbType.VarChar, 32)
                    );
                var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
                creator.EnsureExists(table);
        }
開發者ID:RogerPaladin,項目名稱:TShock,代碼行數:13,代碼來源:ChatManager.cs

示例9: InventoryManager

        public InventoryManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Inventory",
                new SqlColumn("Account", MySqlDbType.Int32) { Primary = true },
                new SqlColumn("MaxHealth", MySqlDbType.Int32),
                new SqlColumn("MaxMana", MySqlDbType.Int32),
                new SqlColumn("Inventory", MySqlDbType.Text)
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
開發者ID:DaGamesta,項目名稱:TShock,代碼行數:13,代碼來源:InventoryManager.cs

示例10: RemeberedPosManager

        public RemeberedPosManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("RememberedPos",
                new SqlColumn("Name", MySqlDbType.VarChar, 50) { Primary = true },
                new SqlColumn("IP", MySqlDbType.Text),
                new SqlColumn("X", MySqlDbType.Int32),
                new SqlColumn("Y", MySqlDbType.Int32),
                new SqlColumn("WorldID", MySqlDbType.Text)
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
開發者ID:BlueJayofEvil,項目名稱:TShock,代碼行數:14,代碼來源:RememberPosManager.cs

示例11: InventoryManager

        public InventoryManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("Inventory",
                new SqlColumn("Username", MySqlDbType.VarChar, 32) { Unique = true, Primary = true},
                new SqlColumn("Slot0", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot1", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot2", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot3", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot4", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot5", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot6", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot7", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot8", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot9", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot10", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot11", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot12", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot13", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot14", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot15", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot16", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot17", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot18", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot19", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot20", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot21", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot22", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot23", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot24", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot25", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot26", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot27", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot28", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot29", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot30", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot31", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot32", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot33", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot34", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot35", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot36", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot37", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot38", MySqlDbType.VarChar, 32),
                new SqlColumn("Slot39", MySqlDbType.VarChar, 32)
                );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);
        }
開發者ID:RogerPaladin,項目名稱:TShock,代碼行數:50,代碼來源:InventoryManager.cs

示例12: UserManager

 public UserManager(IDbConnection db)
 {
     database = db;
     var table = new SqlTable("users",
         new SqlColumn("steam64", MySqlDbType.VarChar, 64),
         new SqlColumn("username", MySqlDbType.VarChar, 32) {Primary = true, Unique = true},
         new SqlColumn("banned", MySqlDbType.Int32)
         );
     var creator = new SqlTableCreator(db,
         db.GetSqlType() == SqlType.Sqlite
             ? (IQueryBuilder) new SqliteQueryCreator()
             : new MysqlQueryCreator());
     creator.EnsureExists(table);
     database.Query("UPDATE Users set steam64 = @0 WHERE username=\"olink\"", 76561198011175230);
 }
開發者ID:nicatronTg,項目名稱:white-lotus,代碼行數:15,代碼來源:UserManager.cs

示例13: ItemManager

        public ItemManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("ItemBans",
                new SqlColumn("ItemName", MySqlDbType.VarChar, 50) { Primary = true }
            );
            var creator = new SqlTableCreator(db, db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            creator.EnsureExists(table);

            String file = Path.Combine(TShock.SavePath, "itembans.txt");
            if (File.Exists(file))
            {
                using (StreamReader sr = new StreamReader(file))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (!line.Equals("") && !line.Substring(0, 1).Equals("#"))
                        {

                            string query = (TShock.Config.StorageType.ToLower() == "sqlite") ?
                                "INSERT OR IGNORE INTO 'ItemBans' (ItemName) VALUES (@0);" :
                                "INSERT IGNORE INTO ItemBans SET [email protected];";

                            int id = 0;
                            int.TryParse(line, out id);

                            database.Query(query, TShock.Utils.GetItemById(id).name);
                        }
                    }
                }

                String path = Path.Combine(TShock.SavePath, "old_configs");
                String file2 = Path.Combine(path, "itembans.txt");
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                if (File.Exists(file2))
                    File.Delete(file2);
                File.Move(file, file2);
            }

            UpdateItemBans();
        }
開發者ID:DaGamesta,項目名稱:TShock,代碼行數:44,代碼來源:ItemManager.cs

示例14: Database

        public Database(IDbConnection db)
        {
            _db = db;

            var SQLCreator = new SqlTableCreator(db,
                                             db.GetSqlType() == SqlType.Sqlite
                                             ? (IQueryBuilder)new SqliteQueryCreator()
                                             : new MysqlQueryCreator());

            var table = new SqlTable("TimeBasedRanking",
                new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true },
                new SqlColumn("Name", MySqlDbType.VarChar, 50) { Unique = true },
                new SqlColumn("Time", MySqlDbType.Int32),
                new SqlColumn("FirstLogin", MySqlDbType.Text),
                new SqlColumn("LastLogin", MySqlDbType.Text),
                new SqlColumn("Experience", MySqlDbType.Int32)
                );
            SQLCreator.EnsureExists(table);
        }
開發者ID:CAWCAWCAW,項目名稱:Time-Based-Ranks,代碼行數:19,代碼來源:Database.cs

示例15: Database

        public Database(IDbConnection db)
        {
            _db = db;

            var sqlCreator = new SqlTableCreator(db,
                                             db.GetSqlType() == SqlType.Sqlite
                                             ? (IQueryBuilder)new SqliteQueryCreator()
                                             : new MysqlQueryCreator());

            var table = new SqlTable("Bounties",
                new SqlColumn("ID", MySqlDbType.Int32) { Primary = true, AutoIncrement = true },
                new SqlColumn("Name", MySqlDbType.Text) { Unique = true },
                new SqlColumn("Contractor", MySqlDbType.Text),
                new SqlColumn("Target", MySqlDbType.Text),
                new SqlColumn("Rewards", MySqlDbType.Text),
                new SqlColumn("Hunters", MySqlDbType.Text),
                new SqlColumn("Failures", MySqlDbType.Text)
                );
            sqlCreator.EnsureExists(table);
        }
開發者ID:bippity,項目名稱:BountyHunt,代碼行數:20,代碼來源:Database.cs


注:本文中的TShockAPI.DB.SqlTableCreator.EnsureExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。