public Product(ProductCode productCode, SupplierCode supplierCode, decimal price, CurrencyCode currencyCode)
 {
     ProductCode = productCode;
     SupplierCode = supplierCode;
     Price = price;
     CurrencyCode = currencyCode;
 }
Example #2
0
        /// <summary>
        /// 转换接口商错误代码为系统统一错误代码
        /// </summary>
        /// <param name="supp">接口商</param>
        /// <param name="errcode">错误代码</param>
        /// <returns>系统标准错误代码</returns>
        public static string ConvertSynchronousErrorCode(SupplierCode supp, string errcode)
        {
            string syscode = DefaultSysCode;

            //if (supp == SupplierCode.HuiSu) //汇速通
            //{
            //    syscode = ConvetSyncCodeForHuiSu(errcode);
            //}
            //else
            //if (supp == SupplierCode.Card51) //51
            //{
            //    syscode = ConvetSyncCodeForOf51Esales(errcode);
            //}
            //else
            if (supp == SupplierCode.OfCard) //欧飞
            {
                syscode = ConvetSyncCodeForOfCard(errcode);
            }
            else if (supp == SupplierCode.Cared70) //70卡
            {
                syscode = ConvetSyncCodeFor70Card(errcode);
            }
            //else if (supp == SupplierCode.YeePay) //易宝
            //{
            //    syscode = errcode;
            //}
            return(syscode);
        }
Example #3
0
        public ApiHealthStatus GetHealthStatus(SupplierCode supplier)
        {
            // Send off 10 requests to see how many we get back.
            var store   = Stores.First(s => s.SupplierCode == supplier);
            var success = 0;

            for (var i = 0; i < 10; i++)
            {
                try
                {
                    store.GetAllProducts();
                    success++;
                }
                catch (Exception e)
                {
                    // Swallow exception.
                }
            }

            // Grade API health.
            if (success == 10)
            {
                return(ApiHealthStatus.Good);
            }
            if (success > 5)
            {
                return(ApiHealthStatus.Fair);
            }
            if (success > 0)
            {
                return(ApiHealthStatus.Poor);
            }
            return(ApiHealthStatus.Offline);
        }
Example #4
0
        public void SetUp()
        {
            var priceParent = TestSupplier.CreateNaked(session).Prices[0];
            var price       = TestSupplier.CreateNaked(session).Prices[0];

            price.ParentSynonym = priceParent.Id;
            Save(price);
            _supplier = price.Supplier;
            var client      = TestClient.CreateNaked(session);
            var testAddress = client.Addresses[0];

            var order = new TestOrder();

            _product = new TestProduct("Виагра (табл.)");
            _product.CatalogProduct.Pharmacie = true;
            session.Save(_product);

            _producer = new TestProducer("Пфайзер");
            session.Save(_producer);
            session.Save(new TestSynonym()
            {
                Synonym = "Виагра", ProductId = _product.Id, PriceCode = (int?)price.Id
            });

            session.Save(new TestSynonymFirm()
            {
                Synonym = "Пфайзер", CodeFirmCr = (int?)_producer.Id, PriceCode = (int?)price.Id
            });

            TestAssortment.CheckAndCreate(session, _product, _producer);

            var log = new DocumentReceiveLog(session.Load <Supplier>(_supplier.Id), session.Load <Address>(testAddress.Id))
            {
                MessageUid   = 123,
                DocumentSize = 100
            };

            _doc = new Document(log)
            {
                OrderId      = order.Id,
                Address      = log.Address,
                DocumentDate = DateTime.Now
            };

            _supplierCode = new SupplierCode {
                Code       = "45678",
                Supplier   = session.Load <Supplier>(_supplier.Id),
                ProducerId = _producer.Id,
                Product    = session.Load <Product>(_product.Id),
                CodeCr     = string.Empty
            };
            session.Save(_supplierCode);

            // сопоставляется по коду
            _documentLine          = _doc.NewLine();
            _documentLine.Product  = "Виагра";
            _documentLine.Producer = " Тестовый производитель  ";
            _documentLine.Code     = "45678";
        }
