Exemple #1
0
        /// <summary>
        /// Processes <see cref="ImporterWorkerAction"/>s posted to the <see cref="_actionBlock"/>
        /// </summary>
        /// <param name="action"><see cref="ImporterWorkerAction"/> to be processed</param>
        private void ProcessActionRequest(ImporterWorkerAction action)
        {
            try
            {
                switch (action.Type)
                {
                case ImporterWorkerAction.ActionType.Startup:
                    DoStartup();
                    break;

                case ImporterWorkerAction.ActionType.Activate:
                    DoActivate(action.MediaBrowsingCallback, action.ImportResultHandler);
                    break;

                case ImporterWorkerAction.ActionType.ScheduleImport:
                    DoScheduleImport(action.JobInformation.GetValueOrDefault());
                    break;

                case ImporterWorkerAction.ActionType.CancelImport:
                    DoCancelImport(action.JobInformation);
                    break;

                case ImporterWorkerAction.ActionType.Suspend:
                    DoSuspend();
                    break;

                case ImporterWorkerAction.ActionType.Shutdown:
                    DoShutdown();
                    break;
                }
                action.Complete();
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("ImporterWorker: Error while processing Action of type {0}", ex, action.Type);
                action.Fault(ex);
            }
        }
Exemple #2
0
 /// <summary>
 /// Requests an <see cref="ImporterWorkerAction"/>
 /// </summary>
 /// <param name="action"><see cref="ImporterWorkerAction"/> to be requested</param>
 /// <returns><see cref="System.Threading.Tasks.Task"/> that completes when the <see cref="ImporterWorkerAction"/> is completed</returns>
 internal Task RequestAction(ImporterWorkerAction action)
 {
     _actionBlock.Post(action);
     return(action.Completion);
 }
 /// <summary>
 /// Requests an <see cref="ImporterWorkerAction"/>
 /// </summary>
 /// <param name="action"><see cref="ImporterWorkerAction"/> to be requested</param>
 /// <returns><see cref="System.Threading.Tasks.Task"/> that completes when the <see cref="ImporterWorkerAction"/> is completed</returns>
 internal Task RequestAction(ImporterWorkerAction action)
 {
   _actionBlock.Post(action);
   return action.Completion;
 }
 /// <summary>
 /// Processes <see cref="ImporterWorkerAction"/>s posted to the <see cref="_actionBlock"/>
 /// </summary>
 /// <param name="action"><see cref="ImporterWorkerAction"/> to be processed</param>
 private void ProcessActionRequest(ImporterWorkerAction action)
 {
   try
   {
     switch (action.Type)
     {
       case ImporterWorkerAction.ActionType.Startup:
         DoStartup();
         break;
       case ImporterWorkerAction.ActionType.Activate:
         DoActivate(action.MediaBrowsingCallback, action.ImportResultHandler);
         break;
       case ImporterWorkerAction.ActionType.ScheduleImport:
         DoScheduleImport(action.JobInformation.GetValueOrDefault());
         break;
       case ImporterWorkerAction.ActionType.CancelImport:
         DoCancelImport(action.JobInformation);
         break;
       case ImporterWorkerAction.ActionType.Suspend:
         DoSuspend();
         break;
       case ImporterWorkerAction.ActionType.Shutdown:
         DoShutdown();
         break;
     }
     action.Complete();
   }
   catch (Exception ex)
   {
     ServiceRegistration.Get<ILogger>().Error("ImporterWorker: Error while processing Action of type {0}", ex, action.Type);
     action.Fault(ex);
   }
 }