private void OnTick() { for (int i = 0; i < m_taskRunners.Length; ++i) { ITaskRunner taskRunner = m_taskRunners[i]; if (taskRunner != null) { taskRunner.Tick(); } } for (int i = 0; i < m_pathFinders.Length; ++i) { IPathFinder pathFinder = m_pathFinders[i]; if (pathFinder != null) { pathFinder.Tick(); } } for (int i = 0; i < m_taskEngines.Length; ++i) { ITaskEngine taskEngine = m_taskEngines[i]; if (taskEngine != null) { taskEngine.Tick(); } } }
public ConditionGroupsEditorViewModel(Func <IHistoryManager> historyCreator, IConditionDataProvider conditionDataProvider, IWindowManager windowManager, IMessageBoxService messageBoxService, ITaskRunner taskRunner) { this.conditionDataProvider = conditionDataProvider; this.windowManager = windowManager; this.messageBoxService = messageBoxService; SourceItems = new ObservableCollection <ConditionGroupsEditorData>(); foreach (var item in conditionDataProvider.GetConditionGroups()) { SourceItems.Add(new ConditionGroupsEditorData(in item)); } Save = new DelegateCommand(() => { taskRunner.ScheduleTask("Saving condition groups", SaveGroupsToFile); }, () => IsModified); AddGroup = new AsyncCommand(AddGroupToSource); DeleteItem = new DelegateCommand <object>(DeleteItemFromSource); AddMember = new AsyncCommand <ConditionGroupsEditorData>(AddItemToGroup); EditItem = new AsyncCommand <ConditionGroupsEditorData>(EditSourceItem); // history setup historyHandler = new ConditionGroupsEditorHistoryHandler(SourceItems !); History = historyCreator(); undoCommand = new DelegateCommand(History.Undo, () => History.CanUndo); redoCommand = new DelegateCommand(History.Redo, () => History.CanRedo); History.PropertyChanged += (sender, args) => { undoCommand.RaiseCanExecuteChanged(); redoCommand.RaiseCanExecuteChanged(); IsModified = !History.IsSaved; }; History.AddHandler(historyHandler); }
public CurrentMachineStateManager(IPerformanceManager performanceManager, IComponentProperties machineInfo, ITaskRunner <TJob> localBallancer) { this.performanceManager = performanceManager; this.machineInfo = machineInfo; this.localBallancer = localBallancer; }
protected BaseCallbackStore(IStoreProvider storeProvider, ITaskRunner taskRunner, ILogProvider logProvider, CancellationToken token) { Assert.IsNotNull(storeProvider, "Store Provider can't be null"); Assert.IsNotNull(taskRunner, "Task Runner can't be null"); Assert.IsNotNull(logProvider, "Log Provider can't be null"); this.singleAccessLock = new SemaphoreSlim(1); this.callbackMap = new Dictionary <NotifyFilter, IList <Func <ScenarioData, Task> > >(); this.Logger = logProvider.CreateLoggerInstance(this.GetType().ToString().Split('.').Last()); this.taskRunner = taskRunner; this.InternalTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); token = this.InternalTokenSource.Token; // Some signals may not show up immedietly so we don't want their last seen time bailing on us. this.callBackCheckPointTimeStore = storeProvider.CreatePersistentStoreForTimeAsync(CallbackTimeBookmarkStore, AgeBasedRetentionPolicy.OneDay, token) .GetAwaiter().GetResult(); // This store keeps track of unique Ids of signals seen to avoid duplicate reporting. The entries in this // collection needs to be long lived. Consider a signal that is living in the system for a long time // If we don't track that this has been reported, we may try to report it again. this.reportedSignalsUniqueIdsStore = storeProvider .CreatePersistentStoreKeyGuidValueStringAsync(ReportedSignalUniqueIdsStoreName, AgeBasedRetentionPolicy.OneWeek, token).GetAwaiter() .GetResult(); this.signalsInDispatchQueuePersistentStore = storeProvider .CreatePersistentStoreKeyGuidValueStringAsync(SignalsInDispatchQueueStoreName, AgeBasedRetentionPolicy.OneHour, token).GetAwaiter().GetResult(); this.producerConsumerBufferBlock = new BufferBlock <ScenarioNotificationData>(); this.InitSignalSeenBookmarkStoreAsync(token).Wait(token); }
public async Task <List <TaskRunnerInformation> > FindTasks( IWorkspaceFileObject workspaceFileObject, HashSet <FilePath> filesAdded) { List <TaskRunnerInformation> foundTasks = null; foreach (FilePath configFile in GetFiles(workspaceFileObject)) { if (!filesAdded.Contains(configFile)) { ITaskRunner runner = taskRunnerProvider.GetTaskRunner(configFile); if (runner != null) { ITaskRunnerConfig config = await runner.ParseConfig(null, configFile); var info = new TaskRunnerInformation(workspaceFileObject, config, runner.Options, configFile); if (foundTasks == null) { foundTasks = new List <TaskRunnerInformation> (); } foundTasks.Add(info); filesAdded.Add(configFile); } } } return(foundTasks); }
public void Execute(ITaskRunner taskRunner) { ProductFile file = taskRunner.GetProductFile(GeneratePreviewPolishFileTask.PolishPreviewFile); if (file == null) { consoleLogger.WriteLine(log, Level.Warn, "WARNING: there is no polish preview file to process, preview file will not be generated"); return; } taskRunner.RunCPreview( "\"{0}\"", file.ProductFileName); string previewIntermediateFile = Path.GetFullPath( Path.Combine( taskRunner.MapMakerSettings.TempDir, String.Format( CultureInfo.InvariantCulture, "{0}.mp", taskRunner.MapMakerSettings.ProductCode))); taskRunner.RunCGpsMapper( "\"{0}\"", previewIntermediateFile); taskRunner.RegisterProductFile(new ProductFile(PreviewImgFile, Path.ChangeExtension(previewIntermediateFile, ".img"), false)); taskRunner.RegisterProductFile(new ProductFile(TdbFile, Path.ChangeExtension(previewIntermediateFile, ".tdb"), false)); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool disposing) { if (m_Disposed) { return; } if (disposing) { try { if (TaskRunners != null) { for (int i = 0; i < TaskRunners.Count; i++) { ITaskRunner taskRunner = TaskRunners[i]; taskRunner.Dispose(); } } } finally { m_IsRunning = false; m_Disposed = true; } } }
public DbcStore(IParameterFactory parameterFactory, ITaskRunner taskRunner, IDbcSettingsProvider settingsProvider, IMessageBoxService messageBoxService, IEventAggregator eventAggregator, ICurrentCoreVersion currentCoreVersion, NullSpellService nullSpellService, CataSpellService cataSpellService, WrathSpellService wrathSpellService, DBCD.DBCD dbcd) { this.parameterFactory = parameterFactory; this.taskRunner = taskRunner; dbcSettingsProvider = settingsProvider; this.messageBoxService = messageBoxService; this.eventAggregator = eventAggregator; this.currentCoreVersion = currentCoreVersion; this.nullSpellService = nullSpellService; this.cataSpellService = cataSpellService; this.wrathSpellService = wrathSpellService; this.dbcd = dbcd; spellServiceImpl = nullSpellService; Load(); }
public void GuidIndexer_IsNotExisting_ReturnNull() { runners.AddRange(new TaskRunner("Test1", () => { })); ITaskRunner taskRunner = runners[Guid.Empty]; taskRunner.Should().BeNull(); }
/// <summary> /// </summary> /// <param name="runtime"></param> /// <param name="token"></param> protected BaseCallbackStore(IInsightRuntime runtime, CancellationToken token) { this.singleAccessLock = new SemaphoreSlim(1); this.callbackMap = new Dictionary <NotifyFilter, IList <Func <ScenarioData, Task> > >(); this.Runtime = runtime; string typeName = this.GetType().ToString(); this.Logger = this.Runtime.GetLogProvider().CreateLoggerInstance(typeName.Split('.').Last()); this.taskRunner = runtime.TaskRunner; this.InternalTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); token = this.InternalTokenSource.Token; this.Query = this.Runtime.GetService(typeof(IClusterQuery)) as IClusterQuery; Assert.IsNotNull(this.Query, "Runtime doesn't contain valid Cluster Query object"); // Some signals may not show up immedietly so we don't want their last seen time bailing on us. this.signalSeenTillThisTimeStore = this.Runtime.GetStoreProvider() .CreatePersistentStoreForTimeAsync(SignalSeenTillTimeStoreName, AgeBasedRetentionPolicy.TwoWeek, token).GetAwaiter().GetResult(); // This store keeps track of unique Ids of signals seen to avoid duplicate reporting. The entries in this // collection needs to be long lived. Consider a signal that is living in the system for a long time // If we don't track that this has been reported, we may try to report it again. this.reportedSignalsUniqueIdsStore = this.Runtime.GetStoreProvider() .CreatePersistentStoreForIntAsync(ReportedSignalUniqueIdsStoreName, AgeBasedRetentionPolicy.OneWeek, token).GetAwaiter().GetResult(); this.signalsInDispatchQueuePersistentStore = this.Runtime.GetStoreProvider() .CreatePersistentStoreForStringsAsync(SignalsInDispatchQueueStoreName, AgeBasedRetentionPolicy.OneHour, token).GetAwaiter().GetResult(); this.producerConsumerBufferBlock = new BufferBlock <ScenarioNotificationData>(); this.InitSignalSeenBookmarkStoreAsync(token).Wait(token); }
private SqlEditorViewModel(IMySqlExecutor mySqlExecutor, IStatusBar statusBar, IDatabaseProvider databaseProvider, ITaskRunner taskRunner, INativeTextDocument sql) { Code = sql; ExecuteSql = new DelegateCommand(() => { taskRunner.ScheduleTask("Executing query", async() => { statusBar.PublishNotification(new PlainNotification(NotificationType.Info, "Executing query")); try { await mySqlExecutor.ExecuteSql(Code.ToString()); statusBar.PublishNotification(new PlainNotification(NotificationType.Success, "Query executed")); } catch (Exception e) { statusBar.PublishNotification(new PlainNotification(NotificationType.Error, "Failure during query execution")); Console.WriteLine(e); } }); }, () => databaseProvider.IsConnected); IsLoading = false; Save = new DelegateCommand(() => { ExecuteSql.Execute(null); }); }
public InjectionConfigurationViewModelFactory( DomainActionBuilder actionBuilder, ComponentViewModelFactory componentViewModelFactory, IFindFirstLaunchTimeQuery findFirstLaunchTimeQuery, IFindGamePackageByIdQuery findGamePackageByIdQuery, IFindGamesQuery findGamesQuery, IFindLastEditedGamePackageQuery findLastEditedGamePackageQuery, IDirectoryPicker directoryPicker, IEqualityComparer <ProxySettings> stateEqualityComparer, IEventPublisher eventPublisher, IFilePicker filePicker, IPluginFactory pluginFactory, INavigationService navigationService, ITaskRunner runner) { _actionBuilder = actionBuilder; _componentViewModelFactory = componentViewModelFactory; _findFirstLaunchTimeQuery = findFirstLaunchTimeQuery; _findGamePackageByIdQuery = findGamePackageByIdQuery; _findGamesQuery = findGamesQuery; _findLastEditedGamePackageQuery = findLastEditedGamePackageQuery; _directoryPicker = directoryPicker; _stateEqualityComparer = stateEqualityComparer; _eventPublisher = eventPublisher; _filePicker = filePicker; _pluginFactory = pluginFactory; _navigationService = navigationService; _runner = runner; }
public ConditionsDefinitionEditorViewModel(Func <IHistoryManager> historyCreator, IConditionDataProvider conditionDataProvider, IWindowManager windowManager, ITaskRunner taskRunner, IParameterFactory parameterFactory) { this.conditionDataProvider = conditionDataProvider; SourceItems = new ObservableCollection <ConditionJsonData>(conditionDataProvider.GetConditions().ToList()); this.windowManager = windowManager; this.parameterFactory = parameterFactory; SelectedIndex = -1; Save = new DelegateCommand(() => { taskRunner.ScheduleTask("Saving conditions definition list", SaveConditions); }, () => IsModified); Delete = new DelegateCommand(DeleteItem); AddItem = new AsyncCommand(AddNewItem); EditItem = new AsyncCommand <ConditionJsonData?>(EditCondition); // history setup historyHandler = new ConditionsEditorHistoryHandler(SourceItems); History = historyCreator(); undoCommand = new DelegateCommand(History.Undo, () => History.CanUndo); redoCommand = new DelegateCommand(History.Redo, () => History.CanRedo); History.PropertyChanged += (sender, args) => { undoCommand.RaiseCanExecuteChanged(); redoCommand.RaiseCanExecuteChanged(); IsModified = !History.IsSaved; }; History.AddHandler(historyHandler); }
public Host(IBusConfig busConfig, ITaskRunner taskRunner) { this.busConfig = busConfig ?? throw new ArgumentNullException(nameof(busConfig)); this.taskRunner = taskRunner ?? throw new ArgumentNullException(nameof(taskRunner)); ConfigureLogging(); }
public Synchronizer(ITaskRunner taskRunner, IPlanetRunner planetRunner, IMotherRunner motherRunner, IServiceProvider svp) { _svp = svp; _taskRunner = taskRunner; _planetRunner = planetRunner; _motherRunner = motherRunner; }
private void Update() { for (int i = 0; i < m_taskRunners.Length; ++i) { ITaskRunner taskRunner = m_taskRunners[i]; if (taskRunner != null) { taskRunner.Update(); } } for (int i = 0; i < m_pathFinders.Length; ++i) { IPathFinder pathFinder = m_pathFinders[i]; if (pathFinder != null) { pathFinder.Update(); } } if (m_bots != null) { for (int i = 0; i < m_bots.Length; ++i) { IBotController bot = m_bots[i]; if (bot != null) { bot.Update(Time.realtimeSinceStartup); } } } }
private static RetryingTaskRunner SutFactoryWithNext(ITaskRunner next) { return(SutFactory( next, 0, TimeSpan.Zero)); }
public Bus(IBroker broker, ITaskRunner taskRunner, ISubscriptionManager subscriptionManager, ILogger <Bus> logger) { this.broker = broker ?? throw new ArgumentNullException(nameof(broker)); this.taskRunner = taskRunner ?? throw new ArgumentNullException(nameof(taskRunner)); this.subscriptionManager = subscriptionManager ?? throw new ArgumentNullException(nameof(subscriptionManager)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public SmartDataEditorsProvider(ISmartRawDataProvider smartDataProvider, IParameterFactory parameterFactory, ISmartDataManager smartDataManager, ITaskRunner taskRunner, IMessageBoxService messageBoxService, IWindowManager windowManager, Func <IHistoryManager> historyCreator) { var editors = new List <IMenuItem> { new SmartDataCategoryMenuItemProvider <SmartDataDefinesListViewModel>("Events", new object[] { smartDataProvider, smartDataManager, parameterFactory, taskRunner, messageBoxService, windowManager, historyCreator, SmartDataSourceMode.SD_SOURCE_EVENTS }), new SmartDataCategoryMenuItemProvider <SmartDataDefinesListViewModel>("Actions", new object[] { smartDataProvider, smartDataManager, parameterFactory, taskRunner, messageBoxService, windowManager, historyCreator, SmartDataSourceMode.SD_SOURCE_ACTIONS }), new SmartDataCategoryMenuItemProvider <SmartDataDefinesListViewModel>("Targets", new object[] { smartDataProvider, smartDataManager, parameterFactory, taskRunner, messageBoxService, windowManager, historyCreator, SmartDataSourceMode.SD_SOURCE_TARGETS }), new SmartDataCategoryMenuItemProvider <SmartDataGroupsEditorViewModel>("Event Groups", new object[] { smartDataProvider, taskRunner, messageBoxService, windowManager, historyCreator, SmartDataSourceMode.SD_SOURCE_EVENTS }), new SmartDataCategoryMenuItemProvider <SmartDataGroupsEditorViewModel>("Action Groups", new object[] { smartDataProvider, taskRunner, messageBoxService, windowManager, historyCreator, SmartDataSourceMode.SD_SOURCE_ACTIONS }), new SmartDataCategoryMenuItemProvider <SmartDataGroupsEditorViewModel>("Target Groups", new object[] { smartDataProvider, taskRunner, messageBoxService, windowManager, historyCreator, SmartDataSourceMode.SD_SOURCE_TARGETS }), }; var saiCategory = new List <IMenuItem> { new SmartDataCategoryItem("Smart Scripts", editors) }; IMenuCategoryItem obj = new SmartDataCategoryItem("Smart Data", saiCategory); SubItems = new List <IMenuItem>() { obj }; }
private static RetryingTaskRunner SutFactory(ITaskRunner next, int retryCount, TimeSpan timeBetweenRetries) { return(new RetryingTaskRunner( next, retryCount, timeBetweenRetries)); }
public UpdateViewModel(IUpdateService updateService, ITaskRunner taskRunner, IStatusBar statusBar, IUpdaterSettingsProvider settingsProvider, IAutoUpdatePlatformService platformService, IFileSystem fileSystem, IStandaloneUpdater standaloneUpdater, IApplication application, IMessageBoxService messageBoxService) { this.updateService = updateService; this.taskRunner = taskRunner; this.statusBar = statusBar; this.settingsProvider = settingsProvider; this.platformService = platformService; this.fileSystem = fileSystem; this.messageBoxService = messageBoxService; CheckForUpdatesCommand = new DelegateCommand(() => { if (updateService.CanCheckForUpdates()) { taskRunner.ScheduleTask("Check for updates", UpdatesCheck); } }, updateService.CanCheckForUpdates); if (!settingsProvider.Settings.DisableAutoUpdates) { CheckForUpdatesCommand.Execute(null); } }
public DatabaseProvider(TrinityMySqlDatabaseProvider trinityDatabase, NullDatabaseProvider nullDatabaseProvider, IDatabaseSettingsProvider settingsProvider, IMessageBoxService messageBoxService, ITaskRunner taskRunner) : base(nullDatabaseProvider) { if (settingsProvider.Settings.IsEmpty) { return; } try { var cachedDatabase = new CachedDatabaseProvider(trinityDatabase, taskRunner); cachedDatabase.TryConnect(); impl = cachedDatabase; } catch (Exception e) { impl = nullDatabaseProvider; messageBoxService.ShowDialog(new MessageBoxFactory <bool>().SetTitle("Database error") .SetIcon(MessageBoxIcon.Error) .SetMainInstruction("Couldn't connect to the database") .SetContent(e.Message) .WithOkButton(true) .Build()); } }
public override bool Run() { Guard.AgainstException<RuntimeBinderException>(() => this.folderToWatch = parameters.FolderToWatch, "The FolderToWatch parameter was not found in the parameters. Ensure that the configuration file is correct."); Guard.Catch<RuntimeBinderException>(() => { if (bool.Parse(parameters.VerboseOutput)) { taskRunner = new VerboseOutputPluginRunner(taskRunner, notificationService); } }); if (!Directory.Exists(folderToWatch)) { notificationService.Notify(this.GetType().Name, String.Format("The directory {0} does not exist and cannot be watched", folderToWatch), NotificationType.Information); return false; } fileSystemWatcher = new FileSystemWatcher(folderToWatch, "*.*"); fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.EnableRaisingEvents = true; fileSystemWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; fileSystemWatcher.Changed += new FileSystemEventHandler(FileSystemChanged); fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemChanged); fileSystemWatcher.Renamed += FileSystemChanged; notificationService.Notify(String.Format("watching {0}", folderToWatch)); return true; }
public TextureManagementWindowViewModel( DomainActionBuilder actionBuilder, IDirectoryPicker directoryPicker, IEventPublisher eventPublisher, IFilePicker filePicker, IFindTextureManagementSettingsQuery findTextureManagementSettingsQuery, IImageProvider emptyImageProvider, ITaskRunner dispatcher) { _actionBuilder = actionBuilder; _directoryPicker = directoryPicker; _eventPublisher = eventPublisher; _filePicker = filePicker; _findTextureManagementSettingsQuery = findTextureManagementSettingsQuery; _eventPublisher.Register(this); StatusViewModel = new StatusViewModel(dispatcher); TexturePreview = new TexturePreviewViewModel(_actionBuilder, _eventPublisher, this, emptyImageProvider); AbortCommand = new ActionCommand(AbortConversion, IsAbortConversionEnabled); CheckAllCommand = new ActionCommand(CheckAll, IsCheckAllEnabled); ConvertMultiCommand = new ActionCommand(() => _queue.QueueTask(ConvertMultiAsync), IsMultiConversionEnabled); ConvertSingleCommand = new ActionCommand(() => _queue.QueueTask(ConvertSingleAsync), IsSingleConversionEnabled); MoveToDestinationDirectoryCommand = new ActionCommand(MoveToDestinationDirectory, () => !DestinationDirectory.IsNullOrEmpty()); MoveToSourceDirectoryCommand = new ActionCommand(MoveToSourceDirectory, () => !SourceDirectory.IsNullOrEmpty()); MultiChangedCommand = new ActionCommand(() => _queue.QueueTask(OnChangedAsync), () => true); PickDestinationDirectoryCommand = new ActionCommand(() => _queue.QueueTask(PickDestinationDirectoryAsync), () => true); PickSourceDirectoryCommand = new ActionCommand(() => _queue.QueueTask(PickSourceDirectoryAsync), () => true); SingleChangedCommand = new ActionCommand(() => _queue.QueueTask(OnSingleChangedAsync), () => true); UncheckAllCommand = new ActionCommand(UncheckAll, IsUncheckAllEnabled); }
public void Execute(ITaskRunner taskRunner) { string sendMapMapListFileName = Path.GetFullPath( Path.Combine( taskRunner.MapMakerSettings.TempDir, String.Format( CultureInfo.InvariantCulture, "filelist_{0}.txt", taskRunner.MapMakerSettings.ProductCode))); using (FileStream stream = File.Open(sendMapMapListFileName, FileMode.Create)) { using (StreamWriter writer = new StreamWriter(stream)) { writer.WriteLine(":region"); // first add the TYP file writer.WriteLine(Path.GetFileName( taskRunner.GetProductFile(GenerateTypeFileTask.TypeFile).ProductFileName)); foreach (ProductFile file in taskRunner.ListProductFiles(GenerateMapImgFilesTask.MapImgFileName)) { writer.WriteLine(Path.GetFileName(file.ProductFileName)); } } } taskRunner.RegisterProductFile(new ProductFile(SendMapListFileType, sendMapMapListFileName, false)); }
/// <summary> /// Start crawl process /// </summary> public virtual async Task CrawlAsync() { if (this.m_OnlyOneCrawlPerInstance) { throw new InvalidOperationException("Crawler instance cannot be reused"); } this.m_OnlyOneCrawlPerInstance = true; var parameters = new Parameter[] { new TypedParameter(typeof(Uri), this.m_BaseUri), new NamedParameter("crawlStart", this.m_BaseUri), new TypedParameter(typeof(Crawler), this), }; this.m_CrawlerQueue = this.m_LifetimeScope.Resolve <ICrawlerQueue>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ICrawlerQueue), this.m_CrawlerQueue)).ToArray(); this.m_CrawlerHistory = this.m_LifetimeScope.Resolve <ICrawlerHistory>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ICrawlerHistory), this.m_CrawlerHistory)).ToArray(); this.m_TaskRunner = this.m_LifetimeScope.Resolve <ITaskRunner>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ITaskRunner), this.m_TaskRunner)).ToArray(); this.m_Logger = this.m_LifetimeScope.Resolve <ILog>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ILog), this.m_Logger)).ToArray(); this.m_CrawlerRules = this.m_LifetimeScope.Resolve <ICrawlerRules>(parameters); this.m_Logger.Verbose("Crawl started @ {0}", this.m_BaseUri); this.m_WebDownloaderFactory = this.m_LifetimeScope.Resolve <Func <IWebDownloader> >(); using (this.m_CrawlCompleteEvent = new ManualResetEvent(false)) { this.m_Crawling = true; this.m_Runtime = Stopwatch.StartNew(); if (this.m_CrawlerQueue.Count > 0) { // Resume enabled ProcessQueue(); } else { await this.AddStepAsync(this.m_BaseUri, 0); } if (!this.m_CrawlStopped) { this.m_CrawlCompleteEvent.WaitOne(); } this.m_Runtime.Stop(); this.m_Crawling = false; } if (this.m_Cancelled) { OnCancelled(); } this.m_Logger.Verbose("Crawl ended @ {0} in {1}", this.m_BaseUri, this.m_Runtime.Elapsed); OnCrawlFinished(); }
private AsyncCommand(ITaskRunner <TParameter> runner, ICondition condition) : base(runner.Run, condition) { this.runner = runner; runner.ObservePropertyChangedSlim(nameof(runner.TaskCompletion)) .Subscribe(_ => this.OnPropertyChanged(nameof(this.Execution))); this.CancelCommand = new ConditionRelayCommand(runner.Cancel, runner.CanCancelCondition); }
/// <summary> /// 执行日志队列 /// </summary> /// <param name="runner">运行的目标Task</param> public void ExecLogQuenuen(ITaskRunner runner) { while (true) { SendQuenuenLog(runner); Thread.Sleep(1000); } }
public TaskHost(ITaskFactory factory, ITaskRunner runner, IWindowsServiceHandler windowsService, IScheduledTaskHandler scheduledTask, TextWriter textWriter) { this._factory = factory; this._runner = runner; this._windowsService = windowsService; this._scheduledTask = scheduledTask; this._textWriter = textWriter; }
public ExecuteTaskMessageHandler() { var runner = new TaskRunner(new TaskSerializer()); runner.LoadXamarinTasks(); this.runner = runner; }
public DbcStore(IParameterFactory parameterFactory, ITaskRunner taskRunner) { this.parameterFactory = parameterFactory; this.taskRunner = taskRunner; dbcSettingsProvider = new DbcSettingsProvider(); Load(); }
public TaskScheduler(ITimer timer, ITaskRunner taskRunner) { _timer = timer; _taskRunner = taskRunner; ProcessTimeout = 1000 * 60 * 10; Granularity = 1000 * 5; }
public RecordingManager(ILogger log, ISettingsProvider settingsProvider, IVlcDriver vlcDriver, ILinearJobManager linearJobManager, ITaskRunner taskRunner) { _log = log; _settingsProvider = settingsProvider; _vlcDriver = vlcDriver; _linearJobManager = linearJobManager; _taskRunner = taskRunner; _hmDirSource = new HumaxDirSource { Location = _settingsProvider.GetSetting("HumaxDirSource") }; }
public TaskExecutionController(SiteSettings siteSettings, ITaskRunner taskRunner) { _siteSettings = siteSettings; _taskRunner = taskRunner; }
public void PerTestSetUp() { _taskRunner = new TaskRunner(); }
/// <summary> /// Start crawl process /// </summary> public virtual void Crawl() { using (var stream = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "OriginalWebSite.txt", Encoding.UTF8)) { var jsonStr = stream.ReadToEnd(); var policy = new CacheItemPolicy(); policy.Priority = CacheItemPriority.NotRemovable; policy.AbsoluteExpiration = DateTimeOffset.Now.AddDays(1); cache.Set(AppDomain.CurrentDomain.BaseDirectory + "OriginalWebSite", jsonStr, policy); Console.WriteLine("cache --" + AppDomain.CurrentDomain.BaseDirectory + " :" + cache.Get(AppDomain.CurrentDomain.BaseDirectory + "OriginalWebSite")); } if (m_OnlyOneCrawlPerInstance) { throw new InvalidOperationException("Crawler instance cannot be reused"); } m_OnlyOneCrawlPerInstance = true; Parameter[] parameters = new Parameter[] { new TypedParameter(typeof (Uri), m_BaseUri), new NamedParameter("crawlStart", m_BaseUri), new TypedParameter(typeof (Crawler), this), }; m_CrawlerQueue = m_LifetimeScope.Resolve<ICrawlerQueue>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ICrawlerQueue), m_CrawlerQueue)).ToArray(); m_CrawlerHistory = m_LifetimeScope.Resolve<ICrawlerHistory>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ICrawlerHistory), m_CrawlerHistory)).ToArray(); m_TaskRunner = m_LifetimeScope.Resolve<ITaskRunner>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ITaskRunner), m_TaskRunner)).ToArray(); m_Logger = m_LifetimeScope.Resolve<ILog>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof(ILog), m_Logger)).ToArray(); m_CrawlerRules = m_LifetimeScope.Resolve<ICrawlerRules>(parameters); m_Logger.Verbose("Crawl started @ {0}", m_BaseUri); m_WebDownloaderFactory = m_LifetimeScope.Resolve<Func<IWebDownloader>>(); using (m_CrawlCompleteEvent = new ManualResetEvent(false)) { m_Crawling = true; m_Runtime = Stopwatch.StartNew(); if (m_CrawlerQueue.Count > 0) { // Resume enabled ProcessQueue(); } else { AddStep(m_BaseUri, 0); } if (!m_CrawlStopped) { m_CrawlCompleteEvent.WaitOne(); } m_Runtime.Stop(); m_Crawling = false; } if (m_Cancelled) { OnCancelled(); } m_Logger.Verbose("Crawl ended @ {0} in {1}", m_BaseUri, m_Runtime.Elapsed); OnCrawlFinished(); }
/// <summary> /// Start crawl process /// </summary> public virtual void Crawl() { if (m_OnlyOneCrawlPerInstance) { throw new InvalidOperationException("Crawler instance cannot be reused"); } m_OnlyOneCrawlPerInstance = true; Parameter[] parameters = new Parameter[] { new TypedParameter(typeof (Uri), m_BaseUri), new NamedParameter("crawlStart", m_BaseUri), new TypedParameter(typeof (Crawler), this), }; m_CrawlerQueue = m_LifetimeScope.Resolve<ICrawlerQueue>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof (ICrawlerQueue), m_CrawlerQueue)).ToArray(); m_CrawlerHistory = m_LifetimeScope.Resolve<ICrawlerHistory>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof (ICrawlerHistory), m_CrawlerHistory)).ToArray(); m_TaskRunner = m_LifetimeScope.Resolve<ITaskRunner>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof (ITaskRunner), m_TaskRunner)).ToArray(); m_Logger = m_LifetimeScope.Resolve<ILog>(parameters); parameters = parameters.AddToEnd(new TypedParameter(typeof (ILog), m_Logger)).ToArray(); m_CrawlerRules = m_LifetimeScope.Resolve<ICrawlerRules>(parameters); m_Logger.Verbose("Crawl started @ {0}", m_BaseUri); m_WebDownloaderFactory = m_LifetimeScope.Resolve<Func<IWebDownloader>>(); using (m_CrawlCompleteEvent = new ManualResetEvent(false)) { m_Crawling = true; m_Runtime = Stopwatch.StartNew(); if (m_CrawlerQueue.Count > 0) { // Resume enabled ProcessQueue(); } else { AddStep(m_BaseUri, 0); } if (!m_CrawlStopped) { m_CrawlCompleteEvent.WaitOne(); } m_Runtime.Stop(); m_Crawling = false; } if (m_Cancelled) { OnCancelled(); } m_Logger.Verbose("Crawl ended @ {0} in {1}", m_BaseUri, m_Runtime.Elapsed); OnCrawlFinished(); }
public BounceRunner(ITaskRunner taskRunner) { TaskRunner = taskRunner; }
private SplunkAppender Create(ITaskRunner taskRunner = null, ISplunkWriterFactory factory = null, ILogBufferItemRepositoryFactory bufferItemRepositoryFactory = null, ITimerFactory timerFactory = null) { // ReSharper disable once UseObjectOrCollectionInitializer var splunkAppender = new SplunkAppender(taskRunner ?? CreateImmediateTaskRunner(), factory ?? Substitute.For<ISplunkWriterFactory>(), bufferItemRepositoryFactory ?? Substitute.For<ILogBufferItemRepositoryFactory>(), timerFactory ?? Substitute.For<ITimerFactory>()); splunkAppender.Name = RandomValueGen.GetRandomString(10, 20); return splunkAppender; }
public FileSystemWatchingRunner(INotificationService notificationService, ITaskProvider taskProvider) { this.notificationService = notificationService; this.taskProvider = taskProvider; this.taskRunner = new TaskRunner(); }
public TestRunner() { _testMethodProvider = VitaUnitRunner.GetService<ITestMethodProvider>(); _taskRunner = VitaUnitRunner.GetService<ITaskRunner>(); }
/// <summary> /// Start crawl process /// </summary> public virtual void Crawl() { if (m_Crawling) { throw new InvalidOperationException("Crawler already running"); } Parameter[] parameters = new Parameter[] { new TypedParameter(typeof (Uri), m_BaseUri), new NamedParameter("crawlStart", m_BaseUri), new NamedParameter("resume", false), new NamedParameter("crawler", this), }; m_CrawlerQueue = m_LifetimeScope.Resolve<ICrawlerQueue>(parameters); m_CrawlerHistory = m_LifetimeScope.Resolve<ICrawlerHistory>(parameters); m_Robot = AdhereToRobotRules ? m_LifetimeScope.Resolve<IRobot>(parameters) : new DummyRobot(); m_TaskRunner = m_LifetimeScope.Resolve<ITaskRunner>(parameters); m_Logger = m_LifetimeScope.Resolve<ILog>(parameters); m_Logger.Verbose("Crawl started @ {0}", m_BaseUri); using (m_CrawlCompleteEvent = new ManualResetEvent(false)) { m_Crawling = true; m_Runtime = Stopwatch.StartNew(); AddStep(m_BaseUri, 0); if (!m_CrawlStopped) { m_CrawlCompleteEvent.WaitOne(); } m_Runtime.Stop(); m_Crawling = false; } if (m_Cancelled) { OnCancelled(); } m_Logger.Verbose("Crawl ended @ {0} in {1}", m_BaseUri, m_Runtime.Elapsed); OnCrawlFinished(); }
public void SetUp() { taskQueue = MockRepository.GenerateStub<ITaskQueue>(); taskRunner = MockRepository.GenerateStub<ITaskRunner>(); taskManager = new TaskManager(taskQueue, taskRunner); }
///<summary> /// Default constructor. ///</summary> ///<param name="taskQueue">A task queue.</param> ///<param name="taskRunner">A task runner.</param> public TaskManager(ITaskQueue taskQueue, ITaskRunner taskRunner) { this.taskQueue = taskQueue; this.taskRunner = taskRunner; }