private void bwCompare_DoWork(object sender, DoWorkEventArgs e) { if (GGKUtilLib.isPhased(kit1)) { phased_kit = kit1; unphased_kit = kit2; phased = true; } else if (GGKUtilLib.isPhased(kit2)) { phased_kit = kit2; unphased_kit = kit1; phased = true; } else { phased = false; } object[] cmp_results = GGKUtilLib.compareOneToOne(kit1, kit2); segment_idx = (DataTable)cmp_results[0]; segments = (List <DataTable>)cmp_results[1]; }
private void bwCompare_DoWork(object sender, DoWorkEventArgs e) { if (redo_again) { GGKUtilLib.clearAllComparisions(no_admixture); } DataTable dt = null; if (no_admixture) { dt = GGKUtilLib.queryDatabase("kit_master", new string[] { "kit_no", "reference", "name" }, "where disabled=0 and reference=0"); } else { dt = GGKUtilLib.queryDatabase("kit_master", new string[] { "kit_no", "reference", "name" }, "where disabled=0"); } int progress = 0; int total = 0; string ref1 = "0"; string ref2 = "0"; for (int i = 0; i < dt.Rows.Count; i++) { for (int j = i; j < dt.Rows.Count; j++) { if (bwCompare.CancellationPending) { break; } kit1 = dt.Rows[i].ItemArray[0].ToString(); kit2 = dt.Rows[j].ItemArray[0].ToString(); if (kit1 == kit2) { continue; } ref1 = dt.Rows[i].ItemArray[1].ToString(); ref2 = dt.Rows[j].ItemArray[1].ToString(); if (ref1 == "1" && ref2 == "1") { continue; } total++; } if (bwCompare.CancellationPending) { break; } } int idx = 0; string name1 = ""; string name2 = ""; bool reference = false; for (int i = 0; i < dt.Rows.Count; i++) { for (int j = i; j < dt.Rows.Count; j++) { if (bwCompare.CancellationPending) { break; } kit1 = dt.Rows[i].ItemArray[0].ToString(); kit2 = dt.Rows[j].ItemArray[0].ToString(); if (kit1 == kit2) { continue; } ref1 = dt.Rows[i].ItemArray[1].ToString(); ref2 = dt.Rows[j].ItemArray[1].ToString(); if (ref1 == "1" && ref2 == "1") { continue; } if (ref1 == "1" || ref2 == "1") { reference = true; } else { reference = false; } name1 = dt.Rows[i].ItemArray[2].ToString(); name2 = dt.Rows[j].ItemArray[2].ToString(); idx++; this.Invoke(new MethodInvoker(delegate { if (reference) { lblComparing.Text = "Comparing Reference " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + ") ... " + progress.ToString() + "%"; tbStatus.Text += ("Comparing Reference " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + "): "); } else { lblComparing.Text = "Comparing Kits " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + ") ... " + progress.ToString() + "%"; tbStatus.Text += ("Comparing Kits " + kit1 + " (" + name1 + ") and " + kit2 + " (" + name2 + "): "); } tbStatus.Select(tbStatus.Text.Length - 1, 0); tbStatus.ScrollToCaret(); })); progress = idx * 100 / total; object[] cmp_results = GGKUtilLib.compareOneToOne(kit1, kit2, bwCompare, reference, true); if (bwCompare.CancellationPending) { break; } segment_idx = (DataTable)cmp_results[0]; segments = (List <DataTable>)cmp_results[1]; //if (segment_idx.Rows.Count>0) if (segment_idx.Rows.Count > 0 || redo_again) { if (!this.IsHandleCreated) { break; } this.Invoke(new MethodInvoker(delegate { if (reference) { tbStatus.Text += segment_idx.Rows.Count.ToString() + " compound segments found.\r\n"; } else { tbStatus.Text += segment_idx.Rows.Count.ToString() + " matching segments found.\r\n"; } tbStatus.Select(tbStatus.Text.Length - 1, 0); tbStatus.ScrollToCaret(); })); } else { this.Invoke(new MethodInvoker(delegate { tbStatus.Text += "Earlier comparision exists, Skipping.\r\n"; tbStatus.Select(tbStatus.Text.Length - 1, 0); tbStatus.ScrollToCaret(); })); } bwCompare.ReportProgress(progress, progress.ToString() + "%"); } if (bwCompare.CancellationPending) { break; } if (!this.IsHandleCreated) { break; } } if (!bwCompare.CancellationPending) { bwCompare.ReportProgress(100, "Done."); } }