private void btnInnovatorPackage_Click(object sender, EventArgs e) { try { using (var dialog = new OpenFileDialog()) { dialog.Filter = "Innovator Package (.innpkg)|*.innpkg|Manifest (.mf)|*.mf"; if (dialog.ShowDialog() == DialogResult.OK) { if (Path.GetExtension(dialog.FileName) == ".innpkg") { using (var pkg = InnovatorPackage.Load(dialog.FileName)) { _wizard.InstallScript = pkg.Read(); } } else { var pkg = new ManifestFolder(dialog.FileName); string title; var doc = pkg.Read(out title); _wizard.InstallScript = _wizard.InstallProcessor.ConvertManifestXml(doc, title); } SetMetadata(); } } } catch (Exception ex) { Utils.HandleError(ex); } }
public void GoNext() { var compare = new Compare(); compare.BaseInstall = InnovatorPackage.Load(leftPath.Text).Read(); _wizard.InstallScript = InnovatorPackage.Load(rightPath.Text).Read(); _wizard.GoToStep(compare); }
private void btnPackageFile_Click(object sender, EventArgs e) { try { using (var dialog = new OpenFileDialog()) { dialog.Filter = "Innovator Package (.innpkg)|*.innpkg|Manifest (.mf)|*.mf"; if (dialog.ShowDialog() == DialogResult.OK) { if (Path.GetExtension(dialog.FileName) == ".innpkg") { using (var pkg = InnovatorPackage.Load(dialog.FileName)) { var installScript = pkg.Read(); _availableRefs.Clear(); foreach (var item in installScript.Lines.Where(l => l.Type == InstallType.Create).Select(l => l.Reference)) { if (!_selectedRefs.Contains(item)) { _selectedRefs.Add(item); } } _existingScript = installScript; _existingScript.Lines = null; } } else { var pkg = new ManifestFolder(dialog.FileName); string title; var doc = pkg.Read(out title); foreach (var item in ItemReference.FromFullItems(doc.DocumentElement, true)) { if (!_selectedRefs.Contains(item)) { _selectedRefs.Add(item); } } _existingScript = _existingScript ?? new InstallScript(); _existingScript.Title = title; } EnsureResultsTab(); tbcSearch.SelectedTab = pgResults; txtFind.Focus(); } } } catch (Exception ex) { Utils.HandleError(ex); } }
public int Execute() { return(ConsoleTask.Execute(this, (console) => { console.WriteLine("Getting package information..."); var script = InnovatorPackage.Load(InputFile).Read(); SharedOptions.WritePackage(console, script, Output, MultipleDirectories, CleanOutput); })); }
public Task <int> Execute() { return(ConsoleTask.ExecuteAsync(this, async(console) => { console.WriteLine("Connecting to innovator..."); var conn = await this.GetConnection().ConfigureAwait(false); var processor = new InstallProcessor(conn); console.WriteLine("Reading the install package..."); var script = default(InstallScript); if (Path.GetExtension(InputFile) == ".innpkg") { using (var pkg = InnovatorPackage.Load(InputFile)) script = pkg.Read(); } else { var pkg = new ManifestFolder(InputFile); var doc = pkg.Read(out var title); script = await processor.ConvertManifestXml(doc, title).ConfigureAwait(false); } console.Write("Installing package `{0}`...", script.Title); using (var prog = console.Progress()) { var tcs = new TaskCompletionSource <int>(); processor.ProgressChanged += (s, e) => prog.Report(e.Progress / 100.0); processor.ErrorRaised += (s, e) => { tcs.TrySetException(e.Exception); e.RecoveryOption = RecoveryOption.Abort; }; processor.ActionComplete += (s, e) => { if (e.Exception == null) { tcs.TrySetResult(0); } else { tcs.TrySetException(e.Exception); } }; await processor.Initialize(script).ConfigureAwait(false); processor.Install(); await tcs.Task.ConfigureAwait(false); } console.WriteLine("Done."); })); }
public static IEnumerable <IDiffDirectory> GetDirectories(params string[] paths) { var repos = new Dictionary <string, GitRepo>(StringComparer.OrdinalIgnoreCase); foreach (var path in paths) { if (path.StartsWith("git://", StringComparison.OrdinalIgnoreCase)) { var query = new QueryString("file://" + path.Substring(6)); var filePath = query.Uri.LocalPath; if (!repos.TryGetValue(filePath, out var repo)) { repo = new GitRepo(filePath); repos[filePath] = repo; } var options = new GitDirectorySearch() { Sha = query["commit"].ToString(), Path = query["path"].ToString() }; foreach (var branch in query["branch"]) { options.BranchNames.Add(branch); } if (string.Equals(options.Sha, "tip", StringComparison.OrdinalIgnoreCase)) { options.Sha = null; } yield return(repo.GetDirectory(options)); } else if (string.Equals(Path.GetExtension(path), ".innpkg", StringComparison.OrdinalIgnoreCase)) { yield return(InnovatorPackage.Load(path).Read()); } else if (string.Equals(Path.GetExtension(path), ".mf", StringComparison.OrdinalIgnoreCase)) { yield return(new FileSysDiffDirectory(Path.GetDirectoryName(path))); } else { yield return(new FileSysDiffDirectory(path)); } } }
public Task <int> Execute() { return(ConsoleTask.ExecuteAsync(this, async(console) => { console.WriteLine("Connecting to innovator..."); var conn = await this.GetConnection().ConfigureAwait(false); var processor = new ExportProcessor(conn); var refsToExport = default(List <ItemReference>); var checkDependencies = true; console.Write("Identifying items to export... "); if (this.InputFile?.EndsWith(".innpkg", StringComparison.OrdinalIgnoreCase) == true || this.InputFile?.EndsWith(".mf", StringComparison.OrdinalIgnoreCase) == true) { var exportScript = InnovatorPackage.Load(this.InputFile).Read(); refsToExport = exportScript.Lines .Where(l => l.Type == InstallType.Create) .Select(l => l.Reference) .Distinct() .ToList(); } else { var exportQuery = XElement.Parse("<AML><Item type='*' /></AML>"); if (!string.IsNullOrEmpty(this.InputFile)) { exportQuery = XElement.Load(this.InputFile); } var firstItem = exportQuery.XPathSelectElement("//Item[1]"); if (firstItem == null) { throw new Exception("No item nodes could be found"); } var items = default(IEnumerable <XElement>); if (firstItem.Parent == null) { items = new[] { firstItem } } ; else { items = firstItem.Parent.Elements("Item"); } var version = await conn.FetchVersion(true).ConfigureAwait(false); var types = ExportAllType.Types.Where(t => t.Applies(version)).ToList(); var queries = GetQueryies(items, types).ToList(); checkDependencies = items.All(e => e.Attribute("type")?.Value != "*"); using (var prog = console.Progress()) { var toExport = await SharedUtils.TaskPool(30, (l, m) => prog.Report(l / 100.0), queries .Select(q => { var aml = new XElement(q); var levels = aml.Attribute("levels"); if (levels != null) { levels.Remove(); } return (Func <Task <QueryAndResult> >)(() => conn.ApplyAsync(aml, true, false) .ToTask() .ContinueWith(t => new QueryAndResult() { Query = q, Result = t.Result })); }) .ToArray()); refsToExport = toExport.SelectMany(r => { var refs = r.Result.Items() .Select(i => ItemReference.FromFullItem(i, true)) .ToList(); var levels = (int?)r.Query.Attribute("levels"); if (levels.HasValue) { foreach (var iRef in refs) { iRef.Levels = levels.Value; } } return refs; }) .ToList(); } } console.WriteLine("Done."); var script = new InstallScript { ExportUri = new Uri(Url), ExportDb = Database, Lines = Enumerable.Empty <InstallItem>(), Title = Title ?? System.IO.Path.GetFileNameWithoutExtension(Output), Creator = Author ?? Username, Website = string.IsNullOrEmpty(Website) ? null : new Uri(Website), Description = Description, Created = DateTime.Now, Modified = DateTime.Now }; console.Write("Exporting metadata... "); using (var prog = console.Progress()) { processor.ProgressChanged += (s, e) => prog.Report(e.Progress / 100.0); processor.ActionComplete += (s, e) => { if (e.Exception != null) { throw new AggregateException(e.Exception); } }; await processor.Export(script, refsToExport, checkDependencies); } console.WriteLine("Done."); WritePackage(console, script, Output, MultipleDirectories, CleanOutput); })); }