![]() EXEC sp_Portal_GetUserLoginDetails_Logger '','' Public class ReportController : ControllerĪnd below are the "MS SQL StoredProcedure" to get the user login details and page wise access summary details Public class AdminController : Controller If (pageName.Contains("UserLandingPage"))įormattedPageName = "Home - App Management" Įlse if (pageName.Contains("AppUtilization"))įormattedPageName = "Application Utilization Report" Įlse if (pageName.Contains("AlertReport"))Īnd finally apply that attribute to the Controller Action/s(which actions you want to track) like below public class HomeController : Controller Public static string GetWebPageName(string pageName) Note : Session and Session data i am initializing in a Separate Controller( AuthController) Action( ValidateUser) which executes when user logging into the application.īelow i am using a Utility class which will get the exact name for the web page from the RawUrl(eg : /Home/M圜ontroller or /Home/M圜ontroller1?id=1&name=chandan) Finishes executing the Logger as normal Select(x => x.Emp_Name).FirstOrDefault() ĪLogger.AccessedType = ("Report") ? "Report" : "Page" ![]() Where(x => x.User_Id = aLogger.LogedUserId)ĪLogger.LogedUserEmpName = context.D_MASTER Using (dbEntities context = new dbEntities())ĪLogger.LogedUserEmpId = context.D_MASTER Timestamp = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE), Get the Web Page name(from the URL that was accessed)ĪreaAccessed = UserActivityUtility.GetWebPageName(request.RawUrl = "/"? "/Home/UserLandingPage" : request.RawUrl), IPAddress = Convert.ToString((address => address.AddressFamily = AddressFamily.InterNetwork)), Portal_Logger aLogger = new Portal_Logger() Stores the Request in an Accessible object Public override void OnActionExecuting(ActionExecutingContext filterContext) IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()) ![]() Private static TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time") Public class LoggerActionFilter : ActionFilterAttribute Next, Created a filter which will track the activity for user/s like below I am able to achieve this by following the below wayĬreate a table(name - Portal_Logger and D_MASTER )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |