private void GetPyroServerConnectionUrl() { // FhirApiDiscoveryTask var FhirApiDiscoveryTaskLauncher = new FhirApiDiscoveryTaskLauncher(Container); ConsoleSupport.TimeStampWriteLine(LogMessageSupport.RegisterTask("FhirApiDiscoveryTaskLauncher")); PyroServerConnectionUrl = FhirApiDiscoveryTaskLauncher.Launch(); }
public void Start() { // write code here that runs when the Windows Service starts up. Console.Clear(); Console.Write(Common.ProductText.PyroText.PyroTextLogo(" Pyro Backburner ")); ConsoleSupport.DateTimeStampWriteLine("Starting..."); Container = new Container(); App_Start.SimpleInjectorWebApiInitializer.Initialize(Container); _timer = new Timer(InitilizeHub, null, _StartupDelay, _StartupDelay); }
/// <summary> /// Launches the service as a Task on it's own thread /// Creates new Dependancy Injection instance for each thread/Task /// </summary> /// <param name="TaskPayloadHiServiceIHISearch"></param> public void Launch(ITaskPayloadHiServiceIHISearch TaskPayloadHiServiceIHISearch) { ConsoleSupport.TimeStampWriteLine(LogMessageSupport.TaskReceived(TaskPayloadHiServiceIHISearch)); Task.Factory.StartNew(() => { try { using (AsyncScopedLifestyle.BeginScope(Container)) { this.Container.GetInstance<IIhiSearchService>().Run(TaskPayloadHiServiceIHISearch); } } catch (Exception Exec) { Pyro.Common.Logging.Logger.Log.Error(Exec, "IhiSearchServiceTaskLauncher threw uncaught exception in Task/Thread."); } }); }
private void LoadTasks() { var hubProxy = hubConnection.CreateHubProxy("BroadcastHub"); Tools.ConsoleSupport.TimeStampWriteLine("Registered Tasks:"); // ======================================================================================== // ============== Registered each task Launcher to run ==================================== // ======================================================================================== // IHI Search Service var IhiSearchServiceTaskLauncher = new IhiSearchServiceTaskLauncher(Container); ConsoleSupport.TimeStampWriteLine(LogMessageSupport.RegisterTask(BackgroundTaskType.HiServiceIHISearch.GetPyroLiteral())); hubProxy.On <TaskPayloadHiServiceIHISearch>(BackgroundTaskType.HiServiceIHISearch.GetPyroLiteral(), IHiServiceResolveIHIPayload => IhiSearchServiceTaskLauncher.Launch(IHiServiceResolveIHIPayload)); // ======================================================================================== }
private void HubConnection_StateChanged(StateChange obj) { if (obj.NewState == ConnectionState.Connected) { Console.Clear(); Console.WriteLine(); Console.Write(Common.ProductText.PyroText.PyroTextLogo("Pyro Backburner", "MyVersion")); Console.WriteLine(); ConsoleSupport.Line(); ConsoleSupport.DateTimeStampWriteLine("Connected to Pyro Server"); ConsoleWriteLine($"At address: {PyroServerConnectionUrl}"); } else { ConsoleWriteLine($"Contection state changed:"); ConsoleWriteLine($" Old state: {obj.OldState.ToString()}"); ConsoleWriteLine($" New state: {obj.NewState.ToString()}"); } }
/// <summary> /// Launches the service as a Task on it's own thread /// Creates new Dependancy Injection instance for each thread/Task /// </summary> /// <param name="TaskPayloadHiServiceIHISearch"></param> public string Launch() { ConsoleSupport.TimeStampWriteLine("Launched FhirApiDiscoveryTaskLauncher"); var TaskResults = Task.Factory.StartNew(() => { try { using (AsyncScopedLifestyle.BeginScope(Container)) { return(this.Container.GetInstance <IFhirApiDiscoveryService>().Run()); } } catch (Exception Exec) { Pyro.Common.Logging.Logger.Log.Error(Exec, "FhirApiDiscoveryTaskLauncher threw uncaught exception in Task/Thread."); } return("FailedReturn"); }); return(TaskResults.Result); }
public void Start() { // write code here that runs when the Windows Service starts up. Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write(Common.ProductText.PyroText.PyroTextLogo("Pyro Backburner", "MyVersion")); Console.ResetColor(); ConsoleSupport.DateTimeStampWriteLine("Starting..."); var WarmUpMessages = new Pyro.Common.ProductText.PyroWarmUpMessages(); WarmUpMessages.Start("Pyro Backburner", $"Version: {System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(Pyro.Common.Global.GlobalProperties).Assembly.Location).ProductVersion}"); Container = new Container(); App_Start.SimpleInjectorWebApiInitializer.Initialize(Container); WarmUpMessages.Stop(); Console.ForegroundColor = ConsoleColor.Cyan; GetPyroServerConnectionUrl(); ConsoleSupport.DateTimeStampWriteLine("Database schema loaded..."); _timer = new Timer(InitilizeHub, null, _StartupDelay, _StartupDelay); }
public void Run(ITaskPayloadHiServiceIHISearch TaskPayloadHiServiceIHISearch) { using (DbContextTransaction Transaction = IUnitOfWork.BeginTransaction()) { try { IRequestMeta RequestMeta = IRequestMetaFactory.CreateRequestMeta().Set("Patient/IHIStatusExample"); IResourceServiceOutcome ResourceServiceOutcome = IResourceApiServices.GetRead("IHIStatusExample", RequestMeta); ResourceServiceOutcome.SummaryType = RequestMeta.SearchParameterGeneric.SummaryType; Transaction.Commit(); ConsoleSupport.TimeStampWriteLine(LogMessageSupport.TaskOutCome(TaskPayloadHiServiceIHISearch, Hl7.Fhir.Model.Task.TaskStatus.Completed)); } catch (Exception Exec) { Transaction.Rollback(); ConsoleSupport.TimeStampWriteLine(LogMessageSupport.TaskException(TaskPayloadHiServiceIHISearch, Hl7.Fhir.Model.Task.TaskStatus.Failed)); ILog.Error(Exec, $"FHIR Task ID: {TaskPayloadHiServiceIHISearch.TaskId}, FHIR Patient ID: {TaskPayloadHiServiceIHISearch.PatientId}"); } } }
private void ConsoleWriteLine(string message) { ConsoleSupport.TimeStampWriteLine(message); }