Ejemplo n.º 1
0
        private int PerformPackageAction(IInstallationPackage package, ListViewItem item)
        {
            //
            // return 0: nothing to do
            //        1: install successufull
            //        2: install error
            //
            CheckResult result = package.CheckStatus();

            if (result.state != CheckState.INSTALLED &&
                result.state != CheckState.REMOVED &&
                result.state != CheckState.DOWNLOADED &&
                result.state != CheckState.SKIPPED)
            {
                item.UseItemStyleForSubItems = false;
                item.SubItems[1].Font        = new Font(item.SubItems[1].Font, FontStyle.Bold);
                switch (result.state)
                {
                case CheckState.NOT_INSTALLED:
                    if (result.needsDownload)
                    {
                        item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgDownloading");
                        listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        listView.Update();
                        if (!package.Download())
                        {
                            Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                                         package.GetDisplayName()));
                            return(2);
                        }
                    }
                    item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgInstalling");
                    listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listView.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.NOT_CONFIGURED:
                    item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgConfiguring");
                    listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listView.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errConfigureFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.NOT_REMOVED:
                    item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgUninstalling");
                    listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listView.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errRemoveFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.VERSION_MISMATCH:
                    item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgUninstalling");
                    listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listView.Update();
                    if (!package.UnInstall())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errUinstallFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    if (result.needsDownload)
                    {
                        item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgDownloading");
                        listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                        listView.Update();
                        if (!package.Download())
                        {
                            Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errDownloadFailed"),
                                                         package.GetDisplayName()));
                            return(2);
                        }
                    }
                    item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgInstalling");
                    listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listView.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.NOT_DOWNLOADED:
                    item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgDownloading");
                    listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    listView.Update();
                    if (!package.Download())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errDownloadFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;
                }
                return(1);
            }
            return(0);
        }
Ejemplo n.º 2
0
    private int PerformPackageAction(IInstallationPackage package, ListViewItem item)
    {
      //
      // return 0: nothing to do
      //        1: install successufull
      //        2: install error
      //
      CheckResult result = package.CheckStatus();
      if (result.state != CheckState.INSTALLED &&
          result.state != CheckState.REMOVED &&
          result.state != CheckState.DOWNLOADED &&
          result.state != CheckState.SKIPPED)
      {
        item.UseItemStyleForSubItems = false;
        item.SubItems[1].Font = new Font(item.SubItems[1].Font, FontStyle.Bold);
        switch (result.state)
        {
          case CheckState.NOT_INSTALLED:
            if (result.needsDownload)
            {
              item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgDownloading");
              listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
              listView.Update();
              if (!package.Download())
              {
                Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                             package.GetDisplayName()));
                return 2;
              }
            }
            item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgInstalling");
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.Update();
            if (!package.Install())
            {
              Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                           package.GetDisplayName()));
              return 2;
            }
            break;

          case CheckState.NOT_CONFIGURED:
            item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgConfiguring");
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.Update();
            if (!package.Install())
            {
              Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errConfigureFailed"),
                                           package.GetDisplayName()));
              return 2;
            }
            break;

          case CheckState.NOT_REMOVED:
            item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgUninstalling");
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.Update();
            if (!package.Install())
            {
              Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errRemoveFailed"),
                                           package.GetDisplayName()));
              return 2;
            }
            break;

          case CheckState.VERSION_MISMATCH:
            item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgUninstalling");
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.Update();
            if (!package.UnInstall())
            {
              Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errUinstallFailed"),
                                           package.GetDisplayName()));
              return 2;
            }
            if (result.needsDownload)
            {
              item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgDownloading");
              listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
              listView.Update();
              if (!package.Download())
              {
                Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errDownloadFailed"),
                                             package.GetDisplayName()));
                return 2;
              }
            }
            item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgInstalling");
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.Update();
            if (!package.Install())
            {
              Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                           package.GetDisplayName()));
              return 2;
            }
            break;

          case CheckState.NOT_DOWNLOADED:
            item.SubItems[1].Text = Localizer.GetBestTranslation("Install_msgDownloading");
            listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listView.Update();
            if (!package.Download())
            {
              Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errDownloadFailed"),
                                           package.GetDisplayName()));
              return 2;
            }
            break;
        }
        return 1;
      }
      return 0;
    }
Ejemplo n.º 3
0
        private int PerformPackageAction(IInstallationPackage package, ApplicationCtrl item)
        {
            //
            // return 0: nothing to do
            //        1: install successufull
            //        2: install error
            //
            if (package == null)
            {
                return(2);
            }
            CheckResult result = package.CheckStatus();

            if (result.state != CheckState.INSTALLED &&
                result.state != CheckState.REMOVED &&
                result.state != CheckState.DOWNLOADED &&
                result.state != CheckState.SKIPPED)
            {
                item.InAction   = true;
                item.StatusName = CheckState.PROGRESS.ToString();
                switch (result.state)
                {
                case CheckState.NOT_INSTALLED:
                    if (result.needsDownload)
                    {
                        item.Action = Localizer.GetBestTranslation("Install_msgDownloading");
                        item.Update();
                        if (!package.Download())
                        {
                            Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                                         package.GetDisplayName()));
                            return(2);
                        }
                    }
                    item.Action = Localizer.GetBestTranslation("Install_msgInstalling");
                    item.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.NOT_CONFIGURED:
                    item.Action = Localizer.GetBestTranslation("Install_msgConfiguring");
                    item.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errConfigureFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.NOT_REMOVED:
                    item.Action = Localizer.GetBestTranslation("Install_msgUninstalling");
                    item.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errRemoveFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.VERSION_MISMATCH:
                    item.Action = Localizer.GetBestTranslation("Install_msgUninstalling");
                    item.Update();
                    if (!package.UnInstall())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errUinstallFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    if (result.needsDownload)
                    {
                        item.Action = Localizer.GetBestTranslation("Install_msgDownloading");
                        item.Update();
                        if (!package.Download())
                        {
                            Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errDownloadFailed"),
                                                         package.GetDisplayName()));
                            return(2);
                        }
                    }
                    item.Action = Localizer.GetBestTranslation("Install_msgInstalling");
                    item.Update();
                    if (!package.Install())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errInstallFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;

                case CheckState.NOT_DOWNLOADED:
                    item.Action = Localizer.GetBestTranslation("Install_msgDownloading");
                    item.Update();
                    if (!package.Download())
                    {
                        Utils.ErrorDlg(string.Format(Localizer.GetBestTranslation("Install_errDownloadFailed"),
                                                     package.GetDisplayName()));
                        return(2);
                    }
                    break;
                }
                return(1);
            }
            item.StatusName = result.state.ToString();
            return(0);
        }