private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { Updatable[] applications = (Updatable[])e.Argument; UpdateXml[] result = new UpdateXml[applications.Length]; bool oneSucceeded = false; for (int i = 0; i < applications.Length; ++i) { Updatable application = applications[i]; if (!UpdateXml.existsOnServer(application.UpdateXmlLocation)) { result[i] = null; } else { result[i] = UpdateXml.parse(application.UpdateXmlLocation, application.ApplicationID); } if (!oneSucceeded && result[i] != null) { oneSucceeded = true; } } if (!oneSucceeded) { e.Cancel = true; } e.Result = result; }
private void downloadUpdate(UpdateXml update, string location, UpdateAction action) { UpdateDownloader form = new UpdateDownloader(update.Uri, update.MD5, applicationInfos[0].ApplicationIcon); DialogResult result = form.ShowDialog(applicationInfos[0].Context); form.Close(); if (result == DialogResult.OK) { string currentPath = location; string newPath = Path.Combine(Path.GetDirectoryName(currentPath), update.FileName); if (action == UpdateAction.RESTART) { updateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs, false); } else if (action == UpdateAction.INSTALL) { updateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs, true); } else if (action == UpdateAction.FILECOPY) { updateFile(form.TempFilePath, currentPath, newPath, update.Version.ToString()); } } else if (result == DialogResult.Abort) { MessageBox.Show(Strings.updateCancelled, "Update Download " + Strings.cancelled, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Strings.updateError, "Update Download " + Strings.error, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public UpdateInfo(Updatable[] applicationInfos, UpdateXml[] updateInfos) { InitializeComponent(); if (applicationInfos[0].ApplicationIcon != null) this.Icon = applicationInfos[0].ApplicationIcon; int firstUpdatable = 0; for (int i = 0; i < updateInfos.Length; ++i) { if (updateInfos[i].ShouldUpdate) { firstUpdatable = i; break; } } this.Text = applicationInfos[firstUpdatable].ApplicationName + " - Update Info"; this.lblVersions.Text = String.Format(Strings.currUpdVersion, applicationInfos[firstUpdatable].ApplicationVersion.ToString(), updateInfos[firstUpdatable].Version.ToString()); this.txtDescription.Text = ""; for (int i = 0; i < updateInfos.Length; ++i){ UpdateXml updateInfo = updateInfos[i]; if (updateInfo.ShouldUpdate) { this.txtDescription.Text += applicationInfos[i].ApplicationName + "\n"; this.txtDescription.Text += updateInfo.Description + "\n\n"; } } }
public UpdateInfo(Updatable[] applicationInfos, UpdateXml[] updateInfos) { InitializeComponent(); if (applicationInfos[0].ApplicationIcon != null) { this.Icon = applicationInfos[0].ApplicationIcon; } int firstUpdatable = 0; for (int i = 0; i < updateInfos.Length; ++i) { if (updateInfos[i].ShouldUpdate) { firstUpdatable = i; break; } } this.Text = applicationInfos[firstUpdatable].ApplicationName + " - Update Info"; this.lblVersions.Text = String.Format(Strings.currUpdVersion, applicationInfos[firstUpdatable].ApplicationVersion.ToString(), updateInfos[firstUpdatable].Version.ToString()); this.txtDescription.Text = ""; for (int i = 0; i < updateInfos.Length; ++i) { UpdateXml updateInfo = updateInfos[i]; if (updateInfo.ShouldUpdate) { this.txtDescription.Text += applicationInfos[i].ApplicationName + "\n"; this.txtDescription.Text += updateInfo.Description + "\n\n"; } } }
internal UpdateXml(UpdateXml other) { this.version = other.version; this.uri = other.uri; this.fileName = other.fileName; this.md5 = other.md5; this.description = other.description; this.launchArgs = other.launchArgs; }
private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { Updatable[] applications = (Updatable[])e.Argument; UpdateXml[] result = new UpdateXml[applications.Length]; bool oneSucceeded = false; for (int i = 0; i < applications.Length; ++i) { Updatable application = applications[i]; if (!UpdateXml.existsOnServer(application.UpdateXmlLocation)) result[i] = null; else result[i] = UpdateXml.parse(application.UpdateXmlLocation, application.ApplicationID); if (!oneSucceeded && result[i] != null) oneSucceeded = true; } if (!oneSucceeded) e.Cancel = true; e.Result = result; }
internal UpdateAccept(Updatable[] applicationInfos, UpdateXml[] updateInfos) { InitializeComponent(); int firstUpdatable = 0; for (int i = 0; i < updateInfos.Length; ++i) { if (updateInfos[i].ShouldUpdate) { firstUpdatable = i; break; } } this.applicationInfos = applicationInfos; this.updateInfos = updateInfos; this.Text = applicationInfos[firstUpdatable].ApplicationName+ Strings.updateAvail; if (applicationInfos[0].ApplicationIcon != null) this.Icon = applicationInfos[0].ApplicationIcon; lblNewVersion.Text = string.Format(Strings.newVersion, updateInfos[firstUpdatable].Version.ToString()); }
private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled) { UpdateXml[] updates = (UpdateXml[])e.Result; if (updates == null) { return; } bool needsUpdate = false; for (int i = 0; i < updates.Length; ++i) { UpdateXml update = (UpdateXml)updates[i]; if (update != null && update.isNewerThan(applicationInfos[i].ApplicationVersion)) { update.ShouldUpdate = true; needsUpdate = true; } } if (!needsUpdate) { return; } if (new UpdateAccept(applicationInfos, updates).ShowDialog(applicationInfos[0].Context) == DialogResult.Yes) { for (int i = 0; i < updates.Length; ++i) { if (updates[i].ShouldUpdate) { downloadUpdate(updates[i], applicationInfos[i].ApplicationLocation, applicationInfos[i].UpdateMode); } } performUpdate(); } } }
private void downloadUpdate(UpdateXml update, string location, UpdateAction action) { UpdateDownloader form = new UpdateDownloader(update.Uri, update.MD5, applicationInfos[0].ApplicationIcon); DialogResult result = form.ShowDialog(applicationInfos[0].Context); form.Close(); if (result == DialogResult.OK) { string currentPath = location; string newPath = Path.Combine(Path.GetDirectoryName(currentPath), update.FileName); if (action == UpdateAction.RESTART) updateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs, false); else if (action == UpdateAction.INSTALL) updateApplication(form.TempFilePath, currentPath, newPath, update.LaunchArgs, true); else if (action == UpdateAction.FILECOPY) updateFile(form.TempFilePath, currentPath, newPath, update.Version.ToString()); } else if (result == DialogResult.Abort) { MessageBox.Show(Strings.updateCancelled, "Update Download "+Strings.cancelled, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(Strings.updateError, "Update Download "+Strings.error, MessageBoxButtons.OK, MessageBoxIcon.Information); } }