示例#1
0
        protected override ChromeOperator CreateChromeOperator(string chromeSessionInfoUrl)
        {
            ChromeOperator chromeOperator = new ChromeOperator(chromeSessionInfoUrl, this._chatRecordChromeTitle, true);

            chromeOperator.ClearChromeConsole();
            chromeOperator.EvalForMessageListen();
            chromeOperator.ListenChromeConsoleMessageAddedMessage(new Action <ConsoleMessage>(this.DealChromeConsoleMessage));
            return(chromeOperator);
        }
示例#2
0
 private void InitServiceInner()
 {
     try
     {
         this.ClearStateValues();
         this.WaitForInit();
         if (!this._isDisposed)
         {
             if (!WinApi.IsHwndAlive(this._hwnd))
             {
                 Log.Info("窗口已关闭," + this._logMark + "关闭");
                 this._isDisposed = true;
             }
             else
             {
                 Log.Info("开始初始化" + this._logMark + "...");
                 this.ChromOp = this.CreateChromeOperator(this._siUrl);
                 if (this.ChromOp == null)
                 {
                     throw new Exception("无法获取  operator," + this._logMark);
                 }
                 this.ChromOp.ListenChromeDetachedTurbo(new Action <string>(this.Detached));
                 this._continuousInitSessionCount = 0;
                 this.IsChromeOk = true;
                 this.Timer.AddAction(new Action(this.ChromOp.VerifySessionAlive), 2000, 0);
                 if (this.EvChromeConnected != null)
                 {
                     EvChromeConnected(this, new ChromeAdapterEventArgs
                     {
                         Connector = this
                     });
                 }
                 Log.Info(this._logMark + "初始化成功!");
             }
         }
     }
     catch (Exception ex)
     {
         this.ClearStateValues();
         this._continuousInitSessionCount++;
         if (this._continuousInitSessionCount > 2)
         {
             this.ChromOp = null;
         }
         Log.Error(this._logMark + "初始化出错,原因=" + ex.Message);
     }
     finally
     {
         Log.Info("结束初始化" + this._logMark);
     }
 }
示例#3
0
 protected ChromeConnector(int hwnd, string logMark)
 {
     this._isDisposed = false;
     this._evslim     = new ManualResetEventSlim(false);
     this._isChromeOk = false;
     this._logMark    = "Ocr";
     this._continuousInitSessionCount = 0;
     this._logMark = logMark;
     this.ClearStateValues();
     this._hwnd  = hwnd;
     this._siUrl = ChromeOperator.GetSessionInfoUrl(hwnd);
     Task.Factory.StartNew(new Action(this.ListenService));
     this.Timer = new NoReEnterTimer(this.ReconnectLoop, 2000, 1000);
 }
示例#4
0
 private void Detached(string reason)
 {
     Log.Info("!!!!!!!!!!!!!!" + this._logMark + " Detached,Reason=" + reason);
     this.ClearStateValues();
     this.ChromOp = null;
 }