示例#1
0
 public virtual void Schedule(ushort step)
 {
     if (Trigger(step))
     {
         OnExecute?.Invoke(this, null);
     }
 }
示例#2
0
        public bool Run(TimeSpan tCurrentTime, bool tManageCamera = false)
        {
            bool ret = StartTime.TotalMilliseconds <= tCurrentTime.TotalMilliseconds && tCurrentTime.TotalMilliseconds <= EndTime.TotalMilliseconds;

            if (ret)
            {
                if (_executionCount < 2)
                {
                    _executionCount += 1;
                }

                if (_setSpeed)
                {
                    CalculateCurrentSpeed();
                }

                if (_setFloat)
                {
                    CalculateCurrentFloat();
                }

                if (tManageCamera && IsSettingCamera && !_disableUpdate)
                {
                    PlaceCamera();
                }

                OnExecute?.Invoke(this);
            }

            return(ret);
        }
示例#3
0
        public void Execute()
        {
            try
            {
                if (!Api.IsAuthorized)
                {
                    Auth();
                }

                OnExecute?.Invoke();
            }
            catch (Exception e)
            {
                if (e is AccessTokenInvalidException)
                {
                    Logger.Error("Trying to renew token...");
                    Auth();
                    OnExecute?.Invoke();
                }
                else
                {
                    Logger.Error(e);
                }
            }
        }
 /// <summary>
 /// Logic to determine when to execute the actions tied to this processor.
 /// </summary>
 public bool Process(T t)
 {
     if (IsFulfilled(t))
     {
         OnExecute?.Invoke(t);
         return(true);
     }
     return(false);
 }
示例#5
0
        public Specter Execute(string code, string filename, IEnumerable <string> args)
        {
            Filename  = filename;
            Arguments = args;

            OnExecute?.Invoke();

            engine.Execute(filename, code);
            return(this);
        }
示例#6
0
        public void Execute(object parameter = default)
        {
            Parameter = parameter.Cast <TParameter>();
            Result    = _execute.Invoke(Parameter, Result);
            History.Snapshot(ToSnapShot());

            Result = default;
            OnExecute?.Invoke(Parameter);
            Parameter = default;
        }
 private void ExecuteProc()
 {
     try
     {
         OnExecute?.Invoke(m_client);
         OnCompleted?.Invoke(m_client);
     }
     catch (Exception)
     {
         OnCompleted?.Invoke(m_client);
     }
 }
示例#8
0
 private void InnerWork()
 {
     _lock.Wait();
     for (int i = 0; i < _stubCounter; i++)
     {
         Thread.Sleep(Random.Get(max: 1200));
         _lock.Wait();
         OnExecute?.Invoke(Id);
     }
     _lock.Wait();
     Thread.Sleep(Random.Get(max: 1200));
     OnComplete?.Invoke(Id);
 }
示例#9
0
        /// <summary>
        /// Starts the Task with the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="interval">The interval.</param>
        /// <returns></returns>
        private async Task Start(CancellationToken token, int interval)
        {
            while (true)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                OnExecute?.Invoke();

                await Task.Delay(interval, token);
            }
        }
示例#10
0
        public Task ExecuteAsync(QueryContext query)
        {
            if (OnExecute != null)
            {
                OnExecute.Invoke(query);
                return(Task.CompletedTask);
            }

            if (OnExecuteAsync != null)
            {
                return(OnExecuteAsync.Invoke(query));
            }

            return(Task.CompletedTask);
        }
示例#11
0
文件: Command.cs 项目: barisozluk/KLC
        public void Execute(object parameter = default)
        {
            Parameters = parameter.Cast <TParameter>();

            Result = this._execute(Parameters, Result).Cast <TResult>();

            ICommandWithUndoRedo.AddInUndo(this.Clone() as ICommandWithUndoRedo);

            ICommandWithUndoRedo.StackRedo.Clear();

            Result = default(TResult);

            Parameters = default(TParameter);

            OnExecute?.Invoke();
        }
