Added method GetChronologyByUnit to AnnotationAuditList class returning AnnotationAuditInfoList for multi unit

Removed blank lines
Added method GetChronologyByUnit to ContentAuditInfoList class returning 	ContentAuditInfoList for multi unit
Added method GetSummaryByUnit to ContentAuditInfoList class returning 	ContentAuditInfoList for multi unit
Added FixTransitionText method to ContentInfo class
This commit is contained in:
Rich 2012-12-04 22:56:07 +00:00
parent 1e2fedc518
commit e086c88bb8
2 changed files with 354 additions and 14 deletions

View File

@ -388,6 +388,83 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
//chronology report by unit
public static AnnotationAuditInfoList GetChronologyByUnit(int @procItemID, int itemID, int unitID)
{
try
{
AnnotationAuditInfoList tmp = DataPortal.Fetch<AnnotationAuditInfoList>(new ChronologyCriteriaByUnit(procItemID, itemID, unitID));
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; }
}
public ChronologyCriteriaByUnit(int procItemID, int itemID, int unitID)
{
_procItemID = procItemID;
_itemID = itemID;
_UnitID = unitID;
}
}
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);
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
}
@ -613,24 +690,20 @@ namespace VEPROMS.CSLA.Library
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; }
}
public ChronologyCriteria(int procedureItemID, int currentItemID, bool includeDeletedChildren)
{
_ProcedureItemID = procedureItemID;
@ -680,6 +753,92 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
//chronology report by unit
public static ContentAuditInfoList GetChronologyByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID)
{
try
{
ContentAuditInfoList tmp = DataPortal.Fetch<ContentAuditInfoList>(new ChronologyCriteriaByUnit(procedureItemID, currentItemID, includeDeletedChildren, unitID));
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; }
}
public ChronologyCriteriaByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID)
{
_ProcedureItemID = procedureItemID;
_CurrentItemID = currentItemID;
_IncludeDeletedChildren = includeDeletedChildren;
_UnitID = unitID;
}
}
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);
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
@ -700,24 +859,20 @@ namespace VEPROMS.CSLA.Library
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; }
}
public SummaryCriteria(int procedureItemID, int currentItemID, bool includeDeletedChildren)
{
_ProcedureItemID = procedureItemID;
@ -767,6 +922,92 @@ namespace VEPROMS.CSLA.Library
}
this.RaiseListChangedEvents = true;
}
//summary report by unit
public static ContentAuditInfoList GetSummaryByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID)
{
try
{
ContentAuditInfoList tmp = DataPortal.Fetch<ContentAuditInfoList>(new SummaryCriteriaByUnit(procedureItemID, currentItemID, includeDeletedChildren, unitID));
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; }
}
public SummaryCriteriaByUnit(int procedureItemID, int currentItemID, bool includeDeletedChildren, int unitID)
{
_ProcedureItemID = procedureItemID;
_CurrentItemID = currentItemID;
_IncludeDeletedChildren = includeDeletedChildren;
_UnitID = unitID;
}
}
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);
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
}

View File

@ -93,6 +93,105 @@ namespace VEPROMS.CSLA.Library
}
public partial class ContentInfo
{
public void FixTransitionText(TransitionInfo tran)
{
string transText = tran.ResolvePathTo();
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != transText)
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
{
string transText = tran.ResolvePathTo(tranLookup);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != transText)
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != transText)
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
}
}
}
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
{
string newvalue = value;
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
foreach (Match mm in ms)
{
int offset = mm.Index;
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[3];
if (g.ToString() != newvalue)
{
_Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
break; // Text has been processed
}
}
}
// see if there is a grid to update too.
if (rousg.MyContent.MyGrid != null)
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (Text != retlist[0]) _Text = retlist[0];
//if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
}
else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
Match mg = Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = mg.Groups[3];
//if (g.ToString() != newvalue)
// MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
}
}
}
}
}
public PartInfoList LocalContentParts
{
get { return _ContentParts; }