Esempio n. 1
0
        public void LogOrder(object orderInformation, int vendorID, string fileName, AuditLog4Net.Adapter.IAuditLogAdapter log)
        {
            try
            {
                var logPath = ConfigurationManager.AppSettings["ConcentratorOrderLog"];

                logPath = Path.Combine(logPath, DateTime.Now.ToString("yyyyMMdd"), vendorID.ToString());

                if (!Directory.Exists(logPath))
                {
                    Directory.CreateDirectory(logPath);
                }

                var order = (BrightPointOrder.Order1_1)orderInformation;

                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(order.GetType());

                using (FileStream fs = File.Open(
                           Path.Combine(logPath, fileName),
                           FileMode.OpenOrCreate,
                           FileAccess.Write,
                           FileShare.ReadWrite))
                {
                    x.Serialize(fs, order);
                }
            }
            catch (Exception ex)
            {
                log.AuditError("Failed to log order information for " + vendorID, ex);
            }
        }
Esempio n. 2
0
        public void LogOrder(object orderInformation, int vendorID, string fileName, AuditLog4Net.Adapter.IAuditLogAdapter log)
        {
            try
            {
                var logPath = ConfigurationManager.AppSettings["ConcentratorOrderLog"];

                logPath = Path.Combine(logPath, DateTime.Now.ToString("yyyyMMdd"), vendorID.ToString());

                if (!Directory.Exists(logPath))
                {
                    Directory.CreateDirectory(logPath);
                }

                ((XDocument)orderInformation).Save(Path.Combine(logPath, fileName));
            }
            catch (Exception ex)
            {
                log.AuditError("Failed to log order information for " + vendorID, ex);
            }
        }
Esempio n. 3
0
        public void GetAvailableDispatchAdvices(Vendor vendor, AuditLog4Net.Adapter.IAuditLogAdapter log, string logPath, IUnitOfWork unit)
        {
            FtpManager acknowledgementManager = new FtpManager(vendor.VendorSettings.GetValueByKey("LenmarFtpUrl", string.Empty),
                                                               vendor.VendorSettings.GetValueByKey("LenmarFtpPathACK", string.Empty),
                                                               vendor.VendorSettings.GetValueByKey("LenmarUserName", string.Empty),
                                                               vendor.VendorSettings.GetValueByKey("LenmarPassword", string.Empty), true, true, log);

            ProcessNotifications(acknowledgementManager, OrderResponseTypes.Acknowledgement, log, vendor, logPath, unit);

            FtpManager shipmentNotificationManager = new FtpManager(vendor.VendorSettings.GetValueByKey("LenmarFtpUrl", string.Empty),
                                                                    vendor.VendorSettings.GetValueByKey("LenmarFtpPathASN", string.Empty),
                                                                    vendor.VendorSettings.GetValueByKey("LenmarUserName", string.Empty),
                                                                    vendor.VendorSettings.GetValueByKey("LenmarPassword", string.Empty), true, true, log);

            ProcessNotifications(shipmentNotificationManager, OrderResponseTypes.ShipmentNotification, log, vendor, logPath, unit);

            FtpManager InvoiceNotificationManager = new FtpManager(vendor.VendorSettings.GetValueByKey("LenmarFtpUrl", string.Empty),
                                                                   vendor.VendorSettings.GetValueByKey("LenmarFtpPathInvoice", string.Empty),
                                                                   vendor.VendorSettings.GetValueByKey("LenmarUserName", string.Empty),
                                                                   vendor.VendorSettings.GetValueByKey("LenmarPassword", string.Empty), true, true, log);

            ProcessNotifications(InvoiceNotificationManager, OrderResponseTypes.InvoiceNotification, log, vendor, logPath, unit);
        }