示例#12
0
        protected override Value Evaluate(ValueContainer scopes)
        {
            InitExpression.Process(scopes);

            Value lastVal = null;

            while (CondExpression.Process(scopes).IsTrue)
            {
                lastVal = OnExecute.Process(scopes);

                if (lastVal?.IsReturning ?? false)
                {
                    return(lastVal);
                }

                IncrementExpression.Process(scopes);
            }

            return(lastVal);
        }
示例#13
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                if (_outputOption.HasValue() && !_frameworkOption.HasValue())
                {
                    Reporter.Error.WriteLine("When the '--output' option is provided, the '--framework' option must also be provided.");
                    return(1);
                }

                OutputValue        = _outputOption.Value();
                BuildBasePathValue = PathUtility.GetFullPath(_buildBasePath.Value());
                ConfigValue        = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                RuntimeValue       = _runtimeOption.Value();
                VersionSuffixValue = _versionSuffixOption.Value();
                ShouldPrintIncrementalPreconditions = _shouldPrintIncrementalPreconditionsArgument.HasValue();
                ShouldNotUseIncrementality          = _shouldNotUseIncrementalityArgument.HasValue();
                ShouldSkipDependencies = _shouldSkipDependenciesArgument.HasValue();

                // Set defaults based on the environment
                if (Workspace == null)
                {
                    Workspace = BuildWorkspace.Create(VersionSuffixValue);
                }

                var files = new ProjectGlobbingResolver().Resolve(_projectArgument.Values);
                IEnumerable <NuGetFramework> frameworks = null;
                if (_frameworkOption.HasValue())
                {
                    frameworks = new[] { NuGetFramework.Parse(_frameworkOption.Value()) };
                }
                var success = execute(files, frameworks, this);

                return(success ? 0 : 1);
            });

            return(_app.Execute(args));
        }
示例#14
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                // Locate the project and get the name and full path
                ProjectPathValue = _projectArgument.Value;
                if (string.IsNullOrEmpty(ProjectPathValue))
                {
                    ProjectPathValue = Directory.GetCurrentDirectory();
                }

                OutputValue       = _outputOption.Value();
                IntermediateValue = _intermediateOutputOption.Value();
                ConfigValue       = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                NoHostValue       = _noHostOption.HasValue();

                IsNativeValue         = _nativeOption.HasValue();
                ArchValue             = _archOption.Value();
                IlcArgsValue          = _ilcArgsOption.Value();
                IlcPathValue          = _ilcPathOption.Value();
                IlcSdkPathValue       = _ilcSdkPathOption.Value();
                AppDepSdkPathValue    = _appDepSdkPathOption.Value();
                IsCppModeValue        = _cppModeOption.HasValue();
                CppCompilerFlagsValue = _cppCompilerFlagsOption.Value();


                // Load project contexts for each framework
                var contexts = _frameworkOption.HasValue() ?
                               _frameworkOption.Values.Select(f => ProjectContext.Create(ProjectPathValue, NuGetFramework.Parse(f))) :
                               ProjectContext.CreateContextForEachFramework(ProjectPathValue);

                var success = execute(contexts.ToList(), this);

                return(success ? 0 : 1);
            });

            return(_app.Execute(args));
        }
