C2021-058 Admin Tool Purge Change History/C2025-052 Admin Tool Index Maintenance

This commit is contained in:
2025-09-16 09:08:17 -04:00
parent 1ac6e4b1a0
commit 7555a0389b
6 changed files with 801 additions and 301 deletions

View File

@@ -0,0 +1,92 @@
using System;
using Csla.Data;
using System.Data;
using System.Data.SqlClient;
//CSM - C2021-058 - Minimal Class for User Maintenance
namespace VEPROMS.CSLA.Library
{
public static class Maintenance
{
#region Get User Reports - Admin Tool Purge Change History
//CSM - C2021-058 Maintenance Purge Change History
public static void PurgeChangeHistory(DateTime dte)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_PurgeChangeHistory";
cm.Parameters.AddWithValue("@dte", dte);
cm.CommandTimeout = 0;
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
throw new DbCslaException("Error in PurgeChangeHistory: ", ex);
}
}
//CSM - C2025-052 Rebuild all Indexes
public static void IndexMaintenance()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_IndexMaintenance";
cm.CommandTimeout = 0;
cm.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
throw new DbCslaException("Error in IndexMaintenance: ", ex);
}
}
#endregion
#region Get Other User Sessions In Progress
//returns all users, machine names, login date
//except current user (user supplied)
public static DataTable GetOtherUserSessionsInProgress(string userid)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_GetOtherActiveSessions";
cm.Parameters.AddWithValue("@UsrID", userid);
cm.CommandTimeout = Database.DefaultTimeout;
using (SqlDataAdapter da = new SqlDataAdapter(cm))
{
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
}
}
catch (Exception ex)
{
throw new DbCslaException("Error in vesp_GetOtherActiveSessions: retrieving data failed", ex);
}
}
#endregion
}
}