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:
parent
7cdc7f4994
commit
c4344f2308
@ -27,6 +27,25 @@ namespace VEPROMS.CSLA.Library
|
||||
return _LibTitle;
|
||||
}
|
||||
}
|
||||
public void UpdateDRoUsages(List<string> roids)
|
||||
{
|
||||
if (DocumentDROUsageCount > 0)
|
||||
{
|
||||
foreach (DocumentDROUsage myUsage in DocumentDROUsages)
|
||||
{
|
||||
string roidkey = string.Format("{0}:{1}", myUsage.RODbID, myUsage.ROID);
|
||||
if (roids.Contains(roidkey))
|
||||
roids.Remove(roidkey);// If in both, nothing to do
|
||||
else
|
||||
myUsage.Delete(); // If only in old, remove it
|
||||
}
|
||||
}
|
||||
foreach (string roidkey in roids)
|
||||
{
|
||||
string [] parts = roidkey.Split(":".ToCharArray());
|
||||
DocumentDROUsages.Add(parts[1], RODb.Get(int.Parse(parts[0])));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// FixString processes the string returned and changes any symbols (0xF0??) to normal characters
|
||||
/// </summary>
|
||||
@ -295,7 +314,8 @@ namespace VEPROMS.CSLA.Library
|
||||
doc.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
doc.DTS = _MyFile.LastWriteTime;
|
||||
doc.Save();
|
||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument);
|
||||
List<string> roids = new List<string>();
|
||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument,roids);
|
||||
FileInfo pdfFile = new FileInfo(pdfTmp);
|
||||
fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
buf = new byte[pdfFile.Length];
|
||||
@ -303,6 +323,7 @@ namespace VEPROMS.CSLA.Library
|
||||
fs.Close();
|
||||
pdfFile.Delete();
|
||||
doc.DocPdf = buf;
|
||||
doc.UpdateDRoUsages(roids);
|
||||
doc.Save();
|
||||
}
|
||||
#endregion
|
||||
@ -387,9 +408,10 @@ namespace VEPROMS.CSLA.Library
|
||||
public static bool SetDocPdf(DocumentInfo docInfo)
|
||||
{
|
||||
string pdfTmp = null;
|
||||
List<string> roids = new List<string>();
|
||||
try
|
||||
{
|
||||
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo);
|
||||
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -408,17 +430,18 @@ namespace VEPROMS.CSLA.Library
|
||||
dc.Printing_Color = MSWordToPDF.OverrideColor;
|
||||
doc.Config = dc.ToString();
|
||||
doc.DocPdf = buf;
|
||||
doc.UpdateDRoUsages(roids);
|
||||
doc.Save();
|
||||
}
|
||||
docInfo.RefreshConfig();
|
||||
return true;
|
||||
}
|
||||
public static string ToPDFReplaceROs(DocumentInfo doc)
|
||||
public static string ToPDFReplaceROs(DocumentInfo doc,List<string> roids)
|
||||
{
|
||||
ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0];
|
||||
return ToPDFReplaceROs(sect, false);
|
||||
return ToPDFReplaceROs(sect, false, roids);
|
||||
}
|
||||
public static string ToPDFReplaceROs(ItemInfo sect, bool openPdf) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm)
|
||||
public static string ToPDFReplaceROs(ItemInfo sect, bool openPdf, List<string> roids) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm)
|
||||
{
|
||||
string fileName = GetFileName(sect);
|
||||
// TODO: do we want to cache the word pdfs
|
||||
@ -465,7 +488,13 @@ namespace VEPROMS.CSLA.Library
|
||||
// if type is null, then set type to zero so that InsertROValue will put in "RO Not Found" for the value
|
||||
if (type == null)
|
||||
type = 0;
|
||||
|
||||
string roid = lookup.GetROIDByAccPagID(sel.Text, spPrefix, igPrefix);
|
||||
if (roid != null)
|
||||
{
|
||||
string roidkey = string.Format("{0}:{1}",rofst.RODbID, roid);
|
||||
if (!roids.Contains(roidkey))
|
||||
roids.Add(roidkey);
|
||||
}
|
||||
if ((int)type == 8) // Image
|
||||
{
|
||||
//Console.WriteLine("Image: {0} - {1}", sect.MyContent.Number, sect.MyContent.Text);
|
||||
@ -716,7 +745,15 @@ namespace VEPROMS.CSLA.Library
|
||||
LBSelection sel = MyApp.Selection;
|
||||
LBFind find = sel.Find;
|
||||
find.ClearFormatting();
|
||||
find.Text = "[<](?@)-(?@)[>]";
|
||||
// Search string format - this is MSWord wildcard format
|
||||
// If you do a search in MSWord, make sure wildcard box is checked and then press the
|
||||
// Special button to see the definitions of the various wildcards
|
||||
// [<] - Less-Than Character
|
||||
// [!<> ]@ - 1 or more characters not including Less-Than, Greater-Than or Space
|
||||
// - Dash
|
||||
// [!<> ]@ - 1 or more characters not including Less-Than, Greater-Than or Space
|
||||
// [>] - Greater-Than Character
|
||||
find.Text = "[<][!<> ]@-[!<> ]@[>]";
|
||||
//find.Wrap = LBWdFindWrap.wdFindStop;
|
||||
find.Wrap = LBWdFindWrap.wdFindContinue;
|
||||
find.MatchCase = false;
|
||||
|
@ -224,14 +224,30 @@ namespace VEPROMS.CSLA.Library
|
||||
// roid's are stored in database as 16 characters long in the rousages table. They may be stored
|
||||
// as 12 characters in the ro.fst.
|
||||
string padroid = chg.Length <= 12 ? chg + "0000" : chg;
|
||||
RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed");
|
||||
foreach (RoUsageInfo roUsg in affected)
|
||||
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed"))
|
||||
{
|
||||
using (Content content = Content.Get(roUsg.MyContent.ContentID))
|
||||
foreach (RoUsageInfo roUsg in affected)
|
||||
{
|
||||
content.FixContentText(roUsg, newvalue);
|
||||
if (content.IsDirty)
|
||||
content.Save();
|
||||
using (Content content = Content.Get(roUsg.MyContent.ContentID))
|
||||
{
|
||||
content.FixContentText(roUsg, newvalue);
|
||||
if (content.IsDirty)
|
||||
content.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
using (DROUsageInfoList affected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed"))
|
||||
{
|
||||
foreach (DROUsageInfo droUsg in affected)
|
||||
{
|
||||
using (Document document = Document.Get(droUsg.DocID))
|
||||
{
|
||||
if (document.DocPdf != null)
|
||||
{
|
||||
document.DocPdf = null;
|
||||
document.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -240,7 +256,8 @@ namespace VEPROMS.CSLA.Library
|
||||
Console.WriteLine("Deleted ROID = {0}", del);
|
||||
string desc = string.Format("Deleted RO: Value = {0}", origLU.GetRoValue(del));
|
||||
string padroiddel = del.Length <= 12 ? del + "0000" : del;
|
||||
RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted");
|
||||
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted")) ;
|
||||
using (DROUsageInfoList Daffected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted")) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,11 +32,19 @@ namespace VEPROMS.CSLA.Library
|
||||
#endregion
|
||||
#region Refresh
|
||||
private List<Document> _RefreshDocuments = new List<Document>();
|
||||
private List<DocumentDROUsage> _RefreshDocumentDROUsages = new List<DocumentDROUsage>();
|
||||
private List<DocumentEntry> _RefreshDocumentEntries = new List<DocumentEntry>();
|
||||
private void AddToRefreshList(List<Document> refreshDocuments, List<DocumentEntry> refreshDocumentEntries)
|
||||
private void AddToRefreshList(List<Document> refreshDocuments, List<DocumentDROUsage> refreshDocumentDROUsages, List<DocumentEntry> refreshDocumentEntries)
|
||||
{
|
||||
if (IsDirty)
|
||||
refreshDocuments.Add(this);
|
||||
if (_DocumentDROUsages != null && _DocumentDROUsages.IsDirty)
|
||||
{
|
||||
foreach (DocumentDROUsage tmp in _DocumentDROUsages)
|
||||
{
|
||||
if (tmp.IsDirty) refreshDocumentDROUsages.Add(tmp);
|
||||
}
|
||||
}
|
||||
if (_DocumentEntries != null && _DocumentEntries.IsDirty)
|
||||
{
|
||||
foreach (DocumentEntry tmp in _DocumentEntries)
|
||||
@ -48,8 +56,9 @@ namespace VEPROMS.CSLA.Library
|
||||
private void BuildRefreshList()
|
||||
{
|
||||
_RefreshDocuments = new List<Document>();
|
||||
_RefreshDocumentDROUsages = new List<DocumentDROUsage>();
|
||||
_RefreshDocumentEntries = new List<DocumentEntry>();
|
||||
AddToRefreshList(_RefreshDocuments, _RefreshDocumentEntries);
|
||||
AddToRefreshList(_RefreshDocuments, _RefreshDocumentDROUsages, _RefreshDocumentEntries);
|
||||
}
|
||||
private void ProcessRefreshList()
|
||||
{
|
||||
@ -57,6 +66,10 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
DocumentInfo.Refresh(tmp);
|
||||
}
|
||||
foreach (DocumentDROUsage tmp in _RefreshDocumentDROUsages)
|
||||
{
|
||||
DROUsageInfo.Refresh(tmp);
|
||||
}
|
||||
foreach (DocumentEntry tmp in _RefreshDocumentEntries)
|
||||
{
|
||||
EntryInfo.Refresh(tmp);
|
||||
@ -290,6 +303,43 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _DocumentDROUsageCount = 0;
|
||||
/// <summary>
|
||||
/// Count of DocumentDROUsages for this Document
|
||||
/// </summary>
|
||||
public int DocumentDROUsageCount
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DocumentDROUsageCount", true);
|
||||
return _DocumentDROUsageCount;
|
||||
}
|
||||
}
|
||||
private DocumentDROUsages _DocumentDROUsages = null;
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(DocumentDROUsagesConverter))]
|
||||
public DocumentDROUsages DocumentDROUsages
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DocumentDROUsages", true);
|
||||
if (_DocumentDROUsageCount < 0 || (_DocumentDROUsageCount > 0 && _DocumentDROUsages == null))
|
||||
_DocumentDROUsages = DocumentDROUsages.GetByDocID(DocID);
|
||||
if (_DocumentDROUsageCount < 0 )
|
||||
_DocumentDROUsageCount = _DocumentDROUsages == null ? 0 : _DocumentDROUsages.Count;
|
||||
if (_DocumentDROUsages == null)
|
||||
_DocumentDROUsages = DocumentDROUsages.New();
|
||||
return _DocumentDROUsages;
|
||||
}
|
||||
}
|
||||
public void Reset_DocumentDROUsages()
|
||||
{
|
||||
_DocumentDROUsageCount = -1;
|
||||
}
|
||||
private int _DocumentEntryCount = 0;
|
||||
/// <summary>
|
||||
/// Count of DocumentEntries for this Document
|
||||
@ -341,7 +391,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if (base.IsDirty || list.Contains(this))
|
||||
return base.IsDirty;
|
||||
list.Add(this);
|
||||
return base.IsDirty || (_DocumentEntries == null ? false : _DocumentEntries.IsDirtyList(list));
|
||||
return base.IsDirty || (_DocumentDROUsages == null ? false : _DocumentDROUsages.IsDirtyList(list)) || (_DocumentEntries == null ? false : _DocumentEntries.IsDirtyList(list));
|
||||
}
|
||||
public override bool IsValid
|
||||
{
|
||||
@ -352,7 +402,7 @@ namespace VEPROMS.CSLA.Library
|
||||
if(list.Contains(this))
|
||||
return (IsNew && !IsDirty) ? true : base.IsValid;
|
||||
list.Add(this);
|
||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_DocumentEntries == null ? true : _DocumentEntries.IsValidList(list));
|
||||
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_DocumentDROUsages == null ? true : _DocumentDROUsages.IsValidList(list)) && (_DocumentEntries == null ? true : _DocumentEntries.IsValidList(list));
|
||||
}
|
||||
// CSLATODO: Replace base Document.ToString function as necessary
|
||||
/// <summary>
|
||||
@ -387,6 +437,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_CheckingBrokenRules = true;
|
||||
IVEHasBrokenRules hasBrokenRules = null;
|
||||
if (_DocumentEntries != null && (hasBrokenRules = _DocumentEntries.HasBrokenRules) != null) return hasBrokenRules;
|
||||
if (_DocumentDROUsages != null && (hasBrokenRules = _DocumentDROUsages.HasBrokenRules) != null) return hasBrokenRules;
|
||||
return hasBrokenRules;
|
||||
}
|
||||
finally
|
||||
@ -503,6 +554,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
// Check to make sure that there are not any related records
|
||||
int usedByCount = 0;
|
||||
usedByCount += _DocumentDROUsageCount;
|
||||
usedByCount += _DocumentEntryCount;
|
||||
return (usedByCount == 0);
|
||||
}
|
||||
@ -726,6 +778,7 @@ namespace VEPROMS.CSLA.Library
|
||||
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
||||
_FileExtension = dr.GetString("FileExtension");
|
||||
_DocPdf = (byte[])dr.GetValue("DocPdf");
|
||||
_DocumentDROUsageCount = dr.GetInt32("DROUsageCount");
|
||||
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
||||
MarkOld();
|
||||
}
|
||||
@ -759,6 +812,9 @@ namespace VEPROMS.CSLA.Library
|
||||
ReadData(dr);
|
||||
// load child objects
|
||||
dr.NextResult();
|
||||
_DocumentDROUsages = DocumentDROUsages.Get(dr);
|
||||
// load child objects
|
||||
dr.NextResult();
|
||||
_DocumentEntries = DocumentEntries.Get(dr);
|
||||
}
|
||||
}
|
||||
@ -835,6 +891,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkOld();
|
||||
// update child objects
|
||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
||||
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLInsert", GetHashCode());
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -944,6 +1001,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkOld();
|
||||
// use the open connection to update child objects
|
||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
||||
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -965,6 +1023,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkOld();
|
||||
}
|
||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
||||
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged, string fileExtension, byte[] docPdf)
|
||||
|
@ -186,6 +186,44 @@ namespace VEPROMS.CSLA.Library
|
||||
return _DocPdf;
|
||||
}
|
||||
}
|
||||
private int _DocumentDROUsageCount = 0;
|
||||
/// <summary>
|
||||
/// Count of DocumentDROUsages for this Document
|
||||
/// </summary>
|
||||
public int DocumentDROUsageCount
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DocumentDROUsageCount", true);
|
||||
if (_DocumentDROUsageCount < 0)
|
||||
_DocumentDROUsageCount = DocumentDROUsages.Count;
|
||||
return _DocumentDROUsageCount;
|
||||
}
|
||||
}
|
||||
private DROUsageInfoList _DocumentDROUsages = null;
|
||||
[TypeConverter(typeof(DROUsageInfoListConverter))]
|
||||
public DROUsageInfoList DocumentDROUsages
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("DocumentDROUsages", true);
|
||||
if (_DocumentDROUsageCount < 0 || (_DocumentDROUsageCount > 0 && _DocumentDROUsages == null))
|
||||
_DocumentDROUsages = DROUsageInfoList.GetByDocID(_DocID);
|
||||
if (_DocumentDROUsageCount < 0)
|
||||
_DocumentDROUsageCount = _DocumentDROUsages.Count;
|
||||
return _DocumentDROUsages;
|
||||
}
|
||||
}
|
||||
public void RefreshDocumentDROUsages()
|
||||
{
|
||||
_DocumentDROUsageCount = -1;
|
||||
ConvertListToDictionary();
|
||||
if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString()))
|
||||
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
|
||||
tmp._DocumentDROUsageCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
private int _DocumentEntryCount = 0;
|
||||
/// <summary>
|
||||
/// Count of DocumentEntries for this Document
|
||||
@ -352,6 +390,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_UserID = dr.GetString("UserID");
|
||||
_FileExtension = dr.GetString("FileExtension");
|
||||
_DocPdf = (byte[])dr.GetValue("DocPdf");
|
||||
_DocumentDROUsageCount = dr.GetInt32("DROUsageCount");
|
||||
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -105,6 +105,8 @@ namespace VEPROMS.CSLA.Library
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class Document
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class DocumentDROUsage
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class DocumentEntry
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class DocumentInfo
|
||||
@ -115,6 +117,10 @@ namespace VEPROMS.CSLA.Library
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class DocVersionInfo
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class DROUsage
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class DROUsageInfo
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class Entry
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class EntryInfo
|
||||
@ -185,6 +191,8 @@ namespace VEPROMS.CSLA.Library
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class RODb
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class RODbDROUsage
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class RODbROFst
|
||||
// { public override string ToString() { return string.Format("{0}", _Name); } }
|
||||
// public partial class RODbROImage
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -169,6 +169,44 @@ namespace VEPROMS.CSLA.Library
|
||||
return _UserID;
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (_RODbDROUsageCount < 0)
|
||||
_RODbDROUsageCount = RODbDROUsages.Count;
|
||||
return _RODbDROUsageCount;
|
||||
}
|
||||
}
|
||||
private DROUsageInfoList _RODbDROUsages = null;
|
||||
[TypeConverter(typeof(DROUsageInfoListConverter))]
|
||||
public DROUsageInfoList RODbDROUsages
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("RODbDROUsages", true);
|
||||
if (_RODbDROUsageCount < 0 || (_RODbDROUsageCount > 0 && _RODbDROUsages == null))
|
||||
_RODbDROUsages = DROUsageInfoList.GetByRODbID(_RODbID);
|
||||
if (_RODbDROUsageCount < 0)
|
||||
_RODbDROUsageCount = _RODbDROUsages.Count;
|
||||
return _RODbDROUsages;
|
||||
}
|
||||
}
|
||||
public void RefreshRODbDROUsages()
|
||||
{
|
||||
_RODbDROUsageCount = -1;
|
||||
ConvertListToDictionary();
|
||||
if (_CacheByPrimaryKey.ContainsKey(_RODbID.ToString()))
|
||||
foreach (RODbInfo tmp in _CacheByPrimaryKey[_RODbID.ToString()])
|
||||
tmp._RODbDROUsageCount = -1; // This will cause the data to be requeried
|
||||
}
|
||||
private int _RODbROFstCount = 0;
|
||||
/// <summary>
|
||||
/// Count of RODbROFsts for this RODb
|
||||
@ -407,6 +445,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_Config = dr.GetString("Config");
|
||||
_DTS = dr.GetDateTime("DTS");
|
||||
_UserID = dr.GetString("UserID");
|
||||
_RODbDROUsageCount = dr.GetInt32("DROUsageCount");
|
||||
_RODbROFstCount = dr.GetInt32("ROFstCount");
|
||||
_RODbROImageCount = dr.GetInt32("ROImageCount");
|
||||
_RODbRoUsageCount = dr.GetInt32("RoUsageCount");
|
||||
|
Loading…
x
Reference in New Issue
Block a user