示例#15
0
        public void execute(SqlQuery aQuery, OnExecute onExecute, BeforeExecute onBefore, AfterExecute onAfterExecute)
        {
            using (SqlCommand Command = new SqlCommand(aQuery.Query, Connection))
            {
                Command.Parameters.AddRange(aQuery.Parameters.ToArray());
                Command.Transaction = Transaction.SqlTransaction;
                onBefore(Command);

                DateTime beforequery = DateTime.Now;;
                logger.Debug(String.Format(EXECUTING_QUERY, aQuery));
                using (SqlDataReader aReader = Command.ExecuteReader())
                {
                    DateTime afterquery = DateTime.Now;
                    logger.Debug(String.Format(QUERY, aQuery, (afterquery - beforequery).Milliseconds));

                    while (aReader.Read())
                    {
                        onExecute(aReader);
                    }
                }
            }
            onAfterExecute();
        }
        // TODO Kill generator if any part of execution fails?
        public void Execute()
        {
            List <UserMoneyTransfer> transfersToExecute;

            lock (_locker)
            {
                transfersToExecute = new List <UserMoneyTransfer>(_openTransfers);
                _openTransfers.Clear();

                OnExecute?.Invoke(this, new EventArgs());
            }


            var groups = transfersToExecute.GroupBy(transfer => new { transfer.UserId, transfer.UserAccount, transfer.Currency }).ToList();

            foreach (var group in groups)
            {
                var taskData = new UserMoneyTransferTask
                {
                    Amount      = group.Sum(transfer => transfer.Amount),
                    Currency    = group.Key.Currency,
                    Status      = UserMoneyTransferTaskStatus.Open,
                    UserId      = group.Key.UserId,
                    UserAccount = group.Key.UserAccount,
                    Transfers   = group.ToList()
                };

                using (var scope = new TransactionScope())
                {
                    _dalTask.Insert(taskData);
                    taskData.Transfers.ForEach(transfer => _dalTransfer.UpdateStatus(transfer, UserMoneyTransferStatus.Tasked));
                    scope.Complete();
                }

                new Tasks.UserMoneyTransferTask(_dependencyFactory, _engine, taskData).Enqueue();
            }
        }
示例#17
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                // Locate the project and get the name and full path
                ProjectPathValue = _projectArgument.Value;
                if (string.IsNullOrEmpty(ProjectPathValue))
                {
                    ProjectPathValue = Directory.GetCurrentDirectory();
                }

                OutputValue = _outputOption.Value();
                IntermediateValue = _intermediateOutputOption.Value();
                ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                NoHostValue = _noHostOption.HasValue();

                IsNativeValue = _nativeOption.HasValue();
                ArchValue = _archOption.Value();
                IlcArgsValue = _ilcArgsOption.Value();
                IlcPathValue = _ilcPathOption.Value();
                IlcSdkPathValue = _ilcSdkPathOption.Value();
                AppDepSdkPathValue = _appDepSdkPathOption.Value();
                IsCppModeValue = _cppModeOption.HasValue();
                CppCompilerFlagsValue = _cppCompilerFlagsOption.Value();

                // Load project contexts for each framework
                var contexts = _frameworkOption.HasValue() ?
                    _frameworkOption.Values.Select(f => ProjectContext.Create(ProjectPathValue, NuGetFramework.Parse(f))) :
                    ProjectContext.CreateContextForEachFramework(ProjectPathValue);

                var success = execute(contexts.ToList(), this);

                return success ? 0 : 1;
            });

            return _app.Execute(args);
        }
示例#18
0
 public void Execute()
 {
     executed = true;
     orderAction.Invoke(Target);
     OnExecute?.Invoke();
 }
示例#19
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                if (_outputOption.HasValue() && !_frameworkOption.HasValue())
                {
                    Reporter.Error.WriteLine("When the '--output' option is provided, the '--framework' option must also be provided.");
                    return 1;
                }

                OutputValue = _outputOption.Value();
                BuildBasePathValue = PathUtility.GetFullPath(_buildBasePath.Value());
                ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                RuntimeValue = _runtimeOption.Value();
                VersionSuffixValue = _versionSuffixOption.Value();
                ShouldPrintIncrementalPreconditions = _shouldPrintIncrementalPreconditionsArgument.HasValue();
                ShouldNotUseIncrementality = _shouldNotUseIncrementalityArgument.HasValue();
                ShouldSkipDependencies = _shouldSkipDependenciesArgument.HasValue();

                // Set defaults based on the environment
                if (Workspace == null)
                {
                    Workspace = BuildWorkspace.Create(VersionSuffixValue);
                }

                var files = new ProjectGlobbingResolver().Resolve(_projectArgument.Values);
                IEnumerable<NuGetFramework> frameworks = null;
                if (_frameworkOption.HasValue())
                {
                    frameworks = new[] { NuGetFramework.Parse(_frameworkOption.Value()) };
                }
                var success = execute(files, frameworks, this);

                return success ? 0 : 1;
            });

            return _app.Execute(args);
        }
 public Task <ExecutionResult> ExecuteCodeAsync(string text)
 {
     OnExecute?.Invoke(this, text);
     return(Task.FromResult(ExecutionResult.Success));
 }
