Ejemplo n.º 1
0
        public void t2()
        {
            var s1 = File.ReadAllText("download2.txt");

            s1 = Regex.Replace(s1, "itemDesc\":\"(.*?)\",\"itemName", "itemDesc\":\"nothing\",\"itemName");

            s1 = s1.Remove(0, 1);
            s1 = s1.Remove(s1.Length - 1, 1);
            File.WriteAllText("temp_record.txt", s1);

            //
            JishiObject js1 = JsonConvert.DeserializeObject(s1, typeof(JishiObject)) as JishiObject;

            //1.抽数据

            JiShi.BLL.js_item Bll = new JiShi.BLL.js_item();

            foreach (var item in js1.pagedata)
            {
                JiShi.Model.js_item model = new JiShi.Model.js_item();
                model.closed     = item.closed.ToString();
                model.createDate = item.createDate.ToString();

                //if (!Bll.Exists(model.id)) {
                //    LogManager.WriteLog("保存:" + Bll.Add(model));
                //}
            }

            Console.WriteLine(js1.pageInfo.pageId + "    " + js1.pageInfo.totalPages + "    ");
            //Console.Write(js1);
            //Console.Write(JsonConvert.SerializeObject(js1));
            //var s1="\"closed\":false,\"createDate\":\",\"curId\":18,"gameId":"","gameItemId":"","gender":"","grade":0,"gradeName":"","guild":"","iconPath":"http://180.153.139.98/res/money/yb.png","id":1518894,"itemAmount":1000000,"itemCode":"CapitalType2","itemDesc":"","itemName":"银子","itemType":"2199","power":"","price":88,"publicityEndDate":"2014-09-12 08:46:09","returnDate":"","saveTime":"2014-09-12 08:46:09","sellerCasId":"","sellerGameId":"B347C67E475948C582DFCE392B02AAA7","sellerRole":"郎纵横四海","serverId":"7100046","shelfDate":"2014-09-12 08:46:09","shelfDays":13,"status":"已上架","unitPrice":0}";
        }