Example #5
0
 public Product GetProductById(int id, SupplierCode supplier)
 {
     if (Stores.All(s => s.SupplierCode != supplier))
     {
         throw new NotSupportedException(string.Format("Could not get product " +
                                                       "by ID because the supplier '{0}' was not found in the aggregator.", supplier));
     }
     return(Stores.First(s => s.SupplierCode == supplier)
            .GetProductById(id));
 }
Example #6
0
 public bool DeleteOrder(int id, SupplierCode supplier)
 {
     if (Stores.All(s => s.SupplierCode != supplier))
     {
         throw new NotSupportedException(string.Format("Could not delete order " +
                                                       "because the supplier '{0}' was not found in the aggregator.", supplier));
     }
     return(Stores.First(s => s.SupplierCode == supplier)
            .DeleteOrder(id));
 }
 /// <summary>
 /// Find all matching. Note that productCode and supplierCode are optional but currencyCode is not.
 /// </summary>
 public IEnumerable<Product> FindMatchingProducts(ProductCode? productCode, SupplierCode? supplierCode,
                                                  CurrencyCode currencyCode)
 {
     return _allProducts
         .Where(p =>
             (!productCode.HasValue || p.ProductCode == productCode.Value)
             && (!supplierCode.HasValue || p.SupplierCode == supplierCode.Value)
             && (p.CurrencyCode == currencyCode)
         );
 }
 public GiftWrappingRange GetGiftWrappingRangeById(int id, SupplierCode supplier)
 {
     if (Suppliers.All(p => p.SupplierCode != supplier))
     {
         throw new NotSupportedException(string.Format("Could not get category " +
                                                       "by ID because the supplier '{0}' was not found in the aggregator.", supplier));
     }
     return(Suppliers.First(p => p.SupplierCode == supplier)
            .GetGiftWrappingRangeById(id));
 }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="supp"></param>
        /// <param name="errcode"></param>
        /// <returns></returns>
        public static string ConvertSynchronousErrorCode(SupplierCode supp, string errcode)
        {
            string syscode = DefaultSysCode;

            if (supp == SupplierCode.HuiSu) //汇速通
            {
                syscode = ConvetSyncCodeForHuiSu(errcode);
            }
            else if (supp == SupplierCode.Card51) //51
            {
                syscode = ConvetSyncCodeForOf51Esales(errcode);
            }
            else if (supp == SupplierCode.OfCard) //欧飞
            {
                syscode = ConvetSyncCodeForOfCard(errcode);
            }
            else if (supp == SupplierCode.YeePay) //易宝
            {
                syscode = errcode;
            }
            return(syscode);
        }
Example #10
0
        public override string ToString()
        {
            string output = "";

            output += "Description: " + Description + Environment.NewLine;
            output += "Status: " + Status + Environment.NewLine;
            output += "Revision: " + Revision + Environment.NewLine;
            output += "PartNumber: " + PartNumber.ToString() + Environment.NewLine;
            output += "Material: " + Material + Environment.NewLine;
            output += "WorkCentres: " + Environment.NewLine;
            foreach (var item in WorkCentres)
            {
                output += "\t" + item + Environment.NewLine;
            }
            output += "Length: " + Length.ToString() + Environment.NewLine;
            output += "Mass: " + Mass.ToString() + Environment.NewLine;
            output += "Finish: " + Finish + Environment.NewLine;
            output += "PurchaseInfo: " + PruchaseInfo + Environment.NewLine;
            output += "SupplierName: " + SupplierName + Environment.NewLine;
            output += "SupplierCode: " + SupplierCode.ToString() + Environment.NewLine;
            output += "Note: " + Note + Environment.NewLine;

            return(output);
        }
Example #11
0
 /// <summary>
 /// Initializes a new instance of an error that occured while querying a supplier.
 /// </summary>
 /// <param name="exception">The underlying exception that was raised.</param>
 /// <param name="supplierCode">The supplier code for the integration that threw the error.</param>
 /// <param name="additionalInformation">Gets any additional information about the error.</param>
 public SupplierError(Exception exception, SupplierCode supplierCode, string additionalInformation = null)
 {
     Exception             = exception;
     SupplierCode          = supplierCode;
     AdditionalInformation = additionalInformation;
 }
