/// <summary> /// Executes command line for any R binary with arguments /// </summary> public static RCommand ExecuteAsync(string executable, string arguments, IActionLog log, string rBasePath) { RCommand command = new RCommand(log); command.SendCommandAsync(rBasePath, executable, arguments); return(command); }
public RemoteUriWebService(string baseUri, ICoreServices services, IConsole console) { PostUri = new Uri(new Uri(baseUri), new Uri("/remoteuri", UriKind.Relative)); _services = services; _console = console; _log = _services.Log; }
public ConnectionManager(IRSettings settings, IRInteractiveWorkflowVisual interactiveWorkflow) { _sessionProvider = interactiveWorkflow.RSessions; _settings = settings; _interactiveWorkflow = interactiveWorkflow; _services = interactiveWorkflow.Services; _containers = interactiveWorkflow.Containers; _securityService = _services.GetService <ISecurityService>(); _log = _services.GetService <IActionLog>(); _installationService = _services.GetService <IRInstallationService>(); _services.GetService <IContainerService>(); _disposableBag = DisposableBag.Create <ConnectionManager>() .Add(() => _sessionProvider.BrokerStateChanged -= BrokerStateChanged) .Add(() => _interactiveWorkflow.RSession.Connected -= SessionConnected) .Add(() => _interactiveWorkflow.RSession.Disconnected -= SessionDisconnected) .Add(() => _interactiveWorkflow.ActiveWindowChanged -= ActiveWindowChanged) .Add(_containers.SubscribeOnChanges(ContainersChanged)); _sessionProvider.BrokerStateChanged += BrokerStateChanged; _interactiveWorkflow.RSession.Connected += SessionConnected; _interactiveWorkflow.RSession.Disconnected += SessionDisconnected; _interactiveWorkflow.ActiveWindowChanged += ActiveWindowChanged; // Get initial values var connections = CreateConnectionList(); _connections = new ConcurrentDictionary <string, IConnection>(connections); UpdateRecentConnections(save: false); }
/// <summary> /// Executes 'RScript --vanilla --slave -e' with the supplied expression asynchronously /// </summary> /// <param name="msTimeout"></param> /// <returns>Standard output produced by RScript.exe</returns> public static RCommand ExecuteRExpressionAsync(string expression, IActionLog log, string rBasePath) { string executable = "RScript.exe"; string baseArgumens = "--vanilla --slave -e "; return(ExecuteAsync(executable, baseArgumens + expression, log, rBasePath)); }
public static string Collect(IActionLog log) { string zipPath = string.Empty; _logFiles.Clear(); try { zipPath = Path.Combine(Path.GetTempPath(), RtvsLogZipFile); var workflowProvider = VsAppShell.Current.GlobalServices.GetService <IRInteractiveWorkflowProvider>(); var rSessionProvider = workflowProvider.GetOrCreate().RSessions; var sessions = rSessionProvider.GetSessions(); foreach (var s in sessions) { s.FlushLog(); } if (File.Exists(zipPath)) { File.Delete(zipPath); } } catch (IOException) { } catch (UnauthorizedAccessException) { } catch (ArgumentException) { } LongOperationNotification.ShowWaitingPopup(Resources.GatheringDiagnosticData, _actions, log); return(zipPath); }
public MsBuildFileSystemWatcher(string directory, string filter, int delayMilliseconds, int recoveryDelayMilliseconds, IFileSystem fileSystem, IMsBuildFileSystemFilter fileSystemFilter, IActionLog log, TaskScheduler taskScheduler = null) { Requires.NotNullOrWhiteSpace(directory, nameof(directory)); Requires.NotNullOrWhiteSpace(filter, nameof(filter)); Requires.Range(delayMilliseconds >= 0, nameof(delayMilliseconds)); Requires.Range(recoveryDelayMilliseconds >= 0, nameof(recoveryDelayMilliseconds)); Requires.NotNull(fileSystem, nameof(fileSystem)); Requires.NotNull(fileSystemFilter, nameof(fileSystemFilter)); _directory = directory; _filter = filter; _delayMilliseconds = delayMilliseconds; _recoveryDelayMilliseconds = recoveryDelayMilliseconds; _fileSystem = fileSystem; _fileSystemFilter = fileSystemFilter; _taskScheduler = taskScheduler ?? TaskScheduler.Default; _log = log; _entries = new MsBuildFileSystemWatcherEntries(); _queue = new ConcurrentQueue <IFileSystemChange>(); _broadcastBlock = new BroadcastBlock <Changeset>(b => b, new DataflowBlockOptions { TaskScheduler = _taskScheduler }); SourceBlock = _broadcastBlock.SafePublicize(); _fileSystemFilter.Seal(); }
public Output(IWindow window, IActionLog log) { Check.ArgumentNull(nameof(window), window); Check.ArgumentNull(nameof(log), log); _window = window; _log = log; }
/// <summary> /// Apply the effects of the action to the target /// </summary> /// <param name="log"></param> /// <param name="context"></param> protected virtual void ApplyEffects(IActionLog log, EffectContext context) { foreach (var effect in Effects) { effect.Apply(log, context); } }
public override bool Apply(IActionLog log, EffectContext context) { // TODO: Test for immunity HitPoints hP = context?.Target?.GetData <HitPoints>(); if (hP != null) { // Calculate damage (taking account of target resistances/vulnerabilities) double damage = Damage * DamageType.MultiplierFor(context.Target); // Apply damage hP.Value -= damage; // Kill the target (if applicable) if (hP.Value <= 0) { Vector position = context.Target.GetData <MapData>()?.Position ?? Vector.Unset; context.SFX.Trigger(SFXKeywords.Bang, position); // Destroy! Equipped equipped = context.Target.GetData <Equipped>(); if (equipped != null) { // Drop held items! equipped.DropAll(context.Target, context); } context.Target.Delete(); } return(true); } else { return(false); } }
public CoreShell(IActionLog log) { ThreadId = Thread.CurrentThread.ManagedThreadId; _serviceManager = new ServiceManager(); _serviceManager .AddService(new MaxLoggingPermissions()) .AddService(log); }
internal ProjectTreeLoader(IFileSystemAccess fileSystem, IProjectReader projectReader, IProjectWriter projectWriter, IPathCalculator path, IActionLog log) { _path = path; _fileSystem = fileSystem; _projectReader = projectReader; _projectWriter = projectWriter; _log = log; }
/// <summary> /// Apply the self-effects of the action, targetting the actor performing /// the action /// </summary> /// <param name="log"></param> /// <param name="context"></param> protected virtual void ApplySelfEffects(IActionLog log, EffectContext context) { context.Target = context.Actor; foreach (var effect in SelfEffects) { effect.Apply(log, context); } }
public override bool Apply(IActionLog log, EffectContext context) { if (context.Target != null) { context.Target.GetData <DisableActions>(true).LifeSpan += 1; return(true); } return(false); }
public RHost(string name, IRCallbacks callbacks, IMessageTransport transport, IActionLog log, CancellationTokenSource cts) { Check.ArgumentStringNullOrEmpty(nameof(name), name); _callbacks = callbacks; _transport = transport; _log = log; _cts = cts; }
public SolutionManagement(IActionLog log) { if (log == null) { throw new ArgumentNullException("log"); } Log = log; }
public override bool Apply(IActionLog log, EffectContext context) { context.SFX.Trigger("ChargeUp", context.Target.GetNominalPosition()); if (context?.Target != null && Ability != null && !context.Target.HasData(Ability.GetType())) { context.Target.Data.Add(Ability.Duplicate()); } return(false); }
public RHost(string name, IRCallbacks callbacks, IMessageTransport transport, IActionLog log) { Check.ArgumentStringNullOrEmpty(nameof(name), name); _name = name; _callbacks = callbacks; _transport = transport; _log = log; _cts = new CancellationTokenSource(); _cts.Token.Register(() => { _log.RHostProcessExited(); }); }
/// <summary> /// Apply all unspent effects in this collection to the target object /// </summary> /// <typeparam name="TTarget"></typeparam> /// <param name="list"></param> /// <param name="target"></param> /// <param name="log"></param> public static void ApplyAll <TTarget>(this IList <IEffect <TTarget> > list, IActionLog log) { foreach (var effect in list) { if (!effect.Spent) { effect.Apply(log); } } }
public RHost(string name, IRCallbacks callbacks, IMessageTransport transport, IActionLog log) { Check.ArgumentStringNullOrEmpty(nameof(name), name); Name = name; _callbacks = callbacks; _transport = transport; Log = log; _cts = new CancellationTokenSource(); _cts.Token.Register(() => { Log.RHostProcessExited(); }); }
public HubViewModel( IActionLog log, IAppWindowManager appWindowManager, IEventAggregator eventAggregator, ISettings settings) { this.log = log; this.appWindowManager = appWindowManager; this.settings = settings; eventAggregator.Subscribe(this); }
public override bool Apply(IActionLog log, EffectContext context) { if (UseTargetPosition) { context.SFX.Trigger(KeyWord, context.Target?.GetData <MapData>()?.Position ?? Vector.Unset, Direction); } else { context.SFX.Trigger(KeyWord, Position, Direction); } return(true); }
private WebServer(string remoteHostIp, int remotePort, string baseAddress, string name, IActionLog log, IConsole console) { _name = name.ToUpperInvariant(); _baseAddress = baseAddress; _log = log; _console = console; LocalHost = IPAddress.Loopback.ToString(); RemoteHost = remoteHostIp; RemotePort = remotePort; _remoteUriService = new RemoteUriWebService(baseAddress, log, console); }
public WelcomeViewModel( IAppWindowManager appWindowManager, ICompanyApiClient companyApiClient, INetworkService networkService, ISettings settings, IActionLog log) { this.appWindowManager = appWindowManager; this.companyApiClient = companyApiClient; this.networkService = networkService; this.settings = settings; this.log = log; }
public FileSystemMirroringProject(UnconfiguredProject unconfiguredProject, IProjectLockService projectLockService, MsBuildFileSystemWatcher fileSystemWatcher, IActionLog log = null) { _unconfiguredProject = unconfiguredProject; _projectLockService = projectLockService; _fileSystemWatcher = fileSystemWatcher; _log = log ?? ProjectSystemActionLog.Default; _unloadCancellationToken = _unconfiguredProject.Services.ProjectAsynchronousTasks.UnloadCancellationToken; _projectDirectory = _unconfiguredProject.GetProjectDirectory(); _inMemoryImportFullPath = _unconfiguredProject.GetInMemoryTargetsFileFullPath(); _fileItems = new Dictionary<string, ProjectItemElement>(StringComparer.OrdinalIgnoreCase); _directoryItems = new Dictionary<string, ProjectItemElement>(StringComparer.OrdinalIgnoreCase); var changesHandler = new Func<MsBuildFileSystemWatcher.Changeset, Task>(FileSystemChanged); _fileSystemWatcher.SourceBlock.LinkTo(new ActionBlock<MsBuildFileSystemWatcher.Changeset>(changesHandler)); }
/// <summary> /// Enact this action /// </summary> /// <param name="log"></param> /// <param name="context"></param> /// <returns></returns> public virtual bool Enact(IActionLog log, EffectContext context) { // Populate context: context = PrePopulateContext(context); if (Attempt(log, context)) { // Apply effects: ApplyEffects(log, context); ApplySelfEffects(log, context); return(true); } return(false); }
public static void WatcherChangesetSent(this IActionLog log, MsBuildFileSystemWatcher.Changeset changeset) { var sb = new StringBuilder(); sb.AppendLine("MsBuildFileSystemWatcher changeset sent.") .AppendWatcherChangesetPart(changeset.AddedFiles, "Added Files:") .AppendWatcherChangesetPart(changeset.RenamedFiles, "Renamed Files:") .AppendWatcherChangesetPart(changeset.RemovedFiles, "Removed Files:") .AppendWatcherChangesetPart(changeset.AddedDirectories, "Added Directories:") .AppendWatcherChangesetPart(changeset.RenamedDirectories, "Renamed Directories:") .AppendWatcherChangesetPart(changeset.RemovedDirectories, "Removed Directories:"); log.Write(LogVerbosity.Normal, MessageCategory.General, sb.ToString()); }
public static void WatcherChangesetSent(this IActionLog log, MsBuildFileSystemWatcher.Changeset changeset) { var sb = new StringBuilder(); sb.AppendLine("MsBuildFileSystemWatcher changeset sent.") .AppendWatcherChangesetPart(changeset.AddedFiles, "Added Files:") .AppendWatcherChangesetPart(changeset.RenamedFiles, "Renamed Files:") .AppendWatcherChangesetPart(changeset.RemovedFiles, "Removed Files:") .AppendWatcherChangesetPart(changeset.AddedDirectories, "Added Directories:") .AppendWatcherChangesetPart(changeset.RenamedDirectories, "Renamed Directories:") .AppendWatcherChangesetPart(changeset.RemovedDirectories, "Removed Directories:"); log.Trace(sb.ToString()); }
public static void RHostProcessStarted(this IActionLog log, ProcessStartInfo psi) { var sb = new StringBuilder(); sb.AppendLine(Invariant($"R Host process started: {psi.FileName}")); if (psi.EnvironmentVariables.Count > 0) { sb.AppendLine("Environment variables:"); foreach (var variable in psi.Environment) { sb.Append(' ', 4).AppendLine(Invariant($"{variable.Key}={variable.Value}")); } } log.WriteLineAsync(MessageCategory.General, sb.ToString()); }
public AppUpdateService( IActionLog log, IUpdateManager updateManager, IRegistryManager registryManager, IAppConfigurationManager configurationManager, IAppWindowManager appWindowManager, DispatcherTimer timer) { this.log = log; this.updateManager = updateManager; this.registryManager = registryManager; this.configurationManager = configurationManager; this.appWindowManager = appWindowManager; this.timer = timer; }
public HibernationWarningViewModel( IActionLog log, IHibernationService hibernationService, ISettings settings, DispatcherTimer timer, IEventAggregator eventAggregator) : base(eventAggregator) { this.log = log; this.hibernationService = hibernationService; this.settings = settings; timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += Timer_Tick_UpdateWindow; timer.Start(); }
public static bool ShowWaitingPopup(string message, IReadOnlyList<LongAction> actions, IActionLog log) { CommonMessagePump msgPump = new CommonMessagePump(); msgPump.AllowCancel = true; msgPump.EnableRealProgress = true; msgPump.WaitTitle = "R Tools for Visual Studio"; msgPump.WaitText = message; msgPump.TotalSteps = actions.Count; CancellationTokenSource cts = new CancellationTokenSource(); Task task = Task.Run(() => { for (int i = 0; i < actions.Count; i++) { cts.Token.ThrowIfCancellationRequested(); msgPump.CurrentStep = i + 1; if (actions[i].Name == null) { msgPump.ProgressText = string.Format(CultureInfo.InvariantCulture, Resources.LongOperationProgressMessage1, i + 1, msgPump.TotalSteps); } else { msgPump.ProgressText = string.Format(CultureInfo.InvariantCulture, Resources.LongOperationProgressMessage2, i + 1, msgPump.TotalSteps, actions[i].Name); } actions[i].Action(actions[i].Data, cts.Token); } }, cts.Token); CommonMessagePumpExitCode exitCode; if (!VsAppShell.Current.IsUnitTestEnvironment) { exitCode = msgPump.ModalWaitForHandles(((IAsyncResult)task).AsyncWaitHandle); } else { exitCode = CommonMessagePumpExitCode.HandleSignaled; } if (exitCode == CommonMessagePumpExitCode.UserCanceled || exitCode == CommonMessagePumpExitCode.ApplicationExit) { cts.Cancel(); msgPump = new CommonMessagePump(); msgPump.AllowCancel = false; msgPump.EnableRealProgress = false; // Wait for the async operation to actually cancel. msgPump.ModalWaitForHandles(((IAsyncResult)task).AsyncWaitHandle); } if (task.IsCanceled) { return false; } try { task.Wait(); } catch (Exception ex) { log?.WriteAsync(LogVerbosity.Minimal, MessageCategory.Error, "Long operation exception: " + ex.Message).DoNotWait(); } return true; }
public FileSystemMirroringProject(UnconfiguredProject unconfiguredProject, IProjectLockService projectLockService, MsBuildFileSystemWatcher fileSystemWatcher, IActionLog log = null) { _unconfiguredProject = unconfiguredProject; _projectLockService = projectLockService; _fileSystemWatcher = fileSystemWatcher; _log = log ?? ProjectSystemActionLog.Default; _unloadCancellationToken = _unconfiguredProject.Services.ProjectAsynchronousTasks.UnloadCancellationToken; _projectDirectory = _unconfiguredProject.GetProjectDirectory(); _inMemoryImportFullPath = _unconfiguredProject.GetInMemoryTargetsFileFullPath(); _fileItems = new Dictionary <string, ProjectItemElement>(StringComparer.OrdinalIgnoreCase); _directoryItems = new Dictionary <string, ProjectItemElement>(StringComparer.OrdinalIgnoreCase); var changesHandler = new Func <MsBuildFileSystemWatcher.Changeset, Task>(FileSystemChanged); _fileSystemWatcher.SourceBlock.LinkTo(new ActionBlock <MsBuildFileSystemWatcher.Changeset>(changesHandler)); }
public static IDisposable Measure(this IActionLog log, LogVerbosity verbosity, string message) { if (log.LogVerbosity < verbosity) { return(Disposable.Empty); } log.Write(verbosity, MessageCategory.General, Invariant($"{message} started")); var stopwatch = new Stopwatch(); stopwatch.Start(); return(Disposable.Create(() => { stopwatch.Stop(); log.Write(verbosity, MessageCategory.General, Invariant($"{message} completed in {stopwatch.ElapsedMilliseconds} ms.")); })); }
public MsBuildFileSystemWatcher(string directory, string filter, int delayMilliseconds, IFileSystem fileSystem, IMsBuildFileSystemFilter fileSystemFilter, TaskScheduler taskScheduler = null, IActionLog log = null) { Requires.NotNullOrWhiteSpace(directory, nameof(directory)); Requires.NotNullOrWhiteSpace(filter, nameof(filter)); Requires.Range(delayMilliseconds >= 0, nameof(delayMilliseconds)); Requires.NotNull(fileSystem, nameof(fileSystem)); Requires.NotNull(fileSystemFilter, nameof(fileSystemFilter)); _directory = directory; _filter = filter; _delayMilliseconds = delayMilliseconds; _fileSystem = fileSystem; _fileSystemFilter = fileSystemFilter; _taskScheduler = taskScheduler ?? TaskScheduler.Default; _log = log ?? ProjectSystemActionLog.Default; _queue = new ConcurrentQueue<IFileSystemChange>(); _broadcastBlock = new BroadcastBlock<Changeset>(b => b, new DataflowBlockOptions { TaskScheduler = _taskScheduler }); SourceBlock = _broadcastBlock.SafePublicize(); _fileSystemFilter.Seal(); }
public CoreServices(IApplicationConstants appConstants , ITelemetryService telemetry , ILoggingPermissions permissions , ISecurityService security , ITaskService tasks , IMainThread mainThread , IActionLog log , IFileSystem fs , IRegistry registry , IProcessServices ps) { LoggingServices = new LoggingServices(permissions, appConstants); Log = log; Telemetry = telemetry; Security = security; Tasks = tasks; ProcessServices = ps; Registry = registry; FileSystem = fs; MainThread = mainThread; }
public static string Collect(IActionLog log) { string zipPath = string.Empty; _logFiles.Clear(); try { zipPath = Path.Combine(Path.GetTempPath(), RtvsLogZipFile); var workflowProvider = VsAppShell.Current.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>(); var rSessionProvider = workflowProvider.GetOrCreate().RSessions; var sessions = rSessionProvider.GetSessions(); foreach (var s in sessions) { s.FlushLog(); } if (File.Exists(zipPath)) { File.Delete(zipPath); } } catch (IOException) { } catch (UnauthorizedAccessException) { } catch (ArgumentException) { } LongOperationNotification.ShowWaitingPopup(Resources.GatheringDiagnosticData, _actions, log); return zipPath; }
/// <summary> /// Asynchronously installs a set of R packages with dependencies /// </summary> public static RCommand Install(string rBasePath, IEnumerable<string> packageNames, IActionLog log) { string arguments = PackageListToString(packageNames); return Install(arguments, log, rBasePath); }
/// <summary> /// Executes 'R CMD arguments' /// </summary> public static RCommand ExecuteAsync(string arguments, IActionLog log, string rBasePath) { return ExecuteAsync("R.exe", "CMD " + arguments, log, rBasePath); }
/// <summary> /// Synchronously install a set of R packages with dependencies. /// Typically only used during setup from the MSI custom action. /// </summary> public static void InstallSynchronously(IEnumerable<string> packageNames, int msTimeout, IActionLog log, string rBasePath) { string arguments = PackageListToString(packageNames); if (!Install(arguments, log, rBasePath).Task.Wait(msTimeout)) { log.WriteFormatAsync(MessageCategory.Error, Resources.Error_InstallTimeout_Format, arguments); } }
/// <summary> /// Executes command line for any R binary with arguments /// </summary> public static RCommand ExecuteAsync(string executable, string arguments, IActionLog log, string rBasePath) { RCommand command = new RCommand(log); command.SendCommandAsync(rBasePath, executable, arguments); return command; }
/// <summary> /// Asynchronously install one R packages with dependencies /// </summary> public static RCommand Install(string packageName, IActionLog log, string rBasePath) { return RCommand.ExecuteAsync("INSTALL " + packageName, log, rBasePath); }
/// <summary> /// Executes 'RScript --vanilla --slave -e' with the supplied expression asynchronously /// </summary> /// <param name="msTimeout"></param> /// <returns>Standard output produced by RScript.exe</returns> public static RCommand ExecuteRExpressionAsync(string expression, IActionLog log, string rBasePath) { string executable = "RScript.exe"; string baseArgumens = "--vanilla --slave -e "; return ExecuteAsync(executable, baseArgumens + expression, log, rBasePath); }
private RCommand(IActionLog log) { _log = log; }
/// <summary> /// Executes 'RScript --vanilla --slave -e' with the supplied expression /// </summary> /// <param name="msTimeout"></param> /// <returns>Standard output produced by RScript.exe</returns> public static bool ExecuteRExpression(string expression, IActionLog log, int msTimeout, string rBasePath) { RCommand command = ExecuteRExpressionAsync(expression, log, rBasePath); return command.Task.Wait(msTimeout); }