コード例 #1
0
        private SalesOrderFeedEntry GetPayload(Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrdersRow row,
            Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsDataTable detailDataTable,
            NorthwindConfig config)
        {
            #region Declarations
            SalesOrderFeedEntry payload;
            string id;
            CountryCodes countryCodes = new CountryCodes();
            #endregion

            id = row.OrderID.ToString();

            payload = new SalesOrderFeedEntry();
            payload.UUID = GetUuid(id, "", SupportedResourceKinds.salesOrders);
            payload.active = true;

            payload.currency = config.CurrencyCode;

            payload.pricelist = new PriceListFeedEntry();
            payload.pricelist.UUID = GetUuid(id, "", SupportedResourceKinds.priceLists);

            if (!row.IsCustomerIDNull())
            {
                /*payload.tradingAccount = new TradingAccountFeedEntry();
                payload.tradingAccount.Key = Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix + row.CustomerID;
                payload.tradingAccount.UUID = GetUuid(payload.tradingAccount.Key, "", SupportedResourceKinds.tradingAccounts);
                payload.tradingAccount.Id = GetSDataId(payload.tradingAccount.Key, SupportedResourceKinds.tradingAccounts);
                payload.tradingAccount.Uri = payload.tradingAccount.Id;*/

                payload.tradingAccount = (TradingAccountFeedEntry)_tradingAccountsFeedEntryWrapper.GetFeedEntry(Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix + row.CustomerID);

            }

            if (!row.IsOrderDateNull())
            {
                payload.date = row.OrderDate;
            }

            //payload.lineCount = detailDataTable.Rows.Count;

            payload.discountTotal = row.IsDiscountAmountNull() ? new decimal(0) : Convert.ToDecimal(row.DiscountAmount);

            payload.netTotal = row.IsTotalNetPriceNull() ? new decimal(0) : Convert.ToDecimal(row.TotalNetPrice);

            payload.carrierTotalPrice = row.IsFreightNull() ? new decimal(0) : row.Freight;

            payload.grossTotal = payload.netTotal;

            if (!row.IsRequiredDateNull())
            {
                payload.dueDate = row.RequiredDate;
            }

            if (!row.IsShipViaNull())
            {
                payload.deliveryMethod = row.ShipVia.ToString(); ;
            }

            PostalAddressFeedEntry address = new PostalAddressFeedEntry();
            address.active = true;
            address.address1 = row.IsShipAddressNull() ? null : row.ShipAddress;
            address.country = row.IsShipCountryNull() ? null : row.ShipCountry;
            address.townCity = row.IsShipCityNull() ? null : row.ShipCity;
            address.zipPostCode = row.IsShipPostalCodeNull() ? null : row.ShipPostalCode;
            address.type = postalAddressTypeenum.Shipping;

            payload.postalAddresses = new PostalAddressFeed();
            //TODO: check if valid Address?
            payload.postalAddresses.Entries.Add(address);

            payload.salesOrderLines = new SalesOrderLineFeed();
            foreach (Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsRow detailRow in detailDataTable.Rows)
            {
                SalesOrderLineFeedEntry soPayload = GetLineItem(detailRow, config);
                payload.salesOrderLines.Entries.Add(soPayload);
            }

            return payload;
        }