Exemplo n.º 1
0
        private static RequestSetting LoadDefaultSetting(RequestSetting setting, string aipUrl)
        {
            if (setting == null)
            {
                setting = new RequestSetting();
            }
            //设置uri 信息等默认配置

            IPosSystemSettingsRepository systemSettingsRepository = new PosSystemSettingsRepository();
            var systemSettings = systemSettingsRepository.Get();

            if (systemSettings == null)
            {
                throw new NetException("系统配置不完善,请先配置系统设置项目!");
            }
            var serverConfig = systemSettings.RemoteServer;

            if (serverConfig == null && !serverConfig.Verfy())
            {
                throw new NetException("服务访问失败,请检查相关服务地址是否配置正确!");
            }
            setting.Host   = serverConfig.Host;
            setting.Port   = serverConfig.Port;
            setting.Schema = serverConfig.Schema;
            setting.Path   = aipUrl;
            return(setting);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 称重条码解析
        /// </summary>
        /// <param name="barcode">条码</param>
        /// <param name="isNotFoundThrowException">当未找到商品时,是否抛出异常</param>
        /// <returns>商品列表</returns>
        public IEnumerable <ProductRecord> WeightBarcodeAnalysis(string barcode, bool isNotFoundThrowException = false)
        {
            IEnumerable <ProductRecord>             products = new ProductRecord[0];
            IPosElectronicBalanceSettingsRepository posElectronicBalanceSettingsRepository = new PosElectronicBalanceSettingsRepository();
            var electronicBalanceSetting = posElectronicBalanceSettingsRepository.Get(true);

            if (electronicBalanceSetting.Enable && electronicBalanceSetting.MaybeWeightProduct(barcode))//处理称重商品
            {
                var productBarcode = string.Empty;
                var productCode    = string.Empty;

                IPosSystemSettingsRepository systemSettingsRepository = new PosSystemSettingsRepository();
                var settings = systemSettingsRepository.Get();
                IProductRepository productRepository = null;
                if (settings.EnableRemoteService)
                {
                    productRepository = new ProductOnlineRepository();
                }
                else
                {
                    productRepository = new ProductOfflineRepository();
                }

                if (electronicBalanceSetting.IsProductCode(barcode, out productCode))
                {
                    var product = productRepository.FindProductByProductCode(productCode);
                    products = new ProductRecord[] { product };
                }
                else if (electronicBalanceSetting.IsProductBarcode(barcode, out productBarcode))
                {
                    products = productRepository.FindProductByBarcode(productBarcode);
                }
            }
            if (isNotFoundThrowException && (products == null || products.Count() == 0))
            {
                throw new NotFoundProductException(string.Format("未能找到指定条码【{0}】的商品!", barcode));
            }
            return(products);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 普通商品条码解析
        /// </summary>
        /// <param name="barcode">条码</param>
        /// <param name="isNotFoundThrowException">当未找到商品时,是否抛出异常</param>
        /// <returns>商品列表</returns>
        public IEnumerable <ProductRecord> BarcodeAnalysis(string barcode, bool isNotFoundThrowException = false)
        {
            IEnumerable <ProductRecord> products = new ProductRecord[0];

            IPosSystemSettingsRepository systemSettingsRepository = new PosSystemSettingsRepository();
            var settings = systemSettingsRepository.Get();
            IProductRepository productRepository = null;

            if (settings.EnableRemoteService)
            {
                productRepository = new ProductOnlineRepository();
            }
            else
            {
                productRepository = new ProductOfflineRepository();
            }

            products = productRepository.FindProductByBarcode(barcode);
            if (isNotFoundThrowException && (products == null || products.Count() == 0))
            {
                throw new NotFoundProductException(string.Format("未能找到指定条码【{0}】的商品!", barcode));
            }
            return(products);
        }