93 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			93 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
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
 | 
						|
 | 
						|
	}
 | 
						|
}
 |