Esempio n. 1
0
        private void GetWindowStr(object sender, EventArgs e)
        {
            ExeTitle = CurrentWindow.GetTopWindowText();
            ExePath  = CurrentWindow.GetTopWindowName();
            if (GlobalCommon.UsingModel != null)
            {
                //如果名字匹配
                if (ExeTitle.Contains(GlobalCommon.UsingModel.ExeTitleName))
                {
                    //如果已设置程序路径,程序名字和路径双重匹配
                    if ((!string.IsNullOrWhiteSpace(GlobalCommon.UsingModel.ExePathName) && ExePath.Contains(GlobalCommon.UsingModel.ExePathName)) ||
                        string.IsNullOrWhiteSpace(GlobalCommon.UsingModel.ExePathName))
                    {
                        CurrentID      = GlobalCommon.CurrentExeID = GlobalCommon.UsingModel.ExeID; //当前ID
                        LeaveExeSecond = 0;                                                         //重置离开程序时间
                        if (WatchExeSecond == 0)
                        {
                            StageName = ProgramStageConfigServiceBLLService.Instance.GetCurrentState();
                            //插入时间到时间表中
                            CurrentWatchTimeModel.StartTime = System.DateTime.Now;
                            CurrentWatchTimeModel.ExeID     = Convert.ToInt32(GlobalCommon.CurrentExeID);

                            int resultID = WatchTimeBLLService.Instance.InsertWathExeTime(CurrentWatchTimeModel);
                            CurrentWatchTimeModel.TimeID = resultID;
                        }
                        WatchExeSecond += 1;
                    }
                }
                else//离开要监视的程序
                {
                    //更新时间
                    if (LeaveExeSecond == 0 && WatchExeSecond != 0)
                    {
                        CurrentWatchTimeModel.EndTime = System.DateTime.Now;
                        int resultID = WatchTimeBLLService.Instance.UpdateWathExeTime(CurrentWatchTimeModel);
                    }
                    LeaveExeSecond++;
                    CurrentID = GlobalCommon.CurrentExeID = null;
                    //监视类型
                    WatchType = WatchTypeBLLService.Instance.SelectData();
                    //当为间隔时间模式时,重置时间
                    if (WatchExeSecond != 0 && true == WatchType?.IntervalType)
                    {
                        WatchExeSecond = 0;
                    }
                }
            }
        }