private void CheckFirmWareDetails(string url) { try { this.Invoke(new Action(() => { dataGridView1.Rows.Clear(); })); RomDetails.RomDetailsClass details = new RomDetails.RomDetailsClass(); RomDetails.GetFirmwareDetails(this, url, ref details, 1); this.Invoke(new Action(() => { for (int i = 0, j = details.SupportedVersions.Length; i < j; i++) { if (details.SupportedVersions[i].Length > 2) { dataGridView1.Rows.Add((i + 1).ToString(), details.SupportedVersions[i]); } } })); } catch (Exception e) { if (!e.Message.StartsWith("Thread was being")) { MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void CheckFirmWareData(string url) { try { this.Invoke(new Action(() => { materialRadioButton1.Checked = false; materialRadioButton1.Enabled = false; materialRadioButton1.Text = "Checking"; })); RomDetails.RomDetailsClass details = new RomDetails.RomDetailsClass(); RomDetails.GetFirmwareDetails(this, url, ref details, 0); this.Invoke(new Action(() => { if (details.ApprovedForInstall) { materialRadioButton1.Text = "Approved for installation"; materialRadioButton1.Enabled = true; materialRadioButton1.Checked = true; } else { materialRadioButton1.Text = "Not Approved for installation"; materialRadioButton1.Enabled = false; materialRadioButton1.Checked = false; } })); } catch (Exception e) { this.Invoke(new Action(() => { materialRadioButton1.Enabled = false; materialRadioButton1.Text = "ERROR"; })); MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void GetFirmwareDetails(FirmFinder form, string url, ref RomDetails.RomDetailsClass romDetails, int DetailsKind) { string VersionID = GetVersionID(url); if (DetailsKind == 0 || DetailsKind == 2) { romDetails.ApprovedForInstall = ApprovedForInstallation(VersionID); } if (DetailsKind == 0) { return; } Progress progress = null; bool Finished = false; Thread thisthread = Thread.CurrentThread; form.Invoke(new Action(() => { progress = new Progress("Getting Package URL"); progress.FormClosing += delegate { if (!Finished) { thisthread.Abort(); } }; progress.Show(form); })); SetProgress(form, progress, 5); string Package = GetPackageURL(url); SetProgress(form, progress, 30, "Initial Request To ZIP"); HTTPStream httpstream = new HTTPStream(Package); ZipInputStream stream = new ZipInputStream(httpstream); SetProgress(form, progress, 40, "Exploring ZIP File..."); int count = 0; while (true) { ZipEntry entry = stream.GetNextEntry(); if (entry != null) { count += 2; if (count > 60) { count = 30; } SetProgress(form, progress, 40 + count, entry.Name); if (entry.Name.Contains("SOFTWARE_VER_LIST.mbn")) { int read = 4096; byte[] buffer = new byte[read]; string content = ""; while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { content += Encoding.UTF8.GetString(buffer, 0, read); } romDetails.SupportedVersions = content.Split('\n'); break; } else { stream.CloseEntry(); } } else { MessageBox.Show("Seems like I couldn't load the data :(", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } Finished = true; progress.Close(); }