Change Manager
This commit is contained in:
875
PROMS/Volian.Controls.Library/DisplayHistory.cs
Normal file
875
PROMS/Volian.Controls.Library/DisplayHistory.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user