Esempio n. 1
0
        public TableUnit GetTableUnitWithSql(string sql)
        {
            TableUnit unit = null;

            unit = new TableUnit(mConn, sql, null);
            return(unit);
        }
Esempio n. 2
0
        private static object[] GetTableIDs(string tblname, object[] ids, string[] dbnames)
        {
            DataTable[] tables = new DataTable[dbnames.Length];
            int         index  = 0;

            foreach (string db in dbnames)
            {
                TableUnitManager tm   = TableHelper.GetTableUnitManangerByDbname(db);
                TableUnit        unit = tm.GetTableUnit(tblname);
                tables[index] = unit.GetTable();
                index++;
            }

            bool bRet = false;

            while (!bRet)
            {
                bRet = true;
                foreach (DataTable table in tables)
                {
                    if (ExistID(table, ids))
                    {
                        bRet = false;
                        break;
                    }
                }
                if (!bRet)
                {
                    ids[0] = (int)(ids[0]) + 1;
                }
            }

            return(ids);
        }
Esempio n. 3
0
        public void MarkTableChanged(string tblname)
        {
            TableUnit unit = null;
            bool      bRet = mTables.TryGetValue(tblname, out unit);

            if (bRet)
            {
                unit.TableChanged = true;
            }
        }
Esempio n. 4
0
        public void ReleaseTable(string tblname)
        {
            TableUnit unit = null;
            bool      bRet = mTables.TryGetValue(tblname, out unit);

            if (bRet)
            {
                unit.ReleaseTable();
                mTables.Remove(tblname);
            }
        }
Esempio n. 5
0
        public int SaveTable(string tblname)
        {
            TableUnit unit = null;
            bool      bRet = mTables.TryGetValue(tblname, out unit);
            int       nRet = 0;

            if (bRet)
            {
                nRet = unit.SaveTable();
            }
            return(nRet);
        }
Esempio n. 6
0
        public static int[] UniteTables(string tblname, string todbname, string[] dblist)
        {
            DataTable[] tables   = new DataTable[dblist.Length - 1];
            DataTable   totable  = null;
            DataTable   untable  = null;
            int         nInsert  = 0;
            int         nModify  = 0;
            int         index    = 0;
            bool        priority = true;

            foreach (string db in dblist)
            {
                TableUnitManager tm   = TableHelper.GetTableUnitManangerByDbname(db);
                TableUnit        unit = tm.GetTableUnit(tblname);
                if (db != todbname)
                {
                    tables[index] = unit.GetTable();
                    index++;
                }
                else
                {
                    priority = false;
                    totable  = unit.GetTable();
                }

                DataTable tbl = unit.GetTable();
                tbl.ExtendedProperties["dbname"] = priority;
            }

            int count = 0;

            foreach (DataTable table in tables)
            {
                if (table != null)
                {
                    bool  cover  = Convert.ToBoolean(table.ExtendedProperties["dbname"]);
                    int[] result = UniteTables(totable, table, cover);
                    nInsert += result[0];
                    nModify += result[1];
                }
            }

            TableUnitManager totm = TableHelper.GetTableUnitManangerByDbname(todbname);

            totm.SaveTable(tblname);

            return(new int[] { nInsert, nModify });
        }
Esempio n. 7
0
        public TableUnit GetSqlTableUnit(string sql, string tblname)
        {
            if (mSqlTableCount > mMaxSqlTable)
            {
                lock (mSqlTables)
                {
                    if (mSqlTableCount > mMaxSqlTable)
                    {
                        foreach (Dictionary <string, TableUnit> units in mSqlTables.Values)
                        {
                            foreach (TableUnit u in units.Values)
                            {
                                u.ReleaseTable();
                            }
                        }
                        mSqlTables.Clear();
                        mSqlTableCount = 0;
                    }
                }
            }
            TableUnit unit = null;
            bool      bRet = mSqlTables.ContainsKey(tblname);

            if (!bRet)
            {
                mSqlTables[tblname] = new Dictionary <string, TableUnit>();
            }
            bRet = mSqlTables[tblname].TryGetValue(sql, out unit);
            if (!bRet)
            {
                unit = new TableUnit(mConn, sql, null);
                mSqlTableCount++;
                if ((!tblname.StartsWith("sys")) || tblname.StartsWith("sys_"))
                {
                    mSqlTables[tblname][sql] = unit;
                }
            }

            return(unit);
        }
Esempio n. 8
0
        public TableUnit GetTableUnit(string tblname)
        {
            TableUnit unit = null;
            bool      bRet = mTables.TryGetValue(tblname, out unit);

            if (!bRet)
            {
                lock (mTables)
                {
                    bRet = mTables.TryGetValue(tblname, out unit);
                    if (!bRet)
                    {
                        unit = new TableUnit(mConn, tblname);
                        if ((!tblname.StartsWith("sys")) || tblname.StartsWith("sys_"))
                        {
                            mTables.Add(tblname, unit);
                        }
                    }
                }
            }
            return(unit);
        }
Esempio n. 9
0
        public LogHelper(string clientkey)
        {
            mClientkey = clientkey;
            NetClient client = NetClientManager.GetNetClient(clientkey);

            if (client.Database != "monitor")
            {
                mTableUnitManager = TableHelper.GetTableUnitManager(clientkey);
                TableUnit unit = mTableUnitManager.GetTableUnit("sys_remote_log");
                mLogTable = unit.GetTable();
            }

            int length = Convert.ToInt32(LogType.END);

            mConsoleFlag = new bool[length];
            mFileFlag    = new bool[length];
            for (int i = 0; i < length; ++i)
            {
                mConsoleFlag[i] = true;
                mFileFlag[i]    = true;
            }
        }
Esempio n. 10
0
        public TableUnit GetSqlTableUnit(string sql, string tblname)
        {
            if (mSqlTableCount > mMaxSqlTable)
            {
                lock (mSqlTables)
                {
                    if (mSqlTableCount > mMaxSqlTable)
                    {
                        foreach (Dictionary<string, TableUnit> units in mSqlTables.Values)
                        {
                            foreach (TableUnit u in units.Values)
                            {
                                u.ReleaseTable();
                            }
                        }
                        mSqlTables.Clear();
                        mSqlTableCount = 0;
                    }
                }
                
            }
            TableUnit unit = null;
            bool bRet = mSqlTables.ContainsKey(tblname);
            if (!bRet)
            {
                mSqlTables[tblname] = new Dictionary<string, TableUnit>();
            }
            bRet = mSqlTables[tblname].TryGetValue(sql, out unit);
            if (!bRet)
            {
                unit = new TableUnit(mConn, sql, null);
                mSqlTableCount++;
                if ((!tblname.StartsWith("sys")) || tblname.StartsWith("sys_"))
                {
                    mSqlTables[tblname][sql] = unit;
                }
            }

            return unit;
        }
Esempio n. 11
0
 public TableUnit GetTableUnitWithSql(string sql)
 {
     TableUnit unit = null;
     unit = new TableUnit(mConn, sql, null);
     return unit;
 }
Esempio n. 12
0
 public TableUnit GetTableUnit(string tblname)
 {
     TableUnit unit = null;
     bool bRet = mTables.TryGetValue(tblname, out unit);
     if (!bRet)
     {
         lock (mTables)
         {
             bRet = mTables.TryGetValue(tblname, out unit);
             if (!bRet)
             {
                 unit = new TableUnit(mConn, tblname);
                 if ((!tblname.StartsWith("sys")) || tblname.StartsWith("sys_"))
                 {
                     mTables.Add(tblname, unit);
                 }
             }
         }
     }
     return unit;
 }