Esempio n. 1
0
        public void CheckDb()
        {
            IDbConnection db = pnDatabase.Connect();

            // Try to insert the Accounts table
            pnSqlCreateTable acct = new pnSqlCreateTable();
            acct.AddColumn("Idx", typeof(uint), pnColumnOption.AutoIncrement);
            acct.AddColumn("Username", typeof(string), pnColumnOption.VariableSize);
            acct.AddColumn("Password", typeof(OpenSSL.Hash));
            acct.AddColumn("Permissions", typeof(int)); // I wanted to use SByte, but that causes an InvalidCastException...
            acct.AddColumn("Guid", typeof(Guid));
            acct.AddKey("Guid");
            acct.Name = "Accounts";
            acct.PrimaryKey = "Idx";
            acct.Execute(db);

            // Now verify the Players table
            pnSqlCreateTable player = new pnSqlCreateTable();
            player.AddColumn("Idx", typeof(uint), pnColumnOption.AutoIncrement);
            player.AddColumn("AcctIdx", typeof(uint));
            player.AddColumn("PlayerIdx", typeof(uint));
            player.AddColumn("Name", typeof(string), pnColumnOption.VariableSize);
            player.AddColumn("Model", typeof(string), pnColumnOption.VariableSize);
            player.AddKey("AcctIdx");
            player.AddKey("PlayerIdx");
            player.Name = "Players";
            player.PrimaryKey = "Idx";
            player.Execute(db);

            // Clean up :)
            db.Close();
        }
Esempio n. 2
0
        public void CheckDb()
        {
            IDbConnection db = pnDatabase.Connect();

            // Try to insert the Nodes table...
            pnSqlCreateTable nodes = new pnSqlCreateTable();
            nodes.AddColumn("NodeIdx", typeof(uint), pnColumnOption.AutoIncrement);
            nodes.AddColumn("CreateTime", typeof(DateTime), pnColumnOption.Nullable);
            nodes.AddColumn("ModifyTime", typeof(DateTime), pnColumnOption.Nullable);
            nodes.AddColumn("CreateAgeName", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("CreateAgeUuid", typeof(Guid), pnColumnOption.Nullable);
            nodes.AddColumn("CreatorIdx", typeof(uint), pnColumnOption.Nullable);
            nodes.AddColumn("CreatorUuid", typeof(Guid), pnColumnOption.Nullable);
            nodes.AddColumn("NodeType", typeof(uint));
            nodes.AddColumn("Int32_1", typeof(int), pnColumnOption.Nullable);
            nodes.AddColumn("Int32_2", typeof(int), pnColumnOption.Nullable);
            nodes.AddColumn("Int32_3", typeof(int), pnColumnOption.Nullable);
            nodes.AddColumn("Int32_4", typeof(int), pnColumnOption.Nullable);
            nodes.AddColumn("UInt32_1", typeof(uint), pnColumnOption.Nullable);
            nodes.AddColumn("UInt32_2", typeof(uint), pnColumnOption.Nullable);
            nodes.AddColumn("UInt32_3", typeof(uint), pnColumnOption.Nullable);
            nodes.AddColumn("UInt32_4", typeof(uint), pnColumnOption.Nullable);
            nodes.AddColumn("Uuid_1", typeof(Guid), pnColumnOption.Nullable);
            nodes.AddColumn("Uuid_2", typeof(Guid), pnColumnOption.Nullable);
            nodes.AddColumn("Uuid_3", typeof(Guid), pnColumnOption.Nullable);
            nodes.AddColumn("Uuid_4", typeof(Guid), pnColumnOption.Nullable);
            nodes.AddColumn("String64_1", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("String64_2", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("String64_3", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("String64_4", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("String64_5", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("String64_6", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("IString64_1", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("IString64_2", typeof(string), pnColumnOption.VariableSize);
            nodes.AddColumn("Text_1", typeof(string));
            nodes.AddColumn("Text_2", typeof(string));
            nodes.AddColumn("Blob_1", typeof(string));
            nodes.AddColumn("Blob_2", typeof(string));
            nodes.AddKey("NodeType"); // For VaultNodeFinds
            nodes.Name = "Nodes";
            nodes.PrimaryKey = "NodeIdx";
            nodes.Execute(db);

            // Try to insert the NodeRefs table...
            pnSqlCreateTable refs = new pnSqlCreateTable();
            refs.AddColumn("Idx", typeof(uint), pnColumnOption.AutoIncrement);
            refs.AddColumn("ParentIdx", typeof(uint));
            refs.AddColumn("ChildIdx", typeof(uint));
            refs.AddColumn("SaverIdx", typeof(uint));
            refs.AddKey("ParentIdx"); // We will be selecting often by this value...
            refs.Name = "NodeRefs";
            refs.PrimaryKey = "Idx";
            refs.Execute(db);

            // We're done for now...
            // NOTE: Initial node population will happen when the first client connects!
            db.Close();
        }