Abp try catch 错误时,保存数据和回滚数据

abp 中,保存状态,回滚数据

 

    using (var unitOfWork = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
                {

                    unitOfWork.Complete();
                }

 

 

 

例如我这里钉钉回调报错了,我需要保存状态


            catch (Exception ex)
            {
                Logger.Error($"处理回调结果发生异常:{ex.Message}");
                Logger.Error($"-----------测试!!!-----------");
                using (var unitOfWork = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
                {
                            var workOrderEntity = await _workOrderManager.GetWorkOrderByProcessInstanceIdAsync(processInstanceId);
                            workOrderEntity.Status = WorkOrderStatus.Error; 

                    unitOfWork.Complete();
                }
                throw new UserFriendlyException($"处理回调结果发生异常:{ex.Message}");
            }

 

你可能感兴趣的:(C#)