public void CopyFile(InstallDirectoryItem appInstallation, PackageFile appFile, string appLibPath) { var installPath = appInstallation.Directory.FullName; var installFiles = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); var destinationPath = Path.Combine(installPath, appLibPath, appFile.InstallPath); CopyFileWithOverwrite(appFile.SourcePath, destinationPath, installFiles); }
public void CopyFiles(InstallDirectoryItem appInstallation, PackageContent appPackage, string appLibPath) { if (!appInstallation.Directory.Exists) { appInstallation.Directory.Create(); } var installPath = appInstallation.Directory.FullName; var installFiles = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); // Копирование файлов из каталога 'lib' foreach (var libFile in appPackage.Lib) { var destinationPath = Path.Combine(installPath, appLibPath, libFile.InstallPath); CopyFileWithOverwrite(libFile.SourcePath, destinationPath, installFiles); } // Копирование файлов из каталога 'content' foreach (var contentFile in appPackage.Content) { var destinationPath = Path.Combine(installPath, "content", contentFile.InstallPath); CopyFileWithOverwrite(contentFile.SourcePath, destinationPath, installFiles); } // Копирование файлов из каталога 'plugin' foreach (var contentFile in appPackage.Plugin) { var destinationPath = Path.Combine(installPath, "platform", contentFile.InstallPath); CopyFileWithOverwrite(contentFile.SourcePath, destinationPath, installFiles); } }
public void CopyFile(InstallDirectoryItem appInstallation, PackageFile appFile, string appLibPath) { var installPath = appInstallation.Directory.FullName; var installFiles = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); var destinationPath = Path.Combine(installPath, appLibPath, appFile.InstallPath); CopyFileWithOverwrite(appFile.SourcePath, destinationPath, installFiles); }
public AppStatus(InstallDirectoryItem appInstallation, string iconUrl, ProcessInfo processInfo, string error) { Id = appInstallation.PackageId; Version = appInstallation.PackageVersion; Instance = appInstallation.Instance; FullName = $"{appInstallation.PackageId}.{appInstallation.PackageVersion}@{appInstallation.Instance}".TrimEnd('@'); IconUrl = iconUrl; ProcessInfo = processInfo; Error = error; }
private static string BuildServiceCommand(string commandVerb, InstallDirectoryItem appInstallation, int? timeoutSeconds, string startOptions) { var command = new StringBuilder(commandVerb); AddCommandOption(command, "packageId", appInstallation.PackageId); AddCommandOption(command, "packageVersion", appInstallation.PackageVersion); AddCommandOption(command, "packageInstance", appInstallation.Instance); AddCommandOption(command, "packageDirectory", appInstallation.Directory.FullName); AddCommandOption(command, "packageTimeout", timeoutSeconds); if (startOptions != null) { AddCommandOption(command, "startOptions", startOptions); } return command.ToString(); }
public IEnumerable <InstallDirectoryItem> GetItems() { if (!Directory.Exists(_rootInstallPath)) { yield break; } var directories = Directory.EnumerateDirectories(_rootInstallPath); foreach (var path in directories) { var installDir = InstallDirectoryItem.Parse(path); if (installDir != null) { yield return(installDir); } } }
public void Delete(InstallDirectoryItem appInstallation) { // Есть вероятность, что при удалении каталога установки его файлы // еще используются, поскольку служба останавливается асинхронно. // Пока более интеллектуального способа не найдено, производится // несколько попыток удаления каталога с интервалом в 1 секунду. Exception exception = null; // Максимальный таймаут равен 2 минуты (24 попытки по 5 секунд каждая) const int attempts = 24; const int timeout = 5000; for (var i = 0; i < attempts; i++) { if (exception != null) { Thread.Sleep(timeout); } try { if (appInstallation.Directory.Exists) { appInstallation.Directory.Delete(true); } return; } catch (Exception e) { exception = e; _log.InfoFormat(Resources.AttemptToDeletePackageDirectoryHasCompletedWithError, i + 1, appInstallation, e.Message); } } if (exception != null) { throw new InvalidOperationException(string.Format(Resources.CannotDeletePackageDirectory, appInstallation), exception); } }
/// <summary> /// Возвращает статус процесса, соответствующего установленному приложению. /// </summary> /// <param name="appInstallation">Сведения об установке приложения.</param> public static Task<ProcessInfo> GetProcessInfo(InstallDirectoryItem appInstallation) { ProcessInfo processInfo; var process = Process.GetProcessesByName("Infinni.NodeWorker") .FirstOrDefault(p => Directory.GetParent(p.MainModule.FileName).Name == appInstallation.Directory.Name); if (process != null) { var versionInfo = process.MainModule.FileVersionInfo; processInfo = new ProcessInfo { Id = process.Id, State = "Running", ModuleName = process.MainModule.ModuleName, FileVersion = versionInfo.FileVersion, ProductVersion = versionInfo.ProductVersion, Language = versionInfo.Language, IsPreRelease = versionInfo.IsPreRelease, IsDebug = versionInfo.IsDebug, ProductName = versionInfo.ProductName, CompanyName = versionInfo.CompanyName, LegalCopyright = versionInfo.LegalCopyright }; } else { processInfo = new ProcessInfo { State = "Stopped" }; } return Task.FromResult(processInfo); }
public void CopyFiles(InstallDirectoryItem appInstallation, PackageContent appPackage, string appLibPath) { if (!appInstallation.Directory.Exists) { appInstallation.Directory.Create(); } var installPath = appInstallation.Directory.FullName; var installFiles = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); // Копирование файлов из каталога 'lib' foreach (var libFile in appPackage.Lib) { var destinationPath = Path.Combine(installPath, appLibPath, libFile.InstallPath); CopyFileWithOverwrite(libFile.SourcePath, destinationPath, installFiles); } // Копирование файлов из каталога 'content' foreach (var contentFile in appPackage.Content) { var destinationPath = Path.Combine(installPath, "content", contentFile.InstallPath); CopyFileWithOverwrite(contentFile.SourcePath, destinationPath, installFiles); } // Копирование файлов из каталога 'plugin' foreach (var contentFile in appPackage.Plugin) { var destinationPath = Path.Combine(installPath, "platform", contentFile.InstallPath); CopyFileWithOverwrite(contentFile.SourcePath, destinationPath, installFiles); } }
private static Task ExecuteWorkerService(string commandVerb, InstallDirectoryItem appInstallation, int? timeoutSeconds = null, string startOptions = null) { var workerServiceFile = Path.Combine(appInstallation.Directory.FullName, WorkerServiceFile); var workerServiceArguments = BuildServiceCommand(commandVerb, appInstallation, timeoutSeconds, startOptions); return MonoHelper.ExecuteProcessAsync(workerServiceFile, workerServiceArguments); }
public Task<ProcessInfo> GetProcessInfo(InstallDirectoryItem appInstallation, int? timeoutSeconds = null) { return ProcessHelper.GetProcessInfo(appInstallation); }
public Task Stop(InstallDirectoryItem appInstallation, int? timeoutSeconds = null) { return ExecuteWorkerService(WorkerServiceStopVerb, appInstallation, timeoutSeconds); }
public Task Start(InstallDirectoryItem appInstallation, int? timeoutSeconds = null) { return ExecuteWorkerService(WorkerServiceStartVerb, appInstallation, timeoutSeconds, StartStartOptionVerb); }
public Task Uninstall(InstallDirectoryItem appInstallation) { return ExecuteWorkerService(WorkerServiceUninstallVerb, appInstallation); }