86 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Text;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using Csla;
 | |
| using Csla.Data;
 | |
| 
 | |
| namespace VEPROMS.CSLA.Library
 | |
| {
 | |
| 	public partial class ROImageInfo
 | |
| 	{
 | |
| 		public static ROImageInfo GetByROFstID_FileName(int rOFstID, string fileName)
 | |
| 		{
 | |
| 			//if (!CanGetObject())
 | |
| 			//    throw new System.Security.SecurityException("User not authorized to view a ROImage");
 | |
| 			try
 | |
| 			{
 | |
| 				ROImageInfo tmp = DataPortal.Fetch<ROImageInfo>(new ROFstID_FileNameCriteria(rOFstID, fileName));
 | |
| 				if (tmp.ErrorMessage == "No Record Found")
 | |
| 				{
 | |
| 					tmp.Dispose(); // Clean-up ROImage
 | |
| 					tmp = null;
 | |
| 				}
 | |
| 				return tmp;
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				throw new DbCslaException("Error on ROImage.GetByROFstID_FileName", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		private void DataPortal_Fetch(ROFstID_FileNameCriteria criteria)
 | |
| 		{
 | |
| 			if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROImageInfo.DataPortal_Fetch", GetHashCode());
 | |
| 			try
 | |
| 			{
 | |
| 				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | |
| 				{
 | |
| 					ApplicationContext.LocalContext["cn"] = cn;
 | |
| 					using (SqlCommand cm = cn.CreateCommand())
 | |
| 					{
 | |
| 						cm.CommandType = CommandType.StoredProcedure;
 | |
| 						cm.CommandText = "getROImageByROFstID_FileName";
 | |
| 						cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
 | |
| 						cm.Parameters.AddWithValue("@FileName", criteria.FileName);
 | |
| 						using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
 | |
| 						{
 | |
| 							if (!dr.Read())
 | |
| 							{
 | |
| 								_ErrorMessage = "No Record Found";
 | |
| 								return;
 | |
| 							}
 | |
| 							ReadData(dr);
 | |
| 						}
 | |
| 					}
 | |
| 					// removing of item only needed for local data portal
 | |
| 					if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
 | |
| 						ApplicationContext.LocalContext.Remove("cn");
 | |
| 				}
 | |
| 			}
 | |
| 			catch (Exception ex)
 | |
| 			{
 | |
| 				if (_MyLog.IsErrorEnabled) _MyLog.Error("ROImageInfo.DataPortal_Fetch", ex);
 | |
| 				_ErrorMessage = ex.Message;
 | |
| 				throw new DbCslaException("ROImageInfo.DataPortal_Fetch", ex);
 | |
| 			}
 | |
| 		}
 | |
| 		[Serializable()]
 | |
| 		private class ROFstID_FileNameCriteria
 | |
| 		{
 | |
| 			private int _ROFstID;
 | |
| 
 | |
| 			public int ROFstID
 | |
| 			{ get { return _ROFstID; } }
 | |
| 			private string _FileName;
 | |
| 			public string FileName
 | |
| 			{ get { return _FileName; } }
 | |
| 			public ROFstID_FileNameCriteria(int rOFstID, string fileName)
 | |
| 			{
 | |
| 				_ROFstID = rOFstID;
 | |
| 				_FileName = fileName;
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 |