private async Task <bool> TryLaunchIntegrationAsync() { try { _logger.LogDebug("Waiting for application configuration to be done"); await _applicationStateTransmitter.ConfigurationDone; var fullPath = _integrationApplicationLocator.GetAbsolutePath(); if (!File.Exists(fullPath)) { _logger.LogError("Cannot launch {Path} because it does not exist", fullPath); return(false); } _logger.LogInformation("Launching application at {Path}", fullPath); ProcessImpersonation.Launch(fullPath); return(true); } catch (Exception e) { _logger.LogError(e, "Exception occured while calling {Name}", nameof(TryLaunchIntegrationAsync)); return(false); } }
public void Start() { var process = "notepad"; Log.Info("Starting main service and executing {process}", process); // Process.Start(process); ProcessImpersonation.Launch(process); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { ProcessImpersonation.Launch("notepad"); while (!stoppingToken.IsCancellationRequested) { using (_logger.BeginScope("Worker cycle.")) { _logger.LogInformation(new EventId(1), "Cycle started {Time}", DateTimeOffset.Now); await Task.Delay(5000, stoppingToken); _logger.LogInformation(new EventId(1), "Cycle done."); } } }
protected void CloseTerminal(int id) { try { var terminal = (Terminal)data.GetObject(EntitiesEnum.Terminal, id); if (terminal != null) { var pi = new ProcessImpersonation(log); pi.CloseTerminal(terminal.FullPath); } } catch (Exception e) { log.Info("CloseTerminal error: " + e); } }
public string DeployToAccount(int id) { if (isDeploying) { var message = "Application already deploying: Skip..."; log.Error(message); return(message); } try { isDeploying = true; var terminal = (Terminal)data.GetObject(EntitiesEnum.Terminal, id); if (terminal != null) { var installDir = GetGlobalProp(xtradeConstants.SETTINGS_PROPERTY_INSTALLDIR); var pi = new ProcessImpersonation(log); var fileName = string.Format(@"{0}\deployto_{1}.bat", installDir, terminal.AccountNumber); var logFile = string.Format(@"{0}\deployto_{1}.log", installDir, terminal.AccountNumber); CloseTerminal(terminal.Id); pi.StartProcessInNewThread(fileName, logFile, terminal.FullPath); return($"Deploy process started for terminal {terminal.AccountNumber}!"); } else { return($"Terminal with ID={id} not found or disabled!!!"); } } catch (Exception e) { var message = "Error: DeployToAccount: " + e; log.Error(message); return(message); } finally { isDeploying = false; } }
public TerminalMonitoringJob() { log = MainService.thisGlobal.Container.Resolve <IWebLog>(); log.Debug("TerminalMonitoringJob c-tor"); procUtil = MainService.thisGlobal.Container.Resolve <ProcessImpersonation>(); }