Ejemplo n.º 2
0
        public void NotifyUser()
        {
            bool needNotify = false;

            JiShi.BLL.js_item Bll = new JiShi.BLL.js_item();
            //更新最低成交价
            var ds0 = DbHelperMySQL.Query(" SELECT itemname,itemprice*par as price  FROM `js_concernitem` ").Tables[0];

            for (int i = 0; i < ds0.Rows.Count; i++)
            {
                var name  = ds0.Rows[i]["itemname"];
                var price = ds0.Rows[i]["price"];

                //2.获取数据库中对应的价格并作比较
                var models1 = Bll.GetModelList("  itemName='{0}'   and status==NULL ".With(name, price));
                if (models1.Count > 0)
                {
                    // MailBll.SendOneEmail(_smtpClient, "*****@*****.**", "*****@*****.**", RandomManager.GetRandomName() + " " + name + price, RandomManager.GetRandomName(), "");
                    LogManager.WriteLog("更新最低价{0}={1}".With(name, price));
                }
            }

            //加入各个残卷的低价获取和通知
            //1.抓取指定表格中的物品名及其价格
            var ds1 = DbHelperMySQL.Query(" SELECT itemname,itemprice*par as price  FROM `js_concernitem` ").Tables[0];

            for (int i = 0; i < ds1.Rows.Count; i++)
            {
                var name  = ds1.Rows[i]["itemname"];
                var price = ds1.Rows[i]["price"];

                //2.获取数据库中对应的价格并作比较
                var models1 = Bll.GetModelList("  itemName='{0}' and rice/itemAmount < {1} and gameItemId<>NULL ".With(name, price));
                if (models1.Count > 0)
                {
                    MailBll.SendOneEmail(_smtpClient, "*****@*****.**", "*****@*****.**", RandomManager.GetRandomName() + " " + name + price, RandomManager.GetRandomName(), "");
                }
            }


            //

            //银子的通知
            var models = Bll.GetModelList("  itemName='银子' and 1000*price/(itemAmount/1000)<75 and gameItemId<>NULL ");

            if (models.Count > 0)
            {
                needNotify = true;
            }

            if (needNotify)
            {
                init_smtpclient();


                MailBll.SendOneEmail(_smtpClient, "*****@*****.**", "*****@*****.**", RandomManager.GetRandomName() + " 低于75银子", RandomManager.GetRandomName(), "");
            }
            //
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 每次都执行
        /// </summary>
        private void OnPageLoaded_JiShi()
        {
            if (!jishi_start)
            {
                return;
            }


            var current_url = MainCefFrame.Url;

            if (!current_url.Contains("Goods") && !current_url.Contains("historicalJsonData") && !current_url.Contains("tradeItemDetail"))
            {
                return;
            }

            Domvisi2T dom1 = new Domvisi2T();

            MainCefFrame.GetSource(dom1);
            var htm = GlobalVar.CurrentHtml;

            if (string.IsNullOrEmpty(htm))
            {
                return;
            }

            ////角色分析模式
            //if (analysisModel == "role") {

            //    //数据导出
            //    LogManager.WriteLog("role-" + DateTime.Now.ToFileTime().ToString(), htm);


            //    return;
            //}

            //物品分析模式

            //0 数据过滤
            htm = htm.Replace("<html><head></head><body>", "");
            htm = htm.Replace("</body></html>", "");
            htm = htm.Replace("</div>", "");
            htm = htm.Replace("</font>", "");


            // File.WriteAllText("tempload/temp_download-{0}.txt".With(DateTime.Now.ToFileTime()), htm);
            try {
                string s1 = "";
                s1 = Regex.Replace(htm, "itemDesc\":\"(.*?)\",\"itemName", "itemDesc\":\"nothing\",\"itemName");
                s1 = Regex.Replace(s1, "itemDesc\":\"(.*?)\",\"itemSellerRole", "itemDesc\":\"nothing\",\"itemSellerRole");
                //itemSellerRole
                s1 = s1.Remove(0, 1);
                s1 = s1.Remove(s1.Length - 1, 1);

                //1.抽数据
                JishiObject       js1 = JsonConvert.DeserializeObject(s1, typeof(JishiObject)) as JishiObject;
                JiShi.BLL.js_item Bll = new JiShi.BLL.js_item();

                foreach (var item in js1.pagedata)
                {
                    #region MyRegion

                    JiShi.Model.js_item model = new JiShi.Model.js_item();
                    model.closed           = item.closed;
                    model.createDate       = item.createDate;
                    model.gameId           = item.gameId;
                    model.gameItemId       = item.gameItemId;
                    model.gender           = item.gender;
                    model.gradeName        = item.gradeName;
                    model.guild            = item.guild;
                    model.iconPath         = item.iconPath;
                    model.itemCode         = item.itemCode;
                    model.itemDesc         = item.itemDesc;
                    model.itemName         = item.itemName;
                    model.itemType         = item.itemType;
                    model.power            = item.power;
                    model.publicityEndDate = item.publicityEndDate;
                    model.sellerCasId      = item.sellerCasId;
                    model.sellerGameId     = item.sellerGameId;
                    model.sellerRole       = item.sellerRole;
                    model.serverId         = item.serverId;
                    //serverid部分数据会丢失
                    model.status = item.status;


                    model.curId      = item.curId;
                    model.grade      = item.grade;
                    model.id         = item.id;
                    model.itemAmount = item.itemAmount.ToString();
                    model.price      = item.price;
                    model.returnDate = item.returnDate;
                    model.saveTime   = item.saveTime;
                    model.shelfDate  = item.shelfDate;
                    model.shelfDays  = item.shelfDays;
                    model.closed     = item.unitPrice;
                    #endregion
                    //为了对付 最近成交模式
                    if (model.id == null)
                    {
                        model.id = model.gameItemId;
                    }
                    //
                    if (!Bll.Exists(model.id))
                    {
                        model.status = modeList[modeListIndex];
                        LogManager.WriteLog("保存:" + model.gameId + " " + model.itemName + " " + Bll.Add(model));
                    }
                    else
                    {
                        // LogManager.WriteLog("更新:" + model.gameId + " " + model.itemName + " " + Bll.Update(model));
                    }
                }

                //2.翻页
                //   Thread.Sleep(TimeSpan.FromSeconds(RandomManager.random.Next(2,4)));
                if (modeList[modeListIndex] == "historicalJsonData")
                {
                    js1.pageInfo.totalPages = 6;//historicalJsonData模式下最多只能抓取6页
                }
                Console.WriteLine("类型:" + modeList[modeListIndex] + " 页码:" + js1.pageInfo.pageId + " 总页数:" + js1.pageInfo.totalPages);
                if (js1.pageInfo.pageId < js1.pageInfo.totalPages)
                {
                    jishi_next.PerformClick();
                }
                else
                {
                    if (modeListIndex + 1 < modeList.Count)
                    {
                        modeListIndex++;
                        currentpage = -1;
                        jishi_next.PerformClick();
                    }
                    else
                    {
                        jishi_start = false;
                    }
                }
            } catch (Exception e) {
                LogManager.WriteLog(e.ToString());
            }
        }