public static ShoppingCart Factory(string storeId, string machineId, int companyId, string deviceSn, bool isNew = false)
        {
            string key = KeyFactory.MachineKeyFactory(companyId, storeId, machineId, deviceSn);

            if (shoppingCartCache.ContainsKey(key) && !isNew)
            {
#if (Local != true)
                shoppingCartCache.JsonSerializerSettings = new Newtonsoft.Json.JsonSerializerSettings();
                shoppingCartCache.JsonSerializerSettings.Converters.Add(new BarcodeConverter());
#endif
                var shoppingCart = shoppingCartCache.Get(key);
                return(shoppingCart);
            }
            else
            {
                shoppingCartCache.Remove(key);
#if (Local != true)
                OnlineCache onlineCache = new OnlineCache();
#endif
#if (Local)
                OnlineCache onlineCache = Salesclerk.onlineCache;
#endif

                var machineInfo = onlineCache.Get(key);
                if (machineInfo != null)
                {
                    var shoppingCart = new ShoppingCart();
                    shoppingCart.MachineInformation = machineInfo;
                    shoppingCart.NewAndResetOrderSN();
                    shoppingCartCache.Set(key, shoppingCart);
                    return(shoppingCart);
                }
                else
                {
                    goto TheSaleException;
                }
            }

TheSaleException:
            throw new SaleException("400", "未登录或者未授权,不允许操作!");
        }
Exemple #2
0
        internal static MachineInformation GetMachineInfo(string storeId, string machineSn, int companyToken, string deviceSn)
        {
            var key = KeyFactory.MachineKeyFactory(companyToken, storeId, machineSn, deviceSn);

            return(onlineCache.Get(key));
        }