예제 #1
0
        public async Task Cancel(DTOperationData data)
        {
            if (data.Status == (int)DTOperationDataStatus.Cancel)
            {
                return;
            }
            var service = getService(data.Type);

            await using (DBTransactionScope transactionScope = new DBTransactionScope(TransactionScopeOption.Required, new TransactionOptions()
            {
                IsolationLevel = IsolationLevel.ReadCommitted, Timeout = new TimeSpan(0, 30, 0)
            }))
            {
                await service.Cancel(data.Data);

                var updateResult = await _dtOperationDataStore.UpdateStatus(data.StoreGroupName, data.HashInfo, data.ID, data.Version, (int)DTOperationDataStatus.Cancel);

                if (!updateResult)
                {
                    var fragment = new TextFragment()
                    {
                        Code = TextCodes.DTOperationDataConcurrenceErrorInCancel,
                        DefaultFormatting = "分布式操作数据在Cancel时发生并发错误,StoreGroupName:{0},HashInfo:{1}",
                        ReplaceParameters = new List <object>()
                        {
                            data.StoreGroupName, data.HashInfo, data.ID.ToString()
                        }
                    };

                    throw new UtilityException((int)Errors.DTOperationDataConcurrenceErrorInCancel, fragment);
                }

                transactionScope.Complete();
            }
        }
예제 #2
0
 public async Task Delete(DTOperationData data)
 {
     await _dtOperationDataStore.Delete(data.StoreGroupName, data.HashInfo, data.ID);
 }
예제 #3
0
 public async Task Add(DTOperationData data)
 {
     await _dtOperationDataStore.Add(data);
 }