public AutoUpdateDetails(List<ComponentData> components, AutoUpdateCheck parent)
        {
            InitializeComponent();

            _data.Columns.Add(new DataColumn("Name", typeof(String)));
            _data.Columns.Add(new DataColumn("CurrentVersion", typeof(String)));
            _data.Columns.Add(new DataColumn("LatestVersion", typeof(String)));
            _data.Columns.Add(new DataColumn("Description", typeof(String)));

            foreach (ComponentData component in components)
            {
                DataRow newRow = _data.NewRow();
                newRow["Name"] = component.Name;
                newRow["CurrentVersion"] = (component.Exists ? (component.currentVersion.Major == 0 ?
                    "Unknown" : component.currentVersion.ToString()) : "None");
                newRow["LatestVersion"] = component.latestVersion.ToString();
                newRow["Description"] = component.Description;
                _data.Rows.Add(newRow);
            }

            try
            {
                string tmpFile = parent.DownloadFile("VersionHistory.rtf");
                richTextBox1.LoadFile(tmpFile);

                // Note: Can't do this because EMMA runs under low privileges.
                // Instead, the version history will be overwritten by the updater itself which
                // runs under admin privileges.
                //try
                //{
                //    // Try and copy the latest version file into our work directory.
                //    // Someone might want to look at it or somthing.
                //    string versionFile = Globals.AppDataDir + Path.DirectorySeparatorChar +
                //        "VersionHistory.rtf";

                //    File.Copy(tmpFile, versionFile, true);
                //}
                //catch { /* don't care */ }

            }
            catch (Exception ex)
            {
                richTextBox1.Text = "Error loading version history: " + ex.Message + "\r\n" + ex.StackTrace;
            }
        }
Ejemplo n.º 2
0
        private void AutoUpdate()
        {
            AutoUpdateCheck checker = new AutoUpdateCheck(AppDomain.CurrentDomain.BaseDirectory,
                Globals.EMMAUpdateServer, Properties.Settings.Default.BetaUpdates);
            if (checker.UpdateNeeded)
            {
                checker.ShowDialog();
            }
            else
            {
                checker = null;
            }

            /*if (!Globals.EMMAUpdateServer.Equals(""))
            {
                string exeFile = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "AutoUpdater.exe";
                if (File.Exists(exeFile))
                {
                    string tmpDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                        Path.DirectorySeparatorChar + "EMMA";
                    string exeTmp = tmpDir + Path.DirectorySeparatorChar + "AutoUpdater.exe";
                    if (Directory.Exists(tmpDir))
                    {
                        Directory.Delete(tmpDir, true);
                    }
                    Directory.CreateDirectory(tmpDir);
                    File.Copy(exeFile, exeTmp);

                    string parameters = "/p " + System.Diagnostics.Process.GetCurrentProcess().Id +
                        " /s " + Globals.EMMAUpdateServer +
                        " /b " + Properties.Settings.Default.BetaUpdates.ToString() +
                        " /h \"" + AppDomain.CurrentDomain.BaseDirectory + "\"";
                    try
                    {
                        System.Diagnostics.Process updateProcess = System.Diagnostics.Process.Start(exeTmp, parameters);
                        while (!updateProcess.HasExited) { }
                    }
                    catch (Win32Exception ex)
                    {
                        if (ex.Message.Contains("The operation was canceled by the user"))
                        {
                            // If this happens then we just ignore it and continue.
                            // The user has cancelled the auto-update program for some reason
                            // (e.g. does not want to give the program admin rights on vista)
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Auto-updater cannot be found. EMMA will not be updated when new features " +
                        "become available.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }*/
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            AutoUpdateCheck checker = new AutoUpdateCheck(AppDomain.CurrentDomain.BaseDirectory,
                Globals.EMMAUpdateServer, Properties.Settings.Default.BetaUpdates);
            if (checker.UpdateNeeded)
            {
                checker.ShowDialog();
            }
            else
            {
                MessageBox.Show("No updates are currently available.", "Notification",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            /*if (!_main.CheckForUpdatesInProg())
            {
                if (MessageBox.Show("Running the updater will cause EMMA to close if updates are available." +
                    "Are you sure you wish to continue?", "Warning", MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    string exeFile = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "AutoUpdater.exe";
                    if (File.Exists(exeFile))
                    {
                        string tmpDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                            Path.DirectorySeparatorChar + "EMMA";
                        string exeTmp = tmpDir + Path.DirectorySeparatorChar + "AutoUpdater.exe";
                        if (Directory.Exists(tmpDir))
                        {
                            Directory.Delete(tmpDir, true);
                        }
                        Directory.CreateDirectory(tmpDir);
                        File.Copy(exeFile, exeTmp);

                        string parameters = "/p " + System.Diagnostics.Process.GetCurrentProcess().Id +
                            " /s " + Globals.EMMAUpdateServer +
                            " /b " + Properties.Settings.Default.BetaUpdates.ToString() +
                            " /h \"" + AppDomain.CurrentDomain.BaseDirectory + "\"";
                        System.Diagnostics.Process updateProcess = System.Diagnostics.Process.Start(exeTmp, parameters);
                        while (!updateProcess.HasExited) { }

                        MessageBox.Show("No updates are currently available.", "Notification",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Updater program cannot be found.", "Error",
                            MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }*/
        }