Exemple #1
0
        public BooleanPlus ReceiveASN(PurchaseOrder purchaseOrder, AdvancedShipingNotice asn)
        {
            BooleanPlus bp = new BooleanPlus();

            if (asn.DirectInsert)
            {
            }

            if (asn.XmlFileOutput)
            {
                ASNxml xAsn = XmlOutput(purchaseOrder);

                XmlWriter w = new XmlWriter();
                w.WriteToFile(xAsn);
                XmlFormatter formatter = new XmlFormatter();
                var          zz        = formatter.Serialize <ASNxml>(xAsn);
                bp.value += zz;
            }

            return(bp);
        }
Exemple #2
0
        private ASNxml XmlOutput(PurchaseOrder po)
        {
            ASNxml ret = new ASNxml();

            ret.CreationDate     = DateTime.Now.ToLongTimeString();
            ret.Number           = po.asn.ASNNumber;
            ret.ShipmentDate     = po.asn.ShipmentDate.ToString();
            ret.ShipToCustomerID = po.asn.ShipToCustomerID;
            string customerPrefix = "";

            List <PalletXml>         pallets         = new List <PalletXml>();
            List <CartonXml>         cartons         = new List <CartonXml>();
            List <LineItemXml>       lineItems       = new List <LineItemXml>();
            List <IndividualItemXml> IndividualItems = new List <IndividualItemXml>();
            var p = new PalletXml();
            var c = new CartonXml();

            int li = 0;

            foreach (var x in po.LineItems)
            {
                if (x.Select)
                {
                    var l = new LineItemXml();

                    var product          = (from zz in entities.IMS_PRODUCTS where zz.GTIN == x.GTIN select zz).SingleOrDefault();
                    var customerSupplier = (from sc in entities.IMS_SUPPLIER_CUSTOMERS where sc.CUSTOMERID == po.CustomerID select sc).SingleOrDefault();
                    customerPrefix = product.COMPANY_PREFIX == null ? "000" : product.COMPANY_PREFIX;


                    if (product != null)
                    {
                        l.Component    = "1";
                        l.PONumber     = po.PONumber;
                        ret.SupplierID = x.SupplierID;
                        li++;
                        l.POLineItem = li.ToString();
                        l.CustomerReferenceNumber = po.POCustomerRef;
                        l.ProductID = product.LISTNUMBER;;
                        l.GTIN      = x.GTIN;
                        l.LotNumber = x.LotNumber == null?Guid.NewGuid().ToString().Substring(20) : x.LotNumber;

                        l.ExpirationDate  = x.LotExpiration.ToShortDateString();
                        l.QuantityOrdered = x.QuantityOrdered.ToString();
                        l.QuantityShipped = x.ASNQty.ToString();

                        IndividualItems = new List <IndividualItemXml>();
                        IndividualItemXml ii = new IndividualItemXml();

                        for (int i = 1; i < x.ASNQty + 1; i++)
                        {
                            ii     = new IndividualItemXml();
                            ii.epc = string.Format("urn:epc:id:sgtin:{0}.{1}.{2}", product.COMPANY_PREFIX, x.GTIN.Substring(product.COMPANY_PREFIX.Length + 1), GetNextSerialNumber(product.GTIN));
                            IndividualItems.Add(ii);
                        }

                        l.individualitems = IndividualItems;
                        lineItems.Add(l);
                    }

                    c.lineitems = lineItems;
                }
            }

            c.epc = GetEpc(customerPrefix);
            cartons.Add(c);
            p.cartons = cartons;
            p.epc     = GetEpc(customerPrefix);
            pallets.Add(p);
            ret.pallets = pallets;

            return(ret);
        }