예제 #1
0
        /// <summary>
        /// 产品数量更新
        /// </summary>
        /// <param name="toClient"></param>
        internal void ServiceProductCountUpdateNotification(ToClientServiceProductCountUpdateNotification toClient)
        {
            try
            {
                Dictionary <long, ProductWithCount> list = toClient.ProductAndCounts.DeserializeObject <Dictionary <long, ProductWithCount> >();
                // 如果有产品则更新产品
                if (null != list)
                {
                    foreach (var product in list.Values)
                    {
                        Product currentProduct = Resources.GetRes().Products.Where(x => x.ProductId == product.Product.ProductId).FirstOrDefault();
                        currentProduct.UpdateTime   = product.Product.UpdateTime;
                        currentProduct.BalanceCount = Math.Round(currentProduct.BalanceCount + product.CountChange, 3);

                        // 如果支出价格有变动则修改
                        if (null != product.NewCostPrice)
                        {
                            currentProduct.CostPrice = product.NewCostPrice.Value;
                        }
                        // 如果价格有变动,则修改
                        if (null != product.NewPrice)
                        {
                            currentProduct.Price = product.NewPrice.Value;
                        }

                        Notification.Instance.ActionProduct(null, product.Product, null);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
예제 #2
0
 public void ServiceProductCountUpdateNotification(string ConnectionId, ToClientServiceProductCountUpdateNotification toClient)
 {
     Task.Run(() => ServiceHubContext.Instance.ServiceHub.Clients.Client(ConnectionId).ServiceProductCountUpdateNotification(toClient)).Wait();
 }