/// <summary> /// Выполняет деплой модуля. /// </summary> /// <param name="deployInfo"></param> internal override bool Deploy(DeployInfo deployInfo) { if (deployInfo == null) { throw new ArgumentNullException(nameof(deployInfo)); } if (!(this.TestComboBox.SelectedItem is OptionItem item)) { throw new NotificationException("Не выбрана папка тестирования"); } //получаем папку тестирования DirectoryInfo testDir = new DirectoryInfo(item.DirectoryPath); //формируем имя папки с комплектом string description = this.TestFoldersBox.SelectedIndex >= 0 ? ((OptionItem)this.TestFoldersBox.SelectedItem).DirectoryPath : this.TestFoldersBox.Text; /*string targetDirName = Path.Combine(testDir.FullName, String.Format("{0:yyyy.MM.dd}{1}", DateTime.Now, * String.IsNullOrEmpty(description) * ? null * : " - " + description));*/ if (String.IsNullOrEmpty(description?.Trim())) { throw new NotificationException("Не задано название папки"); } string targetDirName = Path.Combine(testDir.FullName, description); //создаём папку DirectoryInfo targetDir = this.CreateDirectory(targetDirName); //деплоим в папку if (deployInfo.CreateReleaseDirectory(targetDir, true) == null) { return(false); } deployInfo.CreateSourcesDirectory(targetDir, false); this.Form.Command.Package.WriteToOutput( $"Сформирован комплект для проекта {deployInfo.Project.Name} по пути:\n<file://{targetDir.FullName.TrimStart('\\').Replace('\\', '/')}>"); return(true); }
/// <summary> /// Выкладывает модуль в папку. /// </summary> /// <param name="deployInfo"></param> /// <param name="directory"></param> /// <param name="prevReadmePath"></param> private bool CreatePackage(DeployInfo deployInfo, DirectoryInfo directory, string prevReadmePath) { if (deployInfo == null) { throw new ArgumentNullException(nameof(deployInfo)); } if (directory == null) { throw new ArgumentNullException(nameof(directory)); } //README string readmePath = Path.Combine(directory.FullName, "Readme.txt"); if (!File.Exists(readmePath)) { if (String.IsNullOrEmpty(prevReadmePath)) { File.Copy(deployInfo.LogFile.GetFullPath(), readmePath); } else { if (this.IsASCIIFile(prevReadmePath)) { File.WriteAllLines(readmePath, this.GetUTF8LinesFromASCIIFile(prevReadmePath), Encoding.UTF8); } else { File.Copy(prevReadmePath, readmePath); } } } if (deployInfo.Logs != null && deployInfo.Logs.Count > 0) { List <string> lines = this.GetNewReadmeLines(deployInfo, prevReadmePath); File.WriteAllLines(readmePath, lines, Encoding.UTF8); } DirectoryInfo releaseDir = deployInfo.CreateReleaseDirectory(directory, false); deployInfo.CreateSourcesDirectory(directory, false); this.Form.Command.Package.WriteToOutput( $"Сформирован комплект для проекта {deployInfo.Project.Name} по пути:\n<file://{releaseDir.FullName.TrimStart('\\').Replace('\\', '/')}>"); return(true); }
/// <summary> /// Выполняет деплой модуля. /// </summary> /// <param name="deployInfo"></param> internal override bool Deploy(DeployInfo deployInfo) { if (deployInfo == null) { throw new ArgumentNullException(nameof(deployInfo)); } //получаем указанную папку string selectedPath = this.FolderPath.Text; if (String.IsNullOrEmpty(selectedPath)) { throw new NotificationException("Не выбран путь для комплекта"); } DirectoryInfo targetDir; if (!Directory.Exists(selectedPath)) { if (WSSDeveloperPackage.ShowUserConfirmOkCancel("Папка " + selectedPath + " отсутствует.\nСоздать?", "Папка отсутствует")) { targetDir = Directory.CreateDirectory(selectedPath); } else { return(false); } } else { targetDir = new DirectoryInfo(selectedPath); } //деплоим в указанную папку deployInfo.CreateReleaseDirectory(targetDir, false); deployInfo.CreateSourcesDirectory(targetDir, false); this.Form.Command.Package.WriteToOutput( $"Сформирован комплект для проекта {deployInfo.Project.Name} по пути:\n<file://{targetDir.FullName.TrimStart('\\').Replace('\\', '/')}>"); return(true); }