private static void AddRow(ProductInstallation p) { myRow r = new myRow(p); rows.Add(r); Logger.LogMsg(r.ToString()); try { IEnumerable <PatchInstallation> patches = PatchInstallation.GetPatches(null, p.ProductCode, null, UserContexts.All, PatchStates.All); foreach (PatchInstallation patch in patches) { myRow patchRow = new myRow(patch); rows.Add(patchRow); Logger.LogMsg(patchRow.ToString()); } }catch (Exception ex) { Logger.LogError("AddRow:" + ex.Message); } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex != -1) { if (this.dataGridView1.Columns[e.ColumnIndex].Name == "FixIt")// { // MessageBox.Show(this.dataGridView1.Rows[e.RowIndex].Cells["PackageName"].Value.ToString()); if ((CacheFileStatus)(this.dataGridView1.Rows[e.RowIndex].Cells["Status"].Value) == CacheFileStatus.Missing || (CacheFileStatus)(this.dataGridView1.Rows[e.RowIndex].Cells["Status"].Value) == CacheFileStatus.Mismatched) { int idx = e.RowIndex; var rowIndexCellValue = (int)this.dataGridView1.Rows[e.RowIndex].Cells["Index"].Value; myRow r = null; foreach (myRow rr in myData.rows) { if (rr.Index == rowIndexCellValue) { r = rr; break; } } if (r == null) { MessageBox.Show("Internal data error! Clicked row not found in rows!"); return; } if (r.isPatch) { var matchedFile = myData.FindMsp(r.ProductName, r.PackageName, r.PatchCode); if (!String.IsNullOrEmpty(matchedFile)) { string destination = Path.Combine(@"c:\WINDOWS\INSTALLER\", r.CachedMsiMsp); bool copied = CopyFile(matchedFile, destination); if (copied) { r.Status = CacheFileStatus.Fixed; var row = this.dataGridView1.Rows[e.RowIndex]; row.DefaultCellStyle.BackColor = Color.YellowGreen; row.Cells["FixIt"].Value = null; row.Cells["FixIt"] = new DataGridViewTextBoxCell(); UpdateStatistics(); Logger.LogMsg("[Copy Done]" + destination + "==>" + destination); } else { Logger.LogMsg("[Copy Failed]" + destination + "==>" + destination); } } else { MessageBox.Show("Missing MSP not found!\n" + r.PackageName, "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { var matchedFile = myData.FindMsi(r.ProductName, r.PackageName, r.ProductCode, r.ProductVersion, r.PackageCode); if (!String.IsNullOrEmpty(matchedFile)) { string destination = Path.Combine(@"c:\WINDOWS\INSTALLER\", r.CachedMsiMsp); bool copied = CopyFile(matchedFile, destination); if (copied) { r.Status = CacheFileStatus.Fixed; var row = this.dataGridView1.Rows[e.RowIndex]; row.DefaultCellStyle.BackColor = Color.YellowGreen; row.Cells["FixIt"].Value = null; row.Cells["FixIt"] = new DataGridViewTextBoxCell(); UpdateStatistics(); Logger.LogMsg("[Copy Done]" + destination + "==>" + destination); } else { Logger.LogMsg("[Copy Failed]" + destination + "==>" + destination); } } else { MessageBox.Show("Missing MSI not found!\n" + r.PackageName, "File Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } //IF CLICK "fix it" } //if click onte first colum } }
public static void AddRow(myRow r) { rows.Add(r); }