示例#21
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                // Locate the project and get the name and full path
                ProjectPathValue = _projectArgument.Value;
                if (string.IsNullOrEmpty(ProjectPathValue))
                {
                    ProjectPathValue = Directory.GetCurrentDirectory();
                }

                OutputValue = _outputOption.Value();
                BuildBasePathValue = _buildBasePath.Value();
                ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                RuntimeValue = _runtimeOption.Value();
                VersionSuffixValue = _versionSuffixOption.Value();

                IsNativeValue = _nativeOption.HasValue();
                ArchValue = _archOption.Value();
                IlcArgsValue = _ilcArgsOption.HasValue() ? _ilcArgsOption.Values : Enumerable.Empty<string>();
                IlcPathValue = _ilcPathOption.Value();
                IlcSdkPathValue = _ilcSdkPathOption.Value();
                AppDepSdkPathValue = _appDepSdkPathOption.Value();
                IsCppModeValue = _cppModeOption.HasValue();
                CppCompilerFlagsValue = _cppCompilerFlagsOption.Value();

                IEnumerable<ProjectContext> contexts;
                
                // Set defaults based on the environment
                var settings = ProjectReaderSettings.ReadFromEnvironment();

                if (!string.IsNullOrEmpty(VersionSuffixValue))
                {
                    settings.VersionSuffix = VersionSuffixValue;
                }

                if (_frameworkOption.HasValue())
                {
                    contexts = _frameworkOption.Values
                        .Select(f =>
                        {
                            return ProjectContext.CreateBuilder(ProjectPathValue, NuGetFramework.Parse(f))
                                                 .WithReaderSettings(settings)
                                                 .Build();
                        });
                }
                else
                {
                    if (!string.IsNullOrEmpty(OutputValue))
                    {
                        throw new InvalidOperationException($"'{_frameworkOption.LongName}' is required when '{_outputOption.LongName}' is specified");
                    }
                    else
                    {
                        contexts = ProjectContext.CreateContextForEachFramework(ProjectPathValue, settings);
                    }
                }

                var success = execute(contexts.ToList(), this);

                return success ? 0 : 1;
            });

            return _app.Execute(args);
        }
示例#22
0
 public void Execute(object parameter = null)
 {
     OnExecute?.Invoke(parameter);
 }
