二开案例.单据长时间不操作,自动关闭

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

二开案例.单据长时间不操作,自动关闭

using Kingdee.BOS.Core.Const;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.JSON;
using System;

namespace Test2024
{
    [Kingdee.BOS.Util.HotUpdate]
    public class 长时间不操作自动关闭单据 : AbstractDynamicFormPlugIn
    {
        public DateTime LastOperationTime = DateTime.Now;   //最后一次操作时间
        public int AutoCloseSeconds = 60 * 10;   //600秒不操作,自动关闭
        public int AutoCloseIntervalSeconds = 30;   //30秒钟检测一次页面是否需要自动关闭
        string CheckAutoCloseEventKey = "CheckAutoCloseEventKey";

        public override void AfterBindData(EventArgs e)
        {
            CheckAutoClose();
        }
        void CheckAutoClose()
        {
            //页面加载后,30秒钟检测一次页面是否需要自动关闭
            JSONObject param = new JSONObject();
            param["key"] = CheckAutoCloseEventKey;
            param["eventName"] = CheckAutoCloseEventKey;
            param["delay"] = 1000 * AutoCloseIntervalSeconds;
            this.View.AddAction(JSAction.FireCustomRequest, param);
        }
        public override void CustomEvents(CustomEventsArgs e)
        {
            if (e.Key == CheckAutoCloseEventKey)
            {
                if (LastOperationTime.AddSeconds(AutoCloseSeconds) < DateTime.Now)
                {
                    //长时间未操作,自动关闭。
                    this.View.Close();
                }
                else
                {
                    CheckAutoClose();
                }
            }
        }

        //录入数据、点击按钮、点击菜等事件触发时,更新最后一次操作时间
        public override void DataChanged(DataChangedEventArgs e)
        {
            LastOperationTime = DateTime.Now;
        }

        public override void AfterBarItemClick(AfterBarItemClickEventArgs e)
        {
            LastOperationTime = DateTime.Now;
        }

        public override void AfterEntryBarItemClick(AfterBarItemClickEventArgs e)
        {
            LastOperationTime = DateTime.Now;
        }

        public override void AfterButtonClick(AfterButtonClickEventArgs e)
        {
            LastOperationTime = DateTime.Now;
        }

    }
}


二开案例.单据长时间不操作,自动关闭

using Kingdee.BOS.Core.Const;using Kingdee.BOS.Core.DynamicForm.PlugIn;using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;using Kingde...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息