public void Clone(DishInfo source) { this.DishId = source.DishId; this.Title = source.Title; this.Rank = source.Rank; this.Price = source.Price; this.CurrentPrice = source.CurrentPrice; }
private void GetDishInMenu() { TryCatchBlock th = new TryCatchBlock(delegate { _module = Constants.MSG_UPDATEDATA; SetMessageLn("刷新[菜谱中菜肴列表]..."); if (!this.ValidationLogin()) { if (DishesFetched != null) DishesFetched(null); return; } string content = RequestCafeHomePage(false); Collection<DishInfo> dishes = new Collection<DishInfo>(); int page = 0; do { HH.DelayedTime = Constants.DELAY_1SECONDS; content = HH.Get(string.Format("http://www.kaixin001.com/cafe/api_dishlist.php?verify={0}&page={1}&r=0.11418269015848637", DataConvert.GetEncodeData(this._verifyCode), page)); Collection<DishInfo> dishes2 = new Collection<DishInfo>(); dishes2 = ConfigCtrl.GetOriginalDishes(content); if (dishes2 == null || dishes2.Count == 0) break; else { foreach (DishInfo item in dishes2) { DishInfo dish = new DishInfo(); dish.Clone(item); dishes.Add(dish); } page += 1; } } while (true); if (dishes == null || dishes.Count == 0) SetMessageLn("[菜谱中菜肴列表]信息刷新失败!"); else SetMessageLn("[菜谱中菜肴列表]信息刷新成功!"); //invoke event if (DishesFetched != null) DishesFetched(dishes); }); base.ExecuteTryCatchBlock(th, "[菜谱中菜肴列表]信息刷新失败!"); }
public static Collection<DishInfo> GetPurchaseDishes(string content) { try { //http://www.kaixin001.com/cafe/api_frienddish.php?verify=2588258_1136_2588258_1267104985_295bd02d0d7f370d3be08fa81d916e0e&uid=6195212&cafeid=2729328&page=0 if (String.IsNullOrEmpty(content)) return new Collection<DishInfo>(); XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.LoadXml(content); DataView dv = GetData(objXmlDoc, "data/dish"); Collection<DishInfo> dishes = new Collection<DishInfo>(); for (int ix = 0; ix < dv.Table.Rows.Count; ix++) { DishInfo dish = new DishInfo(); dish.DishId = DataConvert.GetInt32(dv.Table.Rows[ix]["dishid"]); dish.Title = DataConvert.GetString(dv.Table.Rows[ix]["name"]); dish.CurrentPrice = DataConvert.GetDecimal(dv.Table.Rows[ix]["price"]); dishes.Add(dish); } return dishes; } catch (Exception ex) { LogHelper.Write("ConfigCtrl.GetPurchaseDishes", ex); return null; } }
public static Collection<DishInfo> GetTransactionDishes() { try { XmlDocument objXmlDoc = GetMasterDataFile(Constants.FILE_CAFEDISHESTRANSACTIONMASTERDATA); if (objXmlDoc == null) return null; DataView dv = GetData(objXmlDoc, "data/transactiondishes"); Collection<DishInfo> dishes = new Collection<DishInfo>(); for (int ix = 0; ix < dv.Table.Rows.Count; ix++) { DishInfo dish = new DishInfo(); dish.DishId = DataConvert.GetInt32(dv.Table.Rows[ix]["dishid"]); dish.Title = DataConvert.GetString(dv.Table.Rows[ix]["title"]); dish.MaxPrice = DataConvert.GetDecimal(dv.Table.Rows[ix]["maxprice"]); dish.MinPrice = DataConvert.GetDecimal(dv.Table.Rows[ix]["minprice"]); dish.SellPrice = DataConvert.GetDecimal(dv.Table.Rows[ix]["sellprice"]); dish.PurchasePrice = DataConvert.GetDecimal(dv.Table.Rows[ix]["purchaseprice"]); dishes.Add(dish); } return dishes; } catch (Exception ex) { LogHelper.Write("ConfigCtrl.GetTransactionDishes", ex); return null; } }
public static Collection<DishInfo> GetDishesInMenu() { try { XmlDocument objXmlDoc = GetMasterDataFile(Constants.FILE_CAFEDISHESMASTERDATA); if (objXmlDoc == null) return null; DataView dv = GetData(objXmlDoc, "data/dishes"); Collection<DishInfo> dishes = new Collection<DishInfo>(); for (int ix = 0; ix < dv.Table.Rows.Count; ix++) { DishInfo dish = new DishInfo(); dish.DishId = DataConvert.GetInt32(dv.Table.Rows[ix]["dishid"]); dish.Title = DataConvert.GetString(dv.Table.Rows[ix]["title"]); dish.Price = DataConvert.GetInt32(dv.Table.Rows[ix]["price"]); dish.Rank = DataConvert.GetInt32(dv.Table.Rows[ix]["rank"]); dishes.Add(dish); } return dishes; } catch (Exception ex) { LogHelper.Write("ConfigCtrl.GetDishesInMenu", ex); return null; } }
public static Collection<DishInfo> GetOriginalDishes(string content) { try { if (String.IsNullOrEmpty(content)) return new Collection<DishInfo>(); XmlDocument objXmlDoc = new XmlDocument(); objXmlDoc.LoadXml(content); DataView dv = GetData(objXmlDoc, "data/dish"); Collection<DishInfo> dishes = new Collection<DishInfo>(); for (int ix = 0; ix < dv.Table.Rows.Count; ix++) { DishInfo dish = new DishInfo(); dish.DishId = DataConvert.GetInt32(dv.Table.Rows[ix]["dishid"]); dish.Title = DataConvert.GetString(dv.Table.Rows[ix]["title"]); dish.Price = DataConvert.GetInt32(DataConvert.GetString(dv.Table.Rows[ix]["price"]).Replace("¥", "")); dish.Rank = DataConvert.GetInt32(dv.Table.Rows[ix]["rank"]); dishes.Add(dish); } return dishes; } catch (Exception ex) { LogHelper.Write("ConfigCtrl.GetOriginalDishes", content, ex, LogSeverity.Error); return null; } }