增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Logger;
|
||||
using MAX.Framework.Logger;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Store.Framework.Inerterfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Product.Publish;
|
||||
|
||||
public abstract class PublishStep<TContext> : IPublishStep<TContext>, IDisposable where TContext : PublishContextBase
|
||||
{
|
||||
protected ILoggerFacade Looger => LazyServiceProvider.Instance.LazyGetService<ILoggerFacade>();
|
||||
protected ICurrentUser CurrentUser => LazyServiceProvider.Instance.LazyGetService<ICurrentUser>();
|
||||
public abstract string Description { get; }
|
||||
public async Task<bool> CanExecuteAsync(TContext context, CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
return await CanExecuteProvider(context, token);
|
||||
}
|
||||
catch (OperationCanceledException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Looger.Error(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
protected virtual Task<bool> CanExecuteProvider(TContext context, CancellationToken token) => Task.FromResult(true);
|
||||
|
||||
public async Task ExecuteAsync(TContext context, CancellationToken token)
|
||||
{
|
||||
try
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
await ExecuteProvider(context, token);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Looger.Error(ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Task ExecuteProvider(TContext context, CancellationToken token);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user