/// <summary>
        /// 全局锁
        /// </summary>
        public static Object SyncObject = new object();

var syncObject = isTrans ? Util.SyncObject : new Object();

            lock (syncObject)
            {

var transactionOption = new TransactionOptions { IsolationLevel = IsolationLevel.Serializable, Timeout = TimeSpan.FromMilliseconds(10 * 60 * 1000) };
                  int i = 0;
                string errmessage = "";
                Exception exception = new Exception();
                do
                {
                    errmessage = "";
                    if (i++ > 3)
                        break;
                using (var scope = isTrans ? new TransactionScope(TransactionScopeOption.Required, transactionOption) : null)
                {

                     try
                        {
                
                    #endregion

                    if (isTrans)
                    {
                        scope.Complete();
                    }

}

    catch (Exception err)
                        {
                            scope.Dispose();
                            errmessage = err.Message;
                            exception = err;
                            //throw new Exception(ex.Message.ToString());
                        }
                    }
                } while (errmessage.Contains("死锁牺牲品"));
                if (!string.IsNullOrEmpty(errmessage))
                {
                    throw (new Exception(errmessage, exception));
                }

                  }
                }

posted on 2016-12-01 16:53  菜鸟Only  阅读(152)  评论(0编辑  收藏  举报