|
|
|
@@ -34,7 +34,8 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
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<DocumentDROUsage> refreshDocumentDROUsages, List<DocumentEntry> refreshDocumentEntries)
|
|
|
|
|
private List<DocumentPdf> _RefreshDocumentPdfs = new List<DocumentPdf>();
|
|
|
|
|
private void AddToRefreshList(List<Document> refreshDocuments, List<DocumentDROUsage> refreshDocumentDROUsages, List<DocumentEntry> refreshDocumentEntries, List<DocumentPdf> refreshDocumentPdfs)
|
|
|
|
|
{
|
|
|
|
|
if (IsDirty)
|
|
|
|
|
refreshDocuments.Add(this);
|
|
|
|
@@ -52,13 +53,21 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
if (tmp.IsDirty) refreshDocumentEntries.Add(tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_DocumentPdfs != null && _DocumentPdfs.IsDirty)
|
|
|
|
|
{
|
|
|
|
|
foreach (DocumentPdf tmp in _DocumentPdfs)
|
|
|
|
|
{
|
|
|
|
|
if (tmp.IsDirty) refreshDocumentPdfs.Add(tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void BuildRefreshList()
|
|
|
|
|
{
|
|
|
|
|
_RefreshDocuments = new List<Document>();
|
|
|
|
|
_RefreshDocumentDROUsages = new List<DocumentDROUsage>();
|
|
|
|
|
_RefreshDocumentEntries = new List<DocumentEntry>();
|
|
|
|
|
AddToRefreshList(_RefreshDocuments, _RefreshDocumentDROUsages, _RefreshDocumentEntries);
|
|
|
|
|
_RefreshDocumentPdfs = new List<DocumentPdf>();
|
|
|
|
|
AddToRefreshList(_RefreshDocuments, _RefreshDocumentDROUsages, _RefreshDocumentEntries, _RefreshDocumentPdfs);
|
|
|
|
|
}
|
|
|
|
|
private void ProcessRefreshList()
|
|
|
|
|
{
|
|
|
|
@@ -74,6 +83,10 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
{
|
|
|
|
|
EntryInfo.Refresh(tmp);
|
|
|
|
|
}
|
|
|
|
|
foreach (DocumentPdf tmp in _RefreshDocumentPdfs)
|
|
|
|
|
{
|
|
|
|
|
PdfInfo.Refresh(this, tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region Collection
|
|
|
|
@@ -283,26 +296,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private byte[] _DocPdf;
|
|
|
|
|
public byte[] DocPdf
|
|
|
|
|
{
|
|
|
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
CanReadProperty("DocPdf", true);
|
|
|
|
|
return _DocPdf;
|
|
|
|
|
}
|
|
|
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
CanWriteProperty("DocPdf", true);
|
|
|
|
|
if (_DocPdf != value)
|
|
|
|
|
{
|
|
|
|
|
_DocPdf = value;
|
|
|
|
|
PropertyHasChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private int _DocumentDROUsageCount = 0;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of DocumentDROUsages for this Document
|
|
|
|
@@ -377,6 +370,43 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
{
|
|
|
|
|
_DocumentEntryCount = -1;
|
|
|
|
|
}
|
|
|
|
|
private int _DocumentPdfCount = 0;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Count of DocumentPdfs for this Document
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int DocumentPdfCount
|
|
|
|
|
{
|
|
|
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
CanReadProperty("DocumentPdfCount", true);
|
|
|
|
|
return _DocumentPdfCount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private DocumentPdfs _DocumentPdfs = null;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Related Field
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TypeConverter(typeof(DocumentPdfsConverter))]
|
|
|
|
|
public DocumentPdfs DocumentPdfs
|
|
|
|
|
{
|
|
|
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
CanReadProperty("DocumentPdfs", true);
|
|
|
|
|
if (_DocumentPdfCount < 0 || (_DocumentPdfCount > 0 && _DocumentPdfs == null))
|
|
|
|
|
_DocumentPdfs = DocumentPdfs.GetByDocID(DocID);
|
|
|
|
|
if (_DocumentPdfCount < 0 )
|
|
|
|
|
_DocumentPdfCount = _DocumentPdfs == null ? 0 : _DocumentPdfs.Count;
|
|
|
|
|
if (_DocumentPdfs == null)
|
|
|
|
|
_DocumentPdfs = DocumentPdfs.New();
|
|
|
|
|
return _DocumentPdfs;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Reset_DocumentPdfs()
|
|
|
|
|
{
|
|
|
|
|
_DocumentPdfCount = -1;
|
|
|
|
|
}
|
|
|
|
|
public override bool IsDirty
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
@@ -391,7 +421,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
if (base.IsDirty || list.Contains(this))
|
|
|
|
|
return base.IsDirty;
|
|
|
|
|
list.Add(this);
|
|
|
|
|
return base.IsDirty || (_DocumentDROUsages == null ? false : _DocumentDROUsages.IsDirtyList(list)) || (_DocumentEntries == null ? false : _DocumentEntries.IsDirtyList(list));
|
|
|
|
|
return base.IsDirty || (_DocumentDROUsages == null ? false : _DocumentDROUsages.IsDirtyList(list)) || (_DocumentEntries == null ? false : _DocumentEntries.IsDirtyList(list)) || (_DocumentPdfs == null ? false : _DocumentPdfs.IsDirtyList(list));
|
|
|
|
|
}
|
|
|
|
|
public override bool IsValid
|
|
|
|
|
{
|
|
|
|
@@ -402,7 +432,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
if(list.Contains(this))
|
|
|
|
|
return (IsNew && !IsDirty) ? true : base.IsValid;
|
|
|
|
|
list.Add(this);
|
|
|
|
|
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_DocumentDROUsages == null ? true : _DocumentDROUsages.IsValidList(list)) && (_DocumentEntries == null ? true : _DocumentEntries.IsValidList(list));
|
|
|
|
|
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_DocumentDROUsages == null ? true : _DocumentDROUsages.IsValidList(list)) && (_DocumentEntries == null ? true : _DocumentEntries.IsValidList(list)) && (_DocumentPdfs == null ? true : _DocumentPdfs.IsValidList(list));
|
|
|
|
|
}
|
|
|
|
|
// CSLATODO: Replace base Document.ToString function as necessary
|
|
|
|
|
/// <summary>
|
|
|
|
@@ -438,6 +468,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
IVEHasBrokenRules hasBrokenRules = null;
|
|
|
|
|
if (_DocumentEntries != null && (hasBrokenRules = _DocumentEntries.HasBrokenRules) != null) return hasBrokenRules;
|
|
|
|
|
if (_DocumentDROUsages != null && (hasBrokenRules = _DocumentDROUsages.HasBrokenRules) != null) return hasBrokenRules;
|
|
|
|
|
if (_DocumentPdfs != null && (hasBrokenRules = _DocumentPdfs.HasBrokenRules) != null) return hasBrokenRules;
|
|
|
|
|
return hasBrokenRules;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
@@ -509,7 +540,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowRead(FileExtension, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowRead(DocPdf, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
|
|
|
|
@@ -517,7 +547,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowWrite(FileExtension, "<Role(s)>");
|
|
|
|
|
//AuthorizationRules.AllowWrite(DocPdf, "<Role(s)>");
|
|
|
|
|
_DocumentExtension.AddAuthorizationRules(AuthorizationRules);
|
|
|
|
|
}
|
|
|
|
|
protected override void AddInstanceAuthorizationRules()
|
|
|
|
@@ -556,6 +585,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
int usedByCount = 0;
|
|
|
|
|
usedByCount += _DocumentDROUsageCount;
|
|
|
|
|
usedByCount += _DocumentEntryCount;
|
|
|
|
|
usedByCount += _DocumentPdfCount;
|
|
|
|
|
return (usedByCount == 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -607,7 +637,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
throw new DbCslaException("Error on Document.New", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static Document New(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension, byte[] docPdf)
|
|
|
|
|
public static Document New(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension)
|
|
|
|
|
{
|
|
|
|
|
Document tmp = Document.New();
|
|
|
|
|
tmp.LibTitle = libTitle;
|
|
|
|
@@ -617,12 +647,11 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
tmp.DTS = dts;
|
|
|
|
|
tmp.UserID = userID;
|
|
|
|
|
tmp.FileExtension = fileExtension;
|
|
|
|
|
tmp.DocPdf = docPdf;
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension, byte[] docPdf)
|
|
|
|
|
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension)
|
|
|
|
|
{
|
|
|
|
|
Document tmp = Document.New(libTitle, docContent, docAscii, config, dts, userID, fileExtension, docPdf);
|
|
|
|
|
Document tmp = Document.New(libTitle, docContent, docAscii, config, dts, userID, fileExtension);
|
|
|
|
|
if (tmp.IsSavable)
|
|
|
|
|
{
|
|
|
|
|
Document tmp2 = tmp;
|
|
|
|
@@ -640,19 +669,18 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
}
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
public static Document New(string libTitle, byte[] docContent, string docAscii, string config, byte[] docPdf)
|
|
|
|
|
public static Document New(string libTitle, byte[] docContent, string docAscii, string config)
|
|
|
|
|
{
|
|
|
|
|
Document tmp = Document.New();
|
|
|
|
|
tmp.LibTitle = libTitle;
|
|
|
|
|
tmp.DocContent = docContent;
|
|
|
|
|
tmp.DocAscii = docAscii;
|
|
|
|
|
tmp.Config = config;
|
|
|
|
|
tmp.DocPdf = docPdf;
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config, byte[] docPdf)
|
|
|
|
|
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config)
|
|
|
|
|
{
|
|
|
|
|
Document tmp = Document.New(libTitle, docContent, docAscii, config, docPdf);
|
|
|
|
|
Document tmp = Document.New(libTitle, docContent, docAscii, config);
|
|
|
|
|
if (tmp.IsSavable)
|
|
|
|
|
{
|
|
|
|
|
Document tmp2 = tmp;
|
|
|
|
@@ -777,9 +805,9 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
_UserID = dr.GetString("UserID");
|
|
|
|
|
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
|
|
|
|
_FileExtension = dr.GetString("FileExtension");
|
|
|
|
|
_DocPdf = (byte[])dr.GetValue("DocPdf");
|
|
|
|
|
_DocumentDROUsageCount = dr.GetInt32("DROUsageCount");
|
|
|
|
|
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
|
|
|
|
_DocumentPdfCount = dr.GetInt32("PdfCount");
|
|
|
|
|
MarkOld();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@@ -816,6 +844,9 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
// load child objects
|
|
|
|
|
dr.NextResult();
|
|
|
|
|
_DocumentEntries = DocumentEntries.Get(dr);
|
|
|
|
|
// load child objects
|
|
|
|
|
dr.NextResult();
|
|
|
|
|
_DocumentPdfs = DocumentPdfs.Get(dr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// removing of item only needed for local data portal
|
|
|
|
@@ -874,7 +905,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
|
|
|
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
|
|
|
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
|
|
|
|
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
|
|
|
|
// Output Calculated Columns
|
|
|
|
|
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
|
|
|
|
param_DocID.Direction = ParameterDirection.Output;
|
|
|
|
@@ -892,6 +922,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
// update child objects
|
|
|
|
|
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
|
|
|
|
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
|
|
|
|
if (_DocumentPdfs != null) _DocumentPdfs.Update(this);
|
|
|
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.SQLInsert", GetHashCode());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@@ -902,7 +933,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[Transactional(TransactionalTypes.TransactionScope)]
|
|
|
|
|
public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension, byte[] docPdf)
|
|
|
|
|
public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension)
|
|
|
|
|
{
|
|
|
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Add", 0);
|
|
|
|
|
try
|
|
|
|
@@ -919,7 +950,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
|
|
|
|
cm.Parameters.AddWithValue("@UserID", userID);
|
|
|
|
|
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
|
|
|
|
cm.Parameters.AddWithValue("@DocPdf", docPdf);
|
|
|
|
|
// Output Calculated Columns
|
|
|
|
|
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
|
|
|
|
param_DocID.Direction = ParameterDirection.Output;
|
|
|
|
@@ -987,7 +1017,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
|
|
|
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
|
|
|
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
|
|
|
|
cm.Parameters.AddWithValue("@DocPdf", _DocPdf);
|
|
|
|
|
// Output Calculated Columns
|
|
|
|
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
|
|
|
|
param_LastChanged.Direction = ParameterDirection.Output;
|
|
|
|
@@ -1002,6 +1031,7 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
// use the open connection to update child objects
|
|
|
|
|
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
|
|
|
|
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
|
|
|
|
if (_DocumentPdfs != null) _DocumentPdfs.Update(this);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
@@ -1017,16 +1047,17 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
{
|
|
|
|
|
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
|
|
|
|
if (IsNew)
|
|
|
|
|
_LastChanged = Document.Add(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension, _DocPdf);
|
|
|
|
|
_LastChanged = Document.Add(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension);
|
|
|
|
|
else
|
|
|
|
|
_LastChanged = Document.Update(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, ref _LastChanged, _FileExtension, _DocPdf);
|
|
|
|
|
_LastChanged = Document.Update(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, ref _LastChanged, _FileExtension);
|
|
|
|
|
MarkOld();
|
|
|
|
|
}
|
|
|
|
|
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
|
|
|
|
if (_DocumentDROUsages != null) _DocumentDROUsages.Update(this);
|
|
|
|
|
if (_DocumentPdfs != null) _DocumentPdfs.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)
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Update", 0);
|
|
|
|
|
try
|
|
|
|
@@ -1045,7 +1076,6 @@ namespace VEPROMS.CSLA.Library
|
|
|
|
|
cm.Parameters.AddWithValue("@UserID", userID);
|
|
|
|
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
|
|
|
|
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
|
|
|
|
cm.Parameters.AddWithValue("@DocPdf", docPdf);
|
|
|
|
|
// Output Calculated Columns
|
|
|
|
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
|
|
|
|
param_LastChanged.Direction = ParameterDirection.Output;
|
|
|
|
|