Added FileExtension Field
This commit is contained in:
		@@ -250,6 +250,27 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		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;
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// Count of DocumentEntries for this Document
 | 
			
		||||
@@ -361,6 +382,11 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			ValidationRules.AddRule(
 | 
			
		||||
				Csla.Validation.CommonRules.StringMaxLength,
 | 
			
		||||
				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");
 | 
			
		||||
			_DocumentExtension.AddValidationRules(ValidationRules);
 | 
			
		||||
			// TODO:  Add other validation rules
 | 
			
		||||
@@ -393,12 +419,14 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			//AuthorizationRules.AllowRead(Config, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowRead(FileExtension, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
 | 
			
		||||
			//AuthorizationRules.AllowWrite(FileExtension, "<Role(s)>");
 | 
			
		||||
			_DocumentExtension.AddAuthorizationRules(AuthorizationRules);
 | 
			
		||||
		}
 | 
			
		||||
		protected override void AddInstanceAuthorizationRules()
 | 
			
		||||
@@ -487,7 +515,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)
 | 
			
		||||
		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;
 | 
			
		||||
@@ -496,11 +524,12 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			tmp.Config = config;
 | 
			
		||||
			tmp.DTS = dts;
 | 
			
		||||
			tmp.UserID = userID;
 | 
			
		||||
			tmp.FileExtension = fileExtension;
 | 
			
		||||
			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)
 | 
			
		||||
			{
 | 
			
		||||
				Document tmp2 = tmp;
 | 
			
		||||
@@ -636,6 +665,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			// Database Defaults
 | 
			
		||||
			_DTS = _DocumentExtension.DefaultDTS;
 | 
			
		||||
			_UserID = _DocumentExtension.DefaultUserID;
 | 
			
		||||
			_FileExtension = _DocumentExtension.DefaultFileExtension;
 | 
			
		||||
			// TODO: Add any defaults that are necessary
 | 
			
		||||
			ValidationRules.CheckRules();
 | 
			
		||||
		}
 | 
			
		||||
@@ -652,6 +682,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				_DTS = dr.GetDateTime("DTS");
 | 
			
		||||
				_UserID = dr.GetString("UserID");
 | 
			
		||||
				dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
 | 
			
		||||
				_FileExtension = dr.GetString("FileExtension");
 | 
			
		||||
				_DocumentEntryCount = dr.GetInt32("EntryCount");
 | 
			
		||||
				MarkOld();
 | 
			
		||||
			}
 | 
			
		||||
@@ -743,6 +774,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
					cm.Parameters.AddWithValue("@Config", _Config);
 | 
			
		||||
					if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
 | 
			
		||||
					cm.Parameters.AddWithValue("@UserID", _UserID);
 | 
			
		||||
					cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
 | 
			
		||||
					// Output Calculated Columns
 | 
			
		||||
					SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
 | 
			
		||||
					param_DocID.Direction = ParameterDirection.Output;
 | 
			
		||||
@@ -769,7 +801,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)
 | 
			
		||||
		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
 | 
			
		||||
@@ -785,6 +817,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
					cm.Parameters.AddWithValue("@Config", config);
 | 
			
		||||
					if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
 | 
			
		||||
					cm.Parameters.AddWithValue("@UserID", userID);
 | 
			
		||||
					cm.Parameters.AddWithValue("@FileExtension", fileExtension);
 | 
			
		||||
					// Output Calculated Columns
 | 
			
		||||
					SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int);
 | 
			
		||||
					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);
 | 
			
		||||
						cm.Parameters.AddWithValue("@UserID", _UserID);
 | 
			
		||||
						cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
 | 
			
		||||
						cm.Parameters.AddWithValue("@FileExtension", _FileExtension);
 | 
			
		||||
						// Output Calculated Columns
 | 
			
		||||
						SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
 | 
			
		||||
						param_LastChanged.Direction = ParameterDirection.Output;
 | 
			
		||||
@@ -879,15 +913,15 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			{
 | 
			
		||||
				SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
 | 
			
		||||
				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
 | 
			
		||||
					_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();
 | 
			
		||||
			}
 | 
			
		||||
			if (_DocumentEntries != null) _DocumentEntries.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)
 | 
			
		||||
		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
 | 
			
		||||
@@ -905,6 +939,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
					if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
 | 
			
		||||
					cm.Parameters.AddWithValue("@UserID", userID);
 | 
			
		||||
					cm.Parameters.AddWithValue("@LastChanged", lastChanged);
 | 
			
		||||
					cm.Parameters.AddWithValue("@FileExtension", fileExtension);
 | 
			
		||||
					// Output Calculated Columns
 | 
			
		||||
					SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
 | 
			
		||||
					param_LastChanged.Direction = ParameterDirection.Output;
 | 
			
		||||
@@ -1045,6 +1080,10 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			{
 | 
			
		||||
				get { return Environment.UserName.ToUpper(); }
 | 
			
		||||
			}
 | 
			
		||||
			public virtual string DefaultFileExtension
 | 
			
		||||
			{
 | 
			
		||||
				get { return ".Doc"; }
 | 
			
		||||
			}
 | 
			
		||||
			// Authorization Rules
 | 
			
		||||
			public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | 
			
		||||
			{
 | 
			
		||||
@@ -1106,6 +1145,10 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
//      {
 | 
			
		||||
//        get { return Environment.UserName.ToUpper(); }
 | 
			
		||||
//      }
 | 
			
		||||
//      public virtual string DefaultFileExtension
 | 
			
		||||
//      {
 | 
			
		||||
//        get { return ".Doc"; }
 | 
			
		||||
//      }
 | 
			
		||||
//      public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
 | 
			
		||||
//      {
 | 
			
		||||
//        //rules.AllowRead(Dbid, "<Role(s)>");
 | 
			
		||||
 
 | 
			
		||||
@@ -167,6 +167,16 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				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;
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// Count of DocumentEntries for this Document
 | 
			
		||||
@@ -264,6 +274,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			_Config = tmp.Config;
 | 
			
		||||
			_DTS = tmp.DTS;
 | 
			
		||||
			_UserID = tmp.UserID;
 | 
			
		||||
			_FileExtension = tmp.FileExtension;
 | 
			
		||||
			_DocumentInfoExtension.Refresh(this);
 | 
			
		||||
			OnChange();// raise an event
 | 
			
		||||
		}
 | 
			
		||||
@@ -329,6 +340,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				_Config = dr.GetString("Config");
 | 
			
		||||
				_DTS = dr.GetDateTime("DTS");
 | 
			
		||||
				_UserID = dr.GetString("UserID");
 | 
			
		||||
				_FileExtension = dr.GetString("FileExtension");
 | 
			
		||||
				_DocumentEntryCount = dr.GetInt32("EntryCount");
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user