Exemple #1
0
 static void Main(string[] args)
 {
     log.Error("Main", new Exception("发生了一个异常"));   //错误
     log.Fatal("Main", new Exception("发生了一个致命错误")); //严重错误
     log.Info("Main", "信息");                        //记录一般信息
     log.Debug("Main", "调试信息");                     //记录调试信息
     log.Warn("Main", "警告");                        //记录警告信息
     Console.ReadKey();
 }
Exemple #2
0
        private void DaTi(IWebDriver iframeElWebDriver)
        {
            IWebElement bigImgEl = iframeElWebDriver.FinElement(By.ClassName("bg-placeholder"));

            if (bigImgEl != null)
            {
                string base64img = this.GetPicBase64Data(iframeElWebDriver);
                if (!base64img.IsNullOrWhiteSpace())
                {
                    string base64imgNoHeand = ImageHelper.TakeOutHeand(base64img);
                    if (this.OldImgBase64 == base64imgNoHeand)
                    {
                        this.dtMgr.report_error();
                        XLog.Error("Vtt验证码识别错误,报错", Array.Empty <object>());
                    }
                    this.OldImgBase64 = base64imgNoHeand;
                    PointLianZhong[] zuobiaos = this.dtMgr.GetPoints(base64imgNoHeand, 3, 3);
                    if (zuobiaos != null)
                    {
                        List <PointX>    l = new List <PointX>();
                        PointLianZhong[] pointLianZhongArray = zuobiaos;
                        for (int i = 0; i < (int)pointLianZhongArray.Length; i++)
                        {
                            PointLianZhong item = pointLianZhongArray[i];
                            l.Add(new PointX()
                            {
                                X = item.X,
                                Y = item.Y
                            });
                        }
                        ImageHelper.HuaDianAndSave(base64img, l);
                        Actions          actions = new Actions(iframeElWebDriver);
                        PointLianZhong[] pointLianZhongArray1 = zuobiaos;
                        for (int j = 0; j < (int)pointLianZhongArray1.Length; j++)
                        {
                            PointLianZhong zuobiao = pointLianZhongArray1[j];
                            actions.MoveToElement(bigImgEl, zuobiao.X, zuobiao.Y).Perform();
                            Thread.Sleep(HelperGeneral.Random.Next(1000, 2500));
                            actions.MoveToElement(bigImgEl, zuobiao.X, zuobiao.Y).Click().Perform();
                            Thread.Sleep(HelperGeneral.Random.Next(1000, 2500));
                        }
                        Thread.Sleep(6000);
                    }
                }
                else
                {
                    XLog.Error("图标点击-->js 注入取图片 获取失败", Array.Empty <object>());
                }
            }
            else
            {
                XLog.Debug("图标点击,大图元素找不到", Array.Empty <object>());
            }
        }
Exemple #3
0
        /// <summary>
        /// Sends a ping packet to the server, keeping the connection alive.
        /// </summary>
        /// <returns>Nothing</returns>
        private void SendPingPacket()
        {
            // As long as there is a connection to the game server (sorry for the checks xP)
            while (m_cGameConnection != null && m_cGameConnection.Socket != null && m_cGameConnection.Socket.Connected)
            {
                PacketOut o = new PacketOut(9999);
                o.FinalizeLengthAndChecksum();
                m_cGameConnection.SendTCP(o);

                XLog.Debug("Ping packet sent.");
                System.Threading.Thread.Sleep(1000 * 60);
            }
            m_tPingThread.Abort();
        }
Exemple #4
0
        private string GetPicBase64Data(IWebDriver iframeElWebDriver)
        {
            string str;

            try
            {
                string zhuRuJs = Resources.getBase64Image_tbdj;
                str = (string)SelementHelper.ExecJs(iframeElWebDriver, zhuRuJs, null);
                return(str);
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                XLog.Debug(string.Concat("GetPicBase64Data ", ex.ToString()), Array.Empty <object>());
            }
            str = null;
            return(str);
        }
Exemple #5
0
        private void VTTShiBieGuoChengDaTi(IWebDriver iframeElWebDriver, IWebElement tcaptcha_vtt0Elem)
        {
            XLog.Debug("VTTShiBieGuoChengDaTi 开始", Array.Empty <object>());
            string      tcaptcha_titleStr = iframeElWebDriver.GetTextByElement(By.ClassName("tcaptcha-title"), null);
            IWebElement tcaptcha_imgEl    = iframeElWebDriver.FinElement(By.Id("tcaptcha-img"));

            if (tcaptcha_imgEl != null)
            {
                (new Actions(iframeElWebDriver)).Click();
                string base64img = this.GetPicBase64Data(iframeElWebDriver, tcaptcha_titleStr);
                if (!base64img.IsNullOrWhiteSpace())
                {
                    string base64imgNoHeand = ImageHelper.TakeOutHeand(base64img);
                    if (this.OldImgBase64 == base64imgNoHeand)
                    {
                        this.dtMgr.report_error();
                        XLog.Error("Vtt验证码识别错误,报错", Array.Empty <object>());
                    }
                    this.OldImgBase64 = base64imgNoHeand;
                    PointLianZhong zuobiao = this.dtMgr.GetPoint(base64imgNoHeand, 1, 1);
                    if (zuobiao != null)
                    {
                        ImageHelper.HuaDianAndSave(base64img, zuobiao.X, zuobiao.Y);
                        Actions actions = new Actions(iframeElWebDriver);
                        actions.MoveToElement(tcaptcha_imgEl, zuobiao.X, zuobiao.Y).Perform();
                        Thread.Sleep(1000);
                        actions.MoveToElement(tcaptcha_imgEl, zuobiao.X, zuobiao.Y).Click().Perform();
                        Thread.Sleep(6000);
                    }
                }
                else
                {
                    XLog.Error("Vtt验证码-->获取失败", Array.Empty <object>());
                }
            }
        }
Exemple #6
0
 public void TestLog()
 {
     XLog log = new XLog();
     log.Debug("Test");
 }