You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
6.0 KiB
C#
166 lines
6.0 KiB
C#
using NetLibrary.Common.Configuration;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Net;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace TradeServer
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
OrderInfoService ser = new OrderInfoService();
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
ReadSetting();
|
|
ser.StartRunTime = StaticModel.OrderReadTime;
|
|
ser.OrderDelayTime = StaticModel.OrderDelayTime;
|
|
ser.OrderReadNum = StaticModel.OrderReadNum;
|
|
ser.Start();
|
|
|
|
var list = DataLogic.GetLinkList();
|
|
if (list != null)
|
|
{
|
|
foreach (var md in list)
|
|
{
|
|
if (md.Url == null || md.Url == "")
|
|
continue;
|
|
string aa = "";
|
|
try
|
|
{
|
|
WebRequest request = WebRequest.Create(md.Url);
|
|
WebResponse response = request.GetResponse();
|
|
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("gb2312"));
|
|
|
|
aa = reader.ReadToEnd();
|
|
|
|
reader.Close();
|
|
reader.Dispose();
|
|
response.Close();
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
|
|
|
|
}
|
|
Match m = Regex.Match(aa, "<span data-hook=\"total-review-count\" class=\"a-size-medium totalReviewCount\">(?<TotalNum>.*?)</span>");
|
|
|
|
int TotalNum = 0;
|
|
if (m.Success)
|
|
{
|
|
if (m.Groups["TotalNum"] != null && m.Groups["TotalNum"].Value != null)
|
|
TotalNum = Convert.ToInt32(m.Groups["TotalNum"].Value);
|
|
}
|
|
|
|
|
|
int Star1 = 0;
|
|
int Star2 = 0;
|
|
int Star3 = 0;
|
|
int Star4 = 0;
|
|
int Star5 = 0;
|
|
int s1 = aa.IndexOf("cm_cr_dp_d_hist_1");
|
|
if (s1 > 0)
|
|
{
|
|
int s = aa.IndexOf("star (", s1);
|
|
int end = aa.IndexOf("%)", s);
|
|
string bb = aa.Substring(s + 6, end - s - 6);
|
|
if (bb != "")
|
|
Star1 = Convert.ToInt32(bb);
|
|
}
|
|
|
|
s1 = aa.IndexOf("cm_cr_dp_d_hist_2");
|
|
if (s1 > 0)
|
|
{
|
|
int s = aa.IndexOf("star (", s1);
|
|
int end = aa.IndexOf("%)", s);
|
|
string bb = aa.Substring(s + 6, end - s - 6);
|
|
if (bb != "")
|
|
Star2 = Convert.ToInt32(bb);
|
|
}
|
|
s1 = aa.IndexOf("cm_cr_dp_d_hist_3");
|
|
if (s1 > 0)
|
|
{
|
|
int s = aa.IndexOf("star (", s1);
|
|
int end = aa.IndexOf("%)", s);
|
|
string bb = aa.Substring(s + 6, end - s - 6);
|
|
if (bb != "")
|
|
Star3 = Convert.ToInt32(bb);
|
|
|
|
}
|
|
s1 = aa.IndexOf("cm_cr_dp_d_hist_4");
|
|
if (s1 > 0)
|
|
{
|
|
int s = aa.IndexOf("star (", s1);
|
|
int end = aa.IndexOf("%)", s);
|
|
string bb = aa.Substring(s + 6, end - s - 6);
|
|
if (bb != "")
|
|
Star4 = Convert.ToInt32(bb);
|
|
}
|
|
s1 = aa.IndexOf("cm_cr_dp_d_hist_5");
|
|
if (s1 > 0)
|
|
{
|
|
int s = aa.IndexOf("star (", s1);
|
|
int end = aa.IndexOf("%)", s);
|
|
string bb = aa.Substring(s + 6, end - s - 6);
|
|
if (bb != "")
|
|
Star5 = Convert.ToInt32(bb);
|
|
}
|
|
if (TotalNum > 0 && (Star1 > 0 || Star2 > 0 || Star3 > 0 || Star4 > 0 || Star5 > 0))
|
|
{
|
|
md.Star6 = TotalNum;
|
|
md.Star1 = Star1;
|
|
md.Star2 = Star2;
|
|
md.Star3 = Star3;
|
|
md.Star4 = Star4;
|
|
md.Star5 = Star5;
|
|
|
|
DataLogic.Save_GoodsStar(md);
|
|
|
|
}
|
|
else
|
|
{
|
|
DataLogic.UpdateGoodsStar2(md.Id.Value);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#region 读取配置
|
|
public void ReadSetting()
|
|
{
|
|
string SetupPath = AppDomain.CurrentDomain.BaseDirectory + "Setup.ini";
|
|
StaticModel.OrderReadTime = ConfigurationSourceSection.LoadXml_Attribute(SetupPath, "OrderReadTime");
|
|
|
|
string OrderDelayTime = ConfigurationSourceSection.LoadXml_Attribute(SetupPath, "OrderDelayTime");
|
|
if (string.IsNullOrEmpty(OrderDelayTime) == false) StaticModel.OrderDelayTime = Convert.ToInt32(OrderDelayTime);
|
|
|
|
string OrderReadNum = ConfigurationSourceSection.LoadXml_Attribute(SetupPath, "OrderReadNum");
|
|
if (string.IsNullOrEmpty(OrderReadNum) == false) StaticModel.OrderReadNum = Convert.ToInt32(OrderReadNum);
|
|
//OrderInfoService obj = new OrderInfoService();
|
|
//obj.Start();
|
|
|
|
}
|
|
#endregion
|
|
|
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
ser.Stop();
|
|
}
|
|
}
|
|
}
|