.net c#我如何计算某人已登录我的系统的次数?

How do I count how many times someone has logged onto my system?
2021-09-14
  •  译文(汉语)
  •  原文(英语)

我正在建立一个基本的atm,想知道如何计算某人已登录的次数.我有一个按钮,当我按该按钮时,我希望它在其旁边的文本框中显示登录数量,但是我不确定如何将计算某人登录的次数.

任何建议将不胜感激

我正在使用C#

速聊1:
当有人登录时,打开一个文件,从文件中读取登录次数,将登录次数增加一个,然后将其保存回该文件.
速聊2:
开始问自己:当有人登录到我的系统时会发生什么?接受凭据并对其进行验证的代码在哪里?
速聊3:
Windows事件查看器处于"安全"状态,它将记录所有登录事件!:)
速聊4:
运行管理员:wevtutil qe安全性>%userprofile%\ Desktop \ log.txt
解决过程1

在用于身份验证的任何数据存储中,您还可以存储某人登录的次数.因此,您可以在用户表中查找用户,然后在登录成功后更新用户行.

如果这是一种从程序学习的东西,则可能没有像sql数据库这样的高级数据存储,因此可以使用简单的数据存储.

System.Data.DataSet可以保存到文件,其行为类似于小型数据库.这是我在编写一次性代码并且不想建立sql数据库时要使用的东西,但是与使用System.IO写入文本文件相比,我想要更多的功能.(或具有自身开销的原始xml文件,例如必须编写相当复杂的读取和解析逻辑)

I am building a basic atm and want to know how to count how many times someone has logged in. I have a button which when I press I want it to display the amount of logins in the textbox next to it but I am unsure how I would count how many times someone logs in.

Any advice would be great thanks

I am using c#

Talk1:
when someone logs in, open a file, read the number of logins from the file, increase the number by one and save the number back to the file.
Talk2:
Start asking yourself: what happens when someone logs into my system? Where is the code that accepts the credentials and verify them?
Talk3:
the windows Event Viewer in "security", it logs all Login events ! :)
Talk4:
run admin: wevtutil qe security >%userprofile%\Desktop\log.txt
Solutions1

In whatever data store that you are using to authenticate, you can also store how many times someone logged in. So you look up the user in a user table, and then update the user's row when the log on is successful.

If this is a learning-to-program sort of thing, you might not have a fancy datastore like a sql database, so you can use simple data stores.

The System.Data.DataSet can be saved to a file and behaves like a mini-database. It's what I use when I'm writing throwaway code and I don't want to set up a sql database, but want more features than using System.IO to write to text files. (or raw xml files which have their own overhead, like having to write rather involved reading & parsing logic)

转载于:https://stackoverflow.com/questions/15593437/how-do-i-count-how-many-times-someone-has-logged-onto-my-system

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入