コード例 #1
0
        /// <summary>
        /// 取消指定执行上下文关联的任务。
        /// </summary>
        /// <param name="context">执行上下文关联。</param>
        public static void Cancel(this DataPumpControllableExecutionContext context)
        {
            if (context == null)
            {
                return;
            }
            ControllableDataPumpBase dataPump = context.Owner as ControllableDataPumpBase;

            dataPump.Cancel(context);
        }
コード例 #2
0
        /// <summary>
        /// 取消指定执行上下文关联的任务。
        /// </summary>
        /// <param name="context">执行上下文关联。</param>
        public static void Cancel(this DataPumpExecutionContext context)
        {
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx == null)
            {
                return;
            }
            Cancel(contextEx);
        }
コード例 #3
0
 /// <summary>
 /// 使用特定的执行上下文执行服务,并在第一次执行时初始化相关数据。
 /// </summary>
 /// <param name="context">执行上下文。</param>
 protected sealed override void ExecuteCore(DataPumpControllableExecutionContext context)
 {
     if (!_isInited)
     {
         _isInited = InitAtFirstTime();
     }
     if (_isInited)
     {
         OverrideExecute(context);
     }
 }
コード例 #4
0
        /// <summary>
        /// 执行数据泵。
        /// </summary>
        /// <param name="pump">元数据。</param>
        /// <param name="savePath">保存路径。</param>
        /// <param name="source">数据源。</param>
        /// <param name="reporter">异步通知器。</param>
        /// <param name="items">提取项列表。</param>
        /// <returns>数据泵任务执行上下文。</returns>
        public static DataPumpExecutionContext Execute(this Pump pump, String savePath, SourceFileItem source, IAsyncProgress reporter, IEnumerable <ExtractItem> items = null)
        {
            DataPumpBase                         dataPump  = pump.GetDataPump();
            DataPumpExecutionContext             context   = dataPump.CreateContext(pump, savePath, source);
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = reporter;
            }
            dataPump.Execute(context);
            return(context);
        }
コード例 #5
0
        /// <summary>
        /// 创建执行上下文。
        /// </summary>
        /// <param name="dataPump">数据泵。</param>
        /// <param name="metaData">元数据。</param>
        /// <param name="rootSavePath">保存路径。</param>
        /// <param name="source">数据源。</param>
        /// <param name="extractItems">提取项列表。</param>
        /// <param name="asyn">异步通知器。</param>
        /// <returns>执行上下文。</returns>
        internal static DataPumpExecutionContext CreateContext(this DataPumpBase dataPump, Pump metaData, String rootSavePath, SourceFileItem source, IEnumerable <ExtractItem> extractItems, IAsyncProgress asyn = null)
        {
            DataPumpExecutionContext context = dataPump.CreateContext(metaData, rootSavePath, source);

            context.ExtractItems = extractItems;
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = asyn;
            }
            return(contextEx);
        }
コード例 #6
0
 /// <summary>
 /// 取消执行。
 /// </summary>
 public virtual void Cancel(DataPumpControllableExecutionContext context)
 {
     if (context.Owner != this)
     {
         return;
     }
     if ((context.Status == AsyncProgressState.Starting) ||
         (context.Status == AsyncProgressState.Running))
     {
         context.Reporter.Stop();
         context.CancellationTokenSource.Cancel();
         context.Reset();
     }
 }
コード例 #7
0
        /// <summary>
        /// 使用特定的执行上下文执行服务。
        /// </summary>
        /// <param name="context">执行上下文。</param>
        protected sealed override void ExecuteCore(DataPumpExecutionContext context)
        {
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx == null)
            {
                throw new InvalidOperationException("context is not DataPumpControllableExecutionContext");
            }
            if (contextEx.Status == AsyncProgressState.Running || contextEx.Status == AsyncProgressState.Starting)
            {
                return;
            }
            ExecuteCore(contextEx);
        }
コード例 #8
0
 /// <summary>
 /// 取消执行。
 /// </summary>
 public virtual void Cancel(DataPumpControllableExecutionContext context)
 {
     if (context.Owner != this)
     {
         return;
     }
     //枚举值高字节如果为0x01,表示正在执行
     if (((Int32)context.Status & 0xFF00) == 0x0100)
     {
         context.Reporter.StopAll();
         context.CancellationTokenSource.Cancel();
         context.Reset();
     }
 }
コード例 #9
0
        /// <summary>
        /// 执行数据泵。
        /// </summary>
        /// <param name="dataPump">元数据。</param>
        /// <param name="source">数据源。</param>
        /// <param name="reporter">异步通知器。</param>
        /// <param name="items">提取项列表。</param>
        /// <returns>数据泵任务执行上下文。</returns>
        public static DataPumpExecutionContext Execute(this DataPumpBase dataPump, SourceFileItem source, MultiTaskReporterBase reporter, params ExtractItem[] items)
        {
            DataPumpExecutionContext context = dataPump.CreateContext(source);

            context.ExtractItems = items;
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = reporter;
            }
            dataPump.Execute(context);
            return(context);
        }
コード例 #10
0
        public void Extract(SourceFileItem item, IAsyncProgress asyn)
        {
            if (Context == null)
            {
                return;
            }
            Context.UnsafeSource = item;
            DataPumpControllableExecutionContext contextEx = Context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = asyn;
            }
            DataPump.Execute(Context);
        }
コード例 #11
0
 /// <summary>
 /// 初始化当前的执行流程。
 /// </summary>
 /// <param name="context">执行上下文。</param>
 /// <returns>成功返回true;否则返回false。</returns>
 protected virtual Boolean InitExecution(DataPumpControllableExecutionContext context)
 {
     return(true);
 }
コード例 #12
0
 /// <summary>
 /// 使用特定的执行上下文执行服务。
 /// </summary>
 /// <param name="context">执行上下文。</param>
 protected abstract void ExecuteCore(DataPumpControllableExecutionContext context);
コード例 #13
0
 /// <summary>
 /// 使用特定的执行上下文执行服务。
 /// </summary>
 /// <param name="context">执行上下文。</param>
 protected abstract void OverrideExecute(DataPumpControllableExecutionContext context);