Beispiel #1
0
        private void MsgDetectMain()
        {
            try
            {
                exit = false;
                bool firsttime = true;
                long lastdetectmessages = DateTime.Now.Ticks;
                long lastdetectpropmts = DateTime.Now.Ticks;
                long msginterval = 10 * 60;
                long promptinterval = 10 * 60;
                while (!exit)
                {
                    Thread.Sleep(200);

                    if (bSwitching)
                    {
                        msginterval = 10 * 60;
                        promptinterval = 10 * 60;
                        firsttime = true;
                        bSwitching = false;
                        clearPopup();
                    }
                    //检测消息
                    long nowt = DateTime.Now.Ticks;
                    long deltdetectmessages = (nowt - lastdetectmessages) / 10000000;

                    if (firsttime || deltdetectmessages >= msginterval)//10分钟
                    {
                        lastdetectmessages = nowt;//更新检测时间
                        try
                        {
                            ClientMessage cltMessages = DataProcessUtil.getMessages(false);
                            processUnClickedMsgs(false);
                            messages = cltMessages.getMessages();
                            msginterval = cltMessages.getNextRequesttimeInterval()/1000;
                        }
                        catch (Exception ex)
                        {
                            string msg = ex.Message;
                        }
                        msgChanged = true;
                    }

                    long detectPrompmessages = (nowt - lastdetectpropmts) / 10000000;
                    if (firsttime || detectPrompmessages >= promptinterval)//10分钟
                    {
                        lastdetectpropmts = DateTime.Now.Ticks;
                        //弹出消息
                        try
                        {
                            ClientPrompt cltPrompt = DataProcessUtil.getPrompt(false);

                            if (cltPrompt != null)
                            {
                                 //begin for test
                                /*
                                if (DataProcessUtil.isLogin())
                                {
                                    cltPrompt.content += "(已登陆)";
                                }
                                else
                                {
                                    cltPrompt.content += "(未登陆)";
                                }
                                cltPrompt.content += "上次时间间隔:"+promptinterval+"秒";
                                cltPrompt.content += "本次时间间隔:" + Convert.ToInt64(cltPrompt.nextRequestTime) / 1000 + "秒";
                                 * */
                                //end for test

                                if (!string.IsNullOrEmpty(cltPrompt.nextRequestTime))
                                {
                                    if (Convert.ToInt64(cltPrompt.nextRequestTime) < Int32.MaxValue)
                                    {
                                        promptinterval = Convert.ToInt64(cltPrompt.nextRequestTime) / 1000;
                                    }
                                    else
                                    {
                                        promptinterval = 600;
                                    }
                                }
                                else
                                {
                                    promptinterval = 600;
                                }
                                //显示弹出窗口
                                Popup pop = new Popup(cltPrompt);

                                this.Invoke(new System.EventHandler(this.showForm), new object[] { pop, null });
                            }
                            else
                            {
                                promptinterval = 600;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    if (msgChanged)
                    {
                        this.Invoke(new System.EventHandler(this.DisplayMessage), new object[] { null, null });
                    }

                    firsttime = false;
                }

                processUnClickedMsgs(false);
                bManThreadRunning = false;
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
 public void removePopup(Popup p)
 {
     lock (popupsynobj)
     {
         prompwindows.Remove(p);
     }
 }