数据库中的 ASP.Net 用户活动跟踪

时间:2023-02-04
本文介绍了数据库中的 ASP.Net 用户活动跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

这是一个简单而高效的活动日志框架,我想将它与我现有的基于 ASP.Net 的 Web 应用程序集成(我有一个基于 LINQ-to-SQL 的 SQL DB 作为后端).我正在使用类似服务架构的东西来执行数据库操作 - 即调用相关的 LINQ 操作.我为几乎每个实体(即 DB 表)都有一个服务类,它处理 CRUD 操作.

This is about a simple yet efficient activity logging framework that I want to integrate with my existing ASP.Net based web-app (I've a LINQ-to-SQL based SQL DB as backend). I'm using something like a service-architecture to perform DB operations - that is invoke relevant LINQ operations. I've a service class for almost every entity (i.e. DB table) and it handles the CRUD operations.

一般来说,我需要跟踪活动喜欢 - Mr.X 添加了一个新项目 My.Y在此过滤器上搜索,Z 先生导出Grid 到 excel 的结果文档等...和类似的简单基于操作的日志记录(字段级日志记录目前还很远)

In general, I need to track activities like - Mr.X added a new Item, My.Y searched on this filter, Mr.Z exported the result of Grid to an excel document, etc... and similar simple operation based logging (field-level logging is far for now)

所以,这是我在 SO、其他论坛和网络上的两天研发中发现的:

So, here's what I've found in my two days of R&D on the SO, other forums and the web:

方法 1:使用两个表的简单旧方法:Activity(存储所有活动及其参与者)&ActivityType(列出活动类型).我有一个服务层,所以我可以有一个ServieBase"点击所有 CRUD 事件并记录我感兴趣的事件的类.一切都在代码中处理.

Approach 1: Simple old way of using two tables: Activity (stores ALL the activities along with its actor) & ActivityType (lists types of activities). I've a service layer so either I can have a "ServieBase" class which taps ALL the CRUD events and logs the one in which I'm interested. Everything is handled from within the code.

示例:http://dotnetslackers.com/articles/aspnet/Tracking-User-Activity.aspx

方法 2:使用数据库触发器在表级别点击事件,然后执行日志记录.这对应用程序来说将是完全抽象的".我已经LastModifiedBy"每个表中的字段,所以我将获得演员"数据,我可以进行日志记录,但这可能会限制我进行数据库操作和操作.需要我单独跟踪其他应用程序活动.但如果它值得我可以考虑.

Approach 2: Use database TRIGGERs to tap events at table level and then perform logging. This will be completely 'abstract' to the app. I've "LastModifiedBy" field in each table so I'll get the 'actor' data and I can do the logging but this might limit me to DB-operations & need me to track other app-activities separately. but if its worth I can consider it.

方法 3:(概念性的,需要更多指导)

Approach 3: (conceptual, need more guidance)

3.1 MVC 方法 - 我们正在考虑在未来采用 MVC,我在 MVC 中发现了一些有效的日志记录技巧,例如 - (对于传统的基于 L2S 的 Web 应用程序,是否有类似的方法?)

3.1 MVC approach - We're thinking of adopting MVC in future and I've found some efficient logging tricks in MVC like - (is ther anything like that for traditional L2S based web-app?)

在 ASP.NET MVC 应用程序上记录用户活动跟踪 asp.net mvc 网站的用户活动/操作?

3.2 跟踪服务 我在 Windows 中遇到了跟踪服务"功能 - 是否有与网络等效的功能?

3.2 Tracking Services I came across a 'tracking service' feature in windows - is there its web-equivalent?

http://msdn.microsoft.com/en-us/magazine/cc163466.aspxhttp://www.codeproject.com/KB/WF/WWF__Tracking_Service.aspx?msg=2879654

3.3 Misc - 我遇到的一些其他选项,但似乎不太有说服力,或者我最好说他们做他们的工作而不是我的 :-)

3.3 Misc - Some other options which I came across but don't seem too convincing or I'd better say they do their work but not mine :-)

参考 -

http://learn.iis.net/page.aspx/480/sample-web-analytics-tracking-module/

SQL 探查器:https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5054787.htmlhttp://technet.microsoft.com/en-us/library/cc966515.aspx

那么,怎么说?欢迎任何建议和新想法.目前,我似乎介于前两种方法之间,因为我们希望将来能够轻松添加要记录的任何额外活动.

So, what say? Any suggestions and new thoughts are welcome. For now, it seems I'd land somewhere between the first-two approaches because we want it to be easy in future to be able to add any extra activity to be logged.

谢谢.

推荐答案

我最终使用了前两种方法,因为它们看起来更简单、更容易.最重要的是,它们提供了更多的控制,并允许根据需要保持灵活性(即它接近实际的后端编码,使其更易于访问)

I ended up using among the first two approaches because they seem more simple and easier. Most of all they provide more control and allow to keep thing as flexible as required (i.e. its near to the actual backend coding which makes it more accessible)

我正在标记它,因为没有其他广泛的评论.

I'm marking it as there has been no other extensive reviews.

这篇关于数据库中的 ASP.Net 用户活动跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:在 Visual Studio 中添加新数据项时 EF 6.x DbContext Generator 选项的用途 下一篇:在 LINQ 中对多个表进行分组

相关文章

最新文章