Пример #1
0
 public void GetBuyHistory(ProductPrizeInfo prizeInfo)
 {
     Int64 timeStamp = SystemHelper.GetTimeStamp();
     Int64 millSeconds = DateTime.Now.Millisecond;
     string baseUrl = @"http://api.1yyg.com/JPData?action=getLotteryRecords&codeId={0}&fun={1}&_={2}";
     string timeStampStr = timeStamp + "" + millSeconds;
     string url = string.Format(baseUrl, prizeInfo.codeID, timeStampStr, SystemHelper.GetTimeStampWithMillisecond());
     string res = NetHelper.GetByUrl(url);
     if (!String.IsNullOrWhiteSpace(res))
     {
         res = res.Replace(timeStamp + "" + millSeconds + "(", "");
         res = res.Substring(0, res.Length - 1);
         var data = JsonHelper.JsonToDictionary(res);
         if (data != null)
         {
         }
     }
 }
Пример #2
0
 public void AnalysePrizeInfo(ProductTypeInfo product, int recordCount, int minIndex, int pageSize)
 {
     DateTime startTime = DateTime.Now;
     Int64 timeStamp = SystemHelper.GetTimeStamp();
     Int64 millSeconds = DateTime.Now.Millisecond;
     string timeStampStr = timeStamp + "" + millSeconds;
     List<ProductPrizeInfo> prizeInfoList = new List<ProductPrizeInfo>();
     for (int i = recordCount; i >= minIndex; i -= pageSize)
     {
         int startIndex = i - pageSize >= 0 ? i - pageSize : 0;
         string url = string.Format(product.BaseApiUrl, startIndex, i, product.ProductTypeID, timeStampStr, SystemHelper.GetTimeStampWithMillisecond());
         string res = NetHelper.GetByUrl(url);
         if (!String.IsNullOrEmpty(res))
         {
             res = res.Replace(timeStamp + "" + millSeconds + "(", "");
             res = res.Substring(0, res.Length - 1);
             var data = JsonHelper.JsonToDictionary(res);
             if (data != null)
             {
                 SellProductBaseInfo baseInfo = new SellProductBaseInfo();
                 EntityHelper.setPropertiseValue<SellProductBaseInfo>(data, baseInfo);
                 foreach (Dictionary<string, object> dict in baseInfo.listItems)
                 {
                     ProductPrizeInfo prizeInfo = new ProductPrizeInfo();
                     EntityHelper.setPropertiseValue<ProductPrizeInfo>(dict, prizeInfo);
                     if (prizeInfoList.FirstOrDefault(p => p.codeID == prizeInfo.codeID) == null)
                     {
                         prizeInfoList.Add(prizeInfo);
                     }
                 }
                 TimeSpan ts = DateTime.Now - startTime;
                 prizeInfoList = prizeInfoList.OrderBy(p => p.raffTime).Distinct().ToList();
                 rtbResult.Text = "获取" + product.ProductTypeName + " 的购买记录:从" + startIndex + "开始,到" + i + "结束,共计" + prizeInfoList.Count + "条,耗时" + ts.TotalMilliseconds + "毫秒" + Environment.NewLine + rtbResult.Text;
                 InsertPrizeInfoToDB(product, prizeInfoList);
                 prizeInfoList = new List<ProductPrizeInfo>();
                 rtbResult.Text = product.ProductTypeName + " 的购买记录已经存入数据库" + Environment.NewLine + rtbResult.Text;
                 Thread.Sleep(2500);
                 startTime = DateTime.Now;
             }
         }
     }
 }
Пример #3
0
 private void cmbProductType_SelectedIndexChanged(object sender, EventArgs e)
 {
     ProductTypeInfo productType = productList.FirstOrDefault(p => p.ProductTypeID.ToString() == this.cmbProductType.SelectedValue.ToString());
     if (productType != null)
     {
         prizeInfoList = new List<ProductPrizeInfo>();
         List<string> propertiseName = EntityHelper.getPropertiesNames<ProductPrizeInfo>(new ProductPrizeInfo());
         string sqlStr = "select * from productprizeinfo where producttypeid = " + productType.ProductTypeID;
         DataTable dt = DBHelper.QueryToDataTable(sqlStr);
         foreach (DataRow row in dt.Rows)
         {
             Dictionary<string, object> valueDict = new Dictionary<string, object>();
             foreach (string properties in propertiseName)
             {
                 if (valueDict.Keys.Contains(properties))
                 {
                     valueDict[properties] = row[properties];
                 }
                 else
                 {
                     valueDict.Add(properties, row[properties]);
                 }
             }
             ProductPrizeInfo prizeInfo = new ProductPrizeInfo();
             EntityHelper.setPropertiseValue<ProductPrizeInfo>(valueDict, prizeInfo);
             prizeInfoList.Add(prizeInfo);
         }
         Dictionary<string, int> dataDict = new Dictionary<string, int>();
         dataDict.Add("", 0);
         foreach (var prizeinfo in prizeInfoList)
         {
             if (dataDict.Keys.Contains(prizeinfo.goodsName))
             {
                 dataDict[prizeinfo.goodsName] += 1;
             }
             else
             {
                 dataDict.Add(prizeinfo.goodsName, 1);
             }
         }
         this.cmbProductList.DataSource = dataDict.ToList();
         this.cmbProductList.DisplayMember = "key";
         this.cmbProductList.ValueMember = "value";
     }
 }