/// <summary> /// Adds properties to the <see cref="PatchInstallation"/> object and writes it to the pipeline. /// </summary> /// <param name="patch">The <see cref="PatchInstallation"/> to write to the pipeline.</param> private void WritePatch(PatchInstallation patch) { var obj = patch.ToPSObject(this.SessionState.Path); this.WriteObject(obj); }
private DataView GetPatchData(string patchCode) { DataTable table = new DataTable("PatchProperties"); table.Locale = CultureInfo.InvariantCulture; table.Columns.Add("PatchPropertiesProperty", typeof(string)); table.Columns.Add("PatchPropertiesValue", typeof(string)); table.Rows.Add(new object[] { "PatchCode", patchCode }); PatchInstallation patch = new PatchInstallation(patchCode, null); string localPackage = null; foreach(string property in new string[] { "InstallDate", "LocalPackage", "State", "Transforms", "Uninstallable", }) { try { string value = patch[property]; table.Rows.Add(new object[] { property, (value != null ? value : "") }); if(property == "LocalPackage") localPackage = value; } catch(InstallerException iex) { table.Rows.Add(new object[] { property, iex.Message }); } catch(ArgumentException) { } } if(localPackage != null) { try { using(SummaryInfo patchSummaryInfo = new SummaryInfo(localPackage, false)) { table.Rows.Add(new object[] { "Title", patchSummaryInfo.Title }); table.Rows.Add(new object[] { "Subject", patchSummaryInfo.Subject }); table.Rows.Add(new object[] { "Author", patchSummaryInfo.Author }); table.Rows.Add(new object[] { "Comments", patchSummaryInfo.Comments }); table.Rows.Add(new object[] { "TargetProductCodes", patchSummaryInfo.Template }); string obsoletedPatchCodes = patchSummaryInfo.RevisionNumber.Substring(patchSummaryInfo.RevisionNumber.IndexOf('}') + 1); table.Rows.Add(new object[] { "ObsoletedPatchCodes", obsoletedPatchCodes }); table.Rows.Add(new object[] { "TransformNames", patchSummaryInfo.LastSavedBy }); } } catch(InstallerException) { } catch(IOException) { } catch(SecurityException) { } } return new DataView(table, "", "PatchPropertiesProperty ASC", DataViewRowState.CurrentRows); }