Added Class to support Purge of Disconnected Data

Allow Display of the SQL Code Revision
This commit is contained in:
Rich
2016-02-26 16:09:50 +00:00
parent e0c4f8b1f4
commit c2649727e1
2 changed files with 101 additions and 18 deletions

View File

@@ -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