public CashShopInventoryElement(Order order) { this.OrderNo = order.OrderNo; string text = order.ProductID; string attrEx = order.ProductAttribute3.ToString(); Dictionary <string, ItemAttributeElement> attributes = new Dictionary <string, ItemAttributeElement>(); ItemClassExBuilder.Parse(attrEx, out attributes); text = ItemClassExBuilder.Build(text, attributes); this.ProductNo = order.ProductNo; this.ItemClass = order.ProductID; this.ItemClassEx = (string.IsNullOrEmpty(text) ? this.ItemClass : text); this.Count = order.ProductPieces; this.r = (string.IsNullOrEmpty(order.ProductAttribute0) ? "-1" : order.ProductAttribute0); this.g = (string.IsNullOrEmpty(order.ProductAttribute1) ? "-1" : order.ProductAttribute1); this.b = (string.IsNullOrEmpty(order.ProductAttribute2) ? "-1" : order.ProductAttribute2); if (!string.IsNullOrEmpty(order.ProductAttribute3)) { this.ItemClass += order.ProductAttribute3; } this.Expire = order.ProductExpire; this.IsGift = order.IsPresent; this.SenderMessage = (order.SenderPresentMessage ?? ""); this.RemainQuantity = order.RemainOrderQuantity; }
private string ItemClassEx(string itemClass, int enhanceLevel) { if (enhanceLevel <= 0) { return(itemClass); } return(ItemClassExBuilder.Build(itemClass, enhanceLevel)); }
private void UpdatePrice() { Dictionary <string, List <TradeItemAvgPriceResult> > dictionary = new Dictionary <string, List <TradeItemAvgPriceResult> >(); using (TradeDBDataContext tradeDBDataContext = new TradeDBDataContext()) { ISingleResult <TradeItemAvgPriceListResult> singleResult = tradeDBDataContext.TradeItemAvgPriceList(); foreach (TradeItemAvgPriceListResult tradeItemAvgPriceListResult in singleResult) { try { Dictionary <string, ItemAttributeElement> dictionary2; if (tradeItemAvgPriceListResult.AttributeEX == null || !ItemClassExBuilder.Parse(tradeItemAvgPriceListResult.AttributeEX, out dictionary2)) { dictionary2 = new Dictionary <string, ItemAttributeElement>(); } ItemAttributeElement itemAttributeElement; if (dictionary2.TryGetValue("QUALITY", out itemAttributeElement)) { int num = 0; if (itemAttributeElement.Arg > 0) { num = itemAttributeElement.Arg; itemAttributeElement.Value = ""; } else if (!int.TryParse(itemAttributeElement.Value, out num)) { Log <TradeService> .Logger.ErrorFormat("Error while parse quality level {0}", itemAttributeElement.Value); } if (num == 2) { dictionary2.Remove("QUALITY"); } } List <ItemAttributeElement> attributes = (from x in dictionary2.Values orderby x.AttributeName select x).ToList <ItemAttributeElement>(); string text = ItemClassExBuilder.Build(tradeItemAvgPriceListResult.itemClass, attributes); if (text != null) { List <TradeItemAvgPriceResult> list; if (!dictionary.TryGetValue(text, out list)) { list = new List <TradeItemAvgPriceResult>(); dictionary.Add(text, list); } list.Add(new TradeItemAvgPriceResult(tradeItemAvgPriceListResult.MinPrice, tradeItemAvgPriceListResult.MaxPrice, tradeItemAvgPriceListResult.BuyCount, tradeItemAvgPriceListResult.Sales)); } } catch (Exception ex) { Log <TradeService> .Logger.ErrorFormat("Error while get average price of {0} {1} : {2}", tradeItemAvgPriceListResult.itemClass, tradeItemAvgPriceListResult.AttributeEX, ex.Message); } } } this.PricesPage = new Dictionary <int, Dictionary <string, PriceRange> >(); int num2 = 1; this.PricesPage.Add(num2, new Dictionary <string, PriceRange>()); foreach (KeyValuePair <string, List <TradeItemAvgPriceResult> > keyValuePair in dictionary) { List <TradeItemAvgPriceResult> value = keyValuePair.Value; long num3 = value.Sum((TradeItemAvgPriceResult x) => x.BuyCount); long num4 = value.Sum((TradeItemAvgPriceResult x) => x.Sales); if (num3 > 0L && num4 > 0L) { int min = value.Min((TradeItemAvgPriceResult x) => x.Min); int max = value.Max((TradeItemAvgPriceResult x) => x.Max); if (this.PricesPage[num2].Count <KeyValuePair <string, PriceRange> >() >= this.CountPerPage) { this.PricesPage.Add(++num2, new Dictionary <string, PriceRange>()); } this.PricesPage[num2].Add(keyValuePair.Key, new PriceRange { Min = min, Max = max, Price = (int)(num4 / num3) }); } } }