Example #1
0
 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);
     }
 }
 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);
   }
 }
Example #3
0
        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);
            }
        }
Example #4
0
        private void btnPackageFile_Click(object sender, EventArgs e)
        {
            try
            {
                if (FlushMetadata())
                {
                    using (var dialog = new SaveFileDialog())
                    {
                        if (!string.IsNullOrEmpty(_wizard.InstallScript.Title))
                        {
                            dialog.FileName = _wizard.InstallScript.Title + ".innpkg";
                        }
                        dialog.Filter = "Innovator Package (Single file)|*.innpkg|Innovator Package (Multiple files: for development)|*.innpkg|Manifest (Backwards compatible)|*.mf";
                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            ProgressDialog.Display(this, (d) =>
                            {
                                switch (dialog.FilterIndex)
                                {
                                case 2:
                                    var pkgFolder = new DirectoryPackage(dialog.FileName);
                                    if (!_wizard.InstallScript.Created.HasValue)
                                    {
                                        _wizard.InstallScript.Created = DateTime.Now;
                                    }
                                    _wizard.InstallScript.Modified = DateTime.Now;
                                    pkgFolder.Write(_wizard.InstallScript);
                                    break;

                                case 3:
                                    var manifest = new ManifestFolder(dialog.FileName);
                                    manifest.Write(_wizard.InstallScript);
                                    break;

                                default:
                                    using (var pkgFile = new ZipPackage(dialog.FileName))
                                    {
                                        if (!_wizard.InstallScript.Created.HasValue)
                                        {
                                            _wizard.InstallScript.Created = DateTime.Now;
                                        }
                                        _wizard.InstallScript.Modified = DateTime.Now;
                                        pkgFile.Write(_wizard.InstallScript);
                                    }
                                    break;
                                }
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.HandleError(ex);
            }
        }
Example #5
0
        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.");
            }));
        }
Example #6
0
    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);
      }
    }
Example #7
0
        public static void WritePackage(ConsoleTask console, InstallScript script, string output, bool multipleDirectories, bool cleanOutput)
        {
            multipleDirectories = multipleDirectories || string.Equals(Path.GetExtension(output), ".mf", StringComparison.OrdinalIgnoreCase);

            if (cleanOutput)
            {
                console.Write("Cleaning output... ");
                if (multipleDirectories)
                {
                    var dir = new DirectoryInfo(Path.GetDirectoryName(output));
                    if (dir.Exists)
                    {
                        Parallel.ForEach(dir.EnumerateFileSystemInfos(), fs =>
                        {
                            if (fs is DirectoryInfo di)
                            {
                                di.Delete(true);
                            }
                            else
                            {
                                fs.Delete();
                            }
                        });
                    }
                    else
                    {
                        dir.Create();
                    }
                }
                else
                {
                    File.Delete(output);
                }
                console.WriteLine("Done.");
            }

            console.Write("Writing package... ");
            var outputDir = Path.GetDirectoryName(output);

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            switch (Path.GetExtension(output).ToLowerInvariant())
            {
            case ".mf":
                var manifest = new ManifestFolder(output);
                manifest.Write(script);
                break;

            case ".innpkg":
                if (multipleDirectories)
                {
                    using (var pkgFolder = new InnovatorPackageFolder(output))
                        pkgFolder.Write(script);
                }
                else
                {
                    if (File.Exists(output))
                    {
                        File.Delete(output);
                    }
                    using (var pkgFile = new InnovatorPackageFile(output))
                        pkgFile.Write(script);
                }
                break;

            default:
                throw new NotSupportedException("Output file type is not supported");
            }
            console.WriteLine("Done.");
        }
 private void btnPackageFile_Click(object sender, EventArgs e)
 {
   try
   {
     if (FlushMetadata())
     {
       using (var dialog = new SaveFileDialog())
       {
         if (!string.IsNullOrEmpty(_wizard.InstallScript.Title))
         {
           dialog.FileName = _wizard.InstallScript.Title + ".innpkg";
         }
         dialog.Filter = "Innovator Package (Single file)|*.innpkg|Innovator Package (Multiple files: for development)|*.innpkg|Manifest (Backwards compatible)|*.mf";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
           ProgressDialog.Display(this, () =>
           {
             switch (dialog.FilterIndex)
             {
               case 2:
                 var pkgFolder = new InnovatorPackageFolder(dialog.FileName);
                 if (!_wizard.InstallScript.Created.HasValue) _wizard.InstallScript.Created = DateTime.Now;
                 _wizard.InstallScript.Modified = DateTime.Now;
                 pkgFolder.Write(_wizard.InstallScript);
                 break;
               case 3:
                 var manifest = new ManifestFolder(dialog.FileName);
                 manifest.Write(_wizard.InstallScript);
                 break;
               default:
                 using (var pkgFile = new InnovatorPackageFile(dialog.FileName))
                 {
                   if (!_wizard.InstallScript.Created.HasValue) _wizard.InstallScript.Created = DateTime.Now;
                   _wizard.InstallScript.Modified = DateTime.Now;
                   pkgFile.Write(_wizard.InstallScript);
                 }
                 break;
             }
           });
         }
       }
     }
   }
   catch (Exception ex)
   {
     Utils.HandleError(ex);
   }
 }