示例#23
0
        public async Task Execute(PageAction pageAction, IEnumerable <ImageEntity> images, UserEntity user,
                                  SettingEntity settings, CancellationToken ct)
        {
            try
            {
                foreach (var image in images)
                {
                    try
                    {
                        OnStartExecuted.Invoke(image, pageAction);
                        image.ImageState = ImageState.InProcesses;
                        var pageContext = new ImageContext {
                            User = user, Settings = settings
                        };

                        foreach (var page in _pages.Where(a => a.Action == pageAction).OrderBy(a => a.Order))
                        {
                            if (ct.IsCancellationRequested)
                            {
                                break;
                            }

                            await page.ExecuteAsync(image, pageContext, ct);

                            if (page.GetImageState(image) == ImageState.Failed)
                            {
                                _logger.LogWarning(string.Format(LogTemplate, page.Order, page.Action));
                                break;
                            }

                            _logger.LogStep(page.Action.ToString(), image.ImagePath, page.Order.ToString());
                            OnStateChanged.Invoke(image.ImageState, image.Id);

                            await Task.Delay(TimeSpan.FromSeconds(2), ct); // to simulate user action
                        }

                        await _repository.AddOrUpdateAsync(image, ct);

                        OnExecute.Invoke(image, pageAction);

                        await Task.Delay(TimeSpan.FromSeconds(settings.WaitingBetweenUploadingImage), ct);
                    }
                    catch (TaskCanceledException)
                    {
                        break;
                    }
                    catch (Exception ex)
                    {
                        _logger.LogWarning(ex.Message);
                        image.ImageState = ImageState.Failed;
                    }
                }

                if (images.Any(entity => entity.ImageState == ImageState.Failed) &&
                    _retryCount < settings.RetryCount)
                {
                    _retryCount++;
                    await Execute(pageAction, user.Images !.Where(entity => entity.ImageState == ImageState.Failed),
                                  user, settings, ct);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                if (_retryCount > settings.RetryCount)
                {
                    throw;
                }
            }
        }
示例#24
0
 public void execute(QueryEngine.Query.SqlQuery aQuery, OnExecute onExecute, BeforeExecute onBefore, AfterExecute onAfterExecute)
 {
 }
示例#25
0
 public void ExecuteAction(EventArgs e)
 {
     btnExecute.Enabled = false;
     OnExecute?.Invoke(this, e);
     btnExecute.Enabled = true;
 }
示例#26
0
 public void Trigger(IGraphFlow flow)
 {
     OnExecute?.Invoke();
 }
示例#27
0
 private void ExecuteCommand(object sender, EventArgs e)
 {
     OnExecute?.Invoke(Type);
 }
示例#28
0
 protected virtual void Execute()
 {
     OnExecute?.Invoke(this, null);
 }
示例#29
0
 public void Execute()
 {
     OnExecute?.Invoke();
 }
示例#30
0
 public void Execute(TSender sender, TEventArgs eventArgs)
 {
     OnExecute?.Invoke(sender, eventArgs);
 }
示例#31
0
 public void Execute(object parameter)
 {
     OnExecute?.Invoke(this, parameter);
 }
示例#32
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                if (_outputOption.HasValue() && !_frameworkOption.HasValue())
                {
                    Reporter.Error.WriteLine("When the '--output' option is provided, the '--framework' option must also be provided.");
                    return 1;
                }

                // Locate the project and get the name and full path
                ProjectPathValue = _projectArgument.Value;
                if (string.IsNullOrEmpty(ProjectPathValue))
                {
                    ProjectPathValue = Directory.GetCurrentDirectory();
                }

                OutputValue = _outputOption.Value();
                BuildBasePathValue = _buildBasePath.Value();
                ConfigValue = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                RuntimeValue = _runtimeOption.Value();
                VersionSuffixValue = _versionSuffixOption.Value();

                IsNativeValue = _nativeOption.HasValue();
                ArchValue = _archOption.Value();
                IlcArgsValue = _ilcArgsOption.HasValue() ? _ilcArgsOption.Values : Enumerable.Empty<string>();
                IlcPathValue = _ilcPathOption.Value();
                IlcSdkPathValue = _ilcSdkPathOption.Value();
                AppDepSdkPathValue = _appDepSdkPathOption.Value();
                IsCppModeValue = _cppModeOption.HasValue();
                CppCompilerFlagsValue = _cppCompilerFlagsOption.Value();

                // Set defaults based on the environment
                var settings = ProjectReaderSettings.ReadFromEnvironment();

                if (!string.IsNullOrEmpty(VersionSuffixValue))
                {
                    settings.VersionSuffix = VersionSuffixValue;
                }

                // Load the project file and construct all the targets
                var targets = ProjectContext.CreateContextForEachFramework(ProjectPathValue, settings).ToList();

                if (targets.Count == 0)
                {
                    // Project is missing 'frameworks' section
                    Reporter.Error.WriteLine("Project does not have any frameworks listed in the 'frameworks' section.");
                    return 1;
                }

                // Filter the targets down based on the inputs
                if (_frameworkOption.HasValue())
                {
                    var fx = NuGetFramework.Parse(_frameworkOption.Value());
                    targets = targets.Where(t => fx.Equals(t.TargetFramework)).ToList();

                    if (targets.Count == 0)
                    {
                        // We filtered everything out
                        Reporter.Error.WriteLine($"Project does not support framework: {fx.DotNetFrameworkName}.");
                        return 1;
                    }

                    Debug.Assert(targets.Count == 1);
                }

                Debug.Assert(targets.All(t => string.IsNullOrEmpty(t.RuntimeIdentifier)));

                var success = execute(targets, this);

                return success ? 0 : 1;
            });

            return _app.Execute(args);
        }
