Add implementation code for Get Database Users and updated other adminstrative tools to standardize naming of functions

Standardized naming of adminsitrative tools implementing code functions
This commit is contained in:
Jim
2015-04-14 01:35:29 +00:00
parent ac85235031
commit 5282ef114d
3 changed files with 129 additions and 14 deletions

View File

@@ -9,7 +9,7 @@ using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
public class ExecuteStoredProcedureRowsAffected : CommandBase
public class ESP_DeletePDFs : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
@@ -27,9 +27,9 @@ namespace VEPROMS.CSLA.Library
}
public static int Execute(string storedProcedure)
{
ExecuteStoredProcedureRowsAffected cmd = new ExecuteStoredProcedureRowsAffected();
ESP_DeletePDFs cmd = new ESP_DeletePDFs();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ExecuteStoredProcedureRowsAffected>(cmd);
DataPortal.Execute<ESP_DeletePDFs>(cmd);
return cmd.AffectedRows;
}
#endregion
@@ -56,7 +56,7 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
public class ExecuteStoredProcedureRowCount : CommandBase
public class ESP_IdentifyDisconnectedItems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
@@ -74,9 +74,9 @@ namespace VEPROMS.CSLA.Library
}
public static int Execute(string storedProcedure)
{
ExecuteStoredProcedureRowCount cmd = new ExecuteStoredProcedureRowCount();
ESP_IdentifyDisconnectedItems cmd = new ESP_IdentifyDisconnectedItems();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ExecuteStoredProcedureRowCount>(cmd);
DataPortal.Execute<ESP_IdentifyDisconnectedItems>(cmd);
return cmd.RowCount;
}
#endregion
@@ -107,7 +107,7 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
public class ExecuteStoredProcedureItemInfoList : CommandBase
public class ESP_IdentifyNonEditableItems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
@@ -125,9 +125,9 @@ namespace VEPROMS.CSLA.Library
}
public static List<ItemInfo> Execute(string storedProcedure)
{
ExecuteStoredProcedureItemInfoList cmd = new ExecuteStoredProcedureItemInfoList();
ESP_IdentifyNonEditableItems cmd = new ESP_IdentifyNonEditableItems();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ExecuteStoredProcedureItemInfoList>(cmd);
DataPortal.Execute<ESP_IdentifyNonEditableItems>(cmd);
return cmd.ItemInfoList;
}
#endregion
@@ -157,4 +157,98 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
public class ESP_GetDatabaseSessions : 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 string _ResultsString;
public string ResultsString
{
get { return _ResultsString; }
set { _ResultsString = value; }
}
public static string Execute(string storedProcedure)
{
ESP_GetDatabaseSessions cmd = new ESP_GetDatabaseSessions();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_GetDatabaseSessions>(cmd);
return cmd.ResultsString;
}
#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();
StringBuilder sbs = new StringBuilder();
int sessionid = 0;
string ownertypename = string.Empty;
while (dr.Read())
{
if (dr.GetInt32(0) != sessionid)
{
if (sessionid != 0)
sbs.AppendLine();
sessionid = dr.GetInt32(0);
ownertypename = string.Empty;
sbs.AppendLine(string.Format("The User {0} on computer {1} has an {2} session.", dr.GetString(1), dr.GetString(2), dr.GetString(5)));
if (dr.GetInt32(4) == 0)
{
sbs.AppendLine(string.Format("This user has {0} checked out", dr.GetString(3)));
}
else
{
sbs.AppendLine(string.Format("This user has {0} {1}(s) checked out...", dr.GetInt32(4), dr.GetString(3)));
sbs.AppendLine(string.Format("{0} -> {1} -> {2} -> {3} checked out at {4}", dr.GetString(6), dr.GetString(7), dr.GetString(8), dr.GetString(9), dr.GetDateTime(10)));
ownertypename = dr.GetString(3);
}
}
else
{
if (dr.GetInt32(4) > 0)
{
if (dr.GetString(3) != ownertypename)
{
sbs.AppendLine(string.Format("This user has {0} {1}(s) checked out...", dr.GetInt32(4), dr.GetString(3)));
sbs.AppendLine(string.Format("{0} -> {1} -> {2} -> {3} checked out at {4}", dr.GetString(6), dr.GetString(7), dr.GetString(8), dr.GetString(9), dr.GetDateTime(10)));
ownertypename = dr.GetString(3);
}
else
sbs.AppendLine(string.Format("{0} -> {1} -> {2} -> {3} checked out at {4}", dr.GetString(6), dr.GetString(7), dr.GetString(8), dr.GetString(9), dr.GetDateTime(10)));
}
}
}
_ResultsString = sbs.ToString();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ExecuteStoredProcedureString Error", ex);
throw new ApplicationException("Failure on ExecuteStoredProcedureString", ex);
}
}
#endregion
}
public class ESP_FindROProblems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
#endregion
#region Server-Side Code
#endregion
}
}