Beispiel #1
0
        public async Task Delete(UploadFileHandleRecord record)
        {
            await using (DBTransactionScope scope = new DBTransactionScope(TransactionScopeOption.Required, new TransactionOptions()
            {
                IsolationLevel = IsolationLevel.ReadCommitted
            }))
            {
                await _uploadFileHandleRecordStore.Delete(record.ID);

                if (record.UploadFile != null)
                {
                    await record.UploadFile.Delete();
                }

                scope.Complete();
            }
        }
Beispiel #2
0
        public async Task Execute(UploadFileHandleRecord record)
        {
            if (record.UploadFile != null)
            {
                if (!_uploadFileHandleServiceFactories.TryGetValue($"{record.ConfigurationName}-{record.UploadFile.Suffix}", out IFactory <IUploadFileHandleService> serviceFactory))
                {
                    var fragment = new TextFragment()
                    {
                        Code = TextCodes.NotFoundUploadFileHandleServiceByKey,
                        DefaultFormatting = "找不到指定key的上传文件处理服务,key为{0},发生位置:{1}",
                        ReplaceParameters = new List <object>()
                        {
                            $"{record.ConfigurationName}-{record.UploadFile.Suffix}", $"{this.GetType().FullName}.Execute"
                        }
                    };

                    throw new UtilityException((int)Errors.NotFoundUploadFileHandleServiceByKey, fragment);
                }
                var service = serviceFactory.Create();

                await using (DBTransactionScope scope = new DBTransactionScope(TransactionScopeOption.Required, new TransactionOptions()
                {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    try
                    {
                        var result = await service.Execute(record, record.ExtensionInfo, record.UploadFile);

                        await _uploadFileHandleRecordStore.UpdateStatus(record.ID, 2, result, null);
                    }
                    catch (Exception ex)
                    {
                        await _uploadFileHandleRecordStore.UpdateStatus(record.ID, 3, null, $"{ex.Message},stacktrace:{ex.StackTrace}");
                    }
                    scope.Complete();
                }
            }
        }
Beispiel #3
0
 public UploadFile GetUploadFile(UploadFileHandleRecord record)
 {
     return(_uploadFileStore.QueryByIdSync(record.UploadFileRegardingType, record.UploadFileRegardingKey, record.UploadFileId));
 }
Beispiel #4
0
 public async Task UpdateToProcessStatus(UploadFileHandleRecord record)
 {
     await _uploadFileHandleRecordStore.UpdateStatus(record.ID, 1, null, null);
 }
Beispiel #5
0
 public async Task Add(UploadFileHandleRecord record)
 {
     await _uploadFileHandleRecordStore.Add(record);
 }