7天内在c#中过期用户 [英] expire User in c# in 7 days

查看:160
本文介绍了7天内在c#中过期用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何做到这一点,我想过期有加入日期的用户如果他在7天内未访问我们公司那么他将过期.....

PLZ告诉我....提前致谢


How I do this , I want to expire User that have joining date If he not visited our company in 7 days then he will be expired.....
PLZ tell me .... thanks in advance

public bool CheckExpireUser(int UserId)
{
DateTime joingDte= MRB.get_JoingDate(UserId);
DateTime expireUsr = joingDte.AddDays(7);

if (expireUsr<=DateTime.Now)
{
    return true;
}
else
{
    MRB.Expire_Reg_Code(UserId); //EXPIRE USER ID CODE
    return false;

}

推荐答案

您不太可能想要检查joinedDate这个值应该永远不会改变。



我可能会在数据库中添加另一个字段,如lastVisitDate,并在每次用户登录时更新此字段。然后,您可以将该段代码修改为检查lastVisitDate是否早于1周前。
It's unlikely that you want to check for the "joiningDate" as this is a value that should probably never change.

I'd probably add another field in the database like "lastVisitDate" and update this field each time the user loggs in. You can then modify that piece of code to check if the lastVisitDate is older than 1 week ago.


这里的 CodeProject 你可能会发现很多文章制作'试用版' [ ^ ]。
Here at CodeProject you may find many articles on making 'trial version'[^] of your software.


正如Nicholas已经建议的那样。

创建一个新列,比如说UserLastLogin,每次用户登录时更新该列的值。

然后你可以创建一个批处理作业,你将用当前日期检查UserLastLogin,如果差异超过7天(在这种情况下),我们可以从表中删除UserRecord或将Expire标志设置为True。
Exactly, as Nicholas has already suggested.
Create a new column, say UserLastLogin, and every time the user logs in Update that column's value.
And then you can create a batch job where you will be checking the UserLastLogin with the current date, if the difference is more then 7 days(in this case) we can delete the UserRecord from the table or set the Expire flag as True.


这篇关于7天内在c#中过期用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