Esempio n. 4
0
        public int DispatchOrders(Dictionary <Concentrator.Objects.Models.Orders.Order, List <OrderLine> > orderLines, Vendor vendor, AuditLog4Net.Adapter.IAuditLogAdapter log, IUnitOfWork unit)
        {
            var vendorID = vendor.VendorID;

            var CustNo      = vendor.VendorSettings.GetValueByKey("BrightPointCustomerNo", string.Empty);
            var Pass        = vendor.VendorSettings.GetValueByKey("BrightPointPassword", string.Empty);
            var Instance    = vendor.VendorSettings.GetValueByKey("BrightPointInstance", string.Empty);
            var Site        = vendor.VendorSettings.GetValueByKey("BrightPointSite", string.Empty);
            var ConfirmMail = vendor.VendorSettings.GetValueByKey("ConfirmationMailAdress", string.Empty);

            var OrdersToProcess = new Dictionary <int, bool>();


            BrightPointOrder.clsWsOrderSoapClient client = new BrightPointOrder.clsWsOrderSoapClient();

            // Concentrator.Web.ServiceClient.B
            foreach (var order in orderLines.Keys)
            {
                OrdersToProcess.Add(order.OrderID, false);

                BrightPointOrder.Order_V11 newOrder = new BrightPointOrder.Order_V11();

                newOrder.SecurityToken            = new BrightPointOrder.SecurityToken();
                newOrder.SecurityToken.customerNo = CustNo;
                newOrder.SecurityToken.password   = Pass;

                newOrder.oOrders = new BrightPointOrder.Order1_1
                {
                    //Header met order info
                    oOrderH = new BrightPointOrder.OrderHeader1_1
                    {
                        sMessageType                   = "WEBSERVICE",
                        sMessageDate                   = DateTime.Now.Date.ToString("yyyyMMdd"),
                        sMessageTime                   = DateTime.Now.ToString("Hhmmss"),
                        sSite                          = "GBG",
                        sOrderType                     = "WSO",
                        sSenderOrderNumberAtBP         = order.OrderID.ToString(),
                        sOrderDate                     = DateTime.Now.Date.ToString("yyyyMMdd"),
                        sSenderCustomerNumberAtBP      = CustNo,
                        sSenderDeliveryNote            = "TRUE",
                        sOrderConfirmationEmailAddress = ConfirmMail,
                        sConfirmationEmailAddress      = ConfirmMail,
                        sUse3PReceiver                 = "TRUE",
                        sReceiverName                  = order.ShippedToCustomer.CustomerName,
                        sReceiverDeliveryAddress1      = order.ShippedToCustomer.CustomerAddressLine1,
                        sReceiverDeliveryPostalCode    = order.ShippedToCustomer.PostCode,
                        sReceiverDeliveryCity          = order.ShippedToCustomer.City,
                        sReceiverDeliveryCounty        = order.ShippedToCustomer.Country,
                        sReceiverEmail                 = order.ShippedToCustomer.CustomerEmail,
                        sReceiverTelephone             = order.ShippedToCustomer.CustomerTelephone,
                        sSenderEAN                     = order.ShippedToCustomer.EANIdentifier,
                        sSenderInvoice                 = "TRUE",
                        sSenderOrderConfirmation       = "TRUE"
                    },
                    oOrderR = new BrightPointOrder.OrderRows1_1[order.OrderLines.Count]
                };

                int count = 0;
                foreach (var itemOrder in order.OrderLines)
                {
                    //order rows
                    newOrder.oOrders.oOrderR[count] = new BrightPointOrder.OrderRows1_1
                    {
                        iOrderLineNumber       = itemOrder.OrderLineID,
                        sEANArticleNumber      = itemOrder.Product.ProductBarcodes.FirstOrDefault() != null?itemOrder.Product.ProductBarcodes.FirstOrDefault().Barcode : null,
                        iNumberOfArticle       = itemOrder.GetDispatchQuantity(),
                        dReceiverPriceAtSender = 0//(double)itemOrder.Price.Value
                    };
                    count++;
                }

                BrightPointOrder.Response response = client.SendBPeDI(newOrder.SecurityToken, newOrder.oOrders);
                if (response.aErrorCode == null)
                {
                    //order successfully placed
                    foreach (var ob in OrdersToProcess.Keys)
                    {
                        //update
                        OrdersToProcess[ob] = true;
                    }
                }
                else
                {
                    string error = string.Format("OrderID: {0} Error: ", order.OrderID);
                    foreach (int code in response.aErrorCode)
                    {
                        switch (code)
                        {
                        case 110:
                            error += "110 Internal Connection Error, ";
                            break;

                        case 120:
                            error += "120 Internal Webservice Error, ";
                            break;

                        case 210:
                            error += "210 Internal IFS Connection Error, ";
                            break;

                        case 225:
                            error += "225 sOrderType (Invalid Order Type), ";
                            break;

                        case 410:
                            error += "410 IFS SOAP Gateway Error, ";
                            break;

                        case 500:
                            error += "500 The field is invalid, ";
                            break;

                        case 669:
                            error += "669 Invalid request, ";
                            break;

                        case 700:
                            error += "700 Mandatory field, ";
                            break;

                        case 701:
                            error += "701 The field is to long, ";
                            break;

                        case 702:
                            error += "702 The field must be a specified length, ";
                            break;

                        case 704:
                            error += "704 Is mandatory because of another field, ";
                            break;

                        case 705:
                            error += "705 Invalid date format, ";
                            break;

                        case 750:
                            error += "750 Communication error, ";
                            break;

                        case 800:
                            error += "800 Login failed, ";
                            break;

                        case 801:
                            error += "801 You are not registered as a web service-user for BPeDI, ";
                            break;

                        case 900:
                            error += "900 Duplicates of SenderOrderNumberAtBP, ";
                            break;

                        default:
                            break;
                        }
                    }
                    throw new Exception(error);
                }

                LogOrder(newOrder, vendor.VendorID, string.Format("{0}.xml", order.OrderID), log);
            }
            return(0);
        }
