Added FileExtension Field
This commit is contained in:
parent
c09a44a14f
commit
82c30dfe7f
@ -250,6 +250,27 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private byte[] _LastChanged = new byte[8];//timestamp
|
private byte[] _LastChanged = new byte[8];//timestamp
|
||||||
|
private string _FileExtension = string.Empty;
|
||||||
|
public string FileExtension
|
||||||
|
{
|
||||||
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
CanReadProperty("FileExtension", true);
|
||||||
|
return _FileExtension;
|
||||||
|
}
|
||||||
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||||
|
set
|
||||||
|
{
|
||||||
|
CanWriteProperty("FileExtension", true);
|
||||||
|
if (value == null) value = string.Empty;
|
||||||
|
if (_FileExtension != value)
|
||||||
|
{
|
||||||
|
_FileExtension = value;
|
||||||
|
PropertyHasChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private int _DocumentEntryCount = 0;
|
private int _DocumentEntryCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of DocumentEntries for this Document
|
/// Count of DocumentEntries for this Document
|
||||||
@ -361,6 +382,11 @@ namespace VEPROMS.CSLA.Library
|
|||||||
ValidationRules.AddRule(
|
ValidationRules.AddRule(
|
||||||
Csla.Validation.CommonRules.StringMaxLength,
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
|
||||||
|
ValidationRules.AddRule(
|
||||||
|
Csla.Validation.CommonRules.StringRequired, "FileExtension");
|
||||||
|
ValidationRules.AddRule(
|
||||||
|
Csla.Validation.CommonRules.StringMaxLength,
|
||||||
|
new Csla.Validation.CommonRules.MaxLengthRuleArgs("FileExtension", 10));
|
||||||
//ValidationRules.AddDependantProperty("x", "y");
|
//ValidationRules.AddDependantProperty("x", "y");
|
||||||
_DocumentExtension.AddValidationRules(ValidationRules);
|
_DocumentExtension.AddValidationRules(ValidationRules);
|
||||||
// TODO: Add other validation rules
|
// TODO: Add other validation rules
|
||||||
@ -393,12 +419,14 @@ namespace VEPROMS.CSLA.Library
|
|||||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||||
|
//AuthorizationRules.AllowRead(FileExtension, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
|
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
|
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
|
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||||
|
//AuthorizationRules.AllowWrite(FileExtension, "<Role(s)>");
|
||||||
_DocumentExtension.AddAuthorizationRules(AuthorizationRules);
|
_DocumentExtension.AddAuthorizationRules(AuthorizationRules);
|
||||||
}
|
}
|
||||||
protected override void AddInstanceAuthorizationRules()
|
protected override void AddInstanceAuthorizationRules()
|
||||||
@ -487,7 +515,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
throw new DbCslaException("Error on Document.New", ex);
|
throw new DbCslaException("Error on Document.New", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static Document New(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID)
|
public static Document New(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, string fileExtension)
|
||||||
{
|
{
|
||||||
Document tmp = Document.New();
|
Document tmp = Document.New();
|
||||||
tmp.LibTitle = libTitle;
|
tmp.LibTitle = libTitle;
|
||||||
@ -496,11 +524,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
tmp.Config = config;
|
tmp.Config = config;
|
||||||
tmp.DTS = dts;
|
tmp.DTS = dts;
|
||||||
tmp.UserID = userID;
|
tmp.UserID = userID;
|
||||||
|
tmp.FileExtension = fileExtension;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID)
|
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);
|
Document tmp = Document.New(libTitle, docContent, docAscii, config, dts, userID, fileExtension);
|
||||||
if (tmp.IsSavable)
|
if (tmp.IsSavable)
|
||||||
{
|
{
|
||||||
Document tmp2 = tmp;
|
Document tmp2 = tmp;
|
||||||
@ -636,6 +665,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// Database Defaults
|
// Database Defaults
|
||||||
_DTS = _DocumentExtension.DefaultDTS;
|
_DTS = _DocumentExtension.DefaultDTS;
|
||||||
_UserID = _DocumentExtension.DefaultUserID;
|
_UserID = _DocumentExtension.DefaultUserID;
|
||||||
|
_FileExtension = _DocumentExtension.DefaultFileExtension;
|
||||||
// TODO: Add any defaults that are necessary
|
// TODO: Add any defaults that are necessary
|
||||||
ValidationRules.CheckRules();
|
ValidationRules.CheckRules();
|
||||||
}
|
}
|
||||||
@ -652,6 +682,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_DTS = dr.GetDateTime("DTS");
|
_DTS = dr.GetDateTime("DTS");
|
||||||
_UserID = dr.GetString("UserID");
|
_UserID = dr.GetString("UserID");
|
||||||
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
||||||
|
_FileExtension = dr.GetString("FileExtension");
|
||||||
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
@ -743,6 +774,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@Config", _Config);
|
cm.Parameters.AddWithValue("@Config", _Config);
|
||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
||||||
param_DocID.Direction = ParameterDirection.Output;
|
param_DocID.Direction = ParameterDirection.Output;
|
||||||
@ -769,7 +801,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[Transactional(TransactionalTypes.TransactionScope)]
|
||||||
public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID)
|
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);
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Add", 0);
|
||||||
try
|
try
|
||||||
@ -785,6 +817,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
cm.Parameters.AddWithValue("@Config", config);
|
cm.Parameters.AddWithValue("@Config", config);
|
||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
|
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
|
||||||
param_DocID.Direction = ParameterDirection.Output;
|
param_DocID.Direction = ParameterDirection.Output;
|
||||||
@ -851,6 +884,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||||
|
cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
param_LastChanged.Direction = ParameterDirection.Output;
|
||||||
@ -879,15 +913,15 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||||
if (IsNew)
|
if (IsNew)
|
||||||
_LastChanged = Document.Add(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID);
|
_LastChanged = Document.Add(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, _FileExtension);
|
||||||
else
|
else
|
||||||
_LastChanged = Document.Update(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, ref _LastChanged);
|
_LastChanged = Document.Update(cn, ref _DocID, _LibTitle, _DocContent, _DocAscii, _Config, _DTS, _UserID, ref _LastChanged, _FileExtension);
|
||||||
MarkOld();
|
MarkOld();
|
||||||
}
|
}
|
||||||
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
if (_DocumentEntries != null) _DocumentEntries.Update(this);
|
||||||
}
|
}
|
||||||
[Transactional(TransactionalTypes.TransactionScope)]
|
[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)
|
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);
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Document.Update", 0);
|
||||||
try
|
try
|
||||||
@ -905,6 +939,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||||
cm.Parameters.AddWithValue("@UserID", userID);
|
cm.Parameters.AddWithValue("@UserID", userID);
|
||||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||||
|
cm.Parameters.AddWithValue("@FileExtension", fileExtension);
|
||||||
// Output Calculated Columns
|
// Output Calculated Columns
|
||||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||||
param_LastChanged.Direction = ParameterDirection.Output;
|
param_LastChanged.Direction = ParameterDirection.Output;
|
||||||
@ -1045,6 +1080,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
get { return Environment.UserName.ToUpper(); }
|
get { return Environment.UserName.ToUpper(); }
|
||||||
}
|
}
|
||||||
|
public virtual string DefaultFileExtension
|
||||||
|
{
|
||||||
|
get { return ".Doc"; }
|
||||||
|
}
|
||||||
// Authorization Rules
|
// Authorization Rules
|
||||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
{
|
{
|
||||||
@ -1106,6 +1145,10 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// {
|
// {
|
||||||
// get { return Environment.UserName.ToUpper(); }
|
// get { return Environment.UserName.ToUpper(); }
|
||||||
// }
|
// }
|
||||||
|
// public virtual string DefaultFileExtension
|
||||||
|
// {
|
||||||
|
// get { return ".Doc"; }
|
||||||
|
// }
|
||||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||||
// {
|
// {
|
||||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
// //rules.AllowRead(Dbid, "<Role(s)>");
|
||||||
|
@ -167,6 +167,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _UserID;
|
return _UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private string _FileExtension = string.Empty;
|
||||||
|
public string FileExtension
|
||||||
|
{
|
||||||
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||||
|
get
|
||||||
|
{
|
||||||
|
CanReadProperty("FileExtension", true);
|
||||||
|
return _FileExtension;
|
||||||
|
}
|
||||||
|
}
|
||||||
private int _DocumentEntryCount = 0;
|
private int _DocumentEntryCount = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Count of DocumentEntries for this Document
|
/// Count of DocumentEntries for this Document
|
||||||
@ -264,6 +274,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_Config = tmp.Config;
|
_Config = tmp.Config;
|
||||||
_DTS = tmp.DTS;
|
_DTS = tmp.DTS;
|
||||||
_UserID = tmp.UserID;
|
_UserID = tmp.UserID;
|
||||||
|
_FileExtension = tmp.FileExtension;
|
||||||
_DocumentInfoExtension.Refresh(this);
|
_DocumentInfoExtension.Refresh(this);
|
||||||
OnChange();// raise an event
|
OnChange();// raise an event
|
||||||
}
|
}
|
||||||
@ -329,6 +340,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_Config = dr.GetString("Config");
|
_Config = dr.GetString("Config");
|
||||||
_DTS = dr.GetDateTime("DTS");
|
_DTS = dr.GetDateTime("DTS");
|
||||||
_UserID = dr.GetString("UserID");
|
_UserID = dr.GetString("UserID");
|
||||||
|
_FileExtension = dr.GetString("FileExtension");
|
||||||
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
_DocumentEntryCount = dr.GetInt32("EntryCount");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user