Beispiel #1
0
        private void Execute()
        {
            var cx = new CommandServiceContext(this);

            try
            {
                if (this.Commands.Count == 0)
                {
                    this.OnCompleted();
                    return;
                }

                Double d     = 1 / this.Commands.Count;
                var    count = this.Commands.Count;
                for (int i = 0; i < count; i++)
                {
                    var cm         = this.Commands[i];
                    var progressed = d * i;
                    cm.ProcessProgress += (o, e) => this.OnProcessProgress(new ProcessProgressEventArgs(e.Message, progressed + e.Progress / count));
                    cm.Completed       += (o, e) => this.OnCommandCompleted(new CommandCompletedEventArgs(o as DbSharpCommand));
                    cm.Execute(cx);
                    cx.PreviousCommand = cm;
                }
            }
            catch (Exception ex)
            {
                this.Exception = ex;
            }
            this.OnCompleted();
        }
Beispiel #2
0
 public void Execute(CommandServiceContext context)
 {
     this.Context = context;
     this.OnStarted();
     this.Execute();
     this.OnCompleted();
 }