Beispiel #1
0
        public long save(object gid, string tag)
        {
            connet();
            IDbCommand comm = conn.CreateCommand();

            comm.CommandText = "REPLACE INTO `grouptag`(`rid`,`gid`,`tag`) VALUES (@rid,@gid,@tag);select last_insert_rowid();";
            DbParameter parameter = new DbParameter(comm);


            comm.Parameters.Add(parameter.Parameter("@rid", 0));
            comm.Parameters.Add(parameter.Parameter("@gid", gid));
            comm.Parameters.Add(parameter.Parameter("@tag", tag));

            object id = comm.ExecuteScalar();

            if (id == null)
            {
                return(0);
            }

            LoadTag();


            return(Convert.ToInt64(id));
        }
Beispiel #2
0
        private static void LoadForeignKeys(this DbAccess dbAccess, DbmsRelationTree foreignKeyBaseTable)
        {
            const string sp = "GET_FOREIGN_KEY";
            DbParameter  outTable_Schema   = null;
            DbParameter  outTable_Name     = null;
            DbParameter  outQualified_Name = null;

            dbAccess.ExecuteReader(GetProcedure(sp), parameters =>
            {
                parameters.Add("inTable_Name", foreignKeyBaseTable.TableName);
                outTable_Schema   = parameters.AddOutput("outTable_Schema", 64);
                outTable_Name     = parameters.AddOutput("outTable_Name", 64);
                outQualified_Name = parameters.AddOutput("outQualified_Name", 128);
            }, reader =>
            {
                foreignKeyBaseTable.AddForeignKeyColumn(
                    reader.Field <string>("CONSTRAINT_NAME"),
                    reader.Field <string>("FOREIGN_KEY_COLUMN"),
                    reader.Field <bool>("FOREIGN_KEY_NULLABLE"),
                    reader.Field <string>("REFERENCED_TABLE"),
                    reader.Field <string>("REFERENCED_COLUMN"),
                    reader.Field <bool>("REFERENCED_NULLABLE"));
            });

            foreignKeyBaseTable.Schema        = outTable_Schema.Parameter <string>();
            foreignKeyBaseTable.TableName     = outTable_Name.Parameter <string>();
            foreignKeyBaseTable.QualifiedName = outQualified_Name.Parameter <string>();

            foreignKeyBaseTable.Columns = ListTableColumns(dbAccess, foreignKeyBaseTable.QualifiedName).ToArray();

            foreach (DbmsForeignKey fk in foreignKeyBaseTable.ForeignKeys)
            {
                LoadForeignKeys(dbAccess, fk.PrimaryUniqueKeyBaseTable);
            }
        }
Beispiel #3
0
        public static void LoadEngineConfig(this DbAccess dbAccess)
        {
            const string sp = "GET_CONFIG";
            DbParameter  outPollInterval = null;

            dbAccess.ExecuteNonQuery(GetProcedure(sp), parameters =>
            {
                outPollInterval = parameters.AddOutput("outPoll_Interval").SetDbType(DbType.Byte);
            });

            ConfigHelper.EnginePollInterval = outPollInterval.Parameter <byte>() * 1000;
        }
Beispiel #4
0
        internal static Tuple <string, int, byte> GetSampleSetting(this DbAccess dbAccess, string sampleDomain)
        {
            const string sp                         = "GET_SAMPLE_SETTING";
            DbParameter  outStartupMode             = null;
            DbParameter  outRefreshInterval         = null;
            DbParameter  outDegreeOfTaskParallelism = null;

            dbAccess.ExecuteNonQuery(GetProcedure(sp), parameters =>
            {
                parameters.Add("inSample_Domain", sampleDomain);
                outStartupMode             = parameters.AddOutput("outStartup_Mode", 32);
                outRefreshInterval         = parameters.AddOutput("outRefresh_Interval");
                outDegreeOfTaskParallelism = parameters.AddOutput("outParallelism_Degree");
            });

            return(Tuple.Create(outStartupMode.Parameter <string>(),
                                outRefreshInterval.Parameter <int>(),
                                outDegreeOfTaskParallelism.Parameter <byte>()));
        }
Beispiel #5
0
        public static DbAppSettings GetServiceConfig(this DbAccess dbAccess)
        {
            const string sp = "GET_SERVICE_CONFIG";
            DbParameter  outPrimaryInterval = null, outStandbyInterval = null, outMaxThreadsInPool = null, outDegreeOfTaskParallelism = null;

            dbAccess.ExecuteNonQuery(GetProcedure(sp), parameters =>
            {
                outPrimaryInterval         = parameters.AddOutput("outPrimary_Interval").SetDbType(DbType.Int32);
                outStandbyInterval         = parameters.AddOutput("outStandby_Interval").SetDbType(DbType.Int32);
                outDegreeOfTaskParallelism = parameters.AddOutput("outDegree_Task_Parallelism").SetDbType(DbType.Int32);
                outMaxThreadsInPool        = parameters.AddOutput("outMax_Threads_In_Pool").SetDbType(DbType.Int32);
            });

            return(new DbAppSettings(
                       outPrimaryInterval.Parameter <int>(),
                       outStandbyInterval.Parameter <int>() * 1000,
                       outDegreeOfTaskParallelism.Parameter <int>(),
                       outMaxThreadsInPool.Parameter <int>()
                       ));
        }
Beispiel #6
0
        public static DbmsEnvironment GetDbServerEnv(this DbAccess dbAccess)
        {
            const string sp = "GET_DB_SERVER_ENV";
            DbParameter  outDatabase_Platform = null;
            DbParameter  outDatabase_Product  = null;
            DbParameter  outProduct_Version   = null;
            DbParameter  outServer_Name       = null;

            dbAccess.ExecuteNonQuery(GetProcedure(sp), parameters =>
            {
                outDatabase_Platform = parameters.AddOutput("outDatabase_Platform", 32);
                outDatabase_Product  = parameters.AddOutput("outDatabase_Product", 256);
                outProduct_Version   = parameters.AddOutput("outProduct_Version", 64);
                outServer_Name       = parameters.AddOutput("outServer_Name", 64);
            });

            return(new DbmsEnvironment(tableName => dbAccess.ListTableColumns(tableName),
                                       tableName => dbAccess.LoadForeignKeys(tableName),
                                       outDatabase_Platform.Parameter <string>(), outDatabase_Product.Parameter <string>(),
                                       outProduct_Version.Parameter <string>(), outServer_Name.Parameter <string>()));
        }