如何更新数据库的位列true或false定时器的基数。 [英] How to update bit column of database true or false base of timer.
本文介绍了如何更新数据库的位列true或false定时器的基数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的用户表中有一个列,我想在时基上更新它,如果用户没有注销并关闭浏览器那么如何将状态从true更新为false请帮助找出解决方案。我正在使用c#linq。
希望得到积极回应
谢谢
解决方案
您可以在我的下一篇文章的源代码中找到此问题: MVC基本站点:步骤4 - 使用AJAX,JSON,jQuery,LINQ和序列化的MVC 4.0中的jqGrid集成[ ^ ]
您应该查看下一部分:
1.在AccountController
方法OnWindowClosing()
从onBeforeUnload
和onKeyDown
窗口事件调用,并用于做浏览器窗口关闭时的用户会话终结任务。
2.在主布局视图中_Layout.cshtml
从底部开始的javscript部分文件:
函数onWindowClosing(){
if(window.event.clientX< 0 || window.event.clientY< 0){
.ajax({
type:POST,
url:/ Account / OnWindowClosing
});
}
};
函数onKeydown(evt){
if(evt!= undefined&& evt.altKey&& evt.keyCode == 115)// Alt + F4
{
.ajax({
type:POST,
url:/ Account / OnWindowClosing
});
}
};
window.onbeforeunload = onWindowClosing;
window.document.onkeydown = onKeydown;
I have a bit column in my users table, I want to update it on timing base, If user didn't logout and close the browser then how can I update the status from true to false please help to find out the solution. I am using c# linq.
hope for a positive response
Thanks
解决方案
You could find this problem solved in the source code of my next article: MVC Basic Site: Step 4 – jqGrid Integration in MVC 4.0 using AJAX, JSON, jQuery, LINQ, and Serialization[^]
You should look on the next parts:
1. InAccountController
the methodOnWindowClosing()
that is invoked fromonBeforeUnload
andonKeyDown
window events, and used to do user session finalization tasks when the browser window is closing.
2.In the main layout view_Layout.cshtml
the javscript section from the bottom of the file:
function onWindowClosing() { if (window.event.clientX < 0 || window.event.clientY < 0) {
.ajax({ type: "POST", url: "/Account/OnWindowClosing" }); } }; function onKeydown(evt) { if (evt != undefined && evt.altKey && evt.keyCode == 115) //Alt + F4 {
.ajax({ type: "POST", url: "/Account/OnWindowClosing" }); } }; window.onbeforeunload = onWindowClosing; window.document.onkeydown = onKeydown;
这篇关于如何更新数据库的位列true或false定时器的基数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文