public OutlookSearch(AccountConfig config) { EmailAddress = config.EmailAddress; SearchPhrase = config.SearchTag; SearchSize = config.SearchSize; SearchTime = config.SearchTime; TimerInterval = config.TimerInterval; MaxDisplayItems = config.DisplayItems; _searchTimer = new TimerPlus(TimerInterval * 1000) { AutoReset = true }; _outlookTimer = new TimerPlus(2000) { AutoReset = true }; _searchTimer.Start(); _outlookTimer.Start(); // register events _searchTimer.Elapsed += TimerElapsed; _outlookTimer.Elapsed += CheckOutlookStatus; OnSearchErrorOccurred += ErrorHandler; OnFindErrorOccurred += SearchError; OnFindComplete += SearchComplete; OnServiceStart += OnStart; // raise on start events OnServiceStart?.Invoke(this, EventArgs.Empty); }
public SearchTracking() { Logger.Log("Starting search tracker"); OnServiceStart += ServiceStartup; _searchTimer = new TimerPlus(10 * 1000) { AutoReset = true }; _searchTimer.Elapsed += TrackTimerElapsed; _searchTimer.Start(); OnServiceStart?.Invoke(this, EventArgs.Empty); }
internal static void RunServiceStart(PointBlankService service) => OnServiceStart?.Invoke(service);
private async Task HandleServiceEvents() { // Handle one event at a time, oldest first while (serviceEventQueue.TryDequeue(out var evnt)) { switch (evnt.ServiceEventType) { case ServiceEventType.ServiceStart: IsServiceExecutingBootTasks = true; OnServiceStart?.Invoke(); break; case ServiceEventType.BootTasksComplete: IsServiceExecutingBootTasks = false; OnServiceDoneExecutingBootTasks?.Invoke(); break; case ServiceEventType.WaitingForExternalTaskRun: { // TODO: Performance: this should be in its own thread, so other service events can be handled // Only allow one external run at a time TaskRun run = null; while (run == null) { try { run = await Client.QueryTaskRun((Guid)evnt.Guid); if (run == null) { return; } } catch (FactoryOrchestratorConnectionException) { OnConnectionFailure(); while ((OnConnectionPage) || (!Client.IsConnected)) { await Task.Delay(1000); } } } if (!run.TaskRunComplete && Settings.ShowExternalTasks) { // Show external task page await HandleExternalTaskRunAsync(run); } } break; case ServiceEventType.ContainerConnected: IsContainerRunning = true; break; case ServiceEventType.ContainerDisconnected: IsContainerRunning = false; break; case ServiceEventType.ContainerDisabled: IsContainerRunning = false; IsContainerDisabled = true; break; case ServiceEventType.ContainerTaskRunRedirectedToRunAsRDUser: // Check if we are localhost, if so we are the DUT and can try to initiate a RD connection via protocol for the server. // If not, do nothing, as we are not the DUT. if (Client.IsLocalHost) { // TODO: Performance: this should be in its own thread, so other service events can be handled // Only allow one container run at a time TaskRun run = null; while (run == null) { try { run = await Client.QueryTaskRun((Guid)evnt.Guid); if (run == null) { return; } } catch (FactoryOrchestratorConnectionException) { OnConnectionFailure(); while ((OnConnectionPage) || (!Client.IsConnected)) { await Task.Delay(1000); } } } if (!run.TaskRunComplete) { await HandleContainerTaskRunRedirectedToRunAsRDUserAsync(); } } break; default: // Ignore other events break; } } }