예제 #1
0
        public DataTableRemoting(string clientKey)
        {
            mLogHelper = TableHelper.GetLogHelper(clientKey);
            string message = "get new loghelper success.";
            mLogHelper.LogMessage(clientKey, message, LogType.Program);

            mClientKey = clientKey;
            NetClient netclient = NetClientManager.GetNetClient(clientKey);
            mHostName = netclient.HostName;
            mDBName = netclient.Database;
            message = "get net client success.";
            mLogHelper.LogMessage(clientKey, message, LogType.Program);

            mTableUnitManager = TableHelper.GetTableUnitManager(clientKey);
            message = "get table unit manager success.";
            mLogHelper.LogMessage(clientKey, message, LogType.Program);

            message = "get new DataTableRemoting.";
            mLogHelper.LogMessage(mClientKey, message, LogType.Program);
        }
예제 #2
0
        public object[] UTGetTableID(string tblname, object[] ids)
        {
            string[] dbnames = AppTableUnite.GetUniteDBNames();
            object[] ret     = null;
            string   message = string.Empty;

            foreach (string dbname in dbnames)
            {
                TableUnitManager mgr = TableHelper.GetTableUnitManangerByDbname(dbname);
                mgr.AcquireReadTableLock(dbname);
                message = string.Format("AcquireReadTableLock: dbname = {0}, tblname = {1}.", dbname, tblname);
                mLogHelper.LogMessage(mClientKey, message, LogType.ReadWriteTableLock);
            }
            try
            {
                ret     = AppTableUnite.GetTableID(mDBName, tblname, ids);
                message = string.Format("get new id({0}) for {1}", ret[0], tblname);
                mLogHelper.LogMessage(mClientKey, message, LogType.Modify);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                foreach (string dbname in dbnames)
                {
                    TableUnitManager mgr = TableHelper.GetTableUnitManangerByDbname(dbname);
                    mgr.ReleaseReadTableLock(dbname);
                    message = string.Format("ReleaseReadTableLock: dbname = {0}, tblname = {1}.", dbname, tblname);
                    mLogHelper.LogMessage(mClientKey, message, LogType.ReadWriteTableLock);
                }
            }

            return(ret);
        }
예제 #3
0
        public int[] UTUniteTable(string tblname, string todbname, string[] dblist)
        {
            string dbs     = TableHelper.ArrayToString(dblist);
            string message = string.Format("Begin unite table. tblname = {0}, dbnames = {1}.", tblname, dbs);

            mLogHelper.LogMessage(mClientKey, message, LogType.Modify);

            int[] nRet   = new int[] { -1, -1 };
            bool  bExist = true;

            foreach (string db in dblist)
            {
                if (!UTExistDatabase(db))
                {
                    bExist = false;
                }
            }
            if (UTExistDatabase(todbname) && bExist)
            {
                foreach (string db in dblist)
                {
                    TableUnitManager mgr = TableHelper.GetTableUnitManangerByDbname(db);
                    if (db == todbname)
                    {
                        mgr.AcquireWriteTableLock(tblname);
                        mUniteWriteLockList.Add(tblname);
                        message = string.Format("AcquireWriteTableLock: dbname = {0}, tblname = {1}.", db, tblname);
                    }
                    else
                    {
                        mgr.AcquireReadTableLock(tblname);
                        mUniteReadLockList.Add(tblname);
                        message = string.Format("AcquireReadTableLock: dbname = {0}, tblname = {1}.", db, tblname);
                    }
                    mLogHelper.LogMessage(mClientKey, message, LogType.ReadWriteTableLock);
                }

                try
                {
                    nRet    = AppTableUnite.UniteTables(tblname, todbname, dblist);
                    message = string.Format("End unit table. modify {0} rows, add {1} rows.", nRet[1], nRet[0]);
                    mLogHelper.LogMessage(mClientKey, message, LogType.Modify);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    foreach (string db in dblist)
                    {
                        TableUnitManager mgr = TableHelper.GetTableUnitManangerByDbname(db);
                        if (db == todbname)
                        {
                            mgr.ReleaseWriteTableLock(tblname);
                            mUniteWriteLockList.RemoveAt(0);
                            message = string.Format("ReleaseWriteTableLock: dbname = {0}, tblname = {1}.", db, tblname);
                        }
                        else
                        {
                            mgr.ReleaseReadTableLock(tblname);
                            mUniteReadLockList.RemoveAt(0);
                            message = string.Format("ReleaseWriteTableLock: dbname = {0}, tblname = {1}.", db, tblname);
                        }
                        mLogHelper.LogMessage(mClientKey, message, LogType.ReadWriteTableLock);
                    }
                }
            }

            return(nRet);
        }