答案 0 :(得分:2)
好的,这实际上是一个 ''get ftnorder data
Dim entity As New NSWebUtilityEntities
Dim ftnOrder = (From f In entity.FTNFTPOrders Where f.PONum = amazonOrder.AmazonOrderID And f.SalesOrderNum = amazonOrder.GPOrderNumber Select f).ToList()(0)
Dim fulfillmentdata As New NSAmazonFulfillmentData()
Dim carrier As Integer = (From s In entity.ShippingMethods Where s.ShippingMethodId = ftnOrder.ShippingMethodId Select s.CarrierId).ToList()(0)
fulfillmentdata.CarrierCode = (From c In entity.Carriers Where c.CarrierId = carrier Select c.Code).ToList()(0)
fulfillmentdata.CarrierName = (From c In entity.Carriers Where c.CarrierId = carrier Select c.Description).ToList()(0)
fulfillmentdata.ShipperTrackingNumber = ftnOrder.Tracking1
fulfillmentdata.ShippingMethod = (From s In entity.ShippingMethods Where s.ShippingMethodId = ftnOrder.ShippingMethodId Select s.Name).ToList()(0)
Dim appName As String = "CSharpSampleCode"
Dim appVersion As String = "1.0"
Dim serviceURL As String = "https://mws.amazonservices.com"
Dim accessKeyId As String = AmazonEntity.AccessKey
Dim secretAccessKey As String = AmazonEntity.SecretKey
Dim sellerid As String = AmazonEntity.SellerID
Dim config As New MarketplaceWebService.MarketplaceWebServiceConfig
config.ServiceURL = serviceURL
Dim service As New MarketplaceWebService.MarketplaceWebServiceClient(
accessKeyId,
secretAccessKey,
appName,
appVersion,
config)
'----create and write XML file
Dim pre_message As String = ""
pre_message = pre_message + "<Message>"
pre_message = pre_message + "<MessageID>" + "1" + "</MessageID>"
pre_message = pre_message + "<OrderFulfillment>"
pre_message = pre_message + "<AmazonOrderID>" + amazonOrder.AmazonOrderID + "</AmazonOrderID>"
Dim dd As DateTime = ftnOrder.ShipDt
pre_message = pre_message + "<FulfillmentDate>" + dd.ToUniversalTime + "</FulfillmentDate>"
pre_message = pre_message + "<FulfillmentData>"
pre_message = pre_message + "<CarrierCode>" + fulfillmentdata.CarrierCode + "</CarrierCode>"
pre_message = pre_message + "<ShippingMethod>" + fulfillmentdata.ShippingMethod + "</ShippingMethod>"
pre_message = pre_message + "<ShipperTrackingNumber>" + fulfillmentdata.ShipperTrackingNumber + "</ShipperTrackingNumber>"
pre_message = pre_message + "</FulfillmentData>"
pre_message = pre_message + "</OrderFulfillment>"
pre_message = pre_message + "<Item>"
pre_message = pre_message + "<AmazonOrderItemCode>" + amazonOrder.OrderItems(0).OrderItemId + "</AmazonOrderItemCode>"
pre_message = pre_message + "<Quantity>1</Quantity>"
pre_message = pre_message + "</Item>"
pre_message = pre_message + "</Message>"
Dim feed As String = ""
feed = feed + "<?xml version='1.0'?>"
feed = feed + "<AmazonEnvelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='amzn-envelope.xsd'> "
feed = feed + "<Header>"
feed = feed + "<DocumentVersion>1.01</DocumentVersion>"
feed = feed + "<MerchantIdentifier>" + sellerid + "</MerchantIdentifier>"
feed = feed + "</Header>"
feed = feed + "<MessageType>OrderFulfillment</MessageType>"
feed = feed + pre_message
feed = feed + "</AmazonEnvelope>"
feed.Trim()
Dim myPath As String = AppDomain.CurrentDomain.BaseDirectory + "\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "tmp.xml"
If File.Exists(myPath) Then
File.Delete(myPath)
ElseIf Not File.Exists(myPath) Then
' Create a file to write to.
Dim sw As StreamWriter = File.CreateText(myPath)
sw.Write(feed)
sw.Close()
End If
Dim request As New SubmitFeedRequest()
request.Merchant = sellerid
request.MarketplaceIdList = New IdList()
Dim m As New List(Of String)
m.Add(AmazonEntity.MarketPlaceID)
request.MarketplaceIdList.Id = New List(Of String)
request.MarketplaceIdList.Id = m
request.FeedContent = File.Open(myPath, FileMode.Open, FileAccess.Read)
request.ContentMD5 = MarketplaceWebService.MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent)
request.FeedContent.Position = 0
request.PurgeAndReplace = False
request.FeedType = "_POST_ORDER_FULFILLMENT_DATA_"
response = service.SubmitFeed(request)
Catch ex As MarketplaceWebService.MarketplaceWebServiceException
' Exception properties are important for diagnostics.
Catch ex2 As Exception
End Try
Return response
问题。
当项目存在内存管理问题时会发生这种情况。
有关这方面的更多信息可以在这里找到:
https://developer.apple.com/library/mac/recipes/xcode_help-source_editor/chapters/Analyze.html