示例#33
0
 public override void Execute(object parameter)
 {
     OnExecute?.Invoke();
     Action?.Invoke((T)parameter);
 }
示例#34
0
        public int Execute(OnExecute execute, string[] args)
        {
            _app.OnExecute(() =>
            {
                if (_outputOption.HasValue() && !_frameworkOption.HasValue())
                {
                    Reporter.Error.WriteLine("When the '--output' option is provided, the '--framework' option must also be provided.");
                    return(1);
                }

                // Locate the project and get the name and full path
                ProjectPathValue = _projectArgument.Value;
                if (string.IsNullOrEmpty(ProjectPathValue))
                {
                    ProjectPathValue = Directory.GetCurrentDirectory();
                }

                OutputValue        = _outputOption.Value();
                BuildBasePathValue = _buildBasePath.Value();
                ConfigValue        = _configurationOption.Value() ?? Constants.DefaultConfiguration;
                RuntimeValue       = _runtimeOption.Value();
                VersionSuffixValue = _versionSuffixOption.Value();
                PortableMode       = _portableOption.HasValue();

                IsNativeValue         = _nativeOption.HasValue();
                ArchValue             = _archOption.Value();
                IlcArgsValue          = _ilcArgsOption.HasValue() ? _ilcArgsOption.Values : Enumerable.Empty <string>();
                IlcPathValue          = _ilcPathOption.Value();
                IlcSdkPathValue       = _ilcSdkPathOption.Value();
                AppDepSdkPathValue    = _appDepSdkPathOption.Value();
                IsCppModeValue        = _cppModeOption.HasValue();
                CppCompilerFlagsValue = _cppCompilerFlagsOption.Value();

                // Set defaults based on the environment
                var settings = ProjectReaderSettings.ReadFromEnvironment();

                if (!string.IsNullOrEmpty(VersionSuffixValue))
                {
                    settings.VersionSuffix = VersionSuffixValue;
                }

                // Load the project file and construct all the targets
                var targets = ProjectContext.CreateContextForEachFramework(ProjectPathValue, settings).ToList();

                if (targets.Count == 0)
                {
                    // Project is missing 'frameworks' section
                    Reporter.Error.WriteLine("Project does not have any frameworks listed in the 'frameworks' section.");
                    return(1);
                }

                // Filter the targets down based on the inputs
                if (_frameworkOption.HasValue())
                {
                    var fx  = NuGetFramework.Parse(_frameworkOption.Value());
                    targets = targets.Where(t => fx.Equals(t.TargetFramework)).ToList();

                    if (targets.Count == 0)
                    {
                        // We filtered everything out
                        Reporter.Error.WriteLine($"Project does not support framework: {fx.DotNetFrameworkName}.");
                        return(1);
                    }

                    Debug.Assert(targets.Count == 1);
                }

                Debug.Assert(targets.All(t => string.IsNullOrEmpty(t.RuntimeIdentifier)));

                var success = execute(targets, this);

                return(success ? 0 : 1);
            });

            return(_app.Execute(args));
        }