Пример #1
0
 private bool DoUpdate(PackageClass packageClass, PackageClass newpackageClass, bool silent)
 {
   string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(newpackageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted);
   if (!File.Exists(newPackageLoacation))
   {
     if (!silent)
       MessageBox.Show("Can't locate the installer package. Update aborted");
     return false;
   }
   PackageClass pak = new PackageClass();
   pak = pak.ZipProvider.Load(newPackageLoacation);
   if (pak == null)
   {
     if (!silent)
       MessageBox.Show("Invalid package format ! Update aborted !");
     return false;
   }
   if (pak.GeneralInfo.Id != newpackageClass.GeneralInfo.Id ||
       pak.GeneralInfo.Version.CompareTo(newpackageClass.GeneralInfo.Version) < 0)
   {
     if (!silent)
       MessageBox.Show("Invalid update information ! Update aborted!");
     return false;
   }
   if (!pak.CheckDependency(false))
   {
     if (!silent)
     {
       if (MessageBox.Show("Dependency check error! Update aborted!\nWould you like to view more details?", pak.GeneralInfo.Name,
         MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
       {
         DependencyForm frm = new DependencyForm(pak);
         frm.ShowDialog();
       }
     }
     return false;
   }
   if (!silent)
     if (
       MessageBox.Show(
         "This operation will update the extension " + packageClass.GeneralInfo.Name + " to the version " +
         pak.GeneralInfo.Version + " \n Do you want to continue ? ", "Install extension", MessageBoxButtons.YesNo,
         MessageBoxIcon.Exclamation) != DialogResult.Yes)
       return false;
   // only uninstall previous version, if the new package has the setting to force uninstall of previous version on update
   if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool())
   {
     UnInstall dlg = new UnInstall();
     dlg.Execute(packageClass, true);
   }
   else
   {
     MpeCore.MpeInstaller.InstalledExtensions.Remove(packageClass);
   }
   pak.CopyGroupCheck(packageClass);
   pak.Silent = true;
   pak.StartInstallWizard();
   return true;
 }
Пример #2
0
    public void InstallFile(string file, bool silent, bool gui)
    {
      if (!File.Exists(file))
      {
        if (!silent)
          MessageBox.Show("File not found !");
        return;
      }

      if (IsOldFormat(file))
      {
        if (!silent)
          MessageBox.Show("This is an old format file (mpi).  The extension will NOT be installed. ");
        return;
      }
      MpeCore.MpeInstaller.Init();
      PackageClass pak = new PackageClass();
      pak = pak.ZipProvider.Load(file);
      if (pak == null)
      {
        if (!silent)
          MessageBox.Show("Wrong file format !");
        return;
      }
      if (pak.CheckDependency(false))
      {
        PackageClass installedPak = MpeCore.MpeInstaller.InstalledExtensions.Get(pak.GeneralInfo.Id);
        if (installedPak != null)
        {
          if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool())
          {
            if (!silent)
              if (
                MessageBox.Show(
                  "Another version of this extension is installed\nand needs to be uninstalled first.\nDo you want to continue?\n" +
                  "Old extension version: " + installedPak.GeneralInfo.Version + "\n" +
                  "New extension version: " + pak.GeneralInfo.Version,
                  "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                return;
            UnInstall dlg = new UnInstall();
            dlg.Execute(installedPak, true);
            pak.CopyGroupCheck(installedPak);
          }
          else
          {
			  MpeCore.MpeInstaller.InstalledExtensions.Remove(installedPak);
          }
        }
        if (gui)
          this.Hide();
        pak.Silent = silent;
        pak.StartInstallWizard();
        if (gui)
        {
          SetFilterForKnownExtensionsList();
          RefreshListControls();
          this.Show();
        }
      }
      else
      {
        if (!silent)
        {
          if (MessageBox.Show("Dependency check error! Install aborted!\nWould you like to view more details?", pak.GeneralInfo.Name, 
            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
          {
            DependencyForm frm = new DependencyForm(pak);
            frm.ShowDialog();
          }
        }
      }
    }
Пример #3
0
    private void extensionListControl_InstallExtension(object sender, PackageClass packageClass)
    {
      string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(packageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted);
      if (!File.Exists(newPackageLoacation))
      {
        MessageBox.Show("Can't locate the installer package. Install aborted");
        return;
      }
      PackageClass pak = new PackageClass();
      pak = pak.ZipProvider.Load(newPackageLoacation);
      if (pak == null)
      {
        MessageBox.Show("Package loading error ! Install aborted!");
        try
        {
          if (newPackageLoacation != packageClass.GeneralInfo.Location)
            File.Delete(newPackageLoacation);
        }
        catch { }
        return;
      }
      if (!pak.CheckDependency(false))
      {
        if (MessageBox.Show("Dependency check error! Install aborted!\nWould you like to view more details?", pak.GeneralInfo.Name,
          MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
        {
          DependencyForm frm = new DependencyForm(pak);
          frm.ShowDialog();
        }
        pak.ZipProvider.Dispose();
        try
        {
          if (newPackageLoacation != packageClass.GeneralInfo.Location)
            File.Delete(newPackageLoacation);
        }
        catch { }
        return;
      }

      if (packageClass.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) != 0)
      {
        if (MessageBox.Show(
          string.Format(@"Downloaded version of {0} is {1} and differs from your selected version: {2}!
Do you want to continue ?",packageClass.GeneralInfo.Name, pak.GeneralInfo.Version,packageClass.GeneralInfo.Version), "Install extension", MessageBoxButtons.YesNo,
          MessageBoxIcon.Error) != DialogResult.Yes)
        return;
      }

      if (
        MessageBox.Show(
          "This operation will install " + packageClass.GeneralInfo.Name + " version " +
          pak.GeneralInfo.Version + "\n Do you want to continue ?", "Install extension", MessageBoxButtons.YesNo,
          MessageBoxIcon.Exclamation) != DialogResult.Yes)
        return;
      this.Hide();
      packageClass = MpeCore.MpeInstaller.InstalledExtensions.Get(packageClass.GeneralInfo.Id);
      if (packageClass != null)
      {
        if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool())
        {
          if (
            MessageBox.Show(
              "Another version of this extension is installed\nand needs to be uninstalled first.\nDo you want to continue?\n" +
              "Old extension version: " + packageClass.GeneralInfo.Version + "\n" +
              "New extension version: " + pak.GeneralInfo.Version,
              "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
          {
            this.Show();
            return;
          }
          UnInstall dlg = new UnInstall();
          dlg.Execute(packageClass, false);
        }
        else
        {
          MpeCore.MpeInstaller.InstalledExtensions.Remove(packageClass);
        }
        pak.CopyGroupCheck(packageClass);
      }
      pak.StartInstallWizard();
      RefreshListControls();
      pak.ZipProvider.Dispose();
      try
      {
        if (newPackageLoacation != packageClass.GeneralInfo.Location)
          File.Delete(newPackageLoacation);
      }
      catch { }
      this.Show();
    }