예제 #1
0
        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;
        }
        public static GiveItem ToGiveItem(this InventoryPickupOnceResponse result, CashShopService service, bool isGift)
        {
            ItemRequestInfo itemRequestInfo = new ItemRequestInfo();

            if (result.SubProduct.Count == 0)
            {
                string text   = result.ProductID;
                string attrEx = result.ProductAttribute3.ToString();
                Dictionary <string, ItemAttributeElement> attributes = new Dictionary <string, ItemAttributeElement>();
                ItemClassExBuilder.Parse(attrEx, out attributes);
                text = ItemClassExBuilder.Build(text, attributes);
                itemRequestInfo.Add(text, (int)(result.OrderQuantity * result.ProductPieces), string.IsNullOrEmpty(result.ProductAttribute0) ? -1 : result.ProductAttribute0.ParseInt(), string.IsNullOrEmpty(result.ProductAttribute1) ? -1 : result.ProductAttribute1.ParseInt(), string.IsNullOrEmpty(result.ProductAttribute2) ? -1 : result.ProductAttribute2.ParseInt(), (result.ProductExpire > 0) ? new DateTime?(DateTime.UtcNow.AddDays((double)result.ProductExpire)) : null, !(result.ProductID == "gold") && isGift);
            }
            else
            {
                foreach (SubProduct subProduct in result.SubProduct)
                {
                    CashShopProductListElement cashShopProductListElement;
                    if (!service.ProductByProductID.TryGetValue(subProduct.ProductNo, out cashShopProductListElement))
                    {
                        return(null);
                    }
                    string text2   = cashShopProductListElement.ProductID;
                    string attrEx2 = subProduct.ProductAttribute3.ToString();
                    Dictionary <string, ItemAttributeElement> attributes2 = new Dictionary <string, ItemAttributeElement>();
                    ItemClassExBuilder.Parse(attrEx2, out attributes2);
                    text2 = ItemClassExBuilder.Build(text2, attributes2);
                    itemRequestInfo.Add(text2, (int)cashShopProductListElement.ProductPieces, string.IsNullOrEmpty(subProduct.ProductAttribute0) ? -1 : subProduct.ProductAttribute0.ParseInt(), string.IsNullOrEmpty(subProduct.ProductAttribute1) ? -1 : subProduct.ProductAttribute1.ParseInt(), string.IsNullOrEmpty(subProduct.ProductAttribute2) ? -1 : subProduct.ProductAttribute2.ParseInt(), (cashShopProductListElement.ProductExpire > 0) ? new DateTime?(DateTime.UtcNow.AddDays((double)cashShopProductListElement.ProductExpire)) : null, !(cashShopProductListElement.ProductID == "gold") && isGift);
                }
            }
            foreach (BonusProduct bonusProduct in result.BonusProduct)
            {
                CashShopProductListElement cashShopProductListElement2;
                if (!service.ProductByProductID.TryGetValue(bonusProduct.ProductNo, out cashShopProductListElement2))
                {
                    return(null);
                }
                itemRequestInfo.Add(cashShopProductListElement2.ProductID, (int)cashShopProductListElement2.ProductPieces, -1, -1, -1, (cashShopProductListElement2.ProductExpire > 0) ? new DateTime?(DateTime.UtcNow.AddDays((double)cashShopProductListElement2.ProductExpire)) : null, !(cashShopProductListElement2.ProductID == "gold") && isGift);
            }
            return(new GiveItem(itemRequestInfo, GiveItem.FailMethodEnum.OperationFail, GiveItem.SourceEnum.CashShop));
        }
예제 #3
0
        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)
                    });
                }
            }
        }