Пример #1
0
        ///<summary>If AtoZ.manifest was wrong, or if user is not using AtoZ, then just download again.  Will use dir selected by user.  If an appropriate download is not available, it will fail and inform user.</summary>
        private static void DownloadAndRunSetup(Version storedVersion, Version currentVersion)
        {
            string patchName       = "Setup.exe";
            string updateUri       = PrefC.GetString(PrefName.UpdateWebsitePath);
            string updateCode      = PrefC.GetString(PrefName.UpdateCode);
            string updateInfoMajor = "";
            string updateInfoMinor = "";

            if (!FormUpdate.ShouldDownloadUpdate(updateUri, updateCode, out updateInfoMajor, out updateInfoMinor))
            {
                return;
            }
            if (MessageBox.Show(
                    Lan.g("Prefs", "Setup file will now be downloaded.") + "\r\n"
                    + Lan.g("Prefs", "Workstation version will be updated from ") + currentVersion.ToString(3)
                    + Lan.g("Prefs", " to ") + storedVersion.ToString(3),
                    "", MessageBoxButtons.OKCancel)
                != DialogResult.OK)               //they don't want to update for some reason.
            {
                return;
            }
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.SelectedPath = ImageStore.GetPreferredAtoZpath();
            dlg.Description  = Lan.g("Prefs", "Setup.exe will be downloaded to the folder you select below");
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;                //app will exit
            }
            string tempFile = ODFileUtils.CombinePaths(dlg.SelectedPath, patchName);

            //ODFileUtils.CombinePaths(Path.GetTempPath(),patchName);
            FormUpdate.DownloadInstallPatchFromURI(updateUri + updateCode + "/" + patchName, //Source URI
                                                   tempFile, true, false, null);             //Local destination file.
            File.Delete(tempFile);                                                           //Cleanup install file.
        }
Пример #2
0
        ///<summary>Essentially no changes have been made to this since version 6.5.</summary>
        private static bool CheckProgramVersionClassic()
        {
            Version storedVersion  = new Version(PrefC.GetString(PrefName.ProgramVersion));
            Version currentVersion = new Version(Application.ProductVersion);
            string  database       = MiscData.GetCurrentDatabase();

            if (storedVersion < currentVersion)
            {
                Prefs.UpdateString(PrefName.ProgramVersion, currentVersion.ToString());
                Cache.Refresh(InvalidType.Prefs);
            }
            if (storedVersion > currentVersion)
            {
                if (PrefC.UsingAtoZfolder)
                {
                    string setupBinPath = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "Setup.exe");
                    if (File.Exists(setupBinPath))
                    {
                        if (MessageBox.Show("You are attempting to run version " + currentVersion.ToString(3) + ",\r\n"
                                            + "But the database " + database + "\r\n"
                                            + "is already using version " + storedVersion.ToString(3) + ".\r\n"
                                            + "A newer version must have already been installed on at least one computer.\r\n"
                                            + "The setup program stored in your A to Z folder will now be launched.\r\n"
                                            + "Or, if you hit Cancel, then you will have the option to download again."
                                            , "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                        {
                            if (MessageBox.Show("Download again?", "", MessageBoxButtons.OKCancel)
                                == DialogResult.OK)
                            {
                                FormUpdate FormU = new FormUpdate();
                                FormU.ShowDialog();
                            }
                            Application.Exit();
                            return(false);
                        }
                        try {
                            Process.Start(setupBinPath);
                        }
                        catch {
                            MessageBox.Show("Could not launch Setup.exe");
                        }
                    }
                    else if (MessageBox.Show("A newer version has been installed on at least one computer," +
                                             "but Setup.exe could not be found in any of the following paths: " +
                                             ImageStore.GetPreferredAtoZpath() + ".  Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        FormUpdate FormU = new FormUpdate();
                        FormU.ShowDialog();
                    }
                }
                else                  //Not using image path.
                                      //perform program update automatically.
                {
                    string patchName       = "Setup.exe";
                    string updateUri       = PrefC.GetString(PrefName.UpdateWebsitePath);
                    string updateCode      = PrefC.GetString(PrefName.UpdateCode);
                    string updateInfoMajor = "";
                    string updateInfoMinor = "";
                    if (FormUpdate.ShouldDownloadUpdate(updateUri, updateCode, out updateInfoMajor, out updateInfoMinor))
                    {
                        if (MessageBox.Show(updateInfoMajor + Lan.g("Prefs", "Perform program update now?"), "",
                                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            string tempFile = ODFileUtils.CombinePaths(Path.GetTempPath(), patchName);       //Resort to a more common temp file name.
                            FormUpdate.DownloadInstallPatchFromURI(updateUri + updateCode + "/" + patchName, //Source URI
                                                                   tempFile, true, true, null);              //Local destination file.
                            File.Delete(tempFile);                                                           //Cleanup install file.
                        }
                    }
                }
                Application.Exit();                //always exits, whether launch of setup worked or not
                return(false);
            }
            return(true);
        }