Added UpdateDRoUsages to Update DROUsages when a Document is Saved
Added a list of ROIDs as a parameter to the code that walks through the MSWORD Document text and replaces ROs with their values Fixed search string in FindRO Added code to call GetAffectedDROUsages when an RO changes. This adds annotations to show the changes to RO Values. Added DROUsages table to capture ROUsages in Documents
This commit is contained in:
@@ -32,13 +32,21 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Refresh
|
||||
private List<RODb> _RefreshRODbs = new List<RODb>();
|
||||
private List<RODbDROUsage> _RefreshRODbDROUsages = new List<RODbDROUsage>();
|
||||
private List<RODbROFst> _RefreshRODbROFsts = new List<RODbROFst>();
|
||||
private List<RODbROImage> _RefreshRODbROImages = new List<RODbROImage>();
|
||||
private List<RODbRoUsage> _RefreshRODbRoUsages = new List<RODbRoUsage>();
|
||||
private void AddToRefreshList(List<RODb> refreshRODbs, List<RODbROFst> refreshRODbROFsts, List<RODbROImage> refreshRODbROImages, List<RODbRoUsage> refreshRODbRoUsages)
|
||||
private void AddToRefreshList(List<RODb> refreshRODbs, List<RODbDROUsage> refreshRODbDROUsages, List<RODbROFst> refreshRODbROFsts, List<RODbROImage> refreshRODbROImages, List<RODbRoUsage> refreshRODbRoUsages)
|
||||
{
|
||||
if (IsDirty)
|
||||
refreshRODbs.Add(this);
|
||||
if (_RODbDROUsages != null && _RODbDROUsages.IsDirty)
|
||||
{
|
||||
foreach (RODbDROUsage tmp in _RODbDROUsages)
|
||||
{
|
||||
if (tmp.IsDirty) refreshRODbDROUsages.Add(tmp);
|
||||
}
|
||||
}
|
||||
if (_RODbROFsts != null && _RODbROFsts.IsDirty)
|
||||
{
|
||||
foreach (RODbROFst tmp in _RODbROFsts)
|
||||
@@ -64,10 +72,11 @@ namespace VEPROMS.CSLA.Library
|
||||
private void BuildRefreshList()
|
||||
{
|
||||
_RefreshRODbs = new List<RODb>();
|
||||
_RefreshRODbDROUsages = new List<RODbDROUsage>();
|
||||
_RefreshRODbROFsts = new List<RODbROFst>();
|
||||
_RefreshRODbROImages = new List<RODbROImage>();
|
||||
_RefreshRODbRoUsages = new List<RODbRoUsage>();
|
||||
AddToRefreshList(_RefreshRODbs, _RefreshRODbROFsts, _RefreshRODbROImages, _RefreshRODbRoUsages);
|
||||
AddToRefreshList(_RefreshRODbs, _RefreshRODbDROUsages, _RefreshRODbROFsts, _RefreshRODbROImages, _RefreshRODbRoUsages);
|
||||
}
|
||||
private void ProcessRefreshList()
|
||||
{
|
||||
@@ -75,6 +84,10 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
RODbInfo.Refresh(tmp);
|
||||
}
|
||||
foreach (RODbDROUsage tmp in _RefreshRODbDROUsages)
|
||||
{
|
||||
DROUsageInfo.Refresh(tmp);
|
||||
}
|
||||
foreach (RODbROFst tmp in _RefreshRODbROFsts)
|
||||
{
|
||||
ROFstInfo.Refresh(tmp);
|
||||
@@ -289,6 +302,43 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
private byte[] _LastChanged = new byte[8];//timestamp
|
||||
private int _RODbDROUsageCount = 0;
|
||||
/// <summary>
|
||||
/// Count of RODbDROUsages for this RODb
|
||||
/// </summary>
|
||||
public int RODbDROUsageCount
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("RODbDROUsageCount", true);
|
||||
return _RODbDROUsageCount;
|
||||
}
|
||||
}
|
||||
private RODbDROUsages _RODbDROUsages = null;
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(RODbDROUsagesConverter))]
|
||||
public RODbDROUsages RODbDROUsages
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("RODbDROUsages", true);
|
||||
if (_RODbDROUsageCount < 0 || (_RODbDROUsageCount > 0 && _RODbDROUsages == null))
|
||||
_RODbDROUsages = RODbDROUsages.GetByRODbID(RODbID);
|
||||
if (_RODbDROUsageCount < 0 )
|
||||
_RODbDROUsageCount = _RODbDROUsages == null ? 0 : _RODbDROUsages.Count;
|
||||
if (_RODbDROUsages == null)
|
||||
_RODbDROUsages = RODbDROUsages.New();
|
||||
return _RODbDROUsages;
|
||||
}
|
||||
}
|
||||
public void Reset_RODbDROUsages()
|
||||
{
|
||||
_RODbDROUsageCount = -1;
|
||||
}
|
||||
private int _RODbROFstCount = 0;
|
||||
/// <summary>
|
||||
/// Count of RODbROFsts for this RODb
|
||||
@@ -414,7 +464,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (base.IsDirty || list.Contains(this))
|
||||
return base.IsDirty;
|
||||
list.Add(this);
|
||||
return base.IsDirty || (_RODbROFsts == null ? false : _RODbROFsts.IsDirtyList(list)) || (_RODbROImages == null ? false : _RODbROImages.IsDirtyList(list)) || (_RODbRoUsages == null ? false : _RODbRoUsages.IsDirtyList(list));
|
||||
return base.IsDirty || (_RODbDROUsages == null ? false : _RODbDROUsages.IsDirtyList(list)) || (_RODbROFsts == null ? false : _RODbROFsts.IsDirtyList(list)) || (_RODbROImages == null ? false : _RODbROImages.IsDirtyList(list)) || (_RODbRoUsages == null ? false : _RODbRoUsages.IsDirtyList(list));
|
||||
}
|
||||
public override bool IsValid
|
||||
{
|
||||
@@ -425,7 +475,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if(list.Contains(this))
|
||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
||||
list.Add(this);
|
||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_RODbROFsts == null ? true : _RODbROFsts.IsValidList(list)) && (_RODbROImages == null ? true : _RODbROImages.IsValidList(list)) && (_RODbRoUsages == null ? true : _RODbRoUsages.IsValidList(list));
|
||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_RODbDROUsages == null ? true : _RODbDROUsages.IsValidList(list)) && (_RODbROFsts == null ? true : _RODbROFsts.IsValidList(list)) && (_RODbROImages == null ? true : _RODbROImages.IsValidList(list)) && (_RODbRoUsages == null ? true : _RODbRoUsages.IsValidList(list));
|
||||
}
|
||||
// CSLATODO: Replace base RODb.ToString function as necessary
|
||||
/// <summary>
|
||||
@@ -460,6 +510,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_CheckingBrokenRules = true;
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_RODbRoUsages != null && (hasBrokenRules = _RODbRoUsages.HasBrokenRules) != null) return hasBrokenRules;
|
||||
if (_RODbDROUsages != null && (hasBrokenRules = _RODbDROUsages.HasBrokenRules) != null) return hasBrokenRules;
|
||||
if (_RODbROFsts != null && (hasBrokenRules = _RODbROFsts.HasBrokenRules) != null) return hasBrokenRules;
|
||||
if (_RODbROImages != null && (hasBrokenRules = _RODbROImages.HasBrokenRules) != null) return hasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
@@ -578,6 +629,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
// Check to make sure that there are not any related records
|
||||
int usedByCount = 0;
|
||||
usedByCount += _RODbDROUsageCount;
|
||||
usedByCount += _RODbROFstCount;
|
||||
usedByCount += _RODbROImageCount;
|
||||
usedByCount += _RODbRoUsageCount;
|
||||
@@ -852,6 +904,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_DTS = dr.GetDateTime("DTS");
|
||||
_UserID = dr.GetString("UserID");
|
||||
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
||||
_RODbDROUsageCount = dr.GetInt32("DROUsageCount");
|
||||
_RODbROFstCount = dr.GetInt32("ROFstCount");
|
||||
_RODbROImageCount = dr.GetInt32("ROImageCount");
|
||||
_RODbRoUsageCount = dr.GetInt32("RoUsageCount");
|
||||
@@ -887,6 +940,9 @@ namespace VEPROMS.CSLA.Library
|
||||
ReadData(dr);
|
||||
// load child objects
|
||||
dr.NextResult();
|
||||
_RODbDROUsages = RODbDROUsages.Get(dr);
|
||||
// load child objects
|
||||
dr.NextResult();
|
||||
_RODbROFsts = RODbROFsts.Get(dr);
|
||||
// load child objects
|
||||
dr.NextResult();
|
||||
@@ -1002,6 +1058,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkOld();
|
||||
// update child objects
|
||||
if (_RODbRoUsages != null) _RODbRoUsages.Update(this);
|
||||
if (_RODbDROUsages != null) _RODbDROUsages.Update(this);
|
||||
if (_RODbROFsts != null) _RODbROFsts.Update(this);
|
||||
if (_RODbROImages != null) _RODbROImages.Update(this);
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODb.SQLInsert", GetHashCode());
|
||||
@@ -1109,6 +1166,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkOld();
|
||||
// use the open connection to update child objects
|
||||
if (_RODbRoUsages != null) _RODbRoUsages.Update(this);
|
||||
if (_RODbDROUsages != null) _RODbDROUsages.Update(this);
|
||||
if (_RODbROFsts != null) _RODbROFsts.Update(this);
|
||||
if (_RODbROImages != null) _RODbROImages.Update(this);
|
||||
}
|
||||
@@ -1132,6 +1190,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkOld();
|
||||
}
|
||||
if (_RODbRoUsages != null) _RODbRoUsages.Update(this);
|
||||
if (_RODbDROUsages != null) _RODbDROUsages.Update(this);
|
||||
if (_RODbROFsts != null) _RODbROFsts.Update(this);
|
||||
if (_RODbROImages != null) _RODbROImages.Update(this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user