Beispiel #1
0
 public static SyncManager GetInstance()
 {
     lock(instanceLock)
     {
         if ( _instance == null )
         {
             _instance = new SyncManager();
         }
     }
     return _instance;
 }
Beispiel #2
0
        public void Update(CurrencyInfo oParam)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                new CurrencyDac().Update(oParam);
                SyncManager.GetInstance().SetDbLastVersion((int)AppEnum.Sync.Currency);

                currencyHash.Remove(oParam.SysNo);
                currencyHash.Add(oParam.SysNo, oParam);

                scope.Complete();
            }
        }
Beispiel #3
0
        public int Update(StockInfo oParam)
        {
            string  sql = " select top 1 sysno from Stock where StockID = " + Util.ToSqlString(oParam.StockID) + " and sysno <> " + oParam.SysNo;
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                throw new BizException("the same Stock ID exists already");
            }

            int result = new StockDac().Update(oParam);

            SyncManager.GetInstance().SetDbLastVersion((int)AppEnum.Sync.Stock);

            stockHash.Remove(oParam.SysNo);
            stockHash.Add(oParam.SysNo, oParam);
            return(result);
        }
Beispiel #4
0
        public void Insert(CurrencyInfo oParam)
        {
            foreach (CurrencyInfo item in currencyHash.Values)
            {
                if (item.CurrencyID == oParam.CurrencyID)
                {
                    throw new BizException("the same id exists");
                }
            }

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                string  sql = "select isnull(max(sysno),0) as maxsysno from currency";
                DataSet ds  = SqlHelper.ExecuteDataSet(sql);

                int newSysNo = 0;
                if (!Util.HasMoreRow(ds))
                {
                    newSysNo = 0;
                }
                else
                {
                    newSysNo = Util.TrimIntNull(ds.Tables[0].Rows[0]["maxsysno"]);
                }

                oParam.SysNo = newSysNo + 1;

                new CurrencyDac().Insert(oParam);
                SyncManager.GetInstance().SetDbLastVersion((int)AppEnum.Sync.Currency);

                currencyHash.Add(oParam.SysNo, oParam);

                scope.Complete();
            }
        }