diff --git a/NewLife.Cube/Areas/Admin/Controllers/FileController.cs b/NewLife.Cube/Areas/Admin/Controllers/FileController.cs
index cf88ef3..ac20097 100644
--- a/NewLife.Cube/Areas/Admin/Controllers/FileController.cs
+++ b/NewLife.Cube/Areas/Admin/Controllers/FileController.cs
@@ -57,12 +57,14 @@ namespace NewLife.Cube.Admin.Controllers
var inf = GetFile(r) as FileSystemInfo ?? GetDirectory(r);
if (inf == null) return null;
- var fi = new FileItem();
- fi.Name = inf.Name;
- fi.FullName = GetFullName(inf.FullName);
- fi.Raw = inf.FullName;
- fi.Directory = inf is DirectoryInfo;
- fi.LastWrite = inf.LastWriteTime;
+ var fi = new FileItem
+ {
+ Name = inf.Name,
+ FullName = GetFullName(inf.FullName),
+ Raw = inf.FullName,
+ Directory = inf is DirectoryInfo,
+ LastWrite = inf.LastWriteTime
+ };
if (inf is FileInfo)
{
diff --git a/XCode/Transform/ETL.cs b/XCode/Transform/ETL.cs
index fd65130..303347d 100644
--- a/XCode/Transform/ETL.cs
+++ b/XCode/Transform/ETL.cs
@@ -81,6 +81,8 @@ namespace XCode.Transform
/// <summary>开始</summary>
public virtual void Start()
{
+ Modules.Start();
+
var ext = Extracter;
if (ext == null) throw new ArgumentNullException(nameof(Extracter), "没有设置数据抽取器");
@@ -88,14 +90,14 @@ namespace XCode.Transform
ext.Init();
if (Stat == null) Stat = new ETLStat();
-
- Modules.Init(this);
}
/// <summary>停止</summary>
public virtual void Stop()
{
_Inited = false;
+
+ Modules.Stop();
}
#endregion
@@ -108,6 +110,8 @@ namespace XCode.Transform
{
WriteLog("开始处理{0},区间({1} + {3:n0}, {2})", Name, set.Start, set.End, set.Row);
+ Modules.Init();
+
return true;
}
@@ -115,10 +119,9 @@ namespace XCode.Transform
/// <returns>返回抽取数据行数,没有数据返回0,初始化或配置失败返回-1</returns>
public virtual Int32 Process()
{
- if (!Modules.Processing()) return -1;
+ if (!Modules.Processing()) { _Inited = false; return -1; }
var set = Extracter.Setting;
- if (set == null) { _Inited = false; return -1; }
if (!_Inited)
{
diff --git a/XCode/Transform/IETLModule.cs b/XCode/Transform/IETLModule.cs
index 36e5921..7357d17 100644
--- a/XCode/Transform/IETLModule.cs
+++ b/XCode/Transform/IETLModule.cs
@@ -9,23 +9,60 @@ namespace XCode.Transform
/// <summary>数据抽取模块,用于自定义抽取过程中各个环节</summary>
public interface IETLModule
{
- void Init(ETL etl);
+ /// <summary>开始调度</summary>
+ void Start();
+ /// <summary>停止调度</summary>
+ void Stop();
+
+ /// <summary>首次初始化任务</summary>
+ void Init();
+
+ /// <summary>单批数据处理前</summary>
+ /// <returns></returns>
Boolean Processing();
+
+ /// <summary>单批数据处理后</summary>
void Processed();
+ /// <summary>实体列表完成后</summary>
+ /// <param name="list"></param>
+ /// <param name="set"></param>
+ /// <param name="success"></param>
+ /// <param name="fetchCost"></param>
+ /// <param name="processCost"></param>
void OnFinished(IList<IEntity> list, IExtractSetting set, Int32 success, Double fetchCost, Double processCost);
+ /// <summary>出错</summary>
+ /// <param name="source"></param>
+ /// <param name="set"></param>
+ /// <param name="ex"></param>
void OnError(Object source, IExtractSetting set, Exception ex);
}
static class ETLModuleHelper
{
- public static void Init(this IEnumerable<IETLModule> list, ETL etl)
+ public static void Start(this IEnumerable<IETLModule> list)
+ {
+ foreach (var item in list)
+ {
+ item.Start();
+ }
+ }
+
+ public static void Stop(this IEnumerable<IETLModule> list)
+ {
+ foreach (var item in list)
+ {
+ item.Stop();
+ }
+ }
+
+ public static void Init(this IEnumerable<IETLModule> list)
{
foreach (var item in list)
{
- item.Init(etl);
+ item.Init();
}
}