Added Class to support Purge of Disconnected Data
Allow Display of the SQL Code Revision
This commit is contained in:
		@@ -107,6 +107,54 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
		}
 | 
			
		||||
		#endregion
 | 
			
		||||
	}
 | 
			
		||||
	public class ESP_PurgeDisconnectedItems : CommandBase
 | 
			
		||||
	{
 | 
			
		||||
		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | 
			
		||||
		#region Factory Methods
 | 
			
		||||
		private string _StoredProcedure;
 | 
			
		||||
		public string StoredProcedure
 | 
			
		||||
		{
 | 
			
		||||
			get { return _StoredProcedure; }
 | 
			
		||||
			set { _StoredProcedure = value; }
 | 
			
		||||
		}
 | 
			
		||||
		private int _RowCount;
 | 
			
		||||
		public int RowCount
 | 
			
		||||
		{
 | 
			
		||||
			get { return _RowCount; }
 | 
			
		||||
			set { _RowCount = value; }
 | 
			
		||||
		}
 | 
			
		||||
		public static int Execute(string storedProcedure)
 | 
			
		||||
		{
 | 
			
		||||
			ESP_PurgeDisconnectedItems cmd = new ESP_PurgeDisconnectedItems();
 | 
			
		||||
			cmd.StoredProcedure = storedProcedure;
 | 
			
		||||
			DataPortal.Execute<ESP_PurgeDisconnectedItems>(cmd);
 | 
			
		||||
			return cmd.RowCount;
 | 
			
		||||
		}
 | 
			
		||||
		#endregion
 | 
			
		||||
		#region Server-Side code
 | 
			
		||||
		protected override void DataPortal_Execute()
 | 
			
		||||
		{
 | 
			
		||||
			try
 | 
			
		||||
			{
 | 
			
		||||
				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
			
		||||
				{
 | 
			
		||||
					using (SqlCommand cmd = new SqlCommand(StoredProcedure, cn))
 | 
			
		||||
					{
 | 
			
		||||
						cmd.CommandType = CommandType.StoredProcedure;
 | 
			
		||||
						cmd.CommandTimeout = 0;
 | 
			
		||||
						SqlDataReader dr = cmd.ExecuteReader();
 | 
			
		||||
							RowCount = dr.RecordsAffected;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception ex)
 | 
			
		||||
			{
 | 
			
		||||
				if (_MyLog.IsErrorEnabled) _MyLog.Error("ExecuteStoredProcedureRowCount Error", ex);
 | 
			
		||||
				throw new ApplicationException("Failure on ExecuteStoredProcedureRowCount", ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		#endregion
 | 
			
		||||
	}
 | 
			
		||||
	public class ESP_IdentifyNonEditableItems : CommandBase
 | 
			
		||||
	{
 | 
			
		||||
		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | 
			
		||||
 
 | 
			
		||||
@@ -33,35 +33,70 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
		private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 | 
			
		||||
		#endregion
 | 
			
		||||
		private static string _DBServer = null;
 | 
			
		||||
		public static string DBServer
 | 
			
		||||
		{ 
 | 
			
		||||
			get
 | 
			
		||||
		private static DateTime _RevDate=DateTime.MinValue;
 | 
			
		||||
 | 
			
		||||
public static DateTime RevDate
 | 
			
		||||
{
 | 
			
		||||
  get { return Database._RevDate; }
 | 
			
		||||
  set { Database._RevDate = value; }
 | 
			
		||||
}
 | 
			
		||||
		private static string _RevDescription= "Unknown";
 | 
			
		||||
 | 
			
		||||
public static string RevDescription
 | 
			
		||||
{
 | 
			
		||||
  get { return Database._RevDescription; }
 | 
			
		||||
  set { Database._RevDescription = value; }
 | 
			
		||||
}
 | 
			
		||||
public static string DBServer
 | 
			
		||||
{
 | 
			
		||||
	get
 | 
			
		||||
	{
 | 
			
		||||
		if (_DBServer == null)
 | 
			
		||||
		{
 | 
			
		||||
			string cnstr = null;
 | 
			
		||||
			try
 | 
			
		||||
			{
 | 
			
		||||
				if (_DBServer == null)
 | 
			
		||||
				using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
			
		||||
				{
 | 
			
		||||
					string cnstr = null;
 | 
			
		||||
					cnstr = cn.ConnectionString;
 | 
			
		||||
					try
 | 
			
		||||
					{
 | 
			
		||||
						using (SqlConnection cn = Database.VEPROMS_SqlConnection)
 | 
			
		||||
							cnstr = cn.ConnectionString;
 | 
			
		||||
						string server = "";
 | 
			
		||||
						string db = "";
 | 
			
		||||
						Match m = Regex.Match(cnstr, "Data Source=([^;]+)(;[^;]+)*;*Initial Catalog=([^;]+)(;[^;]+)*");
 | 
			
		||||
						if (m.Success && m.Groups.Count > 4)
 | 
			
		||||
						using (SqlCommand cmd = new SqlCommand("vesp_GetSQLCodeRevision", cn))
 | 
			
		||||
						{
 | 
			
		||||
							server = m.Groups[1].Value;
 | 
			
		||||
							db = m.Groups[3].Value;
 | 
			
		||||
							cmd.CommandType = CommandType.StoredProcedure;
 | 
			
		||||
							cmd.CommandTimeout = 0;
 | 
			
		||||
							SqlDataReader dr = cmd.ExecuteReader();
 | 
			
		||||
							while (dr.Read())
 | 
			
		||||
							{
 | 
			
		||||
								_RevDate = dr.GetDateTime(0);
 | 
			
		||||
								_RevDescription = dr.GetString(1);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
						_DBServer = string.Format("{0} - {1}", server, db);
 | 
			
		||||
					}
 | 
			
		||||
					catch (Exception)
 | 
			
		||||
					catch (Exception ex)
 | 
			
		||||
					{
 | 
			
		||||
						_DBServer = cnstr;
 | 
			
		||||
						_RevDate = DateTime.MinValue;
 | 
			
		||||
						_RevDescription = "Unknown";
 | 
			
		||||
					}
 | 
			
		||||
					string server = "";
 | 
			
		||||
					string db = "";
 | 
			
		||||
					Match m = Regex.Match(cnstr, "Data Source=([^;]+)(;[^;]+)*;*Initial Catalog=([^;]+)(;[^;]+)*");
 | 
			
		||||
					if (m.Success && m.Groups.Count > 4)
 | 
			
		||||
					{
 | 
			
		||||
						server = m.Groups[1].Value;
 | 
			
		||||
						db = m.Groups[3].Value;
 | 
			
		||||
					}
 | 
			
		||||
					_DBServer = string.Format("{0} - {1} [SQL:{2:yyMM.ddHH}]", server, db, RevDate);
 | 
			
		||||
				}
 | 
			
		||||
			return _DBServer;
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception)
 | 
			
		||||
			{
 | 
			
		||||
				_DBServer = cnstr;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return _DBServer;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		private static int _DefaultTimeout = 600;    // 600 seconds, i.e. 10 minutes
 | 
			
		||||
 | 
			
		||||
		public static int DefaultTimeout
 | 
			
		||||
@@ -680,6 +715,6 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			_FromStep = fromStep;
 | 
			
		||||
			_ToStep = toStep;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	#endregion
 | 
			
		||||
	}
 | 
			
		||||
} // Namespace
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user