/// <summary>
 /// Initializes a new instance of the <see cref="NotificationService"/> class.
 /// </summary>
 /// <param name="encodeService">
 /// The encode Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The queue Processor.
 /// </param>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 public NotificationService(IEncodeServiceWrapper encodeService, IQueueProcessor queueProcessor, IUserSettingService userSettingService)
 {
     this.userSettingService = userSettingService;
     encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
     queueProcessor.QueueCompleted += this.QueueProcessorQueueCompleted;
     GrowlCommunicator.Register();
 }
Esempio n. 2
0
 public DDPClient(IDdpConnector connector, IQueueProcessor<string> queueProcessor)
 {
     _connector = connector;
     _queueHandler = queueProcessor;
     _connector.OnMessageReceived += (sender, args) => _queueHandler.QueueItem(args.Message);
     _uniqueId = 1;
 }
Esempio n. 3
0
        /// <summary>
        /// Checks with the use if this window can be closed.
        /// </summary>
        /// <returns>
        /// Returns true if the window can be closed.
        /// </returns>
        public bool CanClose()
        {
            IQueueProcessor processor = IoC.Get <IQueueProcessor>();

            if (processor != null && processor.EncodeService.IsEncoding)
            {
                MessageBoxResult result =
                    errorService.ShowMessageBox(
                        "An Encode is currently running. Exiting HandBrake will stop this encode.\nAre you sure you wish to continue?",
                        Resources.Warning,
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Warning);

                if (result == MessageBoxResult.Yes)
                {
                    processor.Pause();
                    processor.EncodeService.Stop();
                    if (this.MainViewModel != null)
                    {
                        this.MainViewModel.Shutdown();
                    }

                    return(true);
                }
                return(false);
            }

            if (this.MainViewModel != null)
            {
                this.MainViewModel.Shutdown();
            }
            return(true);
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationService"/> class.
 /// </summary>
 /// <param name="encodeService">
 /// The encode Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The queue Processor.
 /// </param>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 public NotificationService(IEncodeServiceWrapper encodeService, IQueueProcessor queueProcessor, IUserSettingService userSettingService)
 {
     this.userSettingService        = userSettingService;
     encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
     queueProcessor.QueueCompleted += this.QueueProcessorQueueCompleted;
     GrowlCommunicator.Register();
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
 /// </summary>
 /// <param name="windowManager">
 /// The window manager.
 /// </param>
 /// <param name="queueProcessor">
 /// The Queue Processor Service
 /// </param>
 /// <param name="errorService">
 /// The Error Service
 /// </param>
 public QueueViewModel(IWindowManager windowManager, IQueueProcessor queueProcessor, IErrorService errorService)
 {
     this.queueProcessor = queueProcessor;
     this.errorService   = errorService;
     this.Title          = "Queue";
     this.JobsPending    = "No encodes pending";
     this.JobStatus      = "There are no jobs currently encoding";
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
 /// </summary>
 /// <param name="windowManager">
 /// The window manager.
 /// </param>
 /// <param name="queueProcessor"> 
 /// The Queue Processor Service 
 /// </param>
 /// <param name="errorService"> 
 /// The Error Service 
 /// </param>
 public QueueViewModel(IWindowManager windowManager, IQueueProcessor queueProcessor, IErrorService errorService)
 {
     this.queueProcessor = queueProcessor;
     this.errorService = errorService;
     this.Title = "Queue";
     this.JobsPending = "No encodes pending";
     this.JobStatus = "There are no jobs currently encoding";
 }
Esempio n. 7
0
 internal DiskWatcher(
     IFileSystemWatcherWrapper fileSystemWatcherWrapper,
     IWebLogger logger, IQueueProcessor queueProcessor)
 {
     _fileSystemWatcherWrapper = fileSystemWatcherWrapper;
     _webLogger      = logger;
     _queueProcessor = queueProcessor;
 }
 public SpfRecordProcessor(IQueueProcessor <Message> queueProcessor,
                           ISpfConfigReadModelDao dao,
                           ISpfConfigParser configParser)
 {
     _queueProcessor = queueProcessor;
     _dao            = dao;
     _configParser   = configParser;
 }
 public DmarcRecordProcessor(IQueueProcessor <Message> queueProcessor,
                             IDmarcConfigReadModelDao dmarcConfigReadModelDao,
                             IDmarcConfigParser dmarcConfigParser)
 {
     _queueProcessor          = queueProcessor;
     _dmarcConfigReadModelDao = dmarcConfigReadModelDao;
     _dmarcConfigParser       = dmarcConfigParser;
 }
Esempio n. 10
0
 public EncodeViewModel(IShellViewModel shellViewModel, IWindowManager windowManager, IQueueProcessor queueProcessor, IAppConfigService appConfig)
 {
     _shellViewModel = shellViewModel;
     _queueProcessor = queueProcessor;
     _appConfig      = appConfig;
     WindowManager   = windowManager;
     WindowTitle     = "Encoding";
 }
Esempio n. 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MiniViewModel"/> class.
        /// </summary>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="queueProcessor">
        /// The queue Processor.
        /// </param>
        public MiniViewModel(IEncode encodeService, IQueueProcessor queueProcessor)
        {
            this.encodeService  = encodeService;
            this.queueProcessor = queueProcessor;

            this.Task        = "Ready";
            this.Progress    = string.Empty;
            this.QueueStatus = string.Format("{0} jobs pending", this.queueProcessor.Count);
        }
Esempio n. 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrePostActionService"/> class.
        /// </summary>
        /// <param name="queueProcessor">
        /// The queue processor.
        /// </param>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService)
        {
            this.queueProcessor     = queueProcessor;
            this.userSettingService = userSettingService;

            this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
            this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
            this.queueProcessor.EncodeService.EncodeStarted   += EncodeService_EncodeStarted;
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
 /// </summary>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The Queue Processor Service
 /// </param>
 /// <param name="errorService">
 /// The Error Service
 /// </param>
 public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
 {
     this.userSettingService = userSettingService;
     this.queueProcessor     = queueProcessor;
     this.errorService       = errorService;
     this.Title       = "Queue";
     this.JobsPending = "No encodes pending";
     this.JobStatus   = "There are no jobs currently encoding";
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PrePostActionService"/> class.
        /// </summary>
        /// <param name="queueProcessor">
        /// The queue processor.
        /// </param>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService)
        {
            this.queueProcessor = queueProcessor;
            this.userSettingService = userSettingService;

            this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
            this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
            this.queueProcessor.EncodeService.EncodeStarted += EncodeService_EncodeStarted;
        }
        public AggregateReportProcessor()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            ILogger   log       = new LambdaLoggerAdaptor();

            _queueProcessor = AggregateReportParserLambdaFactory.Create(log);
            log.Debug($"Creating parser took: {stopwatch.Elapsed}");
            stopwatch.Stop();
        }
 public IntegrationEventBus(
     IQueueProcessor queueProcessor,
     IServiceProvider serviceProvider,
     IIntegrationEventTopicMapping integrationEventTopicMapping)
 {
     _serviceProvider = serviceProvider;
     _queueProcessor  = queueProcessor;
     _integrationEventTopicMapping = integrationEventTopicMapping;
 }
Esempio n. 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MiniViewModel"/> class.
        /// </summary>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="queueProcessor">
        /// The queue Processor.
        /// </param>
        public MiniViewModel(IEncode encodeService, IQueueProcessor queueProcessor)
        {
            this.encodeService = encodeService;
            this.queueProcessor = queueProcessor;

            this.Task = "Ready";
            this.Progress = string.Empty;
            this.QueueStatus = string.Format("{0} jobs pending", this.queueProcessor.Count);
        }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
 /// </summary>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The Queue Processor Service 
 /// </param>
 /// <param name="errorService">
 /// The Error Service 
 /// </param>
 public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
 {
     this.userSettingService = userSettingService;
     this.queueProcessor = queueProcessor;
     this.errorService = errorService;
     this.Title = "Queue";
     this.JobsPending = "No encodes pending";
     this.JobStatus = "There are no jobs currently encoding";
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
 /// </summary>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The Queue Processor Service
 /// </param>
 /// <param name="errorService">
 /// The Error Service
 /// </param>
 public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
 {
     this.userSettingService = userSettingService;
     this.queueProcessor     = queueProcessor;
     this.errorService       = errorService;
     this.Title         = Resources.QueueViewModel_Queue;
     this.JobsPending   = Resources.QueueViewModel_NoEncodesPending;
     this.JobStatus     = Resources.QueueViewModel_NoJobsPending;
     this.SelectedItems = new BindingList <QueueTask>();
 }
Esempio n. 20
0
        public DiskWatcher(IFileSystemWatcherWrapper fileSystemWatcherWrapper,
                           IServiceScopeFactory scopeFactory)
        {
            _fileSystemWatcherWrapper = fileSystemWatcherWrapper;
            var serviceProvider = scopeFactory.CreateScope().ServiceProvider;

            _webLogger = serviceProvider.GetService <IWebLogger>();
            var memoryCache = serviceProvider.GetService <IMemoryCache>();

            _queueProcessor = new QueueProcessor(scopeFactory, new SyncWatcherConnector(scopeFactory).Sync, memoryCache);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="QueueProcessorService"/> class.
        /// </summary>
        public QueueProcessorService()
        {
            this.InitializeComponent();

            started = false;
            lockObject = new object();
            this.settings = new Settings();
            this.logger = LogManager.GetLogger("EmailService.Logger");
            var dataAdapter = new DataAdapter(this.settings.ConnectionString, this.logger, this.settings.NextAttemptInterval);
            this.processor = new SendGridQueueProcessor(this.logger, dataAdapter, this.settings);
        }
Esempio n. 22
0
 public UpdateCoinbaseAccountsQueueListener(ILogger <UpdateCoinbaseAccountsQueueListener> logger,
                                            IConfiguration configuration,
                                            UpdateCoinbaseAccountsCommand command,
                                            IQueueProcessor queueProcessor,
                                            TelemetryClient telemetryClient) : base(logger,
                                                                                    configuration,
                                                                                    command,
                                                                                    queueProcessor,
                                                                                    telemetryClient)
 {
 }
Esempio n. 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrePostActionService"/> class.
        /// </summary>
        /// <param name="queueProcessor">
        /// The queue processor.
        /// </param>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        /// <param name="windowManager">
        /// The window Manager.
        /// </param>
        public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService, IWindowManager windowManager, IScan scanService)
        {
            this.queueProcessor     = queueProcessor;
            this.userSettingService = userSettingService;
            this.windowManager      = windowManager;
            this.scanService        = scanService;

            this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
            this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
            this.queueProcessor.EncodeService.EncodeStarted   += EncodeService_EncodeStarted;
        }
Esempio n. 24
0
 public FindSymbolViewModel(
     IDispatcherHelper dispatcherHelper,
     IQueueProcessor queueProcessor,
     IFindSymbolService findSymbolService,
     OrdersListViewModel ordersListViewModel)
     : base(dispatcherHelper, queueProcessor)
 {
     _findSymbolService      = findSymbolService;
     OrdersListViewModel     = ordersListViewModel;
     Symbol.PropertyChanged += OnSymbolPropertyChanged;
 }
Esempio n. 25
0
 public IntegrationRetryBackgroundService(
     IServiceProvider services,
     IQueueProcessor queueProcessor,
     IIntegrationEventTopicMapping topicMapping,
     IConfiguration configuration)
 {
     _services       = services;
     _queueProcessor = queueProcessor;
     _topicMapping   = topicMapping;
     IntegrationEventRetryIntervalInMinute = configuration.GetValue <int>("IntegrationEventRetryIntervalInMinute");
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
        /// </summary>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        /// <param name="queueProcessor">
        /// The Queue Processor Service 
        /// </param>
        /// <param name="errorService">
        /// The Error Service 
        /// </param>
        public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
        {
            this.userSettingService = userSettingService;
            this.queueProcessor = queueProcessor;
            this.errorService = errorService;
            this.Title = Resources.QueueViewModel_Queue;
            this.JobsPending = Resources.QueueViewModel_NoEncodesPending;
            this.JobStatus = Resources.QueueViewModel_NoJobsPending;
            this.SelectedItems = new BindingList<QueueTask>();
            this.DisplayName = "Queue";

            this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);
        }
Esempio n. 27
0
 public NewOrderViewModelFactory(
     IDispatcherHelper dispatcherHelper,
     IQueueProcessor queueProcessor,
     IFindSymbolService findSymbolService,
     IOrderCalculationService orderCalculationService,
     IOrderManager orderManager)
 {
     _dispatcherHelper        = dispatcherHelper;
     _queueProcessor          = queueProcessor;
     _findSymbolService       = findSymbolService;
     _orderCalculationService = orderCalculationService;
     _orderManager            = orderManager;
 }
Esempio n. 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
        /// </summary>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        /// <param name="queueProcessor">
        /// The Queue Processor Service
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
        {
            this.userSettingService = userSettingService;
            this.queueProcessor     = queueProcessor;
            this.errorService       = errorService;
            this.Title         = Resources.QueueViewModel_Queue;
            this.JobsPending   = Resources.QueueViewModel_NoEncodesPending;
            this.JobStatus     = Resources.QueueViewModel_NoJobsPending;
            this.SelectedItems = new BindingList <QueueTask>();
            this.DisplayName   = "Queue";

            this.WhenDoneAction = this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction);
        }
Esempio n. 29
0
 public NewOrderViewModel(
     IDispatcherHelper dispatcherHelper,
     IQueueProcessor queueProcessor,
     IFindSymbolService findSymbolService,
     IOrderCalculationService orderCalculationService,
     IOrderManager orderManager)
     : base(dispatcherHelper, queueProcessor)
 {
     Symbol.PropertyChanged  += OnSymbolPropertyChanged;
     _findSymbolService       = findSymbolService;
     _orderCalculationService = orderCalculationService;
     _orderManager            = orderManager;
     Messenger.Default.Register <AccountSummary>(this, msg => _accountId = msg.AccountId);
     Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Orders, OnOrderStatusChangedMessage);
 }
Esempio n. 30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmQueue"/> class.
        /// </summary>
        /// <param name="q">
        /// An instance of the queue service.
        /// </param>
        /// <param name="mw">
        /// The main window.
        /// </param>
        public frmQueue(IQueueProcessor q, frmMain mw)
        {
            InitializeComponent();

            this.mainWindow = mw;

            this.queue = q;
            queue.EncodeService.EncodeStarted += this.QueueOnEncodeStart;
            queue.QueueCompleted += this.QueueOnQueueFinished;
            queue.QueuePaused += this.QueueOnPaused;
            queue.QueueManager.QueueChanged += new EventHandler(queue_QueueListChanged);

            queue.EncodeService.EncodeStarted += this.queue_EncodeStarted;
            queue.EncodeService.EncodeCompleted += this.queue_EncodeEnded;

            drp_completeOption.Text = Properties.Settings.Default.CompletionOption;
        }
Esempio n. 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmQueue"/> class.
        /// </summary>
        /// <param name="q">
        /// An instance of the queue service.
        /// </param>
        /// <param name="mw">
        /// The main window.
        /// </param>
        public frmQueue(IQueueProcessor q, frmMain mw)
        {
            InitializeComponent();

            this.mainWindow = mw;

            this.queue = q;
            queue.EncodeService.EncodeStarted += this.QueueOnEncodeStart;
            queue.QueueCompleted += this.QueueOnQueueFinished;
            queue.QueuePaused += this.QueueOnPaused;
            queue.QueueManager.QueueChanged += this.queue_QueueListChanged;

            queue.EncodeService.EncodeStarted += this.queue_EncodeStarted;
            queue.EncodeService.EncodeCompleted += this.queue_EncodeEnded;

            drp_completeOption.Text = userSettingService.GetUserSettingString(UserSettingConstants.WhenCompleteAction);
        }
Esempio n. 32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmQueue"/> class.
        /// </summary>
        /// <param name="q">
        /// An instance of the queue service.
        /// </param>
        /// <param name="mw">
        /// The main window.
        /// </param>
        public frmQueue(IQueueProcessor q, frmMain mw)
        {
            InitializeComponent();

            this.mainWindow = mw;

            this.queue = q;
            queue.EncodeService.EncodeStarted += this.QueueOnEncodeStart;
            queue.QueueCompleted            += this.QueueOnQueueFinished;
            queue.QueuePaused               += this.QueueOnPaused;
            queue.QueueManager.QueueChanged += new EventHandler(queue_QueueListChanged);

            queue.EncodeService.EncodeStarted   += this.queue_EncodeStarted;
            queue.EncodeService.EncodeCompleted += this.queue_EncodeEnded;

            drp_completeOption.Text = userSettingService.GetUserSettingString(UserSettingConstants.WhenCompleteAction);
        }
Esempio n. 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmQueue"/> class.
        /// </summary>
        /// <param name="q">
        /// An instance of the queue service.
        /// </param>
        /// <param name="mw">
        /// The main window.
        /// </param>
        public frmQueue(IQueueProcessor q, frmMain mw)
        {
            InitializeComponent();

            this.mainWindow = mw;

            this.queue = q;
            queue.EncodeService.EncodeStarted += this.QueueOnEncodeStart;
            queue.QueueCompleted            += this.QueueOnQueueFinished;
            queue.QueuePaused               += this.QueueOnPaused;
            queue.QueueManager.QueueChanged += new EventHandler(queue_QueueListChanged);

            queue.EncodeService.EncodeStarted   += this.queue_EncodeStarted;
            queue.EncodeService.EncodeCompleted += this.queue_EncodeEnded;

            drp_completeOption.Text = Properties.Settings.Default.CompletionOption;
        }
 public OrdersListViewModel(
     IDispatcherHelper dispatcherHelper,
     IQueueProcessor queueProcessor,
     INewOrderViewModelFactory newOrderViewModelFactory,
     ITradeRepository tradeRepository,
     IMarketDataManager marketDataManager)
     : base(dispatcherHelper, queueProcessor)
 {
     _newOrderViewModelFactory = newOrderViewModelFactory;
     _tradeRepository          = tradeRepository;
     _marketDataManager        = marketDataManager;
     PopulateDirectionList();
     Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Orders, OnOrderStatusChangedMessage);
     Messenger.Default.Register <BarPriceMessage>(this, HandleBarPriceMessage);
     Orders = new ObservableCollectionNoReset <NewOrderViewModel>(dispatcherHelper: DispatcherHelper);
     Orders.CollectionChanged += OnOrdersCollectionChanged;
 }
Esempio n. 35
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        public MainViewModel()
        {
            // Setup Services
            this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 36
0
        /// <summary>
        /// Recover a queue from file.
        /// </summary>
        /// <param name="encodeQueue">
        /// The encode Queue.
        /// </param>
        public static void RecoverQueue(IQueueProcessor encodeQueue)
        {
            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");

            DialogResult  result     = DialogResult.None;
            List <string> queueFiles = CheckQueueRecovery();

            if (queueFiles.Count == 1)
            {
                result = MessageBox.Show(
                    "HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",
                    "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }
            else if (queueFiles.Count > 1)
            {
                result = MessageBox.Show(
                    "HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",
                    "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }

            if (result == DialogResult.Yes)
            {
                foreach (string file in queueFiles)
                {
                    encodeQueue.QueueManager.RestoreQueue(appDataPath + file); // Start Recovery
                }
            }
            else
            {
                if (GeneralUtilities.IsMultiInstance)
                {
                    return;                                   // Don't tamper with the files if we are multi instance
                }
                foreach (string file in queueFiles)
                {
                    if (File.Exists(Path.Combine(appDataPath, file)))
                    {
                        File.Delete(Path.Combine(appDataPath, file));
                    }
                }
            }
        }
Esempio n. 37
0
        public MainViewModel(IWindowManager windowManager) : base(windowManager)
        {
            // Setup Services (TODO - Bring Castle back into the project to wire these up for us)
            this.scanService    = File.Exists("hb.dll") ? (IScan) new LibScan() : new ScanService();
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
            this.presetService  = new PresetService();

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";

            // Setup Events
            this.scanService.ScanStared        += this.ScanStared;
            this.scanService.ScanCompleted     += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused    += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted       += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 38
0
        public MainViewModel(IWindowManager windowManager) : base(windowManager) 
        {
            // Setup Services (TODO - Bring Castle back into the project to wire these up for us)
            this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
            this.presetService = new PresetService();

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 39
0
        public PositionsViewModel(
            IDispatcherHelper dispatcherHelper,
            IMarketDataManager marketDataManager,
            IAccountManager accountManager,
            IPositionManager positionManager,
            IContractManager contractManager,
            IQueueProcessor queueProcessor,
            ITradeRecordingService tradeRecordingService)
            : base(dispatcherHelper, queueProcessor)
        {
            Positions = new ObservableCollectionNoReset <PositionItem>(dispatcherHelper: DispatcherHelper);

            Messenger.Default.Register <ConnectionChangingMessage>(this, HandleConnectionChangingMessage);
            Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Positions, OnOrderStatusChangedMessage);
            Messenger.Default.Register <BarPriceMessage>(this, HandleBarPriceMessage);

            _marketDataManager     = marketDataManager;
            _accountManager        = accountManager;
            _positionManager       = positionManager;
            _contractManager       = contractManager;
            _queueProcessor        = queueProcessor;
            _tradeRecordingService = tradeRecordingService;
        }
Esempio n. 40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstantViewModel"/> class.
        /// </summary>
        /// <param name="userSettingService">
        /// The user setting service.
        /// </param>
        /// <param name="scanService">
        /// The scan service.
        /// </param>
        /// <param name="encodeService">
        /// The encode service.
        /// </param>
        /// <param name="presetService">
        /// The preset service.
        /// </param>
        /// <param name="errorService">
        /// The error service.
        /// </param>
        /// <param name="shellViewModel">
        /// The shell view model.
        /// </param>
        /// <param name="updateService">
        /// The update service.
        /// </param>
        /// <param name="notificationService">
        /// The notification service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when done service.
        /// </param>
        public InstantViewModel(
            IUserSettingService userSettingService,
            IScan scanService,
            IEncodeServiceWrapper encodeService,
            IPresetService presetService,
            IErrorService errorService,
            IShellViewModel shellViewModel,
            IUpdateService updateService,
            INotificationService notificationService,
            IPrePostActionService whenDoneService)
        {
            this.userSettingService = userSettingService;
            this.scanService        = scanService;
            this.encodeService      = encodeService;
            this.presetService      = presetService;
            this.errorService       = errorService;
            this.shellViewModel     = shellViewModel;
            this.updateService      = updateService;

            this.queueProcessor = IoC.Get <IQueueProcessor>();

            // Setup Properties
            this.TitleList     = new BindingList <SelectionTitle>();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared              += this.ScanStared;
            this.scanService.ScanCompleted           += this.ScanCompleted;
            this.scanService.ScanStatusChanged       += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted       += this.QueueCompleted;
            this.queueProcessor.QueueChanged         += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;

            this.Presets           = this.presetService.Presets;
            this.CancelScanCommand = new CancelScanCommand(this.scanService);
        }
Esempio n. 41
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService)
            : base(windowManager)
        {
            this.userSettingService = userSettingService;
            this.scanService        = scanService;
            this.encodeService      = encodeService;
            this.presetService      = presetService;
            this.queueProcessor     = IoC.Get <IQueueProcessor>(); // TODO Instance ID!

            // Setup Properties
            this.WindowTitle   = "HandBrake WPF Test Application";
            this.CurrentTask   = new EncodeTask();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared        += this.ScanStared;
            this.scanService.ScanCompleted     += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused    += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted       += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
        public QueueResult ProcessQueueMessage(CloudQueueMessage cloudMessage, IQueueProcessor queueProcessor)
        {
            QueueMessage qMessage = GetQueueMessageFromCloudMessage(cloudMessage);
            QueueResult queueResult = new QueueResult();

            //test for poison message
            if (cloudMessage.DequeueCount > qMessage.MaxRetries)
            {
                // if poison clear poison message
                ClearPoisonMessage(cloudMessage);
                queueResult.Error = "Max retry count has been exceeded.";
                queueResult.Result = false;
                queueResult.Response = string.Empty;
            }
            else
            {
                //if not process queue message
                //make ProcessQueueMessageCall
                queueResult = queueProcessor.ProcessQueueMessage(qMessage.JsonMessage);

                if (string.IsNullOrEmpty(queueResult.Error))
                {
                    //archive message
                    ArchiveQueueMessage(qMessage);
                    //dequeue message
                    DequeueMessage(cloudMessage);
                }
            }
            return queueResult;
        }
Esempio n. 43
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService)
            : base(windowManager)
        {
            this.userSettingService = userSettingService;
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";
            this.CurrentTask = new EncodeTask();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="windowManager">
        /// The window Manager.
        /// </param>
        /// <param name="pictureSettingsViewModel">
        /// The picture Settings View Model.
        /// </param>
        /// <param name="videoViewModel">
        /// The video View Model.
        /// </param>
        /// <param name="filtersViewModel">
        /// The filters View Model.
        /// </param>
        /// <param name="audioViewModel">
        /// The audio View Model.
        /// </param>
        /// <param name="subtitlesViewModel">
        /// The subtitles View Model.
        /// </param>
        /// <param name="advancedViewModel">
        /// The advanced View Model.
        /// </param>
        /// <param name="chaptersViewModel">
        /// The chapters View Model.
        /// </param>
        /// <param name="staticPreviewViewModel">
        /// The static Preview View Model.
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService, 
            IErrorService errorService, IUpdateService updateService,
            IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel,
            IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel,
            IAdvancedViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.updateService = updateService;
            this.windowManager = windowManager;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            this.PictureSettingsViewModel = pictureSettingsViewModel;
            this.VideoViewModel = videoViewModel;
            this.FiltersViewModel = filtersViewModel;
            this.AudioViewModel = audioViewModel;
            this.SubtitleViewModel = subtitlesViewModel;
            this.ChaptersViewModel = chaptersViewModel;
            this.AdvancedViewModel = advancedViewModel;
            this.StaticPreviewViewModel = staticPreviewViewModel;

            // Setup Properties
            this.WindowTitle = Resources.HandBrake_Title;
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();
            this.HasSource = false;

            // Setup Events
            this.scanService.ScanStarted += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.Drives = new BindingList<SourceMenuItem>();

            HandBrakeInstanceManager.Init();
        }
 public QueueResult ProcessQueueMessage(IQueueProcessor queueProcessor)
 {
     return ProcessQueueMessage(GetQueueMessages(1).FirstOrDefault(), queueProcessor);
 }
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueViewModel"/> class.
 /// </summary>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The Queue Processor Service 
 /// </param>
 /// <param name="errorService">
 /// The Error Service 
 /// </param>
 public QueueViewModel(IUserSettingService userSettingService, IQueueProcessor queueProcessor, IErrorService errorService)
 {
     this.userSettingService = userSettingService;
     this.queueProcessor = queueProcessor;
     this.errorService = errorService;
     this.Title = Resources.QueueViewModel_Queue;
     this.JobsPending = Resources.QueueViewModel_NoEncodesPending;
     this.JobStatus = Resources.QueueViewModel_NoJobsPending;
     this.SelectedItems = new BindingList<QueueTask>();
 }
        public List<QueueResult> ProcessQueueMessages(List<CloudQueueMessage> messages, IQueueProcessor queueProcessor)
        {
            List<QueueResult> results = new List<QueueResult>();
            //loop messages
            foreach (CloudQueueMessage cloudMessage in messages)
                results.Add(ProcessQueueMessage(cloudMessage, queueProcessor));

            return results;
        }
Esempio n. 48
0
 /// <summary>
 /// Add a new named queue processor w/ the specified name.
 /// </summary>
 /// <param name="name">Name of queue processor.</param>
 /// <param name="processor">Instance of queue processor.</param>
 public static void AddProcessor(string name, IQueueProcessor processor)
 {
     _queues[name] = processor;
 }
Esempio n. 49
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
            IErrorService errorService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.queueProcessor = IoC.Get<IQueueProcessor>(); // TODO Instance ID!

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";
            this.CurrentTask = new EncodeTask();
            this.ScannedSource = new Source();
            this.SelectedPreset = this.presetService.DefaultPreset;

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 50
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationService"/> class.
 /// </summary>
 /// <param name="encodeService">
 /// The encode Service.
 /// </param>
 /// <param name="queueProcessor">
 /// The queue Processor.
 /// </param>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 public NotificationService(IEncodeServiceWrapper encodeService, IQueueProcessor queueProcessor, IUserSettingService userSettingService)
 {
     this.userSettingService = userSettingService;
        // encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted;
        // queueProcessor.QueueCompleted += this.QueueProcessorQueueCompleted;
 }
Esempio n. 51
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="shellViewModel">
        /// The shell View Model.
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="notificationService">
        /// The notification Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScanServiceWrapper scanService, IEncodeServiceWrapper encodeService, IPresetService presetService,
            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, INotificationService notificationService,
            IPrePostActionService whenDoneService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            // Setup Properties
            this.WindowTitle = "HandBrake";
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.CancelScanCommand = new CancelScanCommand(this.scanService);
        }
Esempio n. 52
0
        /// <summary>
        /// Recover a queue from file.
        /// </summary>
        /// <param name="encodeQueue">
        /// The encode Queue.
        /// </param>
        public static void RecoverQueue(IQueueProcessor encodeQueue)
        {
            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");

            DialogResult result = DialogResult.None;
            List<string> queueFiles = CheckQueueRecovery();
            if (queueFiles.Count == 1)
            {
                result = MessageBox.Show(
                        "HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",
                        "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }
            else if (queueFiles.Count > 1)
            {
                result = MessageBox.Show(
                        "HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",
                        "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            }

            if (result == DialogResult.Yes)
            {
                foreach (string file in queueFiles)
                {
                    encodeQueue.QueueManager.RestoreQueue(appDataPath + file); // Start Recovery
                }
            }
            else
            {
                if (GeneralUtilities.IsMultiInstance) return; // Don't tamper with the files if we are multi instance

                foreach (string file in queueFiles)
                {
                    if (File.Exists(Path.Combine(appDataPath, file)))
                        File.Delete(Path.Combine(appDataPath, file));
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InstantViewModel"/> class.
        /// </summary>
        /// <param name="userSettingService">
        /// The user setting service.
        /// </param>
        /// <param name="scanService">
        /// The scan service.
        /// </param>
        /// <param name="encodeService">
        /// The encode service.
        /// </param>
        /// <param name="presetService">
        /// The preset service.
        /// </param>
        /// <param name="errorService">
        /// The error service.
        /// </param>
        /// <param name="shellViewModel">
        /// The shell view model.
        /// </param>
        /// <param name="updateService">
        /// The update service.
        /// </param>
        /// <param name="notificationService">
        /// The notification service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when done service.
        /// </param>
        public InstantViewModel(
            IUserSettingService userSettingService,
            IScan scanService,
            IEncodeServiceWrapper encodeService,
            IPresetService presetService,
            IErrorService errorService,
            IShellViewModel shellViewModel,
            IUpdateService updateService,
            INotificationService notificationService,
            IPrePostActionService whenDoneService)
        {
            this.userSettingService = userSettingService;
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;

            this.queueProcessor = IoC.Get<IQueueProcessor>();

            // Setup Properties
            this.TitleList = new BindingList<SelectionTitle>();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;

            this.Presets = this.presetService.Presets;
            this.CancelScanCommand = new CancelScanCommand(this.scanService);
        }
        /// <summary>
        /// Recover a queue from file.
        /// </summary>
        /// <param name="encodeQueue">
        /// The encode Queue.
        /// </param>
        /// <param name="errorService">
        /// The error Service.
        /// </param>
        public static void RecoverQueue(IQueueProcessor encodeQueue, IErrorService errorService)
        {
            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");
            List<string> queueFiles = CheckQueueRecovery();
            MessageBoxResult result = MessageBoxResult.None;
            if (queueFiles.Count == 1)
            {
                result = errorService.ShowMessageBox(
                        "HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",
                        "Queue Recovery Possible", MessageBoxButton.YesNo, MessageBoxImage.Question);
            }
            else if (queueFiles.Count > 1)
            {
                result = MessageBox.Show(
                        "HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",
                        "Queue Recovery Possible", MessageBoxButton.YesNo, MessageBoxImage.Question);
            }

            if (result == MessageBoxResult.Yes)
            {
                foreach (string file in queueFiles)
                {
                    encodeQueue.RestoreQueue(appDataPath + file); // Start Recovery
                    if (!file.Contains(GeneralUtilities.ProcessId.ToString(CultureInfo.InvariantCulture)))
                    {
                        try
                        {
                            // Once we load it in, remove it as we no longer need it.
                            File.Delete(Path.Combine(appDataPath, file));
                        }
                        catch (Exception exc)
                        {
                            // Keep quite, nothing much we can do if there are problems.
                            // We will continue processing files.
                        }
                    }
                }
            }
            else
            {
                foreach (string file in queueFiles)
                {
                    if (File.Exists(Path.Combine(appDataPath, file)))
                    {
                        // Check that the file doesn't belong to another running instance.
                        Match m = Regex.Match(file, @"([0-9]+).xml");
                        if (m.Success)
                        {
                            int processId = int.Parse(m.Groups[1].ToString());
                            if (GeneralUtilities.IsPidACurrentHandBrakeInstance(processId))
                            {
                                continue;
                            }
                        }

                        // Delete it if it doesn't
                        File.Delete(Path.Combine(appDataPath, file));
                    }
                }
            }
        }
Esempio n. 55
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="windowManager">
        /// The window Manager.
        /// </param>
        /// <param name="pictureSettingsViewModel">
        /// The picture Settings View Model.
        /// </param>
        /// <param name="videoViewModel">
        /// The video View Model.
        /// </param>
        /// <param name="filtersViewModel">
        /// The filters View Model.
        /// </param>
        /// <param name="audioViewModel">
        /// The audio View Model.
        /// </param>
        /// <param name="subtitlesViewModel">
        /// The subtitles View Model.
        /// </param>
        /// <param name="advancedViewModel">
        /// The advanced View Model.
        /// </param>
        /// <param name="chaptersViewModel">
        /// The chapters View Model.
        /// </param>
        /// <param name="staticPreviewViewModel">
        /// The static Preview View Model.
        /// </param>
        /// <param name="queueViewModel">
        /// The queue View Model.
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService, 
            IErrorService errorService, IUpdateService updateService, 
            IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel, 
            IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel, 
            IAdvancedViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel,
            IQueueViewModel queueViewModel)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.updateService = updateService;
            this.windowManager = windowManager;
            this.QueueViewModel = queueViewModel;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            this.PictureSettingsViewModel = pictureSettingsViewModel;
            this.VideoViewModel = videoViewModel;
            this.FiltersViewModel = filtersViewModel;
            this.AudioViewModel = audioViewModel;
            this.SubtitleViewModel = subtitlesViewModel;
            this.ChaptersViewModel = chaptersViewModel;
            this.AdvancedViewModel = advancedViewModel;
            this.StaticPreviewViewModel = staticPreviewViewModel;

            // Setup Properties
            this.WindowTitle = Resources.HandBrake_Title;
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();
            this.HasSource = false;

            // Setup Events
            this.scanService.ScanStarted += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.Drives = new BindingList<SourceMenuItem>();

            // Set Process Priority
            switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority))
            {
                case "Realtime":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                    break;
                case "High":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                    break;
                case "Above Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                    break;
                case "Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                    break;
                case "Low":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                    break;
                default:
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                    break;
            }

            HandBrakeInstanceManager.Init();
        }
Esempio n. 56
0
 public JobProcessor(IQueueProcessor[] processors)
 {
     _queueProcessors = processors;
 }
Esempio n. 57
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>(); // TODO Instance ID!

            // Setup Properties
            this.WindowTitle = "HandBrake";
            this.CurrentTask = new EncodeTask();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;

            this.Presets = this.presetService.Presets;
        }
 public List<QueueResult> ProcessQueueMessages(int messageCount, IQueueProcessor queueProcessor)
 {
     return ProcessQueueMessages(GetQueueMessages(messageCount), queueProcessor);
 }