Exemple #1
0
        public void StartChecking(ICheckable checkable)
        {
            lock (oTaskLock)
            {
                //if there is already a Task and it has not completed
                if (_checkTask != null && !_checkTask.IsCompleted)
                {
                    return;
                }

                //else start a new Task
                Reset();
                _checkTask = new Task(() =>
                {
                    try
                    {
                        checkable.Check(this);
                    }
                    catch (Exception ex)
                    {
                        Fatal(new Exception("Entire Checking Process Failed", ex));
                    }
                }
                                      );
                _checkTask.Start();
            }
        }
Exemple #2
0
 public void Check(ICheckable checkable)
 {
     try
     {
         checkable.Check(this);
     }
     catch (Exception ex)
     {
         checksUI1.OnCheckPerformed(new CheckEventArgs("Entire checking process failed", CheckResult.Fail, ex));
     }
 }
Exemple #3
0
 /// <summary>
 /// Runs checks on the <paramref name="checkable"/> and calls <see cref="BasicCommandExecution.SetImpossible(string)"/> if there are any failures
 /// </summary>
 /// <param name="checkable"></param>
 protected void SetImpossibleIfFailsChecks(ICheckable checkable)
 {
     try
     {
         checkable.Check(new ThrowImmediatelyCheckNotifier());
     }
     catch (Exception e)
     {
         SetImpossible(ExceptionHelper.ExceptionToListOfInnerMessages(e));
     }
 }
 public virtual void Check()
 {
     try
     {
         if (_checkable != null)
         {
             _checkable.Check(ragSmiley1);
         }
     }
     catch (Exception e)
     {
         ragSmiley1.Fatal(e);
     }
 }
Exemple #5
0
 private void PerformPreExecutionChecks()
 {
     try
     {
         DataLoadEventListener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Performing pre-execution checks"));
         var thrower = new ThrowImmediatelyCheckNotifier()
         {
             WriteToConsole = false
         };
         _preExecutionChecker.Check(thrower);
     }
     catch (Exception e)
     {
         Exception = e;
         ExitCode  = ExitCodeType.Error;
     }
 }
