public KeepAliveSession(RemoteHostClient client, RemoteHostClient.Connection connection, string serviceName, object callbackTarget) { _gate = new object(); Initialize(client, connection); _remoteHostClientService = client.Workspace.Services.GetService <IRemoteHostClientService>(); _serviceName = serviceName; _callbackTarget = callbackTarget; }
public KeepAliveSession(RemoteHostClient client, RemoteHostClient.Connection connection, string serviceName, object callbackTarget) { Initialize_NoLock(client, connection); _gate = new SemaphoreSlim(initialCount: 1); _remoteHostClientService = client.Workspace.Services.GetService <IRemoteHostClientService>(); _serviceName = serviceName; _callbackTarget = callbackTarget; }
public static CommandResult SendWithErrorHandling(this IRemoteHostClientService client, IOperation operation, string command) { var result = client.Send(command); if (result.HasErrors) { throw CommonExceptions.FailedToSendCommandToRemoteHost(operation, result.Command, result.ExitStatus, result.Error); } return(result); }
protected override AbstractOptionPageControl CreateOptionPage(IServiceProvider serviceProvider) { if (_optionService == null) { var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); _optionService = componentModel.GetService <IGlobalOptionService>(); var workspace = componentModel.GetService <VisualStudioWorkspace>(); _remoteHostClientService = workspace.Services.GetService <IRemoteHostClientService>(); } return(new InternalOptionsControl(nameof(LoggerOptions), serviceProvider)); }
public static void SetLoggers(IGlobalOptionService optionService, IThreadingContext threadingContext, IRemoteHostClientService remoteService) { var loggerTypes = GetLoggerTypes(optionService).ToList(); // first set VS options var options = Logger.GetLoggingChecker(optionService); SetRoslynLogger(loggerTypes, () => new EtwLogger(options)); SetRoslynLogger(loggerTypes, () => new TraceLogger(options)); SetRoslynLogger(loggerTypes, () => new OutputWindowLogger(options)); // second set RemoteHost options var client = threadingContext.JoinableTaskFactory.Run(() => remoteService.TryGetRemoteHostClientAsync(CancellationToken.None)); if (client == null) { // Remote host is disabled return; } var functionIds = GetFunctionIds(options).ToList(); _ = threadingContext.JoinableTaskFactory.Run(() => client.TryRunRemoteAsync( WellKnownRemoteHostServices.RemoteHostService, nameof(IRemoteHostService.SetLoggingFunctionIds), new object[] { loggerTypes, functionIds }, CancellationToken.None)); }
protected override void ExecuteWithFileConfiguration(IOperation operation, IOperationLogger logger, OperatingSystemInstructions instructions, IRemoteHostClientService client) { SendCommands(operation, logger, client, instructions.Camunda?.Workers?.Stop); }
protected abstract void ExecuteWithFileConfiguration(IOperation operation, IOperationLogger logger, OperatingSystemInstructions instructions, IRemoteHostClientService client);
protected override void ExecuteWithFileConfiguration(IOperation operation, IOperationLogger logger, OperatingSystemInstructions instructions, IRemoteHostClientService client) { SendCommands(operation, logger, client, instructions.Application.Launch); }
public static CommandResult CheckConnection(this HostCredentialsItemEntity credentials, HostOperatingSystem operatingSystem, string host, out IRemoteHostClientService client) { client = null; string command; var arguments = new List <string>(); switch (operatingSystem) { case HostOperatingSystem.MacOS: case HostOperatingSystem.Linux: command = "uname"; arguments.Add("-a"); break; case HostOperatingSystem.WindowsOS: command = "ver"; break; default: command = ""; break; } if (credentials.Type == HostConnectionType.SSH) { try { client = SshClientService.Create(new SshConnectionByPasswordCredentials { Host = host, Port = credentials.Port, Username = credentials.Username, Password = credentials.Password }); return(client.Send(command, arguments.ToArray())); } catch (Exception e) { return(new CommandResult { Command = $"{command} {string.Join(' ', arguments)}", Output = null, Error = e.Message, ExitStatus = -1 }); } } return(null); }
protected override void ExecuteWithFileConfiguration(IOperation operation, IOperationLogger logger, OperatingSystemInstructions instructions, IRemoteHostClientService client) { SendCommands(operation, logger, client, instructions.Database?.Downgrade); }