From 792351c922856e8d496eec45033fef8335d05a54 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 1 Aug 2011 20:20:39 +0000 Subject: [PATCH] Change Manager --- .../AnnotationDetails.cs | 15 +- .../Volian.Controls.Library/DisplayHistory.cs | 875 +++++++++++ .../DisplayHistory.designer.cs | Bin 0 -> 32882 bytes .../DisplayTabControl.cs | 1 + PROMS/Volian.Controls.Library/DisplayText.cs | 5 +- PROMS/Volian.Controls.Library/EditItem.cs | 40 +- PROMS/Volian.Controls.Library/GridItem.cs | 21 +- PROMS/Volian.Controls.Library/RTBItem.cs | 12 +- PROMS/Volian.Controls.Library/StepRTB.cs | 17 +- PROMS/Volian.Controls.Library/StepTabPanel.cs | 2 +- .../Volian.Controls.Library/StepTabRibbon.cs | 2 +- PROMS/Volian.Controls.Library/VlnFlexGrid.cs | 5 +- .../PDFChronologyReport.cs | 1368 +++++++++++++++++ PROMS/Volian.Print.Library/PDFReport.cs | 8 +- 14 files changed, 2329 insertions(+), 42 deletions(-) create mode 100644 PROMS/Volian.Controls.Library/DisplayHistory.cs create mode 100644 PROMS/Volian.Controls.Library/DisplayHistory.designer.cs create mode 100644 PROMS/Volian.Print.Library/PDFChronologyReport.cs diff --git a/PROMS/Volian.Controls.Library/AnnotationDetails.cs b/PROMS/Volian.Controls.Library/AnnotationDetails.cs index e9f11f14..6436666b 100644 --- a/PROMS/Volian.Controls.Library/AnnotationDetails.cs +++ b/PROMS/Volian.Controls.Library/AnnotationDetails.cs @@ -109,16 +109,17 @@ namespace Volian.Controls.Library private void btnRemoveAnnotation_Click(object sender, EventArgs e) { - using (Annotation annotation = CurrentAnnotation.Get()) - { - annotation.Delete(); + //using (Annotation annotation = CurrentAnnotation.Get()) + //{ +// annotation.Delete(); _AnnotationSearch.LoadingList = true; - annotation.Save(); + Annotation.DeleteAnnotation(CurrentAnnotation); +// annotation.Save(); _AnnotationSearch.LoadingList = false; CurrentAnnotation = null; UpdateAnnotationGrid(); //_AnnotationSearch.UpdateAnnotationSearchResults(); // update the search results - } + //} } private void btnSaveAnnotation_Click(object sender, EventArgs e) @@ -286,8 +287,8 @@ namespace Volian.Controls.Library using (Annotation annotation = Annotation.MakeAnnotation(myItem, annotationType, rtxbComment.Rtf, rtxbComment.Text, "")) { CurrentAnnotation = AnnotationInfo.Get(annotation.AnnotationID); - annotation.DTS = DateTime.Now; - annotation.Save(); + //annotation.DTS = DateTime.Now; + //annotation.Save(); } } } diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.cs b/PROMS/Volian.Controls.Library/DisplayHistory.cs new file mode 100644 index 00000000..72732a8d --- /dev/null +++ b/PROMS/Volian.Controls.Library/DisplayHistory.cs @@ -0,0 +1,875 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using VEPROMS.CSLA.Library; +using System.IO; +using System.Text.RegularExpressions; + +namespace Volian.Controls.Library +{ + public partial class DisplayHistory : UserControl + { + #region Events + public event DisplayHistoryReportEvent ChronologyPrintRequest; + public event DisplayHistoryReportEvent SummaryPrintRequest; + private void OnChronologyPrintRequest(DisplayHistoryReportEventArgs args) + { + if (ChronologyPrintRequest != null) + ChronologyPrintRequest(this, args); + } + private void OnSummaryPrintRequest(DisplayHistoryReportEventArgs args) + { + if (SummaryPrintRequest != null) + SummaryPrintRequest(this, args); + } + public event DisplayHistoryEvent HistorySelectionChanged; + private void OnHistorySelectionChanged(DisplayHistoryEventArgs args) + { + if (HistorySelectionChanged != null) + HistorySelectionChanged(this, args); + } + public event ItemRestoredHandler ItemRestored; + private void OnItemRestored(ItemInfo restoredItemInfo) + { + if (ItemRestored != null) ItemRestored(restoredItemInfo); + } + #endregion + private ContentAuditInfoList _ChronologyAuditList; + private ContentAuditInfoList _SummaryAuditList; + private AnnotationAuditInfoList _AnnotationList; + private ProcedureInfo _MyProcedureInfo; + public ProcedureInfo MyProcedureInfo + { + get { return _MyProcedureInfo; } + set + { + if (value is ProcedureInfo && _MyProcedureInfo is ProcedureInfo && value.ItemID == _MyProcedureInfo.ItemID) + return; + _MyProcedureInfo = value; + if (_MyProcedureInfo != null && this.Visible) + WalkProcedure(); + } + } + private ItemInfo _MyItemInfo; + public ItemInfo MyItemInfo + { + get { return _MyItemInfo; } + set + { + if (value is ItemInfo && _MyItemInfo is ItemInfo && value.ItemID == _MyItemInfo.ItemID) + return; + _MyItemInfo = value; + if (_MyItemInfo != null) + { + MyProcedureInfo = _MyItemInfo.MyProcedure; + if(this.Visible) + UpdateHistory(); + } + } + } + private EditItem _MyEditItem; + + public EditItem MyEditItem + { + get { return _MyEditItem; } + set + { + _MyEditItem = value; + if (value != null) + MyItemInfo = value.MyItemInfo; + else + MyItemInfo = null; + } + } + public void RefreshList() + { + if (this.Visible) + { + WalkProcedure(); + UpdateHistory(); + } + } + + public DisplayHistory() + { + InitializeComponent(); + myRTB.FormatFont = null; + } + + private void lbChanges_SelectedIndexChanged(object sender, EventArgs e) + { + if (lbChanges.SelectedIndex > -1) + { + if (lbChanges.SelectedIndex < _ChronologyAuditList.Count) + { + ContentAuditInfo cai = _ChronologyAuditList[lbChanges.SelectedIndex]; + OnHistorySelectionChanged(new DisplayHistoryEventArgs(cai.ItemID)); + } + else + { + AnnotationAuditInfo aai = _AnnotationList[lbChanges.SelectedIndex - _ChronologyAuditList.Count]; + OnHistorySelectionChanged(new DisplayHistoryEventArgs(aai.ItemID)); + } + } + } + private void UpdateHistory() + { + this.Cursor = Cursors.WaitCursor; + DateTime start = DateTime.Now; + Console.WriteLine(start); + #region setup + btnRestore.Enabled = false; + myRTB.Clear(); + myVFG.Clear(); + tvAudits.Nodes.Clear(); + if (MyItemInfo == null) return; + MyItemInfo.RefreshItemAnnotations(); + #endregion + //if (AnnotationOnly) + //{ + #region annotation deleted + //annotation deleted by itemid + TreeNode annotationDeleted = null; + AnnotationAuditInfoList aail = AnnotationAuditInfoList.GetByItemID(MyItemInfo.ItemID); + foreach (AnnotationAuditInfo aai in aail) + { + TreeNode tn = null; + if (aai.DeleteStatus > 0) + { + if (annotationDeleted == null) + annotationDeleted = tvAudits.Nodes.Add("Deleted Annotations"); + if (tn == null) + { + AnnotationTypeInfo ati = AnnotationTypeInfo.Get(aai.TypeID); + tn = annotationDeleted.Nodes.Add(ati.Name); + } + TreeNode cn = tn.Nodes.Add(aai.ToString()); + cn.Tag = aai; + } + } + //end annotation deleted + #endregion + #region annotation changes + //annotation change by annotationid + TreeNode annotationHistory = null; + if (MyItemInfo.ItemAnnotationCount > 0) + { + foreach (AnnotationInfo ai in MyItemInfo.ItemAnnotations) + { + TreeNode tn = null; + aail = AnnotationAuditInfoList.GetByAnnotationID(ai.AnnotationID); + foreach (AnnotationAuditInfo aai in aail) + { + if (aai.DTS != ai.DTS) + { + if (annotationHistory == null) + annotationHistory = tvAudits.Nodes.Add("Annotation History"); + if (tn == null) + tn = annotationHistory.Nodes.Add(string.Format("{0} - {1}", ai.MyAnnotationType.Name, ai.SearchText)); + TreeNode cn = tn.Nodes.Add(aai.ToString()); + cn.Tag = aai; + } + } + } + } + //end annotation change + #endregion + // return; + //} + #region content changes + //content changes + TreeNode contentHistory = null; + if (MyItemInfo == null) return; + ContentAuditInfoList cail = ContentAuditInfoList.Get(MyItemInfo.ContentID); + // ContentAuditInfoList cail = ContentAuditInfoList.GetChronology(MyItemInfo.MyProcedure.ItemID, MyItemInfo.ItemID, false); + ContentInfo ci = ContentInfo.Get(MyItemInfo.ContentID); + foreach (ContentAuditInfo cai in cail) + { + if (cai.DeleteStatus == 0) + { + if (cai.Type == 20008) + { + GridAuditInfoList gail = GridAuditInfoList.Get(cai.ContentID); + foreach (GridAuditInfo gai in gail) + { + if (gai.DeleteStatus == 0) + { + if (contentHistory == null) + contentHistory = tvAudits.Nodes.Add("Content Changes"); //contentHistory = tvAudits.Nodes.Add("Content History"); + TreeNode tn = contentHistory.Nodes.Add(gai.ToString()); + tn.Tag = gai; + } + } + break; + } + else if (cai.DTS != ci.DTS) + { + if (contentHistory == null) + contentHistory = tvAudits.Nodes.Add("Content Changes"); //contentHistory = tvAudits.Nodes.Add("Content History"); + TreeNode tn = contentHistory.Nodes.Add(cai.ToString()); + tn.Tag = cai; + } + } + } + //end content changes + #endregion + #region items + TreeNode deletedItems = null; + TreeNode previousItem = null; + TreeNode nextItem = null; + TreeNode procedurePart = null; + TreeNode sectionPart = null; + TreeNode cautionPart = null; + TreeNode notePart = null; + TreeNode rnoPart = null; + TreeNode stepPart = null; + TreeNode tablePart = null; + #endregion + ItemAuditInfoList iail = ItemAuditInfoList.Get(MyItemInfo.ItemID); + foreach (ItemAuditInfo iai in iail) + { + #region old style + // switch (iai.Level) + // { + // #region previous item + // case 0: //previous item + // { + // #region old style + // //if (previousItem == null) + // // previousItem = tvAudits.Nodes.Add("Deleted Previous Item"); //previousItem = tvAudits.Nodes.Add("Previous Item"); + // //TreeNode tn = previousItem.Nodes.Add(iai.ToString()); + // //tn.Tag = iai; + // #endregion + // #region new style + // if (deletedItems == null) + // deletedItems = tvAudits.Nodes.Add("Deleted Items"); + // TreeNode tnn = deletedItems.Nodes.Add(iai.ToString()); + // tnn.Tag = iai; + // #endregion + // break; + // } + // #endregion + // #region next item + // case 1: //next item + // { + // #region old style + // //if (nextItem == null) + // // nextItem = tvAudits.Nodes.Add("Deleted Next Item"); //nextItem = tvAudits.Nodes.Add("Next Item"); + // //TreeNode tn = nextItem.Nodes.Add(iai.ToString()); + // //tn.Tag = iai; + // #endregion + // #region new style + // if (deletedItems == null) + // deletedItems = tvAudits.Nodes.Add("Deleted Items"); + // TreeNode tnn = deletedItems.Nodes.Add(iai.ToString()); + // tnn.Tag = iai; + // #endregion + // break; + // } + // #endregion + // case 2: //parts + // { + // #region old style + // //PartAuditInfoList pail = null; + // //pail = PartAuditInfoList.GetByDeleteStatus(iai.DeleteStatus); + // //if (pail.Count == 0) + // // pail = PartAuditInfoList.GetByItemID(iai.ItemID); + // //foreach (PartAuditInfo pai in pail) + // //{ + // // if (pai.ContentID == MyItemInfo.ContentID) + // // { + // // switch (pai.FromType) + // // { + // // #region procedure part + // // case 1: //procedures + // // { + // // if (procedurePart == null) + // // procedurePart = tvAudits.Nodes.Add("Deleted Procedures"); //procedurePart = tvAudits.Nodes.Add("Procedures"); + // // TreeNode tn = procedurePart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // #region section part + // // case 2: //sections + // // { + // // if (sectionPart == null) + // // sectionPart = tvAudits.Nodes.Add("Deleted Sections"); //sectionPart = tvAudits.Nodes.Add("Sections"); + // // TreeNode tn = sectionPart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // #region caution part + // // case 3: //cautions + // // { + // // if (cautionPart == null) + // // cautionPart = tvAudits.Nodes.Add("Deleted Cautions"); //cautionPart = tvAudits.Nodes.Add("Cautions"); + // // TreeNode tn = cautionPart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // #region note part + // // case 4: //notes + // // { + // // if (notePart == null) + // // notePart = tvAudits.Nodes.Add("Deleted Notes"); //notePart = tvAudits.Nodes.Add("Notes"); + // // TreeNode tn = notePart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // #region rno part + // // case 5: //rnos + // // { + // // if (rnoPart == null) + // // rnoPart = tvAudits.Nodes.Add("Deleted RNOs"); //rnoPart = tvAudits.Nodes.Add("RNOs"); + // // TreeNode tn = rnoPart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // #region step part + // // case 6: //steps + // // { + // // if (stepPart == null) + // // stepPart = tvAudits.Nodes.Add("Deleted Steps"); //stepPart = tvAudits.Nodes.Add("Steps"); + // // TreeNode tn = stepPart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // #region table part + // // case 7: //tables + // // { + // // if (tablePart == null) + // // tablePart = tvAudits.Nodes.Add("Deleted Tables"); //tablePart = tvAudits.Nodes.Add("Tables"); + // // TreeNode tn = tablePart.Nodes.Add(iai.ToString()); + // // tn.Tag = iai; + // // break; + // // } + // // #endregion + // // } + // // } + // //} + // #endregion + // #region new style + // if (deletedItems == null) + // deletedItems = tvAudits.Nodes.Add("Deleted Items"); + // TreeNode tnn = deletedItems.Nodes.Add(iai.ToString()); + // tnn.Tag = iai; + // #endregion + // break; + // } + //} + #endregion + #region new style + if (deletedItems == null) + deletedItems = tvAudits.Nodes.Add("Deleted Items"); + TreeNode tnn = deletedItems.Nodes.Add(iai.ToString()); + tnn.Tag = iai; + #endregion + } + Console.WriteLine("UpdateHistory: {0} seconds",TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + this.Cursor = Cursors.Default; + } + private void WalkProcedure() + { + //return; + this.Cursor = Cursors.WaitCursor; + DateTime start = DateTime.Now; + Console.WriteLine(start); + lbChanges.Items.Clear(); + ContentAuditInfoList cail2 = ContentAuditInfoList.GetChronology(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false); + Console.WriteLine("WalkProcedure cail2: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + _ChronologyAuditList = cail2; + ContentAuditInfoList cail3 = ContentAuditInfoList.GetSummary(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID, false); + _SummaryAuditList = cail3; + AnnotationAuditInfoList aail2 = AnnotationAuditInfoList.GetChronology(MyProcedureInfo.ItemID, MyProcedureInfo.ItemID); + Console.WriteLine("WalkProcedure aail2: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + _AnnotationList = aail2; + foreach (ContentAuditInfo cai in cail2) + { + string itemTitle = Regex.Replace(cai.Path, "^..+?\\u0007", ""); + itemTitle = itemTitle.Replace("\x11", itemTitle[0]=='\x11' ? "" : " - "); + lbChanges.Items.Add(string.Format("{4} item {0} by {1} on {2} @ {3}", cai.ActionWhat, cai.UserID, cai.ActionWhen == DateTime.MinValue ? cai.DTS.ToShortDateString() : cai.ActionWhen.ToShortDateString(), cai.ActionWhen == DateTime.MinValue ? cai.DTS.ToShortTimeString() : cai.ActionWhen.ToShortTimeString(), itemTitle)); + } + foreach (AnnotationAuditInfo aai in aail2) + { + string stepnum = string.Empty; + foreach (ContentAuditInfo cai in cail2) + { + if (cai.ContentID == aai.IContentID) + { + stepnum = Regex.Replace(cai.Path, "^..+?\\u0007.", ""); + break; + } + } + lbChanges.Items.Add(string.Format("{4} Annotation {0} by {1} on {2} @ {3}", aai.ActionWhat, aai.UserID, aai.ActionWhen.ToShortDateString(), aai.ActionWhen.ToShortTimeString(), stepnum)); + } + Console.WriteLine("WalkProcedure fini: {0} seconds", TimeSpan.FromTicks(DateTime.Now.Ticks - start.Ticks).TotalSeconds); + this.Cursor = Cursors.Default; + btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = lbChanges.Items.Count > 0; + return; + + string itemType = string.Empty; + lbChanges.Items.Clear(); + ItemInfo myproc = _MyItemInfo.MyProcedure; + ItemInfo ii = myproc; + int lenNumber = myproc.DisplayNumber.Length + 2; + if (ii == null) return; + while (ii != null && ii.MyProcedure.ItemID == myproc.ItemID) + { + itemType = ii.IsCaution ? "Caution for" : ii.IsNote ? "Note for" : ii.IsStep ? "Step" : "Item"; + //items + if (ii.IsItemNew) + { + lbChanges.Items.Add(string.Format("{4} {0} added by {1} on {2} @ {3}", ii.ShortPath.Substring(lenNumber), ii.UserID, ii.DTS.ToShortDateString(), ii.DTS.ToShortTimeString(), itemType)); + //int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Item Added", ii.DTS.ToString(), ii.DisplayText)); + //ListViewItem lvi = new ListViewItem("Item Added"); + //lvi.SubItems.Add(ii.ItemID.ToString()); + //lvi.SubItems.Add(ii.DTS.ToString()); + //lvi.SubItems.Add(ii.DisplayText); + //lvi.SubItems.Add(ii.ShortPath.Substring(lenNumber)); + //listView1.Items.Add(lvi); + if (ii.IsItemChanged) + { + ContentAuditInfoList cail = ContentAuditInfoList.Get(ii.ContentID); + if (cail.Count > 0) + { + foreach (ContentAuditInfo cai in cail) + { + if (cai.Text != string.Empty) + { + lbChanges.Items.Add(string.Format("{4} {0} changed by {1} on {2} @ {3}", ii.ShortPath.Substring(lenNumber), ii.MyContent.UserID, ii.MyContent.DTS.ToShortDateString(), ii.MyContent.DTS.ToShortTimeString(), itemType)); + } + } + } + } + } + else if (ii.IsItemChanged) + { + //Results.Add(ii); + lbChanges.Items.Add(string.Format("{4} {0} changed by {1} on {2} @ {3}", ii.ShortPath.Substring(lenNumber), ii.MyContent.UserID, ii.MyContent.DTS.ToShortDateString(), ii.MyContent.DTS.ToShortTimeString(), itemType)); + //int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Content Changed", ii.DTS.ToString(), ii.DisplayText)); + //ListViewItem lvi = new ListViewItem("Item Changed"); + //lvi.SubItems.Add(ii.ItemID.ToString()); + //lvi.SubItems.Add(ii.MyContent.DTS.ToString()); + //lvi.SubItems.Add(ii.DisplayText); + //lvi.SubItems.Add(ii.ShortPath.Substring(lenNumber)); + //listView1.Items.Add(lvi); + } + ItemAuditInfoList iail = ItemAuditInfoList.Get(ii.ItemID); + foreach (ItemAuditInfo iai in iail) + { + if (iai.DeleteStatus > 0 && iai.Level == 1) + { + lbChanges.Items.Add(string.Format("{4} after {0} deleted by {1} on {2} @ {3}", ii.ShortPath.Substring(lenNumber), iai.UserID, iai.DTS.ToShortDateString(), iai.DTS.ToShortTimeString(), itemType)); + //int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Item Deleted", ii.DTS.ToString(), "TODO: figure out how to get iai.DisplayText")); + //ListViewItem lvi = new ListViewItem("Item Deleted"); + //lvi.SubItems.Add(iai.ItemID.ToString()); + //lvi.SubItems.Add(iai.DTS.ToString()); //iai.MyContent.DTS.ToString() + //lvi.SubItems.Add("TODO: figure out how to get iai.DisplayText"); //TODO: figure out how to get iai.DisplayText + //lvi.SubItems.Add("After " + ii.ShortPath.Substring(lenNumber)); + } + else + { + PartAuditInfoList pail = null; + pail = PartAuditInfoList.GetByItemID(iai.ItemID); + if (pail.Count > 0) + { + foreach (PartAuditInfo pai in pail) + { + itemType = pai.FromType == 3 ? "Caution for" : pai.FromType == 4 ? "Note for" : pai.FromType == 6 ? "Step" : "Item" + pai.FromType.ToString(); + lbChanges.Items.Add(string.Format("{4} {0} deleted by {1} on {2} @ {3}", ii.ShortPath.Substring(lenNumber), iai.UserID, iai.DTS.ToShortDateString(), iai.DTS.ToShortTimeString(), itemType)); + } + } + } + } + //annotations + if (ii.ItemAnnotations != null) + { + foreach (AnnotationInfo ai in ii.ItemAnnotations) + { + if (ai.IsAnnotationNew) + { + int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Annotation Added", ai.DTS.ToString(), ai.SearchText)); + //ListViewItem lvi = new ListViewItem("Annotation Added"); + //lvi.SubItems.Add(ai.AnnotationID.ToString()); + //lvi.SubItems.Add(ai.DTS.ToString()); + //lvi.SubItems.Add(ai.SearchText); + //lvi.SubItems.Add(ii.ShortPath.Substring(lenNumber)); + //listView1.Items.Add(lvi); + } + else + { + int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Annotation Changed", ai.DTS.ToString(), ai.SearchText)); + //ListViewItem lvi = new ListViewItem("Annotation Changed"); + //lvi.SubItems.Add(ai.AnnotationID.ToString()); + //lvi.SubItems.Add(ai.DTS.ToString()); + //lvi.SubItems.Add(ai.SearchText); + //lvi.SubItems.Add(ii.ShortPath.Substring(lenNumber)); + //listView1.Items.Add(lvi); + } + } + AnnotationAuditInfoList aail = AnnotationAuditInfoList.GetByItemID(ii.ItemID); + foreach (AnnotationAuditInfo aai in aail) + { + if (aai.DeleteStatus > 0) + { + int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Annotation Deleted", aai.DTS.ToString(), aai.SearchText)); + //ListViewItem lvi = new ListViewItem("Annotation Deleted"); + //lvi.SubItems.Add(aai.AnnotationID.ToString()); + //lvi.SubItems.Add(aai.DTS.ToString()); + //lvi.SubItems.Add(aai.SearchText); + //lvi.SubItems.Add(ii.ShortPath.Substring(lenNumber)); + //listView1.Items.Add(lvi); + } + } + } + //content changes + //ContentAuditInfoList cail = ContentAuditInfoList.Get(ii.MyContent.ContentID); + //foreach (ContentAuditInfo cai in cail) + //{ + // int k = lbChanges.Items.Add(string.Format("{0} @ {1} - {2}", "Content Changed", cai.DTS.ToString(), cai.Text)); + //ListViewItem lvi = new ListViewItem("Content Changed"); + //lvi.SubItems.Add(cai.ContentID.ToString()); + //lvi.SubItems.Add(cai.DTS.ToString()); + //lvi.SubItems.Add(cai.Text); + //lvi.SubItems.Add(ii.ShortPath.Substring(lenNumber)); + //listView1.Items.Add(lvi); + //} + ii = ii.SearchNext; + } + btnViewSummaryReport.Enabled = btnViewChronologyReport.Enabled = lbChanges.Items.Count > 0; + } + private void btnViewChronologyReport_Click(object sender, EventArgs e) + { + //if (lbChanges.Items.Count > 0) + //{ + OnChronologyPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MyChronology.pdf", MyItemInfo.MyProcedure, _ChronologyAuditList, _AnnotationList)); + //} + } + private void btnViewSummaryReport_Click(object sender, EventArgs e) + { + //if (lbChanges.Items.Count > 0) + //{ + OnSummaryPrintRequest(new DisplayHistoryReportEventArgs(Volian.Base.Library.VlnSettings.TemporaryFolder + @"\MySummary.pdf", MyItemInfo.MyProcedure, _SummaryAuditList, _AnnotationList)); + //} + } + private void btnRefresh_Click(object sender, EventArgs e) + { + RefreshList(); + } + private void btnRestore_Click(object sender, EventArgs e) + { + TreeNode tn = tvAudits.SelectedNode; + if (tn.Tag is ContentAuditInfo) + { + ContentAuditInfo cai = tn.Tag as ContentAuditInfo; + if (MessageBox.Show(this, "Do you want to restore this content change?", "Confirm Content Change Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + ContentInfo ci = ContentInfo.RestoreContent(cai); + UpdateHistory(); + myRTB.Clear(); + myVFG.Clear(); + } + } + if (tn.Tag is ItemAuditInfo) + { + ItemAuditInfo iai = tn.Tag as ItemAuditInfo; + if (MessageBox.Show(this, string.Format("Do you want to restore this {0}?",iai.ItemType), string.Format("Confirm {0} Restore",iai.ItemType), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + Console.WriteLine("DisplayHistory.btnRestore_Click @ {0}", DateTime.Now); + ItemInfo ii = null; + if (iai.Level == 2) + { + ii = MyItemInfo.RestoreItem(iai); + + //_MyEditItem.AddChild((E_FromType)fromtype, contenttype); + //ii.ItemParts[0].FromType + //ii.MyContent.Type + EditItem nextItem = MyEditItem.GetNextItem((E_FromType)ii.ItemParts[0].FromType, ii); + //MyEditItem.AddChild(ii.MyContent.Text, (E_FromType)ii.ItemParts[0].FromType, (int)ii.MyContent.Type, null); + if (ii.IsStep) + ii = StepInfo.Get(ii.ItemID); + else if (ii.IsSection) + ii = SectionInfo.Get(ii.ItemID); + else if (ii.IsProcedure) + ii = ProcedureInfo.Get(ii.ItemID); + if (nextItem != null) + { + switch (nextItem.MyChildRelation) + { + case ChildRelation.None: + break; + case ChildRelation.After: + MyEditItem.AddChildAfter(ii, nextItem); + break; + case ChildRelation.Before: + MyEditItem.AddChildBefore(ii, nextItem); + break; + case ChildRelation.RNO: + MyEditItem.AddChildRNO(ii, nextItem); + break; + default: + break; + } + } + else + { + switch ((E_FromType)ii.ItemParts[0].FromType) + { + case E_FromType.Caution: + MyEditItem.AddChildBefore(ii, nextItem); + break; + case E_FromType.Note: + MyEditItem.AddChildBefore(ii, nextItem); + break; + case E_FromType.Procedure: + MyEditItem.AddChildAfter(ii, nextItem); + break; + case E_FromType.RNO: + MyEditItem.AddChildRNO(ii, nextItem); + break; + case E_FromType.Section: + MyEditItem.AddChildAfter(ii, nextItem); + break; + case E_FromType.Step: + MyEditItem.AddChildAfter(ii, nextItem); + break; + case E_FromType.Table: + MyEditItem.AddChildAfter(ii, nextItem); + break; + default: + MyEditItem.AddChildAfter(ii, nextItem); + break; + } + } + } + else + { + ii = MyItemInfo.RestoreSibling(iai); + if (ii.IsStep) + ii = StepInfo.Get(ii.ItemID); + else if (ii.IsSection) + ii = SectionInfo.Get(ii.ItemID); + else if (ii.IsProcedure) + ii = ProcedureInfo.Get(ii.ItemID); + EditItem nextItem = iai.Level == 0 ? MyEditItem : MyEditItem.MyNextEditItem; + switch (MyEditItem.MyChildRelation) + { + case ChildRelation.None: + break; + case ChildRelation.After: + MyEditItem.ActiveParent.AddChildAfter(ii, nextItem); + break; + case ChildRelation.Before: + MyEditItem.ActiveParent.AddChildBefore(ii, nextItem); + break; + case ChildRelation.RNO: + MyEditItem.ActiveParent.AddChildRNO(ii, nextItem); + break; + default: + break; + } + } + if(MyEditItem.MyPreviousEditItem != null) + MyEditItem.MyPreviousEditItem.SetAllTabs(); + else + MyEditItem.SetAllTabs(); + UpdateHistory(); + myRTB.Clear(); + myVFG.Clear(); + } + } + if (tn.Tag is AnnotationAuditInfo) + { + AnnotationAuditInfo aai = tn.Tag as AnnotationAuditInfo; + if (MessageBox.Show(this, "Do you want to restore this annotation?", "Confirm Annotation Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + AnnotationInfo ai = AnnotationInfo.RestoreAnnotation(aai); + UpdateHistory(); + myRTB.Clear(); + myVFG.Clear(); + } + } + if (tn.Tag is GridAuditInfo) + { + GridAuditInfo gai = tn.Tag as GridAuditInfo; + if (MessageBox.Show(this, "Do you want to restore this table?", "Confirm Table Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) + { + ContentAuditInfo cai = ContentAuditInfo.Get(gai.ContentAuditID); + ContentInfo ci = ContentInfo.RestoreContent(cai); + UpdateHistory(); + myRTB.Clear(); + myVFG.Clear(); + } + } + } + private void DisplayTagRTF(TreeNode tn) + { + if (tn.Tag != null) + { + if (tn.Tag is GridAuditInfo) + { + btnRestore.Enabled = true; + GridAuditInfo gai = tn.Tag as GridAuditInfo; + myVFG.Visible = true; + myVFG.BringToFront(); + panel1.Invalidate(new Rectangle(0, 0, myVFG.Width + 4, 4)); + panel1.Invalidate(new Rectangle(0, 0, 4, myVFG.Height + 4)); + myRTB.Visible = false; + panel1.Visible = false; + using (StringReader sr = new StringReader(gai.Data)) + { + myVFG.ReadXml(sr); + sr.Close(); + } + panel1.Visible = true; + return; + } + if (tn.Tag is ContentAuditInfo) + { + btnRestore.Enabled = true; + myVFG.Clear(); + ContentAuditInfo cai = tn.Tag as ContentAuditInfo; + GridAuditInfoList gail = GridAuditInfoList.Get(cai.ContentID); + if (gail.Count > 0) + { + foreach (GridAuditInfo gai in gail) + { + if (gai.DTS == cai.DTS) + { + myVFG.Visible = true; + myVFG.BringToFront(); + myRTB.Visible = false; + using (StringReader sr = new StringReader(gai.Data)) + { + myVFG.ReadXml(sr); + sr.Close(); + } + return; + } + } + } + else + { + myRTB.Visible = true; + myRTB.BringToFront(); + myVFG.Visible = false; +// myRTB.Font = new Font("Arial", 12, FontStyle.Regular); +// myRTB.Text = cai.Text; + myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData.Font); + } + } + if (tn.Tag is ItemAuditInfo) + { + btnRestore.Enabled = true; + ItemAuditInfo iai = tn.Tag as ItemAuditInfo; + ContentAuditInfoList cail = ContentAuditInfoList.Get(iai.ContentID); + foreach (ContentAuditInfo cai in cail) + { + if (cai.DeleteStatus == iai.DeleteStatus) + { + //myRTB.Font = new Font("Arial", 12, FontStyle.Regular); + //myRTB.Text = cai.Text; + if (MyItemInfo.FormatStepData != null) + myRTB.SetupRichText(cai.Text, MyItemInfo.FormatStepData.Font); + else + { + myRTB.SetupRichText(cai.Text, new VE_Font(StepRTB.MyFontFamily != null ? StepRTB.MyFontFamily.Name : "arial", 12, E_Style.None, 8)); + } + + } + } + } + if (tn.Tag is AnnotationAuditInfo) + { + btnRestore.Enabled = true; + AnnotationAuditInfo iai = tn.Tag as AnnotationAuditInfo; + myRTB.Font = new Font("Arial", 12, FontStyle.Regular); + myRTB.Rtf = iai.RtfText; + //myRTB.Rtf = iai.RtfText; + } + } + else + { + btnRestore.Enabled = false; + myRTB.Clear(); + myVFG.Clear(); + } + } + private void tvAudits_AfterSelect(object sender, TreeViewEventArgs e) + { + DisplayTagRTF(e.Node); + } + private void DisplayHistory_Resize(object sender, EventArgs e) + { + tvAudits.Height = ((tcpDetail.Height - btnRestore.Height) / 4) * 3; + } + + private void DisplayHistory_VisibleChanged(object sender, EventArgs e) + { + this.RefreshList(); + } + } + + public delegate void ItemRestoredHandler(ItemInfo restoredItemInfo); + public delegate void DisplayHistoryReportEvent(object sender, DisplayHistoryReportEventArgs args); + public delegate void DisplayHistoryEvent(object sender, DisplayHistoryEventArgs args); + public class DisplayHistoryReportEventArgs + { + private string _ReportName; + public string ReportTitle + { + get { return _ReportName; } + set { _ReportName = value; } + } + private ProcedureInfo _ProcedureInfo; + public ProcedureInfo ProcedureInfo + { + get { return _ProcedureInfo; } + set { _ProcedureInfo = value; } + } + private ContentAuditInfoList _AuditList; + public ContentAuditInfoList AuditList + { + get { return _AuditList; } + set { _AuditList = value; } + } + private AnnotationAuditInfoList _AnnotationList; + public AnnotationAuditInfoList AnnotationList + { + get { return _AnnotationList; } + set { _AnnotationList = value; } + } + + public DisplayHistoryReportEventArgs(string reportName, ProcedureInfo procedureInfo, ContentAuditInfoList auditList, AnnotationAuditInfoList annotationList) + { + _ReportName = reportName; + _ProcedureInfo = procedureInfo; + _AuditList = auditList; + _AnnotationList = annotationList; + } + } + public class DisplayHistoryEventArgs + { + private int _ItemID; + public int ItemID + { + get { return _ItemID; } + set { _ItemID = value; } + } + public DisplayHistoryEventArgs(int itemID) + { + _ItemID = itemID; + } + } +} + diff --git a/PROMS/Volian.Controls.Library/DisplayHistory.designer.cs b/PROMS/Volian.Controls.Library/DisplayHistory.designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..7ffbb180f75b4f4246ded061f21171a9d1c72408 GIT binary patch literal 32882 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 B)9e5M literal 0 HcmV?d00001 diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index d338150f..1621babc 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -319,6 +319,7 @@ namespace Volian.Controls.Library public DisplayTabItem OpenItem(ItemInfo myItemInfo) { CleanUpClosedItems(); + if (myItemInfo == null) return null; _MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item. if (myItemInfo.MyContent.MyEntry == null) // If it is a Word document open in step editor return OpenStepTabPage(myItemInfo); diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index da376000..e98f2b50 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -465,8 +465,9 @@ namespace Volian.Controls.Library { Console.WriteLine("{0} - {1}", br.Property, br.Description); } - _MyItem.DTS = DateTime.Now; - _MyItem.UserID = Volian.Base.Library.VlnSettings.UserID; + // Don't update the DTS or User for Text Changes + //_MyItem.DTS = DateTime.Now; + //_MyItem.UserID = Volian.Base.Library.VlnSettings.UserID; _MyItem.Save(); } _MyItem = null; diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 666e490a..6e3ef415 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -66,6 +66,11 @@ namespace Volian.Controls.Library } protected static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); protected ChildRelation _MyChildRelation; + public ChildRelation MyChildRelation + { + get { return _MyChildRelation; } + set { _MyChildRelation = value; } + } protected bool _Loading = true; protected EditItem _MyParentEditItem = null; protected EditItem _MySectionRTBItem; @@ -556,6 +561,7 @@ namespace Volian.Controls.Library } public EditItem DeleteItem() { + MyStepPanel._LookupEditItems.Remove(MyID); EditItem newFocus = null; int? TopMostParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.TopMostEditItem.Top)); int? ParentY = (MyParentEditItem == null ? null : (int?)(MyParentEditItem.Top)); @@ -731,7 +737,8 @@ namespace Volian.Controls.Library public EditItem AddChildAfter(ItemInfo MyItemInfo, bool expand) { EditItem child = null; - if (MyItemInfo.MyContent.ContentGridCount != 0) + //if (MyItemInfo.MyContent.ContentGridCount != 0) + if (MyItemInfo.MyContent.MyGrid != null) child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand); else child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, expand); @@ -740,7 +747,8 @@ namespace Volian.Controls.Library public EditItem AddChildAfter(ItemInfo MyItemInfo, EditItem nextEditItem) { EditItem child = null; - if (MyItemInfo.MyContent.ContentGridCount != 0) + //if (MyItemInfo.MyContent.ContentGridCount != 0) + if (MyItemInfo.MyContent.MyGrid != null) child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem); else child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.After, true, nextEditItem); @@ -760,7 +768,8 @@ namespace Volian.Controls.Library { // not sure about this, i.e. whether a grid can be added here. EditItem child = null; - if (MyItemInfo.MyContent.ContentGridCount != 0) + //if (MyItemInfo.MyContent.ContentGridCount != 0) + if (MyItemInfo.MyContent.MyGrid != null) child = new GridItem(MyItemInfo, MyStepPanel, this, ChildRelation.RNO, true, nextEditItem); else child = new RTBItem(MyItemInfo, MyStepPanel, this, ChildRelation.RNO, true, nextEditItem); @@ -865,15 +874,7 @@ namespace Volian.Controls.Library } } // TODO: We need to determine where this will go in the stack of children - EditItem nextItem = null; - if (newItemInfo.NextItem != null) - nextItem = MyStepPanel.FindItem(newItemInfo.NextItem); - else if (fromType == E_FromType.Table && MyAfterEditItems != null) - nextItem = MyAfterEditItems[0]; - // Cautions come before notes, so if this is a Caution and there are Notes, put this first - else if (fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null - && ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0) - nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]); + EditItem nextItem = GetNextItem(fromType, newItemInfo); // TODO: May need similar logic if a Table is being added to a step that has substeps // else if (fromType == E_FromType.Table && ((ItemInfo)newItemInfo.ActiveParent).Steps != null //&& ((ItemInfo)newItemInfo.ActiveParent).Steps.Count > 0) @@ -908,6 +909,19 @@ namespace Volian.Controls.Library } MyStepPanel.SelectedEditItem = newEditItem;//Update Screen } + public EditItem GetNextItem(E_FromType fromType, ItemInfo newItemInfo) + { + EditItem nextItem = null; + if (newItemInfo.NextItem != null) + nextItem = MyStepPanel.FindItem(newItemInfo.NextItem); + else if (fromType == E_FromType.Table && MyAfterEditItems != null) + nextItem = MyAfterEditItems[0]; + // Cautions come before notes, so if this is a Caution and there are Notes, put this first + else if (fromType == E_FromType.Caution && ((ItemInfo)newItemInfo.ActiveParent).Notes != null + && ((ItemInfo)newItemInfo.ActiveParent).Notes.Count > 0) + nextItem = MyStepPanel.FindItem(((ItemInfo)newItemInfo.ActiveParent).Notes[0]); + return nextItem; + } /// /// Add a list of children after /// @@ -1970,7 +1984,7 @@ namespace Volian.Controls.Library } if (expand) ShowExpanded(); MyStepPanel = myStepPanel; - if (itemInfo != null) myStepPanel._LookupEditItems.Add(itemInfo.ItemID, this); + if (itemInfo != null && !myStepPanel._LookupEditItems.ContainsKey(itemInfo.ItemID)) myStepPanel._LookupEditItems.Add(itemInfo.ItemID, this); _MyChildRelation = myChildRelation; if (myParentEditItem != null) RNOLevel = myParentEditItem.RNOLevel; if (itemInfo != null) diff --git a/PROMS/Volian.Controls.Library/GridItem.cs b/PROMS/Volian.Controls.Library/GridItem.cs index c9f31ea5..5d30741c 100644 --- a/PROMS/Volian.Controls.Library/GridItem.cs +++ b/PROMS/Volian.Controls.Library/GridItem.cs @@ -564,16 +564,21 @@ namespace Volian.Controls.Library // create the usage for it. this code gets run on modify of the ro table and also // on exit of the griditem. We don't want to save the ro usage again, if it's already // been saved. - if (MyFlexGrid.IsRoTable && MyFlexGrid.ROID != null && itm.MyContent.ContentRoUsageCount < 1) - { - searchableText = string.Format(@"\v\v0 ", searchableText, DoLinkForRoTable()); - //if (itm.MyContent.Text != searchableText) - //{ + if (MyFlexGrid.IsRoTable && MyFlexGrid.ROID != null && itm.MyContent.ContentRoUsageCount < 1) + { + searchableText = string.Format(@"\v\v0 ", searchableText, DoLinkForRoTable()); + //if (itm.MyContent.Text != searchableText) + //{ itm.MyContent.Text = searchableText; itm.MyContent.DTS = DateTime.Now; - //} - } - if (!MyFlexGrid.IsRoTable)itm.MyContent.Text = searchableText; + //} + } + else + { + itm.MyContent.Text = searchableText; + itm.MyContent.DTS = DateTime.Now; + } + if (!MyFlexGrid.IsRoTable)itm.MyContent.Text = searchableText; itm.Save(); MyItemInfo.MyContent.MyGrid.ResetContent(itm.MyContent.MyGrid); } diff --git a/PROMS/Volian.Controls.Library/RTBItem.cs b/PROMS/Volian.Controls.Library/RTBItem.cs index 7b4a45b9..5e667f2a 100644 --- a/PROMS/Volian.Controls.Library/RTBItem.cs +++ b/PROMS/Volian.Controls.Library/RTBItem.cs @@ -598,7 +598,7 @@ namespace Volian.Controls.Library { if (MyStepRTB.ReadOnly) return; if (!MyStepRTB.ActiveMode) return; - if (!MyStepRTB.IsDirty && MyStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; + if (MyStepRTB.MyItemInfo.MyContent.Number != null && !MyStepRTB.IsDirty && MyStepRTB.Text.Contains("(Resolved Transition Text)") == false) return; bool success = MyStepRTB.OrigDisplayText.Save((RichTextBox)MyStepRTB); if (success) { @@ -707,7 +707,15 @@ namespace Volian.Controls.Library } public override bool Empty { - get { return MyStepRTB.Text == ""; } + get + { +// Console.WriteLine("step rtb is dirty {0} and rtf is {1}", MyStepRTB.IsDirty, MyStepRTB.Rtf); +// string txt = MyStepRTB.Text; +// Console.WriteLine("step rtb is dirty {0} and rtf is {1}", MyStepRTB.IsDirty, MyStepRTB.Rtf); +// return txt == ""; + //return MyStepRTB.IsEmpty; + return MyStepRTB.Text == ""; + } set { MyStepRTB.Text = value ? "" : " "; } } //public override bool IsEmpty() // this becomes 'Empty' property, i.e. get/set. diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 3b8ec90a..1246e592 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -342,8 +342,12 @@ namespace Volian.Controls.Library { if (_FormatFont == null) { - Font formatFont = MyItemInfo.GetItemFont().WindowsFont; // OrigDisplayText.TextFont.WindowsFont; - if (MyItemInfo.IsTable || MyItemInfo.IsFigure) + Font formatFont; + if (MyItemInfo != null) + formatFont = MyItemInfo.GetItemFont().WindowsFont; // OrigDisplayText.TextFont.WindowsFont; + else + formatFont = Font; + if (MyItemInfo != null && (MyItemInfo.IsTable || MyItemInfo.IsFigure)) _FormatFont = formatFont; else { @@ -357,9 +361,18 @@ namespace Volian.Controls.Library } return _FormatFont; } + set { _FormatFont = value; } + } + public void SetupRichText(string rtf, VE_Font vFont) + { + //FormatFont = vFont.WindowsFont; + DisplayText vlnText = new DisplayText(rtf, vFont, true); + AddRtfText(vlnText.StartText); + ReadOnly = true; } public void RefreshDisplay() { + if (Disposing) return; RefreshDisplay(ActiveMode); } // RefreshDisplay is used to update the rtb for an entire Item as defined by MyItemInfo. diff --git a/PROMS/Volian.Controls.Library/StepTabPanel.cs b/PROMS/Volian.Controls.Library/StepTabPanel.cs index 77eae63c..eae6057e 100644 --- a/PROMS/Volian.Controls.Library/StepTabPanel.cs +++ b/PROMS/Volian.Controls.Library/StepTabPanel.cs @@ -274,7 +274,7 @@ namespace Volian.Controls.Library if (args.MyLinkText.LinkInfoText.IndexOf("Transition") > -1) { ItemInfo item = args.MyLinkText.MyTranToItemInfo; - if (item.PreviousID == null && item.ItemPartCount == 0 && item.ItemDocVersionCount == 0) + if (item == null || (item.PreviousID == null && item.ItemPartCount == 0 && item.ItemDocVersionCount == 0)) { MessageBox.Show("This transition is invalid", "Invalid Transition", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; // Not a valid transition diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index bfeb62b0..7846bca3 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -1444,7 +1444,7 @@ namespace Volian.Controls.Library StepInfo stpi = MyEditItem.MyItemInfo as StepInfo; if (stpi == null) // not sure that it will every get here! { - MessageBox.Show("Unknown type, cannot delete!"); + MessageBox.Show("Unknown type {0}, cannot delete!",MyEditItem.MyItemInfo.GetType().Name); return; } if (!surpressMessageBox) diff --git a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs index 7464db5e..10fd5226 100644 --- a/PROMS/Volian.Controls.Library/VlnFlexGrid.cs +++ b/PROMS/Volian.Controls.Library/VlnFlexGrid.cs @@ -976,10 +976,11 @@ namespace Volian.Controls.Library int x2 = bounds.Right - 1; int y2 = bounds.Bottom - 1; GridItem myGridItem = Parent as GridItem; - if (myGridItem == null) return; + Panel myPanel = Parent as Panel; + if (myGridItem == null && myPanel == null) return; if (row == 0 || col == 0) // Top or Left Edge - Draw on parent { - using (Graphics grParent = myGridItem.CreateGraphics()) + using (Graphics grParent = myGridItem != null ? myGridItem.CreateGraphics() : myPanel.CreateGraphics()) { if (row == 0) { diff --git a/PROMS/Volian.Print.Library/PDFChronologyReport.cs b/PROMS/Volian.Print.Library/PDFChronologyReport.cs new file mode 100644 index 00000000..1e5450d7 --- /dev/null +++ b/PROMS/Volian.Print.Library/PDFChronologyReport.cs @@ -0,0 +1,1368 @@ +using System; +using System.Collections.Generic; +using System.Text; +using VEPROMS.CSLA.Library; +using iTextSharp.text.pdf; +using iTextSharp.text; +using System.IO; +using System.Text.RegularExpressions; + +namespace Volian.Print.Library +{ + public class PDFChronologyReport + { + private string _FileName; + public string FileName + { + get { return _FileName; } + set { _FileName = value; } + } + private ProcedureInfo _MyProc; + public ProcedureInfo MyProc + { + get { return _MyProc; } + set { _MyProc = value; } + } + private ContentAuditInfoList _AuditList; + public ContentAuditInfoList AuditList + { + get { return _AuditList; } + set { _AuditList = value; } + } + private AnnotationAuditInfoList _AnnotationList; + public AnnotationAuditInfoList AnnotationList + { + get { return _AnnotationList; } + set { _AnnotationList = value; } + } + public PDFChronologyReport(string fileName, ProcedureInfo myProc, ContentAuditInfoList auditList, AnnotationAuditInfoList annotationList) + { + _FileName = fileName; + _MyProc = myProc; + _AuditList = auditList; + _AnnotationList = annotationList; + } + public void BuildChronology() + { + iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + if (!CreateResultsPDF(document)) return; + try + { + BuildChronologyReport(document); + } + catch (Exception ex) + { + StringBuilder msg = new StringBuilder(); + document.Add(new Paragraph("Error:")); + while (ex != null) + { + document.Add(new Paragraph(ex.GetType().Name)); + document.Add(new Paragraph(ex.Message)); + ex = ex.InnerException; + } + } + finally + { + if (document.IsOpen()) + { + document.Close(); + System.Diagnostics.Process.Start(_FileName); + } + } + } + public void BuildSummary() + { + bool hasData = false; + iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + if (!CreateResultsPDF(document)) return; + try + { + BuildSummaryReport(document); + } + catch (Exception ex) + { + StringBuilder msg = new StringBuilder(); + document.Add(new Paragraph("Error:")); + while (ex != null) + { + document.Add(new Paragraph(ex.GetType().Name)); + document.Add(new Paragraph(ex.Message)); + ex = ex.InnerException; + } + } + finally + { + if (document.IsOpen()) + { + document.Close(); + System.Diagnostics.Process.Start(_FileName); + } + } + } + private bool CreateResultsPDF(iTextSharp.text.Document document) + { + bool result = false; + string suffix = ""; + int i = 0; + // Try to open a file for creating the PDF. + while (result == false) + { + string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); + try + { + PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); + document.SetMargins(36, 36, 36, 36); + document.Open(); + _FileName = fileName; + result = true; + } + catch (System.IO.IOException exIO) + { + + if (exIO.Message.Contains("because it is being used by another process")) + suffix = string.Format("_{0}", ++i);// If this file is in use, increment the suffix and try again + else // If some other error, display a message and don't print the results + { + ShowException(exIO); + return false; + } + } + catch (Exception ex) + { + ShowException(ex); + return false; // Could not open the output file + } + } + return true; + } + private static void ShowException(Exception ex) + { + Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message); + StringBuilder msg = new StringBuilder(); + string sep = ""; + string indent = ""; + while (ex != null) + { + msg.Append(string.Format("{0}{1}{2}:\r\n{1}{3}", sep, indent, ex.GetType().Name, ex.Message)); + ex = ex.InnerException; + sep = "\r\n"; + indent += " "; + } + System.Windows.Forms.MessageBox.Show(msg.ToString(), "Error during PDF creation for search:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); + } + private PdfPCell BlankCell(int colSpan) + { + PdfPCell c = new PdfPCell(); + c.Colspan = colSpan; + c.Border = 0; + return c; + } + private void BuildChronologyReport(iTextSharp.text.Document doc) + { + int cols = 5; + int borders = 0; + int paddingBottom = 6; + PdfPTable t = new PdfPTable(cols); + t.HeaderRows = 4; + t.DefaultCell.Padding = 4; + t.WidthPercentage = 100; + float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; + t.SetWidths(widths); + //t.HorizontalAlignment = 0; + iTextSharp.text.Font f1 = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK); + iTextSharp.text.Font f3 = pdf.GetFont("Arial Unicode MS", 9, 0, Color.BLACK); + iTextSharp.text.Font f4 = pdf.GetFont("Arial Unicode MS", 9, 1, Color.BLACK); + //report title + Phrase h = new Phrase(); + h.Font = f1; + h.Add("Chronology of Changes Report"); + PdfPCell c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + //procedure title + h = new Phrase(); + h.Font = f2; + h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + string section = string.Empty; + string stepnum = string.Empty; + DateTime maxDTS = DateTime.MinValue; + int lastID = 0; + ContentAuditInfo oldCAI = null; +// Dictionary processedAAI = new Dictionary(); + Dictionary processedAAI = new Dictionary(); + foreach (ContentAuditInfo cai in AuditList) + { + //raw path + string[] NewPath = Regex.Replace(cai.Path, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + if (NewPath[0] != section) + { + section = NewPath[0]; + h = new Phrase(); + h.Font = f4; + h.Add(section); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + } + //step + if (NewPath[1] != stepnum) + { + //see if any annotations for old stepnum here and add them + foreach (AnnotationAuditInfo aai in AnnotationList) + { + if (oldCAI != null && aai.IContentID == oldCAI.ContentID) + { + //add annotation to minilist +// processedAAI.Add(aai.AnnotationID, aai); + processedAAI.Add(aai, aai); + //write row to table + t.AddCell(BlankCell(1)); + h = new Phrase(); + h.Font = f3; + h.Add("Annotation " + aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + oldCAI = cai; + stepnum = NewPath[1]; + string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); + stepnum2 = stepnum2.Replace("RNO.", "RNO"); + h = new Phrase(); + h.Font = f3; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_RIGHT; + c.PaddingBottom = paddingBottom; + c.PaddingRight = 10; + //c.Border = borders; + t.AddCell(c); + } + else + t.AddCell(BlankCell(1)); + //what + if (cai.ContentID != lastID) maxDTS = DateTime.MinValue; + h = new Phrase(); + h.Font = f3; + string actionWhat = (cai.ActionWhat == "Added" && cai.DTS <= MyProc.DTS) ? "Original" : cai.ActionWhat != "Changed" ? cai.ActionWhat : cai.DTS <= maxDTS ? "Restored" : cai.DTS > MyProc.DTS ? cai.ActionWhat : "Original"; + if (actionWhat == "Deleted" || actionWhat == "Restored") + h.Add(actionWhat + "\r\n" + cai.ActionWhen.ToString()); + else + h.Add(actionWhat); + if (cai.DTS > maxDTS) + maxDTS = cai.DTS; + lastID = cai.ContentID; + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(cai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(cai.DTS.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + //h.Add(cai.Text); + if (cai.Type == 20008) + { + GridAuditInfoList gail = GridAuditInfoList.Get(cai.ContentID); + if (gail.Count > 0) + { + GridAuditInfo gai = gail[0]; + System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); + xd.LoadXml(gai.Data); + //int grows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); + int gcols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); + string data = ItemInfo.ConvertToDisplayText(cai.Text); + PdfPTable gtbl = new PdfPTable(gcols); + while (data.Length > 0) + { + string val = data.Substring(0, data.IndexOf(";")); + data = data.Substring(data.IndexOf(";") + 1); + Phrase hh = new Phrase(); + hh.Font = f4; + hh.Add(val); + PdfPCell cc = new PdfPCell(hh); + gtbl.AddCell(cc); + } + c = new PdfPCell(gtbl); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + //c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + else + { + h = new Phrase(); + h.Font = f4; + h.Add(ItemInfo.ConvertToDisplayText(cai.Text)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + ////old text + //t.AddCell(BlankCell(3)); + //h = new Phrase(); + //h.Font = f4; + //h.Add("Old text: " + cai.OldText); + //c = new PdfPCell(h); + //c.Colspan = 7; + //c.Border = 0; + //t.AddCell(c); + } + //see if any annotations for old stepnum here and add them + foreach (AnnotationAuditInfo aai in AnnotationList) + { + if (oldCAI != null && aai.IContentID == oldCAI.ContentID) + { + //add annotation to minilist +// processedAAI.Add(aai.AnnotationID, aai); + processedAAI.Add(aai, aai); + //write row to table + t.AddCell(BlankCell(1)); + h = new Phrase(); + h.Font = f3; + h.Add("Annotation " + aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + bool annotationHeader = false; + stepnum = string.Empty; + foreach (AnnotationAuditInfo aai in AnnotationList) + { +// if (!processedAAI.ContainsKey(aai.AnnotationID)) + if (!processedAAI.ContainsKey(aai)) + { + if (!annotationHeader) + { + t.AddCell(BlankCell(cols)); + h = new Phrase(); + h.Font = f4; + h.Add("ANNOTATIONS"); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + annotationHeader = true; + } + string[] NewPath = GetNewPath(AuditList, aai.IContentID); + if (NewPath[1] != stepnum) + { + stepnum = NewPath[1]; + string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); + stepnum2 = stepnum2.Replace("RNO.", "RNO"); + h = new Phrase(); + h.Font = f3; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_RIGHT; + c.PaddingBottom = paddingBottom; + c.PaddingRight = 10; + //c.Border = borders; + t.AddCell(c); + } + else + { + t.AddCell(BlankCell(1)); + } + //what + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + if (t.Rows.Count == t.HeaderRows) + { + c = new PdfPCell(new Phrase("No changes to report")); + c.Colspan = cols; + t.AddCell(c); + } + doc.Add(t); + } + + private string[] GetNewPath(ContentAuditInfoList AuditList, int contentID) + { + foreach (ContentAuditInfo cai in AuditList) + { + if(cai.ContentID == contentID) + return Regex.Replace(cai.Path, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + } + ItemInfoList iil = ItemInfoList.GetByContentID(contentID); + if (iil.Count > 0) + { + return Regex.Replace(iil[0].SearchPath, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + } + return "obozo\x7obiden".Split("\x7".ToCharArray()); + } + private void BuildSummaryReport2(iTextSharp.text.Document doc) + { + string section = string.Empty; + string stepnum = string.Empty; + ContentAuditInfo firstCAI = null; + ContentAuditInfo nextCAI = null; + ContentAuditInfo lastCAI = null; + List auditList = new List(); + foreach (ContentAuditInfo cai in AuditList) + { + string[] NewPath = Regex.Replace(cai.Path, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + if (NewPath[1] != stepnum) + { + stepnum = NewPath[1]; + if (firstCAI != null) + { + if (lastCAI == null) + { + auditList.Add(firstCAI); + } + else if (lastCAI.ActionWhat == "Deleted" && firstCAI.DTS < MyProc.DTS) + { + auditList.Add(lastCAI); + } + else if (lastCAI.ActionWhat == "Changed" && lastCAI.Text != firstCAI.Text) + { + auditList.Add(firstCAI); + auditList.Add(lastCAI); + } + else if (lastCAI.ActionWhat == "Changed" && firstCAI.ActionWhat == "Added" && lastCAI.Text == firstCAI.Text) + { + auditList.Add(firstCAI); + } + else if (lastCAI == null && firstCAI.ActionWhat == "Added") + { + auditList.Add(firstCAI); + } + lastCAI = null; + } + firstCAI = cai; + } + else + { + lastCAI = cai; + } + } + if (firstCAI != null) + auditList.Add(firstCAI); + if (lastCAI != null) + auditList.Add(lastCAI); + #region annotations + AnnotationAuditInfo firstAAI = null; + AnnotationAuditInfo nextAAI = null; + AnnotationAuditInfo lastAAI = null; + int icontentID = 0; + List annotationList = new List(); + foreach (AnnotationAuditInfo aai in AnnotationList) + { + if (aai.IContentID != icontentID) + { + icontentID = aai.IContentID; + if (firstAAI != null) + { + if (lastAAI == null) + { + annotationList.Add(firstAAI); + } + else if (lastAAI.ActionWhat == "Deleted" && firstAAI.DTS < MyProc.DTS) + { + annotationList.Add(lastAAI); + } + else if (lastAAI.ActionWhat == "Changed" && lastAAI.SearchText != firstAAI.SearchText) + { + annotationList.Add(firstAAI); + annotationList.Add(lastAAI); + } + else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat == "Added" && lastAAI.SearchText == firstAAI.SearchText) + { + annotationList.Add(firstAAI); + } + else if (lastAAI == null && firstAAI.ActionWhat == "Added") + { + annotationList.Add(firstAAI); + } + lastAAI = null; + } + firstAAI = aai; + } + else + lastAAI = aai; + } + if (firstAAI != null) + annotationList.Add(firstAAI); + if (lastAAI != null) + annotationList.Add(lastAAI); + #endregion + int cols = 5; + int borders = 0; + int paddingBottom = 6; + PdfPTable t = new PdfPTable(cols); + t.HeaderRows = 4; + t.DefaultCell.Padding = 4; + t.WidthPercentage = 100; + float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; + t.SetWidths(widths); + //t.HorizontalAlignment = 0; + iTextSharp.text.Font f1 = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK); + iTextSharp.text.Font f3 = pdf.GetFont("Arial Unicode MS", 9, 0, Color.BLACK); + iTextSharp.text.Font f4 = pdf.GetFont("Arial Unicode MS", 9, 1, Color.BLACK); + //report title + Phrase h = new Phrase(); + h.Font = f1; + h.Add("Summary of Changes Report"); + PdfPCell c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + //procedure title + h = new Phrase(); + h.Font = f2; + h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + foreach (ContentAuditInfo cai in auditList) + { + //raw path + string[] NewPath = Regex.Replace(cai.Path, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + if (NewPath[0] != section) + { + section = NewPath[0]; + h = new Phrase(); + h.Font = f4; + h.Add(section); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + } + //step + if (NewPath[1] != stepnum) + { + firstCAI = cai; + stepnum = NewPath[1]; + string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); + stepnum2 = stepnum2.Replace("RNO.", "RNO"); + h = new Phrase(); + h.Font = f3; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_RIGHT; + c.PaddingBottom = paddingBottom; + c.PaddingRight = 10; + //c.Border = borders; + t.AddCell(c); + } + else + { + t.AddCell(BlankCell(1)); + nextCAI = cai; + } + //what + h = new Phrase(); + h.Font = f3; + h.Add(cai.ActionWhen > MyProc.DTS ? cai.ActionWhat : "Original"); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(cai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(cai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(cai.Text)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + ////old text + //t.AddCell(BlankCell(3)); + //h = new Phrase(); + //h.Font = f4; + //h.Add("Old text: " + cai.OldText); + //c = new PdfPCell(h); + //c.Colspan = 7; + //c.Border = 0; + //t.AddCell(c); + } + t.AddCell(BlankCell(cols)); + h = new Phrase(); + h.Font = f4; + h.Add("ANNOTATIONS"); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + stepnum = string.Empty; + foreach (AnnotationAuditInfo aai in annotationList) + { + foreach (ContentAuditInfo cai in auditList) + { + if (cai.ContentID == aai.IContentID) + { + string[] NewPath = Regex.Replace(cai.Path, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + if (NewPath[1] != stepnum) + { + stepnum = NewPath[1]; + string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); + stepnum2 = stepnum2.Replace("RNO.", "RNO"); + h = new Phrase(); + h.Font = f3; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_RIGHT; + c.PaddingBottom = paddingBottom; + c.PaddingRight = 10; + //c.Border = borders; + t.AddCell(c); + break; + } + else + { + t.AddCell(BlankCell(1)); + break; + } + } + } + //what + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + doc.Add(t); + } + private void BuildSummaryReport(iTextSharp.text.Document doc) + { + string section = string.Empty; + string stepnum = string.Empty; + int contentID = 0; + ContentAuditInfo firstCAI = null; + ContentAuditInfo nextCAI = null; + ContentAuditInfo lastCAI = null; + List auditList = new List(); + foreach (ContentAuditInfo cai in AuditList) + { + if (cai.ContentID != contentID) //new content + { + if (firstCAI != null) //not first row + { + if (lastCAI == null) + { + auditList.Add(firstCAI); + firstCAI = null; + } + else + { + if (lastCAI.DTS > firstCAI.DTS) + { + if (firstCAI.ActionWhat == "Added" && lastCAI.ActionWhat != "Deleted") + { + if (firstCAI.DTS > MyProc.DTS) + lastCAI.ActionWhat = firstCAI.ActionWhat; + auditList.Add(lastCAI); + firstCAI = null; + lastCAI = null; + } + } + else if (firstCAI.ActionWhat == "Added" && lastCAI.ActionWhat == "Deleted" && firstCAI.DTS == lastCAI.DTS) + { + auditList.Add(lastCAI); + firstCAI = null; + lastCAI = null; + } + } + } + firstCAI = cai; + contentID = cai.ContentID; + } + else + lastCAI = cai; + } + if (lastCAI == null) + { + if (firstCAI != null) + auditList.Add(firstCAI); + firstCAI = null; + } + else + { + if (lastCAI.DTS > firstCAI.DTS) + { + if (firstCAI.ActionWhat == "Added" && lastCAI.ActionWhat != "Deleted") + { + if (firstCAI.DTS > MyProc.DTS) + lastCAI.ActionWhat = firstCAI.ActionWhat; + auditList.Add(lastCAI); + firstCAI = null; + lastCAI = null; + } + } + else if (firstCAI.ActionWhat == "Added" && lastCAI.ActionWhat == "Deleted" && firstCAI.DTS == lastCAI.DTS) + { + auditList.Add(lastCAI); + firstCAI = null; + lastCAI = null; + } + } + #region annotations commented out + //AnnotationAuditInfo firstAAI = null; + //AnnotationAuditInfo nextAAI = null; + //AnnotationAuditInfo lastAAI = null; + //int icontentID = 0; + //List annotationList = new List(); + //foreach (AnnotationAuditInfo aai in AnnotationList) + //{ + // if (aai.IContentID != icontentID) + // { + // icontentID = aai.IContentID; + // if (firstAAI != null) + // { + // if (lastAAI == null) + // { + // annotationList.Add(firstAAI); + // } + // else if (lastAAI.ActionWhat == "Deleted" && firstAAI.DTS < MyProc.DTS) + // { + // annotationList.Add(lastAAI); + // } + // else if (lastAAI.ActionWhat == "Changed" && lastAAI.SearchText != firstAAI.SearchText) + // { + // annotationList.Add(firstAAI); + // annotationList.Add(lastAAI); + // } + // else if (lastAAI.ActionWhat == "Changed" && firstAAI.ActionWhat == "Added" && lastAAI.SearchText == firstAAI.SearchText) + // { + // annotationList.Add(firstAAI); + // } + // else if (lastAAI == null && firstAAI.ActionWhat == "Added") + // { + // annotationList.Add(firstAAI); + // } + // lastAAI = null; + // } + // firstAAI = aai; + // } + // else + // lastAAI = aai; + //} + //if (firstAAI != null) + // annotationList.Add(firstAAI); + //if (lastAAI != null) + // annotationList.Add(lastAAI); + #endregion + int cols = 5; + int borders = 0; + int paddingBottom = 6; + PdfPTable t = new PdfPTable(cols); + t.HeaderRows = 4; + t.DefaultCell.Padding = 4; + t.WidthPercentage = 100; + float[] widths = new float[] { 1f, 1f, 1f, 1f, 4f }; + t.SetWidths(widths); + //t.HorizontalAlignment = 0; + iTextSharp.text.Font f1 = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK); + iTextSharp.text.Font f2 = pdf.GetFont("Arial Unicode MS", 10, 0, Color.BLACK); + iTextSharp.text.Font f3 = pdf.GetFont("Arial Unicode MS", 9, 0, Color.BLACK); + iTextSharp.text.Font f4 = pdf.GetFont("Arial Unicode MS", 9, 1, Color.BLACK); + //report title + Phrase h = new Phrase(); + h.Font = f1; + h.Add("Summary of Changes Report"); + PdfPCell c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + //procedure title + h = new Phrase(); + h.Font = f2; + h.Add(string.Format("{0} - {1}", MyProc.DisplayNumber, MyProc.DisplayText)); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + ContentAuditInfo oldCAI = null; + // Dictionary processedAAI = new Dictionary(); + Dictionary processedAAI = new Dictionary(); + foreach (ContentAuditInfo cai in auditList) + { + //raw path + string[] NewPath = Regex.Replace(cai.Path, "^..+?\\u0007.", "").Split("\x7".ToCharArray()); + if (NewPath[0] != section) + { + section = NewPath[0]; + h = new Phrase(); + h.Font = f4; + h.Add(section); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + } + //step + if (NewPath[1] != stepnum) + { + //see if any annotations for old stepnum here and add them + foreach (AnnotationAuditInfo aai in AnnotationList) + { + if (oldCAI != null && aai.IContentID == oldCAI.ContentID) + { + //add annotation to minilist + // processedAAI.Add(aai.AnnotationID, aai); + processedAAI.Add(aai, aai); + //write row to table + t.AddCell(BlankCell(1)); + h = new Phrase(); + h.Font = f3; + h.Add("Annotation " + aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + oldCAI = cai; + firstCAI = cai; + stepnum = NewPath[1]; + string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); + stepnum2 = stepnum2.Replace("RNO.", "RNO"); + h = new Phrase(); + h.Font = f3; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_RIGHT; + c.PaddingBottom = paddingBottom; + c.PaddingRight = 10; + //c.Border = borders; + t.AddCell(c); + } + else + { + t.AddCell(BlankCell(1)); + nextCAI = cai; + } + //what + h = new Phrase(); + h.Font = f3; + // h.Add(cai.ActionWhen > MyProc.DTS ? cai.ActionWhat : "Original"); + string actionWhat = cai.ActionWhat; //(cai.ActionWhat == "Added" && cai.DTS <= MyProc.DTS) ? "Original" : cai.ActionWhat != "Changed" ? cai.ActionWhat : cai.DTS <= maxDTS ? "Restored" : cai.DTS > MyProc.DTS ? cai.ActionWhat : "Original"; + if (actionWhat == "Deleted" || actionWhat == "Restored") + h.Add(actionWhat + "\r\n" + cai.ActionWhen.ToString()); + else + h.Add(actionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(cai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(cai.DTS.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + //h.Add(ItemInfo.ConvertToDisplayText(cai.Text)); + if (cai.Type == 20008) + { + GridAuditInfoList gail = GridAuditInfoList.Get(cai.ContentID); + if (gail.Count > 0) + { + GridAuditInfo gai = gail[0]; + System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); + xd.LoadXml(gai.Data); + //int grows = int.Parse(xd.SelectSingleNode("C1FlexGrid/RowInfo/Count").InnerText); + int gcols = int.Parse(xd.SelectSingleNode("C1FlexGrid/ColumnInfo/Count").InnerText); + string data = ItemInfo.ConvertToDisplayText(cai.Text); + PdfPTable gtbl = new PdfPTable(gcols); + while (data.Length > 0) + { + string val = data.Substring(0, data.IndexOf(";")); + data = data.Substring(data.IndexOf(";") + 1); + Phrase hh = new Phrase(); + hh.Font = f4; + hh.Add(val); + PdfPCell cc = new PdfPCell(hh); + gtbl.AddCell(cc); + } + c = new PdfPCell(gtbl); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + //c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + else + { + h = new Phrase(); + h.Font = f4; + h.Add(ItemInfo.ConvertToDisplayText(cai.Text)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + + //c = new PdfPCell(h); + //c.Colspan = cols - 4; + //c.HorizontalAlignment = Element.ALIGN_LEFT; + //c.PaddingBottom = paddingBottom; + ////c.Border = borders; + //t.AddCell(c); + ////old text + //t.AddCell(BlankCell(3)); + //h = new Phrase(); + //h.Font = f4; + //h.Add("Old text: " + cai.OldText); + //c = new PdfPCell(h); + //c.Colspan = 7; + //c.Border = 0; + //t.AddCell(c); + } + //see if any annotations for old stepnum here and add them + foreach (AnnotationAuditInfo aai in AnnotationList) + { + if (oldCAI != null && aai.IContentID == oldCAI.ContentID) + { + //add annotation to minilist + // processedAAI.Add(aai.AnnotationID, aai); + processedAAI.Add(aai, aai); + //write row to table + t.AddCell(BlankCell(1)); + h = new Phrase(); + h.Font = f3; + h.Add("Annotation " + aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + bool annotationHeader = false; + //t.AddCell(BlankCell(cols)); + //h = new Phrase(); + //h.Font = f4; + //h.Add("ANNOTATIONS"); + //c = new PdfPCell(h); + //c.Colspan = cols; + //c.HorizontalAlignment = Element.ALIGN_LEFT; + //c.PaddingBottom = paddingBottom; + ////c.Border = borders; + //t.AddCell(c); + //t.AddCell(BlankCell(cols)); + stepnum = string.Empty; + foreach (AnnotationAuditInfo aai in AnnotationList) + { + // if (!processedAAI.ContainsKey(aai.AnnotationID)) + if (!processedAAI.ContainsKey(aai)) + { + if (!annotationHeader) + { + t.AddCell(BlankCell(cols)); + h = new Phrase(); + h.Font = f4; + h.Add("ANNOTATIONS"); + c = new PdfPCell(h); + c.Colspan = cols; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + t.AddCell(BlankCell(cols)); + annotationHeader = true; + } + string[] NewPath = GetNewPath(AuditList, aai.IContentID); + if (NewPath[1] != stepnum) + { + stepnum = NewPath[1]; + string stepnum2 = Regex.Replace(stepnum, "([0-9])[.]([A-Za-z])", "$1 $2"); + stepnum2 = stepnum2.Replace("RNO.", "RNO"); + h = new Phrase(); + h.Font = f3; + h.Add(string.Format("Step {0}", stepnum2)); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_RIGHT; + c.PaddingBottom = paddingBottom; + c.PaddingRight = 10; + //c.Border = borders; + t.AddCell(c); + } + else + { + t.AddCell(BlankCell(1)); + } + //what + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhat); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //who + h = new Phrase(); + h.Font = f3; + h.Add(aai.UserID); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //when + h = new Phrase(); + h.Font = f3; + h.Add(aai.ActionWhen.ToString()); + c = new PdfPCell(h); + c.Colspan = 1; + c.HorizontalAlignment = Element.ALIGN_CENTER; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + //new text + h = new Phrase(); + h.Font = f4; + //h.Add(cai.Text); + h.Add(ItemInfo.ConvertToDisplayText(aai.SearchText)); + c = new PdfPCell(h); + c.Colspan = cols - 4; + c.HorizontalAlignment = Element.ALIGN_LEFT; + c.PaddingBottom = paddingBottom; + //c.Border = borders; + t.AddCell(c); + } + } + if (t.Rows.Count == t.HeaderRows) + { + c = new PdfPCell(new Phrase("No changes to report")); + c.Colspan = cols; + t.AddCell(c); + } + doc.Add(t); + } + } +} diff --git a/PROMS/Volian.Print.Library/PDFReport.cs b/PROMS/Volian.Print.Library/PDFReport.cs index 00f98d19..3af74491 100644 --- a/PROMS/Volian.Print.Library/PDFReport.cs +++ b/PROMS/Volian.Print.Library/PDFReport.cs @@ -455,7 +455,7 @@ namespace Volian.Print.Library //AddCell(datatable, "Step", f2, subHeaderColor); //AddCell(datatable, "Text", f2, subHeaderColor); datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; - string lastDvPath = ""; + //string lastDvPath = ""; string lastPath = ""; Color AnnoColor = new Color(0xFF, 0xFF, 0xC0); Color TextColor = Color.WHITE; @@ -475,11 +475,11 @@ namespace Volian.Print.Library // AddGroup(datatable, item.SearchDVPath, lastDvPath, f2, false, Color.LIGHT_GRAY, true); //AddGroup(datatable, item.SearchDVPath, lastDvPath, f2, false, new Color(0xC0, 0xFF, 0xC0), true); - lastDvPath = item.SearchDVPath; + //lastDvPath = item.SearchDVPath; //string stepPath = AddGroup(datatable, item.SearchPath, lastPath, f2, true, new Color(0xE0, 0xFF, 0xE0), true); //string stepPath = AddGroup(datatable, item.SearchPath, lastPath, f2, true, new Color(0xC0, 0xFF, 0xC0), true); - string stepPath = AddGroup(subTable, item.SearchPath, lastPath, f2, true, new Color(0xC0, 0xFF, 0xC0), true); - lastPath = item.SearchPath; + string stepPath = AddGroup(subTable, item.SearchPath ?? item.ShortPath, lastPath, f2, true, new Color(0xC0, 0xFF, 0xC0), true); + lastPath = item.SearchPath ?? item.ShortPath; //AddCell(datatable, stepPath, f2, (item.IsSection ? SectColor : TextColor)); AddCell(subTable, stepPath, f2, (item.IsSection ? SectColor : TextColor)); // This was for the old 16-bit style of table - jsj 7/7/2011