Exemple #6
0
        public void StartChecking(ICheckable rootCheckable, bool bClearUI = true)
        {
            if (bClearUI)
            {
                yesNoYesToAllDialog = new YesNoYesToAllDialog();
            }

            if (CheckingInProgress)
            {
                MessageBox.Show("Checking already in progress, please wait for current checks to complete before requesting more");
                return;
            }

            if (bClearUI)
            {
                olvChecks.ClearObjects();
            }

            CheckingInProgress       = true;
            btnAbortChecking.Enabled = true;
            var listener = new ToMemoryCheckNotifier(this);

            _checkingThread = new Thread(() =>
            {
                try
                {
                    rootCheckable.Check(listener);
                    checker_AllChecksFinished(listener);
                }
                catch (Exception e)
                {
                    listener.OnCheckPerformed(new CheckEventArgs("Entire checking process crashed", CheckResult.Fail, e));
                    CheckingInProgress = false;

                    if (AllChecksComplete != null)
                    {
                        AllChecksComplete(this, new AllChecksCompleteHandlerArgs(listener));
                    }
                }
            });
            _checkingThread.Start();
        }
        protected async Task SendTestEmail(TMailActionSettings mailActionSettings, Accounts accounts)
        {
            try
            {
                var job = CreateTestMailJob(mailActionSettings, accounts);
                _mailAction.ApplyPreSpecifiedTokens(job);

                if (!await TrySetJobPasswords(job))
                {
                    return;
                }

                var result = _mailAction.Check(job.Profile, job.Accounts, CheckLevel.Job);

                if (result)
                {
                    result = await Task.Run(() => _mailAction.ProcessJob(job));
                }

                if (result)
                {
                    ShowSuccess(job);
                }
                else
                {
                    ShowErrorMessage(result);
                }
            }
            catch (Exception ex)
            {
                _logger.Warn(ex, "Exception while sending test mail");
            }
            finally
            {
                _testFileDummyHelper.CleanUp();
            }
        }
        /// <summary>
        /// Runs checks on all components in the pipeline that support <see cref="ICheckable"/>
        /// </summary>
        /// <param name="notifier"></param>
        public void Check(ICheckNotifier notifier)
        {
            try
            {
                ICheckable checkableSource = Source as ICheckable;
                if (checkableSource != null)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("About to start checking Source component " + checkableSource,
                                                                 CheckResult.Success));
                    checkableSource.Check(notifier);
                }
                else
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Source component " + Source + " does not support ICheckable so skipping checking it",
                            CheckResult.Warning));
                }

                foreach (IDataFlowComponent <T> component in Components)
                {
                    ICheckable checkable = component as ICheckable;

                    if (checkable != null)
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs("About to start checking component " + component, CheckResult.Success));
                        checkable.Check(notifier);
                    }
                    else
                    {
                        notifier.OnCheckPerformed(
                            new CheckEventArgs(
                                "Component " + component + " does not support ICheckable so skipping checking it",
                                CheckResult.Warning));
                    }
                }

                ICheckable checkableDestination = Destination as ICheckable;
                if (checkableDestination != null)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("About to start checking Destination component " + checkableDestination,
                                                                 CheckResult.Success));
                    checkableDestination.Check(notifier);
                }
                else
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Destination component " + Destination + " does not support ICheckable so skipping checking it",
                            CheckResult.Warning));
                }
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        typeof(DataFlowPipelineEngine <T>).Name + " Checking failed in an unexpected way",
                        CheckResult.Fail, e));
            }


            notifier.OnCheckPerformed(new CheckEventArgs("Finished checking all components", CheckResult.Success));
        }
        public override void Execute()
        {
            base.Execute();

            _checkable.Check(_notifier);
        }
Exemple #10
0
        public int Run(IRDMPPlatformRepositoryServiceLocator repositoryLocator, IDataLoadEventListener listener, ICheckNotifier checkNotifier, GracefulCancellationToken token)
        {
            RepositoryLocator = repositoryLocator;
            Token             = token;
            List <Task> tasks = new List <Task>();

            Semaphore semaphore = null;

            if (_options.MaxConcurrentExtractions != null)
            {
                semaphore = new Semaphore(_options.MaxConcurrentExtractions.Value, _options.MaxConcurrentExtractions.Value);
            }

            Initialize();

            switch (_options.Command)
            {
            case CommandLineActivity.none:
                break;

            case CommandLineActivity.run:

                object[] runnables = GetRunnables();

                foreach (object runnable in runnables)
                {
                    if (semaphore != null)
                    {
                        semaphore.WaitOne();
                    }

                    object r = runnable;
                    tasks.Add(Task.Run(() =>
                    {
                        try
                        {
                            ExecuteRun(r, new OverrideSenderIDataLoadEventListener(r.ToString(), listener));
                        }
                        finally
                        {
                            if (semaphore != null)
                            {
                                semaphore.Release();
                            }
                        }
                    }));
                }

                break;

            case CommandLineActivity.check:

                lock (_oLock)
                    _checksDictionary.Clear();

                ICheckable[] checkables = GetCheckables(checkNotifier);
                foreach (ICheckable checkable in checkables)
                {
                    if (semaphore != null)
                    {
                        semaphore.WaitOne();
                    }

                    ICheckable checkable1 = checkable;
                    var        memory     = new ToMemoryCheckNotifier(checkNotifier);

                    lock (_oLock)
                        _checksDictionary.Add(checkable1, memory);

                    tasks.Add(Task.Run(() =>
                    {
                        try
                        {
                            checkable1.Check(memory);
                        }
                        finally
                        {
                            if (semaphore != null)
                            {
                                semaphore.Release();
                            }
                        }
                    }));
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Task.WaitAll(tasks.ToArray());

            AfterRun();

            return(0);
        }