Example #12
0
 public MatSupplierInfoAddView()
 {
     InitializeComponent();
     SupplierCode.Focus();
 }
Example #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static CardSynchCallBack SendCard(
            SupplierCode supplier
            , CardOrderSummitArgs o)
        {
            var cardsend = new OrderCardSend()
            {
                orderid      = o.SysOrderNo,
                source       = o.Source,
                suppId       = (int)supplier,
                success      = 0,
                summitStatus = 0,
                orderStatus  = 1,
                typeid       = o.CardTypeId,
                facevalue    = o.FaceValue,
                cardno       = o.CardNo,
                cardpass     = o.CardPass,
                suppTransNo  = "",
                errCode      = "",
                errMsg       = "",
                responseText = "",
                initTime     = DateTime.Now,
                message      = ""
            };

            var callback = new CardSynchCallBack();

            switch (supplier)
            {
            case SupplierCode.OfCard:
                callback = OfCard.Card.Default.CardSend(o);
                break;

            case SupplierCode.Cared70:
                callback = Cared70.Card.Default.CardSend(o);
                break;
                #region 暂时用不到的接口
            //case SupplierCode.Card51:
            //    callback = Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.HuiYuan:
            //    callback = HuiYuan.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.HuiSu:
            //    callback = HuiSu.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.Shengpay:
            //    callback = Shengpay.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.Card60866:
            //    callback = Card60866.Card.Default.CardSend(o);
            //    break;

            //case SupplierCode.TaoShang:
            //    callback = TaoShang.Card.Default.CardSend(o);
            //    break;

            case SupplierCode.Card15173:
                callback = Card15173.Card.Default.CardSend(o);
                break;
                #endregion
            }

            cardsend.orderStatus  = callback.OrderStatus;
            cardsend.errCode      = callback.SuppErrorCode;
            cardsend.errMsg       = callback.SuppErrorMsg;
            cardsend.responseText = callback.SuppCallBackText;
            cardsend.suppTransNo  = callback.SuppTransNo;
            cardsend.success      = callback.Success;
            cardsend.summitStatus = callback.SummitStatus;
            cardsend.completeTime = DateTime.Now;

            CardSendBll.Add(cardsend);

            return(callback);
        }