Esempio n. 5
0
        public int DispatchOrders(Dictionary <Concentrator.Objects.Models.Orders.Order, List <OrderLine> > orderLines, Vendor vendor, AuditLog4Net.Adapter.IAuditLogAdapter log, IUnitOfWork unit)
        {
            XNamespace aw = "http://logictec.com/schemas/internaldocuments";

            foreach (var Order in orderLines.Keys)
            {
                var envelopeHeader = new XElement("EnvelopeHeader",
                                                  new XElement("Mode", new XAttribute("xmlns", ""), "Production"),
                                                  new XElement("PartnerIdentifier", new XAttribute("xmlns", ""), "BASGROUP"),
                                                  new XElement("EnvelopeControlNumber", new XAttribute("xmlns", ""), "000000002"),
                                                  new XElement("DocumentType", new XAttribute("xmlns", ""), "PurchaseOrder"),
                                                  new XElement("DocumentDateTime", new XAttribute("xmlns", ""), DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"))
                                                  );


                var messages = new XElement("{http://logictec.com/schemas/internaldocuments}PurchaseOrder", new XAttribute(XNamespace.Xmlns + "int", "http://logictec.com/schemas/internaldocuments"),

                                            new XElement("{http://logictec.com/schemas/internaldocuments}OrderHeader",
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}PartnerPO", Order.OrderID),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}SupplierPO", Order.WebSiteOrderNumber),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}EndUserPO", Order.CustomerOrderReference),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}Email", Order.ShippedToCustomer.CustomerEmail),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}PODateTime", DateTime.Now.ToString("yyyy-MM-dd")),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToCompany"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToAddress1", Order.ShippedToCustomer.CustomerAddressLine1 + " " + Order.ShippedToCustomer.HouseNumber),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToAddress2", Order.ShippedToCustomer.CustomerAddressLine2),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToCity", Order.ShippedToCustomer.City),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToState"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToZip", Order.ShippedToCustomer.PostCode),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToContact", Order.ShippedToCustomer.CustomerName),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToPhone", Order.ShippedToCustomer.CustomerTelephone),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToFName"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToLName", Order.ShippedToCustomer.CustomerName),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToFax"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}ShipToCountryCode", Order.ShippedToCustomer.Country),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}HandlingAmt"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}HandlingTax"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}MiscAmt"),
                                                         new XElement("{http://logictec.com/schemas/internaldocuments}MiscTax")
                                                         ),

                                            new XElement("{http://logictec.com/schemas/internaldocuments}OrderItems",
                                                         from line in orderLines[Order]
                                                         let assortmentItem = line.Product.VendorAssortments.FirstOrDefault(c => c.VendorID == vendor.VendorID)
                                                                              where line.Product != null
                                                                              select
                                                                              new XElement("{http://logictec.com/schemas/internaldocuments}OrderItem",

                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}LineID", Order.OrderLines.ToList().IndexOf(line)),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}PartnerLineID", line.OrderLineID),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}Qty", line.GetDispatchQuantity()),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}PartnerSku", line.ProductID),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}SupplierSKU", assortmentItem.CustomItemNumber),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}CustomerPrice", Math.Floor((assortmentItem.VendorPrices.FirstOrDefault() != null ? (double)assortmentItem.VendorPrices.FirstOrDefault().Price.Value : line.Price.Value) * 100)),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}Description", assortmentItem.ShortDescription),
                                                                                           new XElement("{http://logictec.com/schemas/internaldocuments}RequestedShipDate", DateTime.Now.ToString(@"yyyy-MM-dd"))


                                                                                           ))


                                            );
                XDocument docs = new XDocument(
                    new XElement(aw + "Envelope", new XAttribute("xmlns", "http://logictec.com/schemas/internaldocuments"),
                                 new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),

                                 envelopeHeader,
                                 new XElement("Messages", messages

                                              )));
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(docs.ToString().Replace("<EnvelopeHeader xmlns=\"\">", "<EnvelopeHeader>"));

                FtpManager manager = new FtpManager(vendor.VendorSettings.GetValueByKey("LenmarFtpUrl", string.Empty),
                                                    vendor.VendorSettings.GetValueByKey("LenmarFtpPath", string.Empty),
                                                    vendor.VendorSettings.GetValueByKey("LenmarUserName", string.Empty),
                                                    vendor.VendorSettings.GetValueByKey("LenmarPassword", string.Empty), true, true, log);

                string fileName = string.Format("LenmarExport-{0}.xml", Order.OrderID);

                using (Stream s = new MemoryStream())
                {
                    doc.Save(s);
                    manager.Upload(s, fileName);
                }

                LogOrder(doc, vendor.VendorID, fileName, log);
            }
            return(0);
        }