Use new generic property (ActiveDatabase) to access the current database name. About Screen

Use new generic property (ActiveDatabase) to access the current database name.  Name of Export File
Use new generic property (ActiveDatabase) to access the current database name.  Name of Error Log FIle.
Added new generic property (ActiveDatabase) to access the current database name.
This commit is contained in:
Rich 2014-09-03 19:37:24 +00:00
parent ca30984031
commit 3a7667d9b7
4 changed files with 16 additions and 5 deletions

View File

@ -29,7 +29,7 @@ namespace VEPROMS
Match mServer = Regex.Match(connectionString,".*Data Source=([^;]*).*"); Match mServer = Regex.Match(connectionString,".*Data Source=([^;]*).*");
string server = (mServer.Success)?mServer.Groups[1].Value:"unknown"; string server = (mServer.Success)?mServer.Groups[1].Value:"unknown";
if (server.StartsWith(@".\")) server = @"Local \ " + server.Substring(2); if (server.StartsWith(@".\")) server = @"Local \ " + server.Substring(2);
string databaseName = Database.SelectedDatabase; string databaseName = Database.ActiveDatabase;
this.Text = String.Format("About {0}", AssemblyTitle + " " + demoTxt); this.Text = String.Format("About {0}", AssemblyTitle + " " + demoTxt);
this.labelProductName.Text = AssemblyProduct; this.labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
@ -40,7 +40,7 @@ namespace VEPROMS
this.labelCompanyName.Links[0].LinkData = "Volian Enterprises Inc."; this.labelCompanyName.Links[0].LinkData = "Volian Enterprises Inc.";
this.labelCompanyName.Links.Add(0,23,"www.volian.com"); this.labelCompanyName.Links.Add(0,23,"www.volian.com");
this.labelServer.Text = string.Format("SQL Server: {0}", server); this.labelServer.Text = string.Format("SQL Server: {0}", server);
if (databaseName == null) databaseName = Regex.Replace(connectionString, "^.*Initial Catalog=([^;]*);.*$", "$1", RegexOptions.IgnoreCase); //if (databaseName == null) databaseName = Regex.Replace(connectionString, "^.*Initial Catalog=([^;]*);.*$", "$1", RegexOptions.IgnoreCase);
this.labelDatabase.Text = string.Format("Database: {0}", databaseName); this.labelDatabase.Text = string.Format("Database: {0}", databaseName);
} }

View File

@ -94,7 +94,7 @@ namespace VEPROMS
{ {
//Database.SelectedDatabase //Database.SelectedDatabase
//sfd.FileName = string.Format("{0}.expx", MyFolder.Name); //sfd.FileName = string.Format("{0}.expx", MyFolder.Name);
sfd.FileName = string.Format("{0}-{1}.expx",Database.SelectedDatabase, MyFolder.Name); sfd.FileName = string.Format("{0}-{1}.expx",Database.ActiveDatabase, MyFolder.Name);
if (sfd.ShowDialog(this) == DialogResult.OK) if (sfd.ShowDialog(this) == DialogResult.OK)
{ {
if (sfd.FileName != string.Empty) if (sfd.FileName != string.Empty)

View File

@ -224,7 +224,7 @@ namespace VEPROMS
} }
displayBookMarks.SetupBookMarks(); displayBookMarks.SetupBookMarks();
DateTime dtSunday = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek)); DateTime dtSunday = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek));
ChangeLogFileName("LogFileAppender", Database.SelectedDatabase + " " + dtSunday.ToString("yyyyMMdd") + " ErrorLog.txt"); ChangeLogFileName("LogFileAppender", Database.ActiveDatabase + " " + dtSunday.ToString("yyyyMMdd") + " ErrorLog.txt");
_MyLog.InfoFormat("\r\nSession Beginning\r\n<========={0}=========== User: {1}/{2} Started {3} =====================>" _MyLog.InfoFormat("\r\nSession Beginning\r\n<========={0}=========== User: {1}/{2} Started {3} =====================>"
, Application.ProductVersion, Environment.UserDomainName,Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt")); , Application.ProductVersion, Environment.UserDomainName,Environment.UserName, DateTime.Now.ToString("dddd MMMM d, yyyy h:mm:ss tt"));
foreach (string parameter in parameters) foreach (string parameter in parameters)
@ -863,7 +863,7 @@ namespace VEPROMS
System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(this.PingSession); System.Threading.TimerCallback timerDelegate = new System.Threading.TimerCallback(this.PingSession);
if (!System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost")) if (!System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost"))
MyActivityTimer = new System.Threading.Timer(timerDelegate, autoEvent, 10000, 10000); MyActivityTimer = new System.Threading.Timer(timerDelegate, autoEvent, 10000, 10000);
//string debugMode = ConfigurationManager.AppSettings["Debug"]; //string debugMode = ConfigurationManager.AppSettings["Debug"];
//VlnSettings.DebugMode = bool.Parse(debugMode); // set debug for the Volian.Controls.Library //VlnSettings.DebugMode = bool.Parse(debugMode); // set debug for the Volian.Controls.Library

View File

@ -18,6 +18,7 @@ using System.IO;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
@ -136,6 +137,16 @@ namespace VEPROMS.CSLA.Library
get { return Database._SelectedDatabase; } get { return Database._SelectedDatabase; }
set { Database._SelectedDatabase = value; } set { Database._SelectedDatabase = value; }
} }
public static string ActiveDatabase
{
get
{
string activeDatabase = SelectedDatabase;
if(activeDatabase == null)
activeDatabase = Regex.Replace(VEPROMS_Connection, "^.*Initial Catalog=([^;]*);.*$", "$1", RegexOptions.IgnoreCase);
return activeDatabase;
}
}
private static string _LastDatabase="NoDefault"; private static string _LastDatabase="NoDefault";
public static string LastDatabase public static string LastDatabase
{ {