using System; using System.Collections.Generic; using System.Text; using Csla; using Csla.Data; using Csla.Validation; using System.Data.SqlClient; using System.Data; using System.Text.RegularExpressions; using System.Xml; namespace VEPROMS.CSLA.Library { public partial class AnnotationAuditInfo { internal string _ActionWhat; public string ActionWhat { get { return _ActionWhat; } set { _ActionWhat = value; } } internal DateTime _ActionWhen; public DateTime ActionWhen { get { return _ActionWhen; } set { _ActionWhen = value; } } internal int _IContentID; public int IContentID { get { return _IContentID; } set { _IContentID = value; } } public ItemInfo MyItemInfo { get {return ItemInfo.Get(this.ItemID);} } public string ListString() { string who = string.Empty; string when = string.Empty; if (this.UserID != "Migration" || this.TypeID != 1) who = string.Format(" by {0}", this.UserID); if (this.DTS != DateTime.Parse("1/1/1980")) when = string.Format(" on {0}", this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); //return string.Format("{0}{1}{2}", this.ActionWhat, who, when); return string.Format("{0}{1}{2}", this.DeleteStatus == 0 ? "Changed" : "Deleted", who, when); } public override string ToString() { string itemTitle = Regex.Replace(this.MyItemInfo.SearchPath, "^..+?\\u0007", ""); itemTitle = itemTitle.Replace("\x11", itemTitle[0] == '\x11' ? "" : " - ").Replace("\\u8209?", "-").Replace(@"\u9586?", @"\"); return string.Format("{0} Annotation {1}", itemTitle, this.ListString()); } } public partial class ContentAuditInfo { internal string _ActionWhat; public string ActionWhat { get { return _ActionWhat; } set { _ActionWhat = value; } } internal DateTime _ActionWhen; public DateTime ActionWhen { get { return _ActionWhen; } set { _ActionWhen = value; } } internal string _Path; public string Path { get { return _Path; } set { _Path = value; } } internal int _ItemID; public int ItemID { get { return _ItemID; } set { _ItemID = value; } } internal string _Typename; public string TypeName { get { return _Typename; } set { _Typename = value; } } public override string ToString() { string itemTitle = Regex.Replace(this.Path, "^..+?\\u0007", ""); itemTitle = itemTitle.Replace("\x11", itemTitle[0] == '\x11' ? "" : " - ").Replace("\\u8209?", "-").Replace(@"\u9586?",@"\"); return string.Format("{4} item {0} by {1} on {2} @ {3}", this.ActionWhat, this.UserID, this.ActionWhen == DateTime.MinValue ? this.DTS.ToShortDateString() : this.ActionWhen.ToShortDateString(), this.ActionWhen == DateTime.MinValue ? this.DTS.ToShortTimeString() : this.ActionWhen.ToShortTimeString(), itemTitle); //return string.Format("{0} by {1} on {2}", this.DeleteStatus == 0 ? "Changed" : "Deleted", this.UserID, this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); //return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } public string ListString() { string who = string.Empty; string when = string.Empty; if (this.UserID != "Migration") who = string.Format(" by {0}", this.UserID); if (this.DTS != DateTime.Parse("1/1/1980")) when = string.Format(" on {0}", this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); return string.Format("{0}{1}{2}", this.ActionWhat, who, when); } } public partial class DocumentAuditInfo { public override string ToString() { return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } } public partial class EntryAuditInfo { public override string ToString() { return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } } public partial class GridAuditInfo { public override string ToString() { return string.Format("{0} by {1} on {2}", this.DeleteStatus == 0 ? "Changed" : "Deleted", this.UserID, this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss")); //return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } } public partial class ImageAuditInfo { public override string ToString() { return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } } public partial class ItemAuditInfo { public static bool IsChangeManagerVersion() { try { using (ItemAuditInfo info = ItemAuditInfo.Get(0)) { ; } } catch (Exception ex1) { Exception ex = ex1; while (ex.InnerException != null) ex = ex.InnerException; if (ex.Message.StartsWith("Could not find stored procedure")) { System.Windows.Forms.MessageBox.Show("Running Change Manager Code with Non-Change Manager Data", "Inconsistent Data", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return false; } throw new Exception("Failed on check of Change Manager Data",ex1); } return true; } internal int _Level; public int Level { get { return _Level; } } internal string _ItemType; public string ItemType { get { return _ItemType; } } public override string ToString() { return string.Format("{0}{1} deleted by {2} on {3} @ {4}", this.Level == 0 ? "Previous " : this.Level == 1 ? "Next " : "", this.ItemType, this.UserID, this.DTS.ToShortDateString(), this.DTS.ToShortTimeString()); // return string.Format("Deleted by {0} on {1} @ {2}", this.UserID, this.DTS.ToShortDateString(), this.DTS.ToShortTimeString()); // return string.Format("(ItemID: {4}, DeleteID: {5}, {0} by {1} on {2} Level: {3}", this.DeleteStatus == 0 ? "Changed" : "Deleted", this.UserID, this.DTS.ToString("MM/dd/yyyy @ HH:mm:ss"), Level.ToString(), this.ItemID.ToString(), this.DeleteStatus.ToString()); // return string.Format("Level: {3}, {0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted", this.Level.ToString()); } } public partial class PartAuditInfo { public override string ToString() { return string.Format("{0} - {1} {2}", this.UserID, this.DTS, this.DeleteStatus == 0 ? "" : "Deleted"); } } public partial class AnnotationAuditInfoList { /// /// C2024- 038 - Summary of Changes report generation enhancements /// Constructor - takes a Generic list of AnnotationAuditInfo /// and creates a AnnotationAuditInfoList /// public AnnotationAuditInfoList(List lst) { IsReadOnly = false; if (lst != null) { foreach (AnnotationAuditInfo itm in lst) this.Add(itm); } IsReadOnly = true; } /// /// Return a list of all AnnotationAuditInfo by ItemID. /// /// Selected ItemID for Annotation Audit Records /// public static AnnotationAuditInfoList GetByItemID(int itemID) { try { //if (_AnnotationAuditInfoList != null) // return _AnnotationAuditInfoList; AnnotationAuditInfoList tmp = DataPortal.Fetch(new ItemIDCriteria(itemID)); //AnnotationAuditInfo.AddList(tmp); //tmp.AddEvents(); //_AnnotationAuditInfoList = tmp; return tmp; } catch (Exception ex) { throw new DbCslaException("Error on AnnotationAuditInfoList.GetByItemID", ex); } } [Serializable()] protected class ItemIDCriteria { private int _ItemID; public int ItemID { get { return _ItemID; } } public ItemIDCriteria(int itemID) { _ItemID = itemID; } } private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getAnnotationAuditsByItemID"; cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new AnnotationAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } public static AnnotationAuditInfoList GetByAnnotationID(int annotationID) { try { //if (_AnnotationAuditInfoList != null) // return _AnnotationAuditInfoList; AnnotationAuditInfoList tmp = DataPortal.Fetch(new AnnotationIDCriteria(annotationID)); //AnnotationAuditInfo.AddList(tmp); //tmp.AddEvents(); //_AnnotationAuditInfoList = tmp; return tmp; } catch (Exception ex) { throw new DbCslaException("Error on AnnotationAuditInfoList.GetByAnnotationID", ex); } } [Serializable()] protected class AnnotationIDCriteria { private int _AnnotationID; public int AnnotationID { get { return _AnnotationID; } } public AnnotationIDCriteria(int annotationID) { _AnnotationID = annotationID; } } private void DataPortal_Fetch(AnnotationIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getAnnotationAuditsByAnnotationID"; cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new AnnotationAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } #region ChronologyReport //chronology report public static AnnotationAuditInfoList GetChronology(int @procItemID, int itemID, DateTime dts) { try { AnnotationAuditInfoList tmp = DataPortal.Fetch(new ChronologyCriteria(procItemID, itemID, dts)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on AnnotationAuditInfoList.GetChronology", ex); } } [Serializable()] protected class ChronologyCriteria { private int _procItemID; public int ProcItemID { get { return _procItemID; } } private int _itemID; public int ItemID { get { return _itemID; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public ChronologyCriteria(int procItemID, int itemID, DateTime dts) { _procItemID = procItemID; _itemID = itemID; _DTS = dts; } } private void DataPortal_Fetch(ChronologyCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getAnnotationAuditsChronologyByItemID"; cm.Parameters.AddWithValue("@ProcItemID", criteria.ProcItemID); cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { AnnotationAuditInfo aai = new AnnotationAuditInfo(dr); aai.ActionWhat = dr.GetString("ActionWhat"); aai.ActionWhen = dr.GetDateTime("ActionWhen"); aai.IContentID = dr.GetInt32("IContentID"); this.Add(aai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } //chronology report by unit public static AnnotationAuditInfoList GetChronologyByUnit(int @procItemID, int itemID, int unitID, DateTime dts) { try { AnnotationAuditInfoList tmp = DataPortal.Fetch(new ChronologyCriteriaByUnit(procItemID, itemID, unitID, dts)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on AnnotationAuditInfoList.GetChronologyByUnit", ex); } } [Serializable()] protected class ChronologyCriteriaByUnit { private int _procItemID; public int ProcItemID { get { return _procItemID; } } private int _itemID; public int ItemID { get { return _itemID; } } private int _UnitID; public int UnitID { get { return _UnitID; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public ChronologyCriteriaByUnit(int procItemID, int itemID, int unitID, DateTime dts) { _procItemID = procItemID; _itemID = itemID; _UnitID = unitID; _DTS = dts; } } private void DataPortal_Fetch(ChronologyCriteriaByUnit criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getAnnotationAuditsChronologyByItemIDandUnitID"; cm.Parameters.AddWithValue("@ProcItemID", criteria.ProcItemID); cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.Parameters.AddWithValue("@UnitID", criteria.UnitID); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { AnnotationAuditInfo aai = new AnnotationAuditInfo(dr); aai.ActionWhat = dr.GetString("ActionWhat"); aai.ActionWhen = dr.GetDateTime("ActionWhen"); aai.IContentID = dr.GetInt32("IContentID"); this.Add(aai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("AnnotationAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } #endregion } public partial class ContentAuditInfoList { /// /// C2024- 038 - Summary of Changes report generation enhancements /// Constructor - takes a Generic list of ContentAuditInfo /// and creates a ContentAuditInfoList /// public ContentAuditInfoList(List lst) { IsReadOnly = false; if (lst != null) { foreach (ContentAuditInfo itm in lst) this.Add(itm); } IsReadOnly = true; } /// /// Return a list of all ContentAuditInfo by ContentID. /// /// Selected ContentID for Content Audit Records /// public static ContentAuditInfoList Get(int contentID) { try { //if (_ContentAuditInfoList != null) // return _ContentAuditInfoList; ContentAuditInfoList tmp = DataPortal.Fetch(new ContentIDCriteria(contentID)); //ContentAuditInfo.AddList(tmp); //tmp.AddEvents(); //_ContentAuditInfoList = tmp; return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.Get", ex); } } [Serializable()] protected class ContentIDCriteria { private int _ContentID; public int ContentID { get { return _ContentID; } } public ContentIDCriteria(int contentID) { _ContentID = contentID; } } private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsByContentID"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ContentAuditInfo cai = new ContentAuditInfo(dr); cai.ActionWhat = dr.GetString("ActionWhat"); this.Add(cai); // this.Add(new ContentAuditInfo(dr)); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } //byDTS public static ContentAuditInfoList Get(int contentID, DateTime dts) { try { //if (_ContentAuditInfoList != null) // return _ContentAuditInfoList; ContentAuditInfoList tmp = DataPortal.Fetch(new ContentIDandDTSCriteria(contentID, dts)); //ContentAuditInfo.AddList(tmp); //tmp.AddEvents(); //_ContentAuditInfoList = tmp; return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.Get", ex); } } [Serializable()] protected class ContentIDandDTSCriteria { private int _ContentID; public int ContentID { get { return _ContentID; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public ContentIDandDTSCriteria(int contentID, DateTime dts) { _ContentID = contentID; _DTS = dts; } } private void DataPortal_Fetch(ContentIDandDTSCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsByContentIDandDTS"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ContentAuditInfo cai = new ContentAuditInfo(dr); cai.ActionWhat = dr.GetString("ActionWhat"); this.Add(cai); // this.Add(new ContentAuditInfo(dr)); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } //by delete status public static ContentAuditInfoList GetByDeleteStatus(int deleteStatus) { try { //if (_ContentAuditInfoList != null) // return _ContentAuditInfoList; ContentAuditInfoList tmp = DataPortal.Fetch(new DeleteStatusCriteria(deleteStatus)); //ContentAuditInfo.AddList(tmp); //tmp.AddEvents(); //_ContentAuditInfoList = tmp; return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.GetByDeleteStatus", ex); } } [Serializable()] protected class DeleteStatusCriteria { private int _DeleteStatus; public int DeleteStatus { get { return _DeleteStatus; } } public DeleteStatusCriteria(int deleteStatus) { _DeleteStatus = deleteStatus; } } private void DataPortal_Fetch(DeleteStatusCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsByDeleteStatus"; cm.Parameters.AddWithValue("@DeleteStatus", criteria.DeleteStatus); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new ContentAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } #region ChronologyReport //chronology report public static ContentAuditInfoList GetChronology(int procedureItemID, int currentItemID, bool includeDeletedChildren, DateTime dts) { try { ContentAuditInfoList tmp = DataPortal.Fetch(new ChronologyCriteria(procedureItemID, currentItemID, includeDeletedChildren, dts)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.GetChronology", ex); } } [Serializable()] protected class ChronologyCriteria { private int _ProcedureItemID; public int ProcedureItemID { get { return _ProcedureItemID; } } private int _CurrentItemID; public int CurrentItemID { get { return _CurrentItemID; } } private bool _IncludeDeletedChildren; public bool IncludeDeletedChildren { get { return _IncludeDeletedChildren; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public ChronologyCriteria(int procedureItemID, int currentItemID, bool includeDeletedChildren, DateTime dts) { _ProcedureItemID = procedureItemID; _CurrentItemID = currentItemID; _IncludeDeletedChildren = includeDeletedChildren; _DTS = dts; } } private void DataPortal_Fetch(ChronologyCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsChronologyByItemID"; cm.Parameters.AddWithValue("@ProcedureItemID", criteria.ProcedureItemID); cm.Parameters.AddWithValue("@SelectedItemID", criteria.CurrentItemID); cm.Parameters.AddWithValue("@IncludeDeletedChildren", criteria.IncludeDeletedChildren ? 1 : 0); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ContentAuditInfo cai = new ContentAuditInfo(dr); cai.ActionWhat = dr.GetString("ActionWhat"); cai.ActionWhen = dr.GetDateTime("ActionWhen"); cai.Path = dr.GetString("Path"); cai.ItemID = dr.GetInt32("ItemID"); cai.TypeName = dr.GetString("TypeName"); this.Add(cai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } //chronology report by unit public static ContentAuditInfoList GetChronologyByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID, DateTime dts) { try { ContentAuditInfoList tmp = DataPortal.Fetch(new ChronologyCriteriaByUnit(procedureItemID, currentItemID, includeDeletedChildren, unitID, dts)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.GetChronologyByUnit", ex); } } [Serializable()] protected class ChronologyCriteriaByUnit { private int _ProcedureItemID; public int ProcedureItemID { get { return _ProcedureItemID; } } private int _CurrentItemID; public int CurrentItemID { get { return _CurrentItemID; } } private bool _IncludeDeletedChildren; public bool IncludeDeletedChildren { get { return _IncludeDeletedChildren; } } private int _UnitID; public int UnitID { get { return _UnitID; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public ChronologyCriteriaByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID, DateTime dts) { _ProcedureItemID = procedureItemID; _CurrentItemID = currentItemID; _IncludeDeletedChildren = includeDeletedChildren; _UnitID = unitID; _DTS = dts; } } private void DataPortal_Fetch(ChronologyCriteriaByUnit criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsChronologyByItemIDandUnitID"; cm.Parameters.AddWithValue("@ProcedureItemID", criteria.ProcedureItemID); cm.Parameters.AddWithValue("@SelectedItemID", criteria.CurrentItemID); cm.Parameters.AddWithValue("@IncludeDeletedChildren", criteria.IncludeDeletedChildren ? 1 : 0); cm.Parameters.AddWithValue("@UnitID", criteria.UnitID); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ContentAuditInfo cai = new ContentAuditInfo(dr); cai.ActionWhat = dr.GetString("ActionWhat"); cai.ActionWhen = dr.GetDateTime("ActionWhen"); cai.Path = dr.GetString("Path"); cai.ItemID = dr.GetInt32("ItemID"); cai.TypeName = dr.GetString("TypeName"); this.Add(cai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } #endregion #region SummaryReport //summary report public static ContentAuditInfoList GetSummary(int procedureItemID, int currentItemID, bool includeDeletedChildren, DateTime dts) { try { ContentAuditInfoList tmp = DataPortal.Fetch(new SummaryCriteria(procedureItemID, currentItemID, includeDeletedChildren, dts)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.GetSummary", ex); } } [Serializable()] protected class SummaryCriteria { private int _ProcedureItemID; public int ProcedureItemID { get { return _ProcedureItemID; } } private int _CurrentItemID; public int CurrentItemID { get { return _CurrentItemID; } } private bool _IncludeDeletedChildren; public bool IncludeDeletedChildren { get { return _IncludeDeletedChildren; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public SummaryCriteria(int procedureItemID, int currentItemID, bool includeDeletedChildren, DateTime dts) { _ProcedureItemID = procedureItemID; _CurrentItemID = currentItemID; _IncludeDeletedChildren = includeDeletedChildren; _DTS = dts; } } private void DataPortal_Fetch(SummaryCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsSummaryByItemID"; cm.Parameters.AddWithValue("@ProcedureItemID", criteria.ProcedureItemID); cm.Parameters.AddWithValue("@SelectedItemID", criteria.CurrentItemID); cm.Parameters.AddWithValue("@IncludeDeletedChildren", criteria.IncludeDeletedChildren ? 1 : 0); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ContentAuditInfo cai = new ContentAuditInfo(dr); cai.ActionWhat = dr.GetString("ActionWhat"); cai.ActionWhen = dr.GetDateTime("ActionWhen"); cai.Path = dr.GetString("Path"); cai.ItemID = dr.GetInt32("ItemID"); cai.TypeName = dr.GetString("TypeName"); this.Add(cai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } //summary report by unit public static ContentAuditInfoList GetSummaryByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID, DateTime dts) { try { ContentAuditInfoList tmp = DataPortal.Fetch(new SummaryCriteriaByUnit(procedureItemID, currentItemID, includeDeletedChildren, unitID, dts)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentAuditInfoList.GetSummaryByUnit", ex); } } [Serializable()] protected class SummaryCriteriaByUnit { private int _ProcedureItemID; public int ProcedureItemID { get { return _ProcedureItemID; } } private int _CurrentItemID; public int CurrentItemID { get { return _CurrentItemID; } } private bool _IncludeDeletedChildren; public bool IncludeDeletedChildren { get { return _IncludeDeletedChildren; } } private int _UnitID; public int UnitID { get { return _UnitID; } } private DateTime _DTS; public DateTime DTS { get { return _DTS; } } public SummaryCriteriaByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID, DateTime dts) { _ProcedureItemID = procedureItemID; _CurrentItemID = currentItemID; _IncludeDeletedChildren = includeDeletedChildren; _UnitID = unitID; _DTS = dts; } } private void DataPortal_Fetch(SummaryCriteriaByUnit criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getContentAuditsSummaryByItemIDandUnitID"; cm.Parameters.AddWithValue("@ProcedureItemID", criteria.ProcedureItemID); cm.Parameters.AddWithValue("@SelectedItemID", criteria.CurrentItemID); cm.Parameters.AddWithValue("@IncludeDeletedChildren", criteria.IncludeDeletedChildren ? 1 : 0); cm.Parameters.AddWithValue("@UnitID", criteria.UnitID); cm.Parameters.AddWithValue("@DTS", criteria.DTS); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ContentAuditInfo cai = new ContentAuditInfo(dr); cai.ActionWhat = dr.GetString("ActionWhat"); cai.ActionWhen = dr.GetDateTime("ActionWhen"); cai.Path = dr.GetString("Path"); cai.ItemID = dr.GetInt32("ItemID"); cai.TypeName = dr.GetString("TypeName"); this.Add(cai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ContentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } #endregion } public partial class DocumentAuditInfoList { /// /// Return a list of all DocumentAuditInfo by DocID. /// /// Selected DocID for Document Audit Records /// public static DocumentAuditInfoList Get(int docID) { try { DocumentAuditInfoList tmp = DataPortal.Fetch(new DocumentIDCriteria(docID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on DocumentAuditInfoList.Get", ex); } } [Serializable()] protected class DocumentIDCriteria { private int _DocID; public int DocID { get { return _DocID; } } public DocumentIDCriteria(int docID) { _DocID = docID; } } private void DataPortal_Fetch(DocumentIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getDocumentAuditsByDocID"; cm.Parameters.AddWithValue("@DocID", criteria.DocID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new DocumentAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("DocumentAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } } public partial class EntryAuditInfoList { /// /// Return a list of all EntryAuditInfo by ContentID. /// /// Selected ContentID for Entry Audit Records /// public static EntryAuditInfoList Get(int contentID) { try { EntryAuditInfoList tmp = DataPortal.Fetch(new ContentIDCriteria(contentID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on EntryAuditInfoList.Get", ex); } } [Serializable()] protected class ContentIDCriteria { private int _ContentID; public int ContentID { get { return _ContentID; } } public ContentIDCriteria(int contentID) { _ContentID = contentID; } } private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getEntryAuditsByContentID"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new EntryAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("EntryAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } } public partial class GridAuditInfoList { /// /// Return a list of all GridAuditInfo by ContentID. /// /// Selected ContentID for Grid Audit Records /// public static GridAuditInfoList Get(int contentID) { try { GridAuditInfoList tmp = DataPortal.Fetch(new ContentIDCriteria(contentID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on GridAuditInfoList.Get", ex); } } [Serializable()] protected class ContentIDCriteria { private int _ContentID; public int ContentID { get { return _ContentID; } } public ContentIDCriteria(int contentID) { _ContentID = contentID; } } private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getGridAuditsByContentID"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new GridAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("GridAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } } public partial class ImageAuditInfoList { /// /// Return a list of all ImageAuditInfo by ContentID. /// /// Selected ContentID for Image Audit Records /// public static ImageAuditInfoList Get(int contentID) { try { ImageAuditInfoList tmp = DataPortal.Fetch(new ContentIDCriteria(contentID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ImageAuditInfoList.Get", ex); } } [Serializable()] protected class ContentIDCriteria { private int _ContentID; public int ContentID { get { return _ContentID; } } public ContentIDCriteria(int contentID) { _ContentID = contentID; } } private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getImageAuditsByContentID"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new ImageAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ImageAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } } public partial class ItemAuditInfoList { /// /// Return a list of all ItemAuditInfo by ItemID. /// /// Selected ItemID for Item Audit Records /// public static ItemAuditInfoList Get(int itemID) { try { ItemAuditInfoList tmp = DataPortal.Fetch(new ItemIDCriteria(itemID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ItemAuditInfoList.Get", ex); } } [Serializable()] protected class ItemIDCriteria { private int _ItemID; public int ItemID { get { return _ItemID; } } public ItemIDCriteria(int itemID) { _ItemID = itemID; } } private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getItemAuditsByItemID"; cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) { ItemAuditInfo iai = new ItemAuditInfo(dr); iai._Level = dr.GetInt32("Level"); iai._ItemType = dr.GetString("ItemType"); this.Add(iai); } IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } } public partial class PartAuditInfoList { /// /// Return a list of all PartAuditInfo by ContentID. /// /// Selected ContentID for Part Audit Records /// public static PartAuditInfoList Get(int contentID) { try { PartAuditInfoList tmp = DataPortal.Fetch(new ContentIDCriteria(contentID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on PartAuditInfoList.Get", ex); } } [Serializable()] protected class ContentIDCriteria { private int _ContentID; public int ContentID { get { return _ContentID; } } public ContentIDCriteria(int contentID) { _ContentID = contentID; } } private void DataPortal_Fetch(ContentIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getPartAuditsByContentID"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new PartAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } public static PartAuditInfoList GetByDeleteStatus(int deleteStatus) { try { PartAuditInfoList tmp = DataPortal.Fetch(new DeleteStatusCriteria(deleteStatus)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on PartAuditInfoList.GetByDeleteStatus", ex); } } [Serializable()] protected class DeleteStatusCriteria { private int _DeleteStatus; public int DeleteStatus { get { return _DeleteStatus; } } public DeleteStatusCriteria(int deleteStatus) { _DeleteStatus = deleteStatus; } } private void DataPortal_Fetch(DeleteStatusCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getPartAuditsByDeleteStatus"; cm.Parameters.AddWithValue("@DeleteStatus", criteria.DeleteStatus); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new PartAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } public static PartAuditInfoList GetByItemID(int itemID) { try { PartAuditInfoList tmp = DataPortal.Fetch(new ItemIDCriteria(itemID)); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on PartAuditInfoList.GetByItemID", ex); } } [Serializable()] protected class ItemIDCriteria { private int _ItemID; public int ItemID { get { return _ItemID; } } public ItemIDCriteria(int itemID) { _ItemID = itemID; } } private void DataPortal_Fetch(ItemIDCriteria criteria) { this.RaiseListChangedEvents = false; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getPartAuditsByItemID"; cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { IsReadOnly = false; while (dr.Read()) this.Add(new PartAuditInfo(dr)); IsReadOnly = true; } } } } catch (Exception ex) { if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartAuditInfoList.DataPortal_Fetch", ex); } this.RaiseListChangedEvents = true; } } public partial class ItemInfo { public static event ItemInfoEvent InfoRestored; private void OnInfoRestored(ItemInfo itemInfo) { if (InfoRestored != null) InfoRestored(this); } public ItemInfo RestoreSibling(ItemAuditInfo iai,ROFstInfo myRoFst) { if (iai.DeleteStatus == 0) return null; int nextID = iai.Level == 0 ? ItemID : NextItem == null ? 0 : NextItem.ItemID; ItemInfo tmp = RestoreItem(iai, myRoFst); if(nextID > 0) using (Item item = Item.Get(nextID)) ItemInfo.Refresh(item); if (iai.Level == 0) OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before)); else OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After)); if (!ActiveParent.IsDocVersion) ((ItemInfo)ActiveParent).MyContent.RefreshContentParts(); tmp.OnInfoRestored(tmp); return tmp; } public ItemInfo RestoreItem(ItemAuditInfo iai, ROFstInfo myRoFst) { ItemInfo tmp2 = null; try { ItemInfo tmp = DataPortal.Fetch(new RestoreCriteria(iai, this)); tmp2 = tmp; AddToCache(tmp); if (tmp.ErrorMessage == "No Record Found") tmp = null; if(iai.Level == 2) OnNewChild(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Child)); int? nextID = null; if (tmp.NextItem != null) { nextID = tmp.NextItem.ItemID; ItemInfo.RefreshPrevious(nextID, tmp.ItemID); tmp.NextItem.ResetOrdinal(); } //tmp.UpdateTransitionText(); if (tmp.MyContent.ContentTransitions != null) { foreach (TransitionInfo tran in tmp.MyContent.ContentTransitions) { if(tran.MyItemToID != null) tran.MyItemToID.UpdateTransitionText(); } } tmp.UpdateROText(); using (Content cont = tmp.MyContent.Get()) { if (cont.ContentTransitionCount > 0) { foreach (ContentTransition tran in cont.ContentTransitions) { cont.FixTransitionText(TransitionInfo.Get(tran.TransitionID)); } cont.Save(); } if (cont.ContentRoUsageCount > 0) { //ROFstInfo myrofst = tmp.MyDocVersion.DocVersionAssociations[0].MyROFst; ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.MyContent.ContentItems[0].MyProcedure.MyDocVersion); foreach (ContentRoUsage ro in cont.ContentRoUsages) { RoUsageInfo rou = RoUsageInfo.Get(ro.ROUsageID); string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, tmp.ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false, tmp); ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID); int mytype = rocc.type; cont.FixContentText(rou, myvalue, mytype, myRoFst); } Content cctmp = cont; if (cont.IsDirty) { cctmp.DTS = DateTime.Now; cctmp = cont.Save(); } ContentInfo.Refresh(cctmp); } } // B2017-069 when we restore a step that once had enhanced document links, // remove the enhanced document link information - fixes delete/restore issue of linked steps. // B2017-070 - when retoring a step that once had enhanced links, remove the link info for the notes and cautions as well tmp.RemoveEnhancedFromConfig(); Item.ClearDelProcReason(tmp); // C2020-038: reason was added when procedure was deleted, clear on restore return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ItemInfo.RestoreItem", ex); } } [Serializable()] private class RestoreCriteria { public RestoreCriteria(ItemAuditInfo iai, ItemInfo ii) { _MyAudit = iai; _MyInfo = ii; } private ItemAuditInfo _MyAudit; public ItemAuditInfo MyAudit { get { return _MyAudit; } set { _MyAudit = value; } } private ItemInfo _MyInfo; public ItemInfo MyInfo { get { return _MyInfo; } set { _MyInfo = value; } } } private void DataPortal_Fetch(RestoreCriteria criteria) { ItemAuditInfo iai = criteria.MyAudit; ItemInfo ii = criteria.MyInfo; //if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "restoreDeletedItem"; cm.Parameters.AddWithValue("@ItemID", iai.ItemID); cm.Parameters.AddWithValue("@DeleteID", iai.DeleteStatus); cm.Parameters.AddWithValue("@CurrentID", ii.ItemID); cm.Parameters.AddWithValue("@Level", iai.Level); cm.CommandTimeout = Database.DefaultTimeout; cm.ExecuteNonQuery(); } } } catch (Exception ex) { //if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfoList.DataPortal_Fetch", ex); //throw new DbCslaException("ItemAuditInfoList.DataPortal_Fetch", ex); } DataPortal_Fetch(new PKCriteria(iai.ItemID)); } } public partial class AnnotationInfo { public static AnnotationInfo RestoreAnnotation(AnnotationAuditInfo aai) { try { AnnotationInfo tmp = DataPortal.Fetch(new RestoreCriteria(aai)); // B2023 - 073: Crash when restoring annotation whose type had been removed (if no record return null) if (tmp.ErrorMessage == "No Record Found") return null; AddToCache(tmp); tmp.MyItem.RefreshItemAnnotations(); return tmp; } catch (Exception ex) { throw new DbCslaException("Error on AnnotaionInfo.RestoreAnnotation", ex); } } //criteria to get annotation [Serializable] private class RestoreCriteria { public RestoreCriteria(AnnotationAuditInfo aai) { _MyAudit = aai; } private AnnotationAuditInfo _MyAudit; public AnnotationAuditInfo MyAudit { get { return _MyAudit; } set { _MyAudit = value; } } } private void DataPortal_Fetch(RestoreCriteria criteria) { AnnotationAuditInfo aai = criteria.MyAudit; if (aai.DeleteStatus == 0) { //if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "restoreChangedAnnotation"; cm.Parameters.AddWithValue("@AuditID", aai.AuditID); cm.CommandTimeout = Database.DefaultTimeout; cm.ExecuteNonQuery(); } } } catch (Exception ex) { //if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfoList.DataPortal_Fetch", ex); //throw new DbCslaException("ItemAuditInfoList.DataPortal_Fetch", ex); } } else { //if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "restoreDeletedAnnotation"; cm.Parameters.AddWithValue("@AnnotationID", aai.AnnotationID); cm.CommandTimeout = Database.DefaultTimeout; cm.ExecuteNonQuery(); } } } catch (Exception ex) { //if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfoList.DataPortal_Fetch", ex); //throw new DbCslaException("ItemAuditInfoList.DataPortal_Fetch", ex); } } DataPortal_Fetch(new PKCriteria(aai.AnnotationID)); } } public partial class ContentInfo { public static ContentInfo RestoreImage(ImageAuditInfo iai) { try { using (Content ctmp = Content.Get(iai.ContentID)) { ctmp.MyImage.FileName = iai.FileName; ctmp.MyImage.Data = iai.Data; ctmp.MyImage.Config = iai.Config; ctmp.MyImage.DTS = DateTime.Now; ctmp.MyImage.UserID = Volian.Base.Library.VlnSettings.UserID; ctmp.DTS = DateTime.Now; ImageInfo.Refresh(ctmp.MyImage); ctmp.Save(); return ContentInfo.Get(iai.ContentID); } } catch (Exception ex) { throw new DbCslaException("Error on ContentInfo.RestoreImage", ex); } } public static ContentInfo RestoreContent(ContentAuditInfo cai,ROFstInfo myRoFst) { try { ContentInfo tmp = DataPortal.Fetch(new RestoreCriteria(cai)); AddToCache(tmp); if (tmp.ErrorMessage == "No Record Found") tmp = null; tmp.RefreshContentDetails(); tmp.RefreshContentItems(); tmp.RefreshContentParts(); tmp.RefreshContentRoUsages(); tmp.RefreshContentTransitions(); if (tmp.ContentTransitions != null) { foreach (TransitionInfo tran in tmp.ContentTransitions) { if (tran.MyItemToID != null) tran.MyItemToID.UpdateTransitionText(); } } using (Content ctmp = tmp.Get()) { if (ctmp.ContentTransitionCount > 0) { foreach (ContentTransition tran in ctmp.ContentTransitions) { ctmp.FixTransitionText(TransitionInfo.Get(tran.TransitionID)); } ctmp.Save(); } //ROFstInfo myrofst = tmp.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst; if (tmp.ContentRoUsages.Count != 0) // B2017-118 If no ROUsages ignore ROFST { ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion); foreach (RoUsageInfo rou in tmp.ContentRoUsages) { string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.UseTildaPoundCharsForSuperSubScriptInROValues, false, tmp.ContentItems[0]); ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID); int mytype = rocc.type; ctmp.FixContentText(rou, myvalue, mytype, myRoFst); } } Content cctmp = ctmp; if (ctmp.IsDirty) { cctmp.DTS = DateTime.Now; cctmp = ctmp.Save(); } ContentInfo.Refresh(cctmp); } //FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo return tmp; } catch (Exception ex) { throw new DbCslaException("Error on ContentInfo.RestoreContent", ex); } } //criteria to get content [Serializable] private class RestoreCriteria { public RestoreCriteria(ContentAuditInfo cai) { _MyAudit = cai; } private ContentAuditInfo _MyAudit; public ContentAuditInfo MyAudit { get { return _MyAudit; } set { _MyAudit = value; } } } private void DataPortal_Fetch(RestoreCriteria criteria) { ContentAuditInfo cai = criteria.MyAudit; //if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfoList.DataPortal_Fetch", GetHashCode()); try { using (SqlConnection cn = Database.VEPROMS_SqlConnection) { using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "restoreChangedContent"; cm.Parameters.AddWithValue("@AuditID", cai.AuditID); cm.CommandTimeout = Database.DefaultTimeout; cm.ExecuteNonQuery(); } } } catch (Exception ex) { //if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfoList.DataPortal_Fetch", ex); //throw new DbCslaException("ItemAuditInfoList.DataPortal_Fetch", ex); } DataPortal_Fetch(new PKCriteria(cai.ContentID)); } } public partial class StageInfoList { public static void Refresh() { Reset(); _StageInfoList = Get(); } } }