Example #14
0
        /// <summary>
        /// 提交到点卡供应商接口
        /// </summary>
        /// <param name="supplier">供应商编号</param>
        /// <param name="orderid">订单ID</param>
        /// <param name="cardtype">卡类型</param>
        /// <param name="cardno">卡号</param>
        /// <param name="cardpass">卡密</param>
        /// <param name="attach"></param>
        /// <param name="facevalue">面值</param>
        /// <param name="source"></param>
        /// <returns></returns>
        public static CardSynchCallBack SynchSubmit(
            SupplierCode supplier
            , string orderid
            , int cardtype
            , string cardno
            , string cardpass
            , int facevalue
            , string attach
            , byte source)
        {
            var args = new CardOrderSummitArgs()
            {
                SysOrderNo = orderid,
                CardTypeId = cardtype,
                CardNo     = cardno,
                CardPass   = cardpass,
                FaceValue  = facevalue,
                Attach     = attach,
                Source     = source
            };

            var callBack = SendCard(supplier, args);

            if (callBack.Success == 0)
            {
                //todo:点卡切换通道提交,修改为按优先级高低排序
                #region 切换通道多次提交
                var supplierInfo = viviapi.BLL.Supplier.Factory.GetCacheModel((int)supplier);
                var channelInfo  = BLL.Channel.ChannelType.GetCacheModel(cardtype);

                if (channelInfo != null && supplierInfo != null)
                {
                    if (callBack.Success == 0 || CheckRetCode(callBack.SuppErrorCode, supplierInfo))
                    {
                        string suppList = channelInfo.SuppsWhenExceOccurred;
                        if (!string.IsNullOrEmpty(suppList))
                        {
                            string[] arr = suppList.Split(',');

                            foreach (string s in arr)
                            {
                                try
                                {
                                    callBack.SupplierId = int.Parse(s);

                                    var supplier2 = (SupplierCode)callBack.SupplierId;

                                    if (supplier2 == supplier)
                                    {
                                        continue;
                                    }
                                    callBack = SendCard(supplier2, args);

                                    if (callBack.Success == 1 && !CheckRetCode(callBack.SuppErrorCode, supplierInfo))
                                    {
                                        break;
                                    }
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }
                #endregion
            }

            return(callBack);
        }
        public void DocumentSetIdTest()
        {
            var price       = TestSupplier.CreateTestSupplierWithPrice();
            var supplier    = price.Supplier;
            var client      = TestClient.CreateNaked();
            var testAddress = client.Addresses[0];

            var order = new TestOrder();

            var product1 = new TestProduct("Активированный уголь (табл.)");

            product1.CatalogProduct.Pharmacie = true;
            session.Save(product1);
            var product2 = new TestProduct("Виагра (табл.)");

            product2.CatalogProduct.Pharmacie = true;
            session.Save(product2);
            var product3 = new TestProduct("Крем для кожи (гель.)");

            product3.CatalogProduct.Pharmacie = false;
            session.Save(product3);
            var product4 = new TestProduct("Эластичный бинт");

            product4.CatalogProduct.Pharmacie = false;
            session.Save(product4);
            var product5 = new TestProduct("Стерильные салфетки");

            product5.CatalogProduct.Pharmacie = false;
            session.Save(product5);
            var product6 = new TestProduct("Аспирин (табл.)");

            product6.CatalogProduct.Pharmacie = false;
            session.Save(product6);

            var producer1 = new TestProducer("ВероФарм");

            session.Save(producer1);
            var producer2 = new TestProducer("Пфайзер");

            session.Save(producer2);
            var producer3 = new TestProducer("Воронежская Фармацевтическая компания");

            session.Save(producer3);
            session.Save(new TestSynonym {
                Synonym = "Активированный уголь", ProductId = product1.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonym {
                Synonym = "Виагра", ProductId = product2.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonym {
                Synonym = "Крем для кожи", ProductId = product3.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonym {
                Synonym = "Аспирин", ProductId = product6.Id, PriceCode = (int?)price.Id
            });


            session.Save(new TestSynonymFirm {
                Synonym    = "ВероФарм",
                CodeFirmCr = (int?)producer1.Id,
                PriceCode  = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym = "Пфайзер", CodeFirmCr = (int?)producer1.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym = "Пфайзер", CodeFirmCr = (int?)producer2.Id, PriceCode = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym    = "Верофарм",
                CodeFirmCr = (int?)producer2.Id,
                PriceCode  = (int?)price.Id
            });
            session.Save(new TestSynonymFirm {
                Synonym    = "ВоронежФарм",
                CodeFirmCr = (int?)producer3.Id,
                PriceCode  = (int?)price.Id
            });

            TestAssortment.CheckAndCreate(product1, producer1);
            TestAssortment.CheckAndCreate(product2, producer2);

            var supplierCode2 = new SupplierCode {
                Code       = "45678",
                Supplier   = session.Load <Supplier>(supplier.Id),
                ProducerId = producer2.Id,
                Product    = session.Load <Product>(product2.Id),
                CodeCr     = "1"
            };

            session.Save(supplierCode2);
            var supplierCode4 = new SupplierCode {
                Code       = "789",
                Supplier   = session.Load <Supplier>(supplier.Id),
                ProducerId = producer2.Id,
                Product    = session.Load <Product>(product4.Id),
                CodeCr     = "2"
            };

            session.Save(supplierCode4);
            var supplierCode5 = new SupplierCode {
                Code       = "12345",
                Supplier   = session.Load <Supplier>(supplier.Id),
                ProducerId = producer3.Id,
                Product    = session.Load <Product>(product5.Id),
                CodeCr     = "3"
            };

            session.Save(supplierCode5);

            var log = new DocumentReceiveLog {
                Supplier     = session.Load <Supplier>(supplier.Id),
                ClientCode   = client.Id,
                Address      = session.Load <Address>(testAddress.Id),
                MessageUid   = 123,
                DocumentSize = 100
            };

            var doc = new Document(log)
            {
                OrderId      = order.Id,
                Address      = log.Address,
                DocumentDate = DateTime.Now
            };

            // сопоставляется по наименованию, фармацевтика, product1, producer1
            var line = doc.NewLine();

            line.Product  = "Активированный уголь";
            line.Producer = "ВероФарм";

            // сопоставляется по коду, product2, producer2
            line          = doc.NewLine();
            line.Product  = "Виагра";
            line.Producer = " Тестовый производитель  ";
            line.Code     = "45678";
            line.CodeCr   = "1";

            // сопоставляется по наименованию, product3, производитель - null
            line          = doc.NewLine();
            line.Product  = " КРЕМ ДЛЯ КОЖИ  ";
            line.Producer = "Тестовый производитель";

            // сопоставляется по коду, product4, producer2
            line          = doc.NewLine();
            line.Product  = "эластичный бинт";
            line.Producer = "Воронежфарм";
            line.Code     = "789";
            line.CodeCr   = "2";

            // сопоставляется по коду, product5, producer3
            line          = doc.NewLine();
            line.Product  = "Салфетки";
            line.Producer = "Воронежфарм";
            line.Code     = "12345";
            line.CodeCr   = "3";

            // сопоставляется по наименованию, потому как такого кода нет в базе, product6, producer3
            line          = doc.NewLine();
            line.Product  = "Аспирин";
            line.Producer = "Воронежфарм";
            line.Code     = "1952";

            // не сопоставляется, везде null
            line          = doc.NewLine();
            line.Product  = "Неизвестный продукт";
            line.Producer = "Воронежфарм";
            line.Code     = "1952";

            Reopen();

            doc.SetProductId();

            Assert.That(doc.Lines[0].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[0].ProductEntity.Id, Is.EqualTo(product1.Id));
            Assert.That(doc.Lines[0].ProducerId, Is.EqualTo(producer1.Id));
            Assert.That(doc.Lines[1].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[1].ProductEntity.Id, Is.EqualTo(product2.Id));
            Assert.That(doc.Lines[1].ProducerId, Is.EqualTo(producer2.Id));
            Assert.That(doc.Lines[2].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[2].ProductEntity.Id, Is.EqualTo(product3.Id));
            Assert.That(doc.Lines[2].ProducerId, Is.Null);
            Assert.That(doc.Lines[3].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[3].ProductEntity.Id, Is.EqualTo(product4.Id));
            Assert.That(doc.Lines[3].ProducerId, Is.EqualTo(producer2.Id));
            Assert.That(doc.Lines[4].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[4].ProductEntity.Id, Is.EqualTo(product5.Id));
            Assert.That(doc.Lines[4].ProducerId, Is.EqualTo(producer3.Id));
            Assert.That(doc.Lines[5].ProductEntity, Is.Not.Null);
            Assert.That(doc.Lines[5].ProductEntity.Id, Is.EqualTo(product6.Id));
            Assert.That(doc.Lines[5].ProducerId, Is.EqualTo(producer3.Id));
            Assert.That(doc.Lines[6].ProductEntity, Is.Null);
            Assert.That(doc.Lines[6].ProducerId, Is.Null);
        }
Example #16
0
 public OrderLine PlaceOrder(int productId, int quantity, string accountName, string cardNumber, SupplierCode supplier)
 {
     if (Stores.All(s => s.SupplierCode != supplier))
     {
         throw new NotSupportedException(string.Format("Could not place order " +
                                                       "because the supplier '{0}' was not found in the aggregator.", supplier));
     }
     return(Stores.First(s => s.SupplierCode == supplier)
            .PlaceOrder(productId, quantity, accountName, cardNumber));
 }