C2021-058 Admin Tool Purge Change History/C2025-052 Admin Tool Index Maintenance
This commit is contained in:
@@ -9,6 +9,7 @@ using Volian.Controls.Library;
|
||||
using DevComponents.DotNetBar;
|
||||
using JR.Utils.GUI.Forms;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
|
||||
namespace VEPROMS
|
||||
{
|
||||
@@ -62,7 +63,13 @@ namespace VEPROMS
|
||||
swRmOrphanDataRecs.Enabled = false;
|
||||
swRefreshWordAttmts.Enabled = false;
|
||||
swStandardHypenChars.Enabled = false;
|
||||
|
||||
//if not full admin, disable Purge Change History
|
||||
btnPurgeChange.Enabled = false;
|
||||
}
|
||||
|
||||
//default to 10 years back
|
||||
dtePurge.Value = DateTime.Now.AddYears(-10);
|
||||
}
|
||||
// Make txtProcess text box available to frmAnnotationsClean form.
|
||||
internal TextBox GettxtProcess()
|
||||
@@ -1018,6 +1025,51 @@ namespace VEPROMS
|
||||
}
|
||||
}
|
||||
|
||||
//C2021-058 Admin Tool Purge Change History
|
||||
private void btnPurgeChange_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (AreOtherUserSessionsInProgress() || !CheckProcessLater()) return; // delay processing if set
|
||||
|
||||
//check any users have active sessions
|
||||
//if they do, do not continue
|
||||
if (!AreOtherUserSessionsInProgress())
|
||||
{
|
||||
DialogResult dr = MessageBox.Show("Are you sure you wish to Perform this action. This will remove all audit records before the specified date above, as well as the ability to restore deleted items from before the above date. It is recommended that you perform a database backup prior to performing this action.", "Purge Change History", MessageBoxButtons.OKCancel);
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
|
||||
//Purge Change History
|
||||
string statmsg = $"Purging all Change History before {dtePurge.Value.Date.ToString("MM/dd/yyyy")}";
|
||||
InitialProgressBarMessage = statmsg;
|
||||
txtResults.AppendText(statmsg);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
Maintenance.PurgeChangeHistory(dtePurge.Value);
|
||||
|
||||
//update status
|
||||
statmsg = $"Finished Purging all Change History before {dtePurge.Value.Date.ToString("MM/dd/yyyy")}. Updating indexes to reflect cleaned data.";
|
||||
DoProgressBarRefresh(50, 100, statmsg);
|
||||
txtProcess.AppendText(statmsg);
|
||||
txtProcess.AppendText(Environment.NewLine);
|
||||
txtProcess.AppendText(Environment.NewLine);
|
||||
txtResults.AppendText(statmsg);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
|
||||
//Perform Index Maintenance
|
||||
Maintenance.IndexMaintenance();
|
||||
statmsg = "Finished Purging Change History and Updating indexes to reflect cleaned data.";
|
||||
FinalProgressBarMessage = statmsg;
|
||||
txtResults.AppendText(statmsg);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
|
||||
MessageBox.Show("Purge Change History Completed", "Purge Change History");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void myTV_AfterCheck(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
//B2025 - 013 Admin Tool Tree Behavior
|
||||
@@ -1186,6 +1238,20 @@ namespace VEPROMS
|
||||
ResetDelTV(false);
|
||||
}
|
||||
|
||||
//C2021-058 Admin Tool Purge Change History
|
||||
//new Maintenance tab
|
||||
private void sideNavItmMaint_Click(object sender, EventArgs e)
|
||||
{
|
||||
AdminToolType = E_AdminToolType.Maintenance;
|
||||
setupProgessSteps1();
|
||||
|
||||
//notify Set Admin user that only Full Admins can run maintenance tools
|
||||
if (!IsAdministratorUser)
|
||||
{
|
||||
MessageBox.Show("Note: Only Full PROMS Administrator Users can run Purge Change History", "Maintenance Tools", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
}
|
||||
}
|
||||
|
||||
#region On/Off Swiches
|
||||
|
||||
// C2017-030 new Admin Tools user interface
|
||||
@@ -1193,7 +1259,8 @@ namespace VEPROMS
|
||||
{
|
||||
Repair = 1,
|
||||
Links = 2,
|
||||
Delete = 4
|
||||
Delete = 4,
|
||||
Maintenance = 10
|
||||
};
|
||||
private E_AdminToolType AdminToolType = E_AdminToolType.Repair;
|
||||
|
||||
@@ -1227,6 +1294,7 @@ namespace VEPROMS
|
||||
break;
|
||||
|
||||
case E_AdminToolType.Links:
|
||||
case E_AdminToolType.Maintenance:
|
||||
splitContainer3.Panel2Collapsed = true;
|
||||
progressSteps1.Visible = false;
|
||||
break;
|
||||
@@ -1661,6 +1729,55 @@ namespace VEPROMS
|
||||
//clears the stack to help with memory - should never need to undo text changes to this.
|
||||
txtResults.ClearUndo();
|
||||
}
|
||||
|
||||
//C2025-052 Admin Tool Index Maintenance
|
||||
private void btnIndexMaint_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!CheckProcessLater()) return; // delay processing if set
|
||||
|
||||
//check any users have active sessions
|
||||
if (!AreOtherUserSessionsInProgress())
|
||||
{
|
||||
string statmsg = "Updating Indexes (this may take a few minutes to complete)...";
|
||||
InitialProgressBarMessage = statmsg;
|
||||
txtResults.AppendText(statmsg);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
|
||||
Maintenance.IndexMaintenance();
|
||||
|
||||
statmsg = "Finished Updating indexes.";
|
||||
FinalProgressBarMessage = statmsg;
|
||||
txtResults.AppendText(statmsg);
|
||||
txtResults.AppendText(Environment.NewLine);
|
||||
|
||||
MessageBox.Show("Index Maintenance Completed", "Index Maintenance");
|
||||
}
|
||||
}
|
||||
|
||||
//C2021-058 Admin Tool Purge Change History/C2025-052 Admin Tool Index Maintenance
|
||||
// If any other users have active sessions, stop and write
|
||||
// out list of users
|
||||
private bool AreOtherUserSessionsInProgress()
|
||||
{
|
||||
DataTable dt = Maintenance.GetOtherUserSessionsInProgress(MySessionInfo.UserID);
|
||||
if (dt.Rows.Count == 0) return false;
|
||||
|
||||
txtProcess.AppendText("The following Users are currently in PROMS:");
|
||||
txtProcess.AppendText(Environment.NewLine);
|
||||
txtProcess.AppendText("Userid, Computer Name, last login");
|
||||
txtProcess.AppendText(Environment.NewLine);
|
||||
|
||||
foreach (DataRow r in dt.Rows)
|
||||
{
|
||||
txtProcess.AppendText($"{r["UserID"]}, {r["MachineName"]}, {r["DTSDtart"]}");
|
||||
txtProcess.AppendText(Environment.NewLine);
|
||||
}
|
||||
|
||||
MessageBox.Show("Certain Maintenance functions cannot be run if other users are currently in PROMS. Please see the output Results text for a list of other users with active PROMS sessions.", "Active PROMS Sessions", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user