Ejemplo n.º 1
0
        void Set_CookieVisitor()
        {
            //注册获取cookie回调事件
            CookieVisitor visitor = new CookieVisitor();

            visitor.SendCookie += (Cookie obj) => {
                if (obj.Name != "auth_t")
                {
                    return;
                }
                Token.token = obj.Value;
                //mIsEndCheck = true;
                if (!String.IsNullOrEmpty(Token.token))
                {
                    Thread getDialPhoneManagerThread = new Thread(() =>
                    {
                        while (!this.isExit)
                        {
                            Thread.Sleep(ThreadSleepTime);
                            try
                            {
                                String retString           = HttpControl.GetHttpResponseList(HttpControl.GetNeedCallPhoneCmd, 50000, Token.token);
                                List <DialPhoneInfo> infos = (List <DialPhoneInfo>)HttpControl.JSONStringToList <DialPhoneInfo>(retString);
                                DialPhoneInfo[] dialInfos  = new DialPhoneInfo[infos.Count];
                                int i = 0;
                                foreach (DialPhoneInfo info in infos)
                                {
                                    dialInfos[i] = info;
                                    i++;
                                }
                                phoneControl.startDialPstn(dialInfos, this.Token.token);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    });
                    getDialPhoneManagerThread.Start();
                }
            };;
            mCookieManager.VisitAllCookies(visitor);
        }
Ejemplo n.º 2
0
        void Set_CookieVisitor()
        {
            //注册获取cookie回调事件
            CookieVisitor visitor = new CookieVisitor();

            visitor.SendCookie += (Cookie obj) => {
                switch (obj.Name)
                {
                case "user_n":
                    //userName
                    main.Dispatcher.Invoke(() => {
                        userName.Text         = obj.Value;
                        quitButton.Visibility = Visibility.Visible;
                    });
                    break;

                case TokenKey:
                    Token.TokenCode = obj.Value;
                    Domain          = obj.Domain;
                    ShowLeftBar();
                    StartFistPage();
                    //mIsEndCheck = true;
                    if (!String.IsNullOrEmpty(Token.TokenCode))
                    {
                        Thread getDialPhoneManagerThread = new Thread(() =>
                        {
                            while (!this.isExit && !String.IsNullOrEmpty(Token.TokenCode))
                            {
                                try
                                {
                                    String retString           = HttpControl.GetHttpResponseList(HttpControl.GetNeedCallPhoneCmd, 50000, Token.TokenCode);
                                    List <DialPhoneInfo> infos = (List <DialPhoneInfo>)HttpControl.JSONStringToList <DialPhoneInfo>(retString);
                                    DialPhoneInfo[] dialInfos  = new DialPhoneInfo[infos.Count];
                                    int i = 0;
                                    foreach (DialPhoneInfo info in infos)
                                    {
                                        dialInfos[i] = info;
                                        i++;
                                    }
                                    if (dialInfos.Length > 0)
                                    {
                                        phoneControl.startDialPstn(dialInfos, this.Token.TokenCode);
                                    }
                                    Thread.Sleep(ThreadSleepTime);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        });
                        getDialPhoneManagerThread.Start();
                    }
                    break;

                default:
                    break;
                }
            };;
            mCookieManager.VisitAllCookies(visitor);
        }