diff --git a/PROMS/VEPROMS User Interface/frmBatchRefresh.Designer.cs b/PROMS/VEPROMS User Interface/frmBatchRefresh.Designer.cs index 91f33b1c..0af424b8 100644 --- a/PROMS/VEPROMS User Interface/frmBatchRefresh.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmBatchRefresh.Designer.cs @@ -345,7 +345,7 @@ namespace VEPROMS // // txtResults // - this.txtResults.AcceptsReturn = true; + //this.txtResults.AcceptsReturn = true; this.txtResults.Dock = System.Windows.Forms.DockStyle.Fill; this.txtResults.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txtResults.Location = new System.Drawing.Point(0, 52); diff --git a/PROMS/VEPROMS User Interface/frmBatchRefresh.cs b/PROMS/VEPROMS User Interface/frmBatchRefresh.cs index 01e1927f..d6149c2c 100644 --- a/PROMS/VEPROMS User Interface/frmBatchRefresh.cs +++ b/PROMS/VEPROMS User Interface/frmBatchRefresh.cs @@ -37,6 +37,7 @@ namespace VEPROMS adminToolsList.Add("Identify Disconnected Items", "Identify Disconnected Items Guidance", "Everything in PROMS is inter-related. A working draft knows what is its first procedure and a procedure knows what is its first step. Likewise, a procedure knows what procedure is before it and after it.\r\n\r\nOccasionally, an item will become disconnected and does not know where it fits into the relationships. This tool identifies whether the database has this condition.", "This tool may take an extended period of time to execute.", "NOTE:", true, true, "vesp_GetDisconnectedItemsCount", IdentifyDisconnectedItems); adminToolsList.Add("Identify Non-Editable Items", "Identify Non-Editable Items Guidance", "Typically, a section in PROMS only has sub-sections or sub-steps. There are times when a section has both. When this occurs, the sub-step data can be marked as non-editable. If this occurs, the user can no longer get to these steps and they can become forgotten.\r\n\r\nThis tool will identify if the database has non-editable steps and provide a listing of these steps.", "This tool may take an extended period of time to execute.", "NOTE:", true, true,"vesp_GetNonEditableItems", IdentifyNonEditableItems); adminToolsList.Add("Get Database Users", "Get Database Users Guidance", "This administrative tool will return all of the users currently with open sessions in the database and the details of any items they have checked out", "", "", true, true, "vesp_GetDatabaseSessions", GetDatabaseSessions); + //adminToolsList.Add("Find Referenced Object Problems", "Find Referenced Object Problems Guidance", "description for find ro problems", "", "", true, true, "vesp_FindROProblems", FindROProblems); adminToolsList.Sort(); cbxAdminTools.DataSource = adminToolsList; cbxAdminTools.DisplayMember = "Title"; @@ -389,7 +390,7 @@ namespace VEPROMS txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); Application.DoEvents(); - int affectedRows = ExecuteStoredProcedureRowsAffected.Execute(selectedAdminTool.StoredProcedure); + int affectedRows = ESP_DeletePDFs.Execute(selectedAdminTool.StoredProcedure); txtProcess.AppendText(string.Format("Deleted {0} PDFs", affectedRows)); txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); @@ -407,12 +408,13 @@ namespace VEPROMS txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); Application.DoEvents(); - int rowCount = ExecuteStoredProcedureRowCount.Execute(selectedAdminTool.StoredProcedure); + int rowCount = ESP_IdentifyDisconnectedItems.Execute(selectedAdminTool.StoredProcedure); txtProcess.AppendText(string.Format("Disconnected Items Count: {0}", rowCount)); txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); if (rowCount > 0) { + txtResults.Clear(); txtResults.AppendText(string.Format("The database contains {0} disconnected items.", rowCount)); txtResults.AppendText(Environment.NewLine); txtResults.AppendText(Environment.NewLine); @@ -432,12 +434,13 @@ namespace VEPROMS txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); Application.DoEvents(); - List myItems = ExecuteStoredProcedureItemInfoList.Execute(selectedAdminTool.StoredProcedure); + List myItems = ESP_IdentifyNonEditableItems.Execute(selectedAdminTool.StoredProcedure); txtProcess.AppendText(string.Format("Non-Editable Items Count: {0}",myItems.Count)); txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); if (myItems.Count > 0) { + txtResults.Clear(); txtResults.AppendText("The following items are non-editable..."); txtResults.AppendText(Environment.NewLine); txtResults.AppendText(Environment.NewLine); @@ -461,7 +464,24 @@ namespace VEPROMS txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine); Application.DoEvents(); - txtProcess.AppendText("In Progress"); + txtResults.Clear(); + txtResults.AppendText(ESP_GetDatabaseSessions.Execute(selectedAdminTool.StoredProcedure)); + DateTime pEnd = DateTime.Now; + txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm")); + Application.DoEvents(); + this.Cursor = Cursors.Default; + MessageBox.Show(string.Format("{0} Completed", selectedAdminTool.Title), string.Format("{0} Complete", selectedAdminTool.Title)); + } + private void FindROProblems() + { + this.Cursor = Cursors.WaitCursor; + DateTime pStart = DateTime.Now; + txtProcess.AppendText(pStart.ToString("MM/dd/yyyy @ HH:mm")); + txtProcess.AppendText(Environment.NewLine); + txtProcess.AppendText(Environment.NewLine); + Application.DoEvents(); + txtResults.Clear(); + //txtResults.AppendText(ExecuteStoredProcedureString.Execute(selectedAdminTool.StoredProcedure)); DateTime pEnd = DateTime.Now; txtProcess.AppendText(pEnd.ToString("MM/dd/yyyy @ HH:mm")); Application.DoEvents(); @@ -470,6 +490,7 @@ namespace VEPROMS } private void btnRefresh_Click(object sender, EventArgs e) { + txtProcess.Clear(); if (btnRefresh.Text == "NO OPTION SELECTED") { MessageBox.Show("You must select an option under the Option panel", btnRefresh.Text); diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs index 5215f23a..2b9553e5 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/AdminToolsExt.cs @@ -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(cmd); + DataPortal.Execute(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(cmd); + DataPortal.Execute(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 Execute(string storedProcedure) { - ExecuteStoredProcedureItemInfoList cmd = new ExecuteStoredProcedureItemInfoList(); + ESP_IdentifyNonEditableItems cmd = new ESP_IdentifyNonEditableItems(); cmd.StoredProcedure = storedProcedure; - DataPortal.Execute(cmd); + DataPortal.Execute(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(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 + } } \ No newline at end of file