Beispiel #1
0
        private void Connection_ProductArrayChanged(object sender, EventArgs e)
        {
            this.Products                 = new List <CashShopProductListElement>();
            this.BeautyShopProducts       = new List <CashShopProductListElement>();
            this.ProductByProductID       = new Dictionary <int, CashShopProductListElement>(this.Connection.ProductArray.Count);
            this.ProductByItemClass       = new Dictionary <string, CashShopProductListElement>(this.Connection.ProductArray.Count);
            this.ProductByCashShopItemKey = new Dictionary <CashShopItemKey, CashShopProductListElement>(this.Connection.ProductArray.Count);
            try
            {
                foreach (Product product in this.Connection.ProductArray)
                {
                    Log <CashShopService> .Logger.InfoFormat("product - {0} : {1} ", product.ProductNo, product.ProductID);

                    CashShopProductListElement cashShopProductListElement = new CashShopProductListElement(product);
                    this.Products.Add(cashShopProductListElement);
                    if (this.ProductByProductID.ContainsKey(cashShopProductListElement.ProductNo))
                    {
                        Log <CashShopService> .Logger.ErrorFormat("Duplicate ProductNo[{0}]", cashShopProductListElement.ProductNo);
                    }
                    else
                    {
                        this.ProductByProductID.Add(cashShopProductListElement.ProductNo, cashShopProductListElement);
                    }
                    if (!this.ProductByItemClass.ContainsKey(cashShopProductListElement.ProductID))
                    {
                        this.ProductByItemClass.Add(cashShopProductListElement.ProductID, cashShopProductListElement);
                    }
                    CashShopItemKey key = new CashShopItemKey(cashShopProductListElement.ProductID, cashShopProductListElement.SalePrice, (int)cashShopProductListElement.ProductExpire);
                    if (this.ProductByCashShopItemKey.ContainsKey(key))
                    {
                        Log <CashShopService> .Logger.InfoFormat("Duplicate CashShopItemKey[{0}/{1}/{2}]", cashShopProductListElement.ProductID, cashShopProductListElement.SalePrice, cashShopProductListElement.ProductExpire);
                    }
                    else
                    {
                        this.ProductByCashShopItemKey.Add(key, cashShopProductListElement);
                    }
                    if (this.BeautyShopCategories.ContainsKey(cashShopProductListElement.CategoryNo))
                    {
                        this.BeautyShopProducts.Add(cashShopProductListElement);
                    }
                }
                Log <CashShopService> .Logger.Info("Product Changed!");

                foreach (int serviceID in base.LookUp.FindIndex("FrontendServiceCore.FrontendService"))
                {
                    BroadcastPacket op = BroadcastPacket.Create <ChangedCashShopMessage>(new ChangedCashShopMessage());
                    base.RequestOperation(serviceID, op);
                }
            }
            catch (Exception ex)
            {
                Log <CashShopService> .Logger.Error(ex);
            }
        }
        public override IEnumerable <object> Run()
        {
            base.Finished = true;
            if (this.service.ProductByProductID == null)
            {
                Log <QueryCashShopProductInfoProcessor> .Logger.Error(" ProductList is Empty");

                yield return(new FailMessage("[QueryCashShopProductInfoProcessor] service.ProductByProductID")
                {
                    Reason = FailMessage.ReasonCode.LogicalFail
                });
            }
            else
            {
                CashShopProductListElement e = null;
                try
                {
                    e = (from x in this.service.ProductByProductID
                         where x.Key == base.Operation.QueryProductID
                         select x).Single <KeyValuePair <int, CashShopProductListElement> >().Value;
                }
                catch (Exception ex)
                {
                    Log <QueryCashShopProductInfoProcessor> .Logger.Fatal(" ProductID Not Exists.", ex);
                }
                if (e == null)
                {
                    yield return(new FailMessage("[QueryCashShopProductInfoProcessor] e")
                    {
                        Reason = FailMessage.ReasonCode.LogicalFail
                    });
                }
                else
                {
                    yield return(e);
                }
            }
            yield break;
        }