Exemple #1
0
        public async Task Execute()
        {
            while (_actionToExecute != Enums.Actions.END)
            {
                try
                {
                    switch (_actionToExecute)
                    {
                    case Enums.Actions.GET_TOKEN:
                        StartLog(_actionToExecute);

                        _action = new GetTokenAction();
                        await _action.ExecuteAsync();

                        EndLog(_actionToExecute);
                        break;

                    case Enums.Actions.RUN_JOB:
                        StartLog(_actionToExecute);

                        var vsCronOptions = new VSCronOptions();
                        ServiceConfigurationInstance.Configuration.GetSection(typeof(VSCronOptions).Name).Bind(vsCronOptions);

                        _action = new RunJobAction(Options.Create(vsCronOptions));
                        await _action.ExecuteAsync();

                        EndLog(_actionToExecute);
                        break;
                    }
                    SetNextState(_actionToExecute);
                }
                catch (Exception ex)
                {
                    LogHelper.Print(ex, "Exception occurred during action execution.", true);
                    _actionToExecute = Enums.Actions.END;
                }
            }
        }