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


C# SqlTableCreator.EnsureTableStructure方法代碼示例

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


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

示例1: CharacterManager

        public CharacterManager(IDbConnection db)
        {
            database = db;

            var table = new SqlTable("tsCharacter",
                                     new SqlColumn("Account", MySqlDbType.Int32) {Primary = true},
                                     new SqlColumn("Health", MySqlDbType.Int32),
                                     new SqlColumn("MaxHealth", MySqlDbType.Int32),
                                     new SqlColumn("Mana", MySqlDbType.Int32),
                                     new SqlColumn("MaxMana", MySqlDbType.Int32),
                                     new SqlColumn("Inventory", MySqlDbType.Text),
                                     new SqlColumn("extraSlot", MySqlDbType.Int32),
                                     new SqlColumn("spawnX", MySqlDbType.Int32),
                                     new SqlColumn("spawnY", MySqlDbType.Int32),
                                     new SqlColumn("skinVariant", MySqlDbType.Int32),
                                     new SqlColumn("hair", MySqlDbType.Int32),
                                     new SqlColumn("hairDye", MySqlDbType.Int32),
                                     new SqlColumn("hairColor", MySqlDbType.Int32),
                                     new SqlColumn("pantsColor", MySqlDbType.Int32),
                                     new SqlColumn("shirtColor", MySqlDbType.Int32),
                                     new SqlColumn("underShirtColor", MySqlDbType.Int32),
                                     new SqlColumn("shoeColor", MySqlDbType.Int32),
                                     new SqlColumn("hideVisuals", MySqlDbType.Int32),
                                     new SqlColumn("skinColor", MySqlDbType.Int32),
                                     new SqlColumn("eyeColor", MySqlDbType.Int32),
                                     new SqlColumn("questsCompleted", MySqlDbType.Int32)
                );
            var creator = new SqlTableCreator(db,
                                              db.GetSqlType() == SqlType.Sqlite
                                              	? (IQueryBuilder) new SqliteQueryCreator()
                                              	: new MysqlQueryCreator());
            creator.EnsureTableStructure(table);
        }
開發者ID:sylar605,項目名稱:TshockCN,代碼行數:33,代碼來源:CharacterManager.cs

示例2: 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.EnsureTableStructure(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.EnsureTableStructure(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.EnsureTableStructure(table);
 }
開發者ID:UB1AFU,項目名稱:ExtendedBans,代碼行數:28,代碼來源:EBData.cs

示例3: DBConnect

        internal static void DBConnect()
        {
            switch (TShock.Config.StorageType.ToLower())
            {
                case "mysql":
                    string[] dbHost = TShock.Config.MySqlHost.Split(':');
                    db = new MySqlConnection()
                    {
                        ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                            dbHost[0],
                            dbHost.Length == 1 ? "3306" : dbHost[1],
                            TShock.Config.MySqlDbName,
                            TShock.Config.MySqlUsername,
                            TShock.Config.MySqlPassword)

                    };
                    break;

                case "sqlite":
                    string sql = Path.Combine(TShock.SavePath, "tshock.sqlite");
                    db = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                    break;

            }

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

            sqlcreator.EnsureTableStructure(new SqlTable("NoTpRegions",
                new SqlColumn("Name", MySqlDbType.Text)));
        }
開發者ID:ProfessorXZ,項目名稱:NoTpRegions,代碼行數:30,代碼來源:Database.cs

示例4: HomeManager

		public HomeManager(IDbConnection db)
		{
			this.db = db;

			var sqlCreator = new SqlTableCreator(db,
				db.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder) new SqliteQueryCreator() : new MysqlQueryCreator());
			sqlCreator.EnsureTableStructure(new SqlTable("Homes",
				new SqlColumn("ID", MySqlDbType.Int32) {AutoIncrement = true, Primary = true},
				new SqlColumn("UserID", MySqlDbType.Int32),
				new SqlColumn("Name", MySqlDbType.Text),
				new SqlColumn("X", MySqlDbType.Double),
				new SqlColumn("Y", MySqlDbType.Double),
				new SqlColumn("WorldID", MySqlDbType.Int32)));

			using (QueryResult result = db.QueryReader("SELECT * FROM Homes WHERE WorldID = @0", Main.worldID))
			{
				while (result.Read())
				{
					homes.Add(new Home(
						result.Get<int>("UserID"),
						result.Get<string>("Name"),
						result.Get<float>("X"),
						result.Get<float>("Y")));
				}
			}
		}
開發者ID:WhiteXZ,項目名稱:EssentialsPlus,代碼行數:26,代碼來源:HomeManager.cs

示例5: OnInitialize

        private void OnInitialize(EventArgs args)
        {
            SqlTableCreator sqlcreator = new SqlTableCreator(TShock.DB, TShock.DB.GetSqlType() == SqlType.Sqlite ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());
            sqlcreator.EnsureTableStructure(new SqlTable("TradeRequestLogs",
            new SqlColumn("ID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true },
            new SqlColumn("Trader", MySqlDbType.Text),
            new SqlColumn("Tradee", MySqlDbType.Text),
            new SqlColumn("TraderItems", MySqlDbType.Text),
            new SqlColumn("TradeeItems", MySqlDbType.Text),
            new SqlColumn("TradeDate", MySqlDbType.Text)
            ));

            #region Commands
            Action<Command> Add = c =>
            {
                TShockAPI.Commands.ChatCommands.RemoveAll(c2 => c2.Names.Select(s => s.ToLowerInvariant()).Intersect(c.Names.Select(s => s.ToLowerInvariant())).Any());
                TShockAPI.Commands.ChatCommands.Add(c);
            };

            Add(new Command(Permissions.trade, Commands.Trade, "trade")
            {
                AllowServer = true,
                HelpText = "Allows the user to trade with another user."
            });

            Add(new Command(Permissions.tradelogs, Commands.TradeLogs, "tradelogs")
            {
                AllowServer = true,
                HelpText = "Allows the user check trade logs."
            });
            #endregion
        }
開發者ID:Marcus101RR,項目名稱:TradeRequest,代碼行數:32,代碼來源:TradeRequest.cs

示例6: BanManager

        /// <summary>
        /// Initializes a new instance of the <see cref="TShockAPI.DB.BanManager"/> class.
        /// </summary>
        /// <param name="db">A valid connection to the TShock database</param>
		public BanManager(IDbConnection db)
		{
			database = db;

			var table = new SqlTable("Bans",
			                         new SqlColumn("IP", MySqlDbType.String, 16) {Primary = true},
			                         new SqlColumn("Name", MySqlDbType.Text),
									 new SqlColumn("UUID", MySqlDbType.Text),
			                         new SqlColumn("Reason", MySqlDbType.Text),
                                     new SqlColumn("BanningUser", MySqlDbType.Text),
                                     new SqlColumn("Date", MySqlDbType.Text),
                                     new SqlColumn("Expiration", MySqlDbType.Text)
				);
			var creator = new SqlTableCreator(db,
			                                  db.GetSqlType() == SqlType.Sqlite
			                                  	? (IQueryBuilder) new SqliteQueryCreator()
			                                  	: new MysqlQueryCreator());
			try
			{
				creator.EnsureTableStructure(table);
			}
			catch (DllNotFoundException)
			{
				System.Console.WriteLine("Possible problem with your database - is Sqlite3.dll present?");
				throw new Exception("Could not find a database library (probably Sqlite3.dll)");
			}
		}
開發者ID:sliekasirdis79,項目名稱:TShock,代碼行數:31,代碼來源:BanManager.cs

示例7: EnsureExists

        /* EnsureExists
         *
         * Checks if tables exists and creates them if not
         *
         * */
        public void EnsureExists(params SqlTable[] Tables)
        {
            // We want to use TShock creator for checking
            SqlTableCreator SqlCreator = new SqlTableCreator(DB,
                (IQueryBuilder)new SqliteQueryCreator());

            foreach (var Table in Tables)
            {
                SqlCreator.EnsureTableStructure(Table);
            }
        }
開發者ID:matthewgrzegorczyk,項目名稱:SPlugin,代碼行數:16,代碼來源:Database.cs

示例8: Initialize

        public static void Initialize()
        {
            if (!Directory.Exists(SavePath))
                Directory.CreateDirectory(SavePath);

            switch (TShock.Config.StorageType.ToLower())
            {
                case "mysql":
                    string[] host = TShock.Config.MySqlHost.Split(':');
                    Database = new MySqlConnection()
                    {
                        ConnectionString = string.Format("Server={0}; Port={1}; Database={2}; Uid={3}; Pwd={4};",
                                host[0],
                                host.Length == 1 ? "3306" : host[1],
                                TShock.Config.MySqlDbName,
                                TShock.Config.MySqlUsername,
                                TShock.Config.MySqlPassword)
                    };
                    break;
                case "sqlite":
                    string sql = Path.Combine(SavePath, "Clans.sqlite");
                    Database = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
                    break;
            }
            SqlTableCreator SQLcreator = new SqlTableCreator(Database, Database.GetSqlType() == SqlType.Sqlite
            ? (IQueryBuilder)new SqliteQueryCreator() : new MysqlQueryCreator());

            SqlTable[] tables = new SqlTable[]
            {
                 new SqlTable("Clans",
                     new SqlColumn("Name", MySqlDbType.VarChar) { Primary=true, Unique=true },
                     new SqlColumn("Owner", MySqlDbType.VarChar),
                     new SqlColumn("InviteMode", MySqlDbType.Int32),
                     new SqlColumn("TileX", MySqlDbType.Int32),
                     new SqlColumn("TileY", MySqlDbType.Int32),
                     new SqlColumn("ChatColor", MySqlDbType.VarChar),
                     new SqlColumn("Bans", MySqlDbType.VarChar)
                     ),
                 new SqlTable("ClanMembers",
                     new SqlColumn("Username",MySqlDbType.VarChar) { Primary=true, Unique=true },
                     new SqlColumn("ClanName", MySqlDbType.VarChar)
                     ),
                 new SqlTable("ClanWarps",
                     new SqlColumn("WarpName",MySqlDbType.VarChar) { Primary=true, Unique=true }                  
                     )
            };

            for (int i = 0; i < tables.Length; i++)
                SQLcreator.EnsureTableStructure(tables[i]);

            Config = Config.Read();
            LoadClans();
        }
開發者ID:MichaelMan57,項目名稱:Clans,代碼行數:53,代碼來源:ClanManager.cs

示例9: VocationManager

        public VocationManager(IDbConnection conn)
        {
            _conn = conn;

            var table = new SqlTable(TableName,
                new SqlColumn("id", MySqlDbType.Int32) { Primary = true },
                new SqlColumn("level", MySqlDbType.Int32),
                new SqlColumn("experience", MySqlDbType.Int64),
                new SqlColumn("vocation", MySqlDbType.VarChar) { Primary = true, Length = 16 });

            var creator = new SqlTableCreator(conn, DbProvider);
            creator.EnsureTableStructure(table);
        }
開發者ID:hastinbe,項目名稱:VocationPlugin,代碼行數:13,代碼來源:VocationManager.cs

示例10: MuteManager

		public MuteManager(IDbConnection db)
		{
			this.db = db;

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

			sqlCreator.EnsureTableStructure(new SqlTable("Mutes",
				new SqlColumn("ID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true },
				new SqlColumn("Name", MySqlDbType.Text),
				new SqlColumn("UUID", MySqlDbType.Text),
				new SqlColumn("IP", MySqlDbType.Text),
				new SqlColumn("Date", MySqlDbType.Text),
				new SqlColumn("Expiration", MySqlDbType.Text)));
		}
開發者ID:CrazyLegsSteph,項目名稱:EssentialsPlus,代碼行數:16,代碼來源:MuteManager.cs

示例11: RememberedPosManager

		public RememberedPosManager(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.EnsureTableStructure(table);
		}
開發者ID:sliekasirdis79,項目名稱:TShock,代碼行數:17,代碼來源:RememberedPosManager.cs

示例12: WarpManager

		internal WarpManager(IDbConnection db)
		{
			database = db;

			var table = new SqlTable("Warps",
			                         new SqlColumn("Id", MySqlDbType.Int32){Primary = true, AutoIncrement = true},
									 new SqlColumn("WarpName", MySqlDbType.VarChar, 50) {Unique = true},
			                         new SqlColumn("X", MySqlDbType.Int32),
			                         new SqlColumn("Y", MySqlDbType.Int32),
									 new SqlColumn("WorldID", MySqlDbType.VarChar, 50) { Unique = true },
			                         new SqlColumn("Private", MySqlDbType.Text)
				);
			var creator = new SqlTableCreator(db,
			                                  db.GetSqlType() == SqlType.Sqlite
			                                  	? (IQueryBuilder) new SqliteQueryCreator()
			                                  	: new MysqlQueryCreator());
			creator.EnsureTableStructure(table);
		}
開發者ID:sliekasirdis79,項目名稱:TShock,代碼行數:18,代碼來源:WarpsManager.cs

示例13: 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("Reports",
                new SqlColumn("ReportID", MySqlDbType.Int32) {AutoIncrement = true, Primary = true},
                new SqlColumn("UserID", MySqlDbType.Int32),
                new SqlColumn("ReportedID", MySqlDbType.Int32),
                new SqlColumn("Message", MySqlDbType.Text),
                new SqlColumn("Position", MySqlDbType.Text),
                new SqlColumn("State", MySqlDbType.Int32));

            sqlCreator.EnsureTableStructure(table);
        }
開發者ID:bippity,項目名稱:Reports-1,代碼行數:19,代碼來源:Database.cs

示例14: Database

		private Database(IDbConnection db)
		{
			_db = db;

			//Define a table creator that will be responsible for ensuring the database table exists
			_tableCreator = new SqlTableCreator(_db,
				_db.GetSqlType() == SqlType.Sqlite
					? (IQueryBuilder)new SqliteQueryCreator()
					: new MysqlQueryCreator());

			//Define the table
			var table = new SqlTable("ServerEvents",
				new SqlColumn("UserID", MySqlDbType.Int32) { AutoIncrement = true, Primary = true },
				new SqlColumn("LastLoginTime", MySqlDbType.VarChar),
				new SqlColumn("DailyLogIn", MySqlDbType.Int32) { DefaultValue = "0" },
				new SqlColumn("DailyLogInStreak", MySqlDbType.Int32));

			_tableCreator.EnsureTableStructure(table);
		}
開發者ID:WhiteXZ,項目名稱:ServerEvents,代碼行數:19,代碼來源:Database.cs

示例15: SqlLog

		/// <summary>
		/// Sets the database connection and the initial log level.
		/// </summary>
		/// <param name="db">Database connection</param>
		/// <param name="textlogFilepath">File path to a backup text log in case the SQL log fails</param>
		/// <param name="clearTextLog"></param>
		public SqlLog(IDbConnection db, string textlogFilepath, bool clearTextLog)
		{
			FileName = string.Format("{0}://database", db.GetSqlType());
			_database = db;
			_backupLog = new TextLog(textlogFilepath, clearTextLog);

			var table = new SqlTable("Logs",
				new SqlColumn("ID", MySqlDbType.Int32) {AutoIncrement = true, Primary = true},
				new SqlColumn("TimeStamp", MySqlDbType.Text),
				new SqlColumn("LogLevel", MySqlDbType.Int32),
				new SqlColumn("Caller", MySqlDbType.Text),
				new SqlColumn("Message", MySqlDbType.Text)
				);

			var creator = new SqlTableCreator(db,
				db.GetSqlType() == SqlType.Sqlite
					? (IQueryBuilder) new SqliteQueryCreator()
					: new MysqlQueryCreator());
			creator.EnsureTableStructure(table);
		}
開發者ID:sliekasirdis79,項目名稱:TShock,代碼行數:26,代碼來源:SqlLog.cs


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