protected async Task NotifyExecutionAsync(params object[] eventArguments)
        {
            await OnBeforeNotifyExecution();

            CallCount++;
            Executed?.Invoke(this, eventArguments);
        }
Пример #2
0
        public void Rollback()
        {
            while (Executed.Count > 0)
            {
                try
                {
                    Context.Current = Executed.Dequeue();
                    var undoable = Context.Current as ICanUndo;
                    if (undoable != null)
                    {
                        undoable.Undo();
                    }
                }
                catch (Exception e)
                {
                    if (Context.ErrorHandler != null)
                    {
                        Context.ErrorHandler.OnError(e);
                    }
                }

                Unexecuted.Enqueue(Context.Current);
            }

            Context.State = TranscationStates.Cancelled;
        }
Пример #3
0
        public void Execute(object parameter)
        {
            bool muted = ((AnimationTagRail)parameter).Muted;

            ((AnimationTagRail)parameter).Muted = !muted;
            Executed?.Invoke(this, parameter);
        }
Пример #4
0
        /// <exception cref="DockerException"/>
        public async Task <string> ExecuteAsync(string command)
        {
            var processStartInfo = CreateProcessStartInfo(command);

            using var process = Process.Start(processStartInfo);
            Executed?.Invoke(this, $"docker {command}");

            string output = await process.StandardOutput.ReadToEndAsync();

            if (!string.IsNullOrEmpty(output))
            {
                Output?.Invoke(this, output);
            }

            string error = await process.StandardError.ReadToEndAsync();

            if (!string.IsNullOrEmpty(error))
            {
                Error?.Invoke(this, error);
            }

            int exitCode = await process.WaitForExitAsync().ConfigureAwait(false);

            if (exitCode != 0)
            {
                throw new DockerException(error, process.ExitCode);
            }

            return(output);
        }
Пример #5
0
        public void Begin(object parameters = null)
        {
            Context = new TranscationContext()
            {
                TranID = Guid.NewGuid(),
                State  = TranscationStates.Executing
            };

            while (Unexecuted.Count > 0)
            {
                try
                {
                    Context.Current = Unexecuted.Dequeue();
                    Context.Current.Execute(parameters);
                }
                catch (Exception e)
                {
                    if (Context.ErrorHandler != null)
                    {
                        Context.ErrorHandler.OnError(e);
                    }
                }

                Executed.Enqueue(Context.Current);
            }
        }
Пример #6
0
 public void Execute(object parameter = null)
 {
     Refresh();
     _execute(parameter);
     Executed?.Invoke(this, parameter);
     Refresh();
 }
Пример #7
0
        public Int32 InsertRoutineExecuted(Executed ExecutedRoutine)
        {
            var maxPK = db.Table <Executed>().OrderByDescending(c => c.ID).FirstOrDefault();

            if (maxPK != null)
            {
                rExecuted = new Executed()
                {
                    ID         = (maxPK == null ? 1 : (maxPK.ID + 1)),
                    RoutineID  = ExecutedRoutine.RoutineID,
                    ExerciseID = ExecutedRoutine.ExerciseID,
                    Date       = ExecutedRoutine.Date,
                    Reps       = ExecutedRoutine.Reps,
                    Sets       = ExecutedRoutine.Sets,
                    lbs        = ExecutedRoutine.lbs
                };
            }
            else
            {
                db.CreateTable <Executed>();
                rExecuted = new Executed()
                {
                    ID         = 0,
                    RoutineID  = ExecutedRoutine.RoutineID,
                    ExerciseID = ExecutedRoutine.ExerciseID,
                    Date       = ExecutedRoutine.Date,
                    Reps       = ExecutedRoutine.Reps,
                    Sets       = ExecutedRoutine.Sets,
                    lbs        = ExecutedRoutine.lbs
                };
            }
            return(DataLinkLayer.DBinsert <Executed>(rExecuted));
        }
Пример #8
0
 private void OnExecuted(JobInfo jobInfo)
 {
     Executed?.Invoke(this,
                      new JobOperationEventArgs {
         Job = jobInfo
     });
 }
Пример #9
0
 protected void OnExecuted()
 {
     if (Executed != null)
     {
         Executed.Invoke(this, new EventArgs());
     }
 }
Пример #10
0
        /// <summary>
        ///     Returns true if Action instances are equal
        /// </summary>
        /// <param name="other">Instance of Action to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Action other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Index == other.Index ||
                     Index.Equals(other.Index)
                     ) &&
                 (
                     Type == other.Type ||
                     Type.Equals(other.Type)
                 ) &&
                 (
                     Executed == other.Executed ||
                     Executed.Equals(other.Executed)
                 ) &&
                 (
                     Requestor == other.Requestor ||
                     Requestor.Equals(other.Requestor)
                 ));
        }
Пример #11
0
        public BLRoutineShow()
        {
            db = DataLinkLayer.DBconnect();

            bLPlanned  = new BLPlanned();
            bLExecuted = new BLExecuted();

            Executed executed = new Executed()
            {
                ID = 1,
                RoutinePlannedID = 0,
                RoutineID        = 0,
                ExerciseID       = 0,
                Date             = "01:01:01",
                Reps             = "0",
                Sets             = 2,
                lbs = "0"
            };
            // db.CreateTable<Executed>();
            //bLExecuted.InsertRoutineExecuted(executed);

            //db.DropTable<Exercise>();
            //db.CreateTable<Exercise>();
            //BLExercise bl = new BLExercise();
            //bl.InsertExcercise(new Exercise());

            //db.DropTable<Routine>();
            //db.CreateTable<Routine>();
            //BLRoutine bL = new BLRoutine();
            //bL.InsertRoutine(new Routine());

            //db.DropTable<Planned>();
            //db.CreateTable<Planned>();
        }
Пример #12
0
        public void Execute(object parameter)
        {
            var selectedWindowEntry = _getEntryAt(int.Parse((string)parameter) - 1);

            selectedWindowEntry?.Select();

            Executed?.Invoke(this, new EventArgs());
        }
Пример #13
0
 protected void InvokeExecuted(CommandEventArgs args)
 {
     //  Вызвать все события
     ThreadManager.Instance.InvokeUI((arg) =>
     {
         Executed?.Invoke(this, arg);
     },
                                     args);
 }
Пример #14
0
        /// <summary>
        /// Raises the <see cref="Executed" /> event.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>Task.</returns>
        protected virtual void RaiseExecuted(object parameter)
        {
            var action = new Action(() =>
            {
                var eventArgs = new CommandExecutedEventArgs(this, parameter);
                Executed?.Invoke(this, eventArgs);
            });

            AutoDispatchIfRequired(action);
        }
Пример #15
0
        /// <summary>
        /// Raises the Executed event and clears the operation cache.
        /// </summary>
        /// <param name="e">The ExecutableEventArgs.</param>
        protected virtual void OnExecuted(ExecutableEventArgs e)
        {
            if (clearCache && e.Executable is IOperation operation)
            {
                OperationCache cache = new OperationCache(operation);
                cache.Clear();
            }

            Executed?.Invoke(this, e);
        }
Пример #16
0
 public override void Invoke()
 {
     if ((Execute || ExecuteOnLoad && Wrapper.LoadedFrame) && !WasExecuted(Wrapper.BrowserId))
     {
         OnBeforeExecute?.Invoke(this, Wrapper);
         Operation(Wrapper);
         Executed.UpdateGeneric(Wrapper.BrowserId, true);
         OnAfterExecute?.Invoke(this, Wrapper);
     }
 }
Пример #17
0
        public void Run()
        {
            OnExecuting?.Invoke(this, new SimulatorEventArgs(_args));

            foreach (var battery in _args.Batteries)
            {
                Discharge(battery, _args.GetDischargeCurrent(battery.Uid), _args.CycleDuration);
            }

            Executed?.Invoke(this, new SimulatorEventArgs(_args));
        }
Пример #18
0
 private void OnExecuted()
 {
     try
     {
         Executed?.Invoke(this, EventArgs.Empty);
     }
     catch (Exception)
     {
         // ignored
     }
 }
Пример #19
0
        /// <summary>
        /// Raises the <see cref="Executed" /> event.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        /// <returns>Task.</returns>
        protected Task RaiseExecutedAsync(object parameter)
        {
            var action = new Func <Task>(async() =>
            {
                var eventArgs = new CommandExecutedEventArgs(this, parameter);
                Executed.SafeInvoke(this, eventArgs);
                await ExecutedAsync.SafeInvokeAsync(this, eventArgs);
            });

            return(AutoDispatchIfRequiredAsync(action));
        }
 /// <summary>
 /// UnExecutes the command
 /// </summary>
 public void UnExecute()
 {
     if (type == typeof(Vertex))
     {
         target.VerticesColor = oldColor;
     }
     else
     {
         target.ArcsColor = oldColor;
     }
     Executed?.Invoke(oldColor, null);
 }
Пример #21
0
 /// <summary>
 /// Исполнение
 /// </summary>
 /// <param name="parameter">Параметр</param>
 public void Execute(object parameter)
 {
     try
     {
         _execute(parameter);
         Executed?.Invoke(this, new EventArgs());
     }
     catch (Exception exception)
     {
         _exceptionAction(exception);
     }
 }
Пример #22
0
        protected override void OnTouchTap(TouchEventArgs args)
        {
            base.OnTouchTap(args);

            EventArgs e = EventArgsPool.Instance.Take();

            OnExecuted(e);
            Executed?.Invoke(this, e);

            EventArgsPool.Instance.Release(e);

            args.Handled = true;
        }
Пример #23
0
        /// <summary>
        /// Wird aufgerufen, wenn mit der linken Maustaste auf das Steuerelement geklickt wird.
        /// </summary>
        /// <param name="args">Weitere Informationen zum Ereignis.</param>
        protected override void OnLeftMouseClick(MouseEventArgs args)
        {
            base.OnLeftMouseClick(args);

            EventArgs e = EventArgsPool.Instance.Take();

            OnExecuted(e);
            Executed?.Invoke(this, e);

            EventArgsPool.Instance.Release(e);

            args.Handled = true;
        }
Пример #24
0
        public void Run()
        {
            OnExecuting?.Invoke(this, new SimulatorEventArgs(_args));

            if (!_args.NetworkOutdated)
            {
                return;
            }

            CalculateDistances();
            CalculateOrientations();
            _args.NetworkOutdated = false;

            Executed?.Invoke(this, new SimulatorEventArgs(_args));
        }
Пример #25
0
        public void Execute(object parameter)
        {
            try
            {
                _executing = true;

                CanExecuteChanged?.Invoke(this, new EventArgs());

                Executed?.Invoke(parameter);
            }
            finally
            {
                _executing = false;
                CanExecuteChanged?.Invoke(this, new EventArgs());
            }
        }
Пример #26
0
        /// <inheritdoc />
        /// <summary>
        ///     Executes the command from the specified caster.
        /// </summary>
        /// <param name="caster">The caster.</param>
        /// <param name="args">The arguments.</param>
        public void Execute(ICharacterSpawn caster, params string[] args)
        {
            ExecutingCommandEventArgs executingCommandEventArgs = new ExecutingCommandEventArgs(caster, args);

            Executing?.Invoke(this, executingCommandEventArgs);
            if (executingCommandEventArgs.Cancel)
            {
                return;
            }

            ExecuteCommand(executingCommandEventArgs.Caster, executingCommandEventArgs.Args);

            ExecutedCommandEventArgs executedCommandEventArgs = new ExecutedCommandEventArgs(executingCommandEventArgs.Caster, executingCommandEventArgs.Args);

            Executed?.Invoke(this, executedCommandEventArgs);
        }
Пример #27
0
        /// <summary>
        /// Wird aufgrefufen, wenn eine Taste gedrückt wird.
        /// </summary>
        /// <param name="args">Ein <see cref="KeyEventArgs"/>-Objekt mit weiteren Informationen zum Event</param>
        protected override void OnKeyPress(KeyEventArgs args)
        {
            base.OnKeyPress(args);

            if (Focused == TreeState.Active &&
                (args.Key == Keys.Enter || args.Key == Keys.Space))
            {
                EventArgs e = EventArgsPool.Instance.Take();

                OnExecuted(e);
                Executed?.Invoke(this, e);

                EventArgsPool.Instance.Release(e);

                args.Handled = true;
            }
        }
Пример #28
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked             // Overflow is fine, just wrap
            {
                int hashCode = 41;
                // Suitable nullity checks etc, of course :)

                hashCode = hashCode * 59 + Index.GetHashCode();

                hashCode = hashCode * 59 + Type.GetHashCode();

                hashCode = hashCode * 59 + Executed.GetHashCode();

                hashCode = hashCode * 59 + Requestor.GetHashCode();
                return(hashCode);
            }
        }
        // The command execution.
        void ICommand.Execute(object parameter)
        {
            Executing?.Invoke(this, EventArgs.Empty);

            Action          action = _action;
            Action <object> parameterizedAction = _parameterizedAction;

            if (action != null)
            {
                action();
            }
            else
            {
                parameterizedAction?.Invoke(parameter);
            }

            Executed?.Invoke(this, EventArgs.Empty);
        }
Пример #30
0
        public void ExecutePlugins(IFrame frame, PluginEnvironment environment, bool includeDisabled)
        {
            if (includeDisabled)
            {
                ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GenerateConfig(Config), "gen:pluginconfig");
            }

            List <string> failedPlugins = new List <string>(1);

            foreach (Plugin plugin in Plugins)
            {
                string path = plugin.GetScriptPath(environment);
                if (string.IsNullOrEmpty(path) || (!includeDisabled && !Config.IsEnabled(plugin)) || !plugin.CanRun)
                {
                    continue;
                }

                string script;

                try{
                    script = File.ReadAllText(path);
                }catch (Exception e) {
                    failedPlugins.Add(plugin.Identifier + " (" + Path.GetFileName(path) + "): " + e.Message);
                    continue;
                }

                int token;

                if (tokens.ContainsValue(plugin))
                {
                    token = GetTokenFromPlugin(plugin);
                }
                else
                {
                    token         = GenerateToken();
                    tokens[token] = plugin;
                }

                ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GeneratePlugin(plugin.Identifier, script, token, environment), "plugin:" + plugin);
            }

            Executed?.Invoke(this, new PluginErrorEventArgs(failedPlugins));
        }
Пример #31
0
 protected void UnaryOperator_CreateExecutedSupport(StillOneScriptCore.EntityModel.CustomFunctionModel.Support.ExecutedFunctionContext context, Executed.UnaryOperator item)
 {
     item.Left = mLeft.CreateExecuted(context);
 }