private static void UpdateTrackingNumberDetails(SOGetFBATrackingNumberProcess graph, List <SOProcessOrder> list, SOAmazonSetup objSOAmazonSetupDetails, SOOrderEntry orderEntry, SOPartialMaint objPartialMaint, InvokeReporstServicesCallResponse liShipmentResponse) { string trackingNumber = string.Empty; string carrier = string.Empty; foreach (SOProcessOrder currentRecord in list) { try { if (liShipmentResponse != null && liShipmentResponse.objShipmentResponse != null && liShipmentResponse.objShipmentResponse.Count > 0) { trackingNumber = SOHelper.GetTrackingForFBAOrders(currentRecord.AmazonOrderID, liShipmentResponse.objShipmentResponse, out carrier); currentRecord.AmazonTrackingNumber = !string.IsNullOrEmpty(trackingNumber) ? trackingNumber : null; currentRecord.Carrier = !string.IsNullOrEmpty(carrier) ? carrier : null; graph.TrackingNumberOrdersList.Cache.Update(currentRecord); SOOrder objSOOrder = objPartialMaint.SOOrderView.Select(objSOAmazonSetupDetails.OrderType, currentRecord.AmazonOrderID); if (objSOOrder != null) { PXNoteAttribute.SetNote(orderEntry.Document.Cache, objSOOrder, trackingNumber); orderEntry.Document.Cache.Update(objSOOrder); orderEntry.Actions.PressSave(); } } } catch (Exception ex) { throw new PXException(ex.Message); } } }
private MarketplaceWebService.MarketplaceWebService Configurations(string intergrationType, string accessKey, string secretKey) { MarketplaceWebService.MarketplaceWebServiceConfig config = new MarketplaceWebService.MarketplaceWebServiceConfig(); config.ServiceURL = SOHelper.GetIntegrationType(intergrationType.Trim(), SOConstants.serviceUrl); MarketplaceWebService.MarketplaceWebService serviceConfig = new MarketplaceWebService.MarketplaceWebServiceClient(accessKey, secretKey, SOConstants.appName, SOConstants.version, config); return(serviceConfig); }
public virtual void GetAmazonOrdersbyNextToken(SOScheduleProcess graph, PrepareAndImportOrdersParams objScheduleParams, ref bool isErrorOccured) { objSyncOrderResponse = new InvokeServicesCallResponse(); amwOrders = new List <Order>(); amwLineItems = new List <OrderItem>(); objServiceCallParams = new ServiceCallParameters(); objServiceCallParams.objSOAmazonSetup = objScheduleParams.objSOAmazonSetup; objServiceCallParams.amwOrderID = string.Empty; objServiceCallParams.methodCall = SOConstants.invokeListOrdersByNextToken; objServiceCallParams.fromDate = objScheduleParams.objSOPrepareAndImport.LastSyncDate; objServiceCallParams.toDate = objScheduleParams.objSOPrepareAndImport.ToDate; objServiceCallParams.nextToken = objScheduleParams.objNextToken; objSyncOrderResponse = new SOOrdersServiceCall(clientOrder).InvokeServicesCalls(graph, objServiceCallParams); if (objSyncOrderResponse != null && objSyncOrderResponse.objListOrdersByNextToken != null && objSyncOrderResponse.objListOrdersByNextToken.ListOrdersByNextTokenResult != null && objSyncOrderResponse.objListOrdersByNextToken.ListOrdersByNextTokenResult.Orders.Count > 0) { amwOrders = objSyncOrderResponse.objListOrdersByNextToken.ListOrdersByNextTokenResult.Orders.ToList(); objScheduleParams.amwOrders = amwOrders; SOHelper.PrepareRecord(graph, objScheduleParams, ref isErrorOccured); if (objSyncOrderResponse.objListOrdersByNextToken.ListOrdersByNextTokenResult.NextToken != null) { objScheduleParams.objNextToken = objSyncOrderResponse.objListOrdersByNextToken.ListOrdersByNextTokenResult.NextToken; GetAmazonOrdersbyNextToken(graph, objScheduleParams, ref isErrorOccured); } } }
private ListOrdersResponse InvokeListOrders(PXGraph graph, ServiceCallParameters objParams) { ListOrdersResponse response = new ListOrdersResponse(); try { ListOrdersRequest request = new ListOrdersRequest(); request.SellerId = objParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; List <string> marketplaceId = new List <string>(); marketplaceId.Add(objParams.objSOAmazonSetup.MarketplaceId); request.MarketplaceId = marketplaceId; request.CreatedAfter = Convert.ToDateTime(objParams.fromDate); if (objParams.toDate.Value.Date < DateTime.Now.Date) { request.CreatedBefore = objParams.toDate.Value.AddDays(1).AddTicks(-1); } PXTrace.WriteInformation("objParams.fromDate.Value.Date:" + objParams.fromDate.Value.Date.ToString()); PXTrace.WriteInformation("objParams.toDate.Value.Date:" + objParams.toDate.Value.Date.ToString()); PXTrace.WriteInformation("request.CreatedAfter:" + request.CreatedAfter.ToString()); PXTrace.WriteInformation("request.CreatedBefore:" + request.CreatedBefore.ToString()); List <string> liFulfillmentChannel = null; List <string> liOrderStatus = null; SOHelper.GetFilterValues(objParams.objSOAmazonSetup.IntegrationType.Trim(), out liFulfillmentChannel, out liOrderStatus); request.FulfillmentChannel = liFulfillmentChannel; request.OrderStatus = liOrderStatus; response = this.clientOrder.ListOrders(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceOrdersException) { MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiListOrders)); response = InvokeListOrders(graph, objParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(response); }
public static void CreateSalesOrderandPayments(PrepareAndImportOrdersParams objParams) { try { using (PXTransactionScope ts = new PXTransactionScope()) { if (objParams.objliUsrMapping.Where(X => X.IntegrationID == objParams.objSOProcessOrderRecord.IntegrationID).Count() == 0) { objParams.objliUsrMapping.Clear(); objParams.objliUsrMapping = SOHelper.GetUsrFieldMapping(objParams.objSOOrderEntry, objParams.objSOProcessOrderRecord.IntegrationID); } if (objParams.objliUsrMapping.Count > 0) { CreateSO objCreateSO = new CreateSO(); objCreateSO.SetSOHeaderObjectsData(objParams); objCreateSO.SetSOLineObjectsData(objParams); objCreateSO.SetBillingContactObjectsData(objParams); objCreateSO.SetBillingAddressobjectsData(objParams); objCreateSO.SetFinancialInformationobjectsData(objParams); objCreateSO.SetShippingContactObjectsData(objParams); objCreateSO.SetShippingAddressObjectsData(objParams); objCreateSO.SetFreightData(objParams); objCreateSO.SetDocumentLevelDiscountandTaxData(objParams); //Validate order total - decimal dAmazonTotal = 0; Decimal.TryParse(objParams.ObjCurrentOrder.OrderTotal.Amount, out dAmazonTotal); if (dAmazonTotal != objParams.objSOOrderEntry.Document.Current.CuryOrderTotal.GetValueOrDefault(0)) { throw new PXException(SOMessages.ErrorOrderTotalNotMatch); } objParams.objSOOrderEntry.Actions.PressSave(); objCreateSO.CreatePaymentProcess(objParams); if (objParams.objSOOrderEntry.Document.Current != null && !string.IsNullOrEmpty(objParams.objSOOrderEntry.Document.Current.OrderNbr)) { ts.Complete(); SOLogService.LogImportStatus(objParams, true, SOMessages.sucess); PXProcessing <SOProcessOrder> .SetInfo(objParams.CurrentOrderIndex, SOMessages.sucess); } } else { throw new PXException(SOMessages.FieldMappingEmptyErrMsg); } } } catch (Exception ex) { throw ex; } }
private void SetShippingAddressObjectsData(PrepareAndImportOrdersParams orderParams) { orderParams.objSOOrderEntry.Shipping_Address.Current = (SOShippingAddress)orderParams.objSOOrderEntry.Shipping_Address.Select(); if (orderParams.objSOOrderEntry.Shipping_Address.Current != null) { if (orderParams.objliUsrMapping.Where(x => (x.TargetObject == orderParams.objSOOrderEntry.Shipping_Address.View.Name)).Count() > 0) { orderParams.objSOOrderEntry.Shipping_Address.Current.OverrideAddress = true; orderParams.objSOOrderEntry.Shipping_Address.Update(orderParams.objSOOrderEntry.Shipping_Address.Current); AssignValueAsPerIntegrationMapping(orderParams.objliUsrMapping, orderParams.objSOOrderEntry.Shipping_Address.Current, orderParams.ObjCurrentOrder, null, orderParams.objSOOrderEntry.Shipping_Address.View.Name); if (orderParams.objSOOrderEntry.Shipping_Address.Current.State != null) { orderParams.objSOOrderEntry.Shipping_Address.Current.State = SOHelper.GetStateID(orderParams.objSOOrderEntry, orderParams.objSOOrderEntry.Shipping_Address.Current.State, orderParams.objSOOrderEntry.Shipping_Address.Current.CountryID); } orderParams.objSOOrderEntry.Shipping_Address.Update(orderParams.objSOOrderEntry.Shipping_Address.Current); } } }
public virtual void UpdateReportDetails(SOGetFBATrackingNumberProcess graph, List <SOProcessOrder> list, SOTrackingReportFilter currentFilter) { if (list.Count < 0) { return; } if (currentFilter.CurrentDay == false && Convert.ToInt32((Convert.ToDateTime(currentFilter.TODate) - Convert.ToDateTime(currentFilter.FromDate)).TotalDays) > SOConstants.limitForReports) { throw new PXException(SOMessages.ReportDateValidation); } SOAmazonSetup objSOAmazonSetupDetails = null; SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>(); SOPartialMaint objPartialMaint = PXGraph.CreateInstance <SOPartialMaint>(); orderEntry.Clear(); InvokeReporstServicesCallResponse liShipmentResponse = null; bool isValidConfiguration = SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objSOAmazonSetupDetails); if (currentFilter.IntegrationID != null && currentFilter.ProcessAllTypes == false) { if (isValidConfiguration) { liShipmentResponse = GetShipmentInformation(graph, currentFilter, objSOAmazonSetupDetails); } UpdateTrackingNumberDetails(graph, list, objSOAmazonSetupDetails, orderEntry, objPartialMaint, liShipmentResponse); } else if (string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true) { TrackingNumberOrdersList.Cache.Clear(); foreach (SOAmazonSetup objSOAmazonSetup in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True>, And <SOAmazonSetup.integrationType, NotEqual <SOConstants.FBMIntegrationType> > > > .Select(graph)) { try { liShipmentResponse = GetShipmentInformation(graph, currentFilter, objSOAmazonSetup); UpdateTrackingNumberDetails(graph, list, objSOAmazonSetupDetails, orderEntry, objPartialMaint, liShipmentResponse); } catch (Exception ex) { throw new PXException(ex.Message); } } } graph.Actions.PressSave(); }
private SubmitFeedResponse InvokeSubmitFeed(SubmitFeedParamaters objParams, string xmlFeedContent) { SubmitFeedResponse resSubmitFeed = new SubmitFeedResponse(); try { UTF8Encoding encoding = new UTF8Encoding(); Stream streamData = new MemoryStream(encoding.GetBytes(xmlFeedContent)); SubmitFeedRequest request = new SubmitFeedRequest(); request.Merchant = objParams.objSOAmazonSetup.SellerId; request.FeedContent = streamData; request.ContentMD5 = MarketplaceWebServiceClient.CalculateContentMD5(request.FeedContent); request.FeedContent.Position = 0; request.PurgeAndReplace = false; request.FeedType = SOConstants.feedTypePostOrderFulfillment; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; resSubmitFeed = clientFeed.SubmitFeed(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceException) { MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(objParams.objPartialMaint, SOConstants.apiSubmitFeed)); resSubmitFeed = InvokeSubmitFeed(objParams, xmlFeedContent); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(resSubmitFeed); }
internal static void TestSellerAccount(SOAmazonSetup setupview) { bool marketplaceIdExist = false; try { if (setupview != null) { MarketplaceWebServiceSellersConfig msconfig = new MarketplaceWebServiceSellersConfig(); msconfig.ServiceURL = SOHelper.GetIntegrationType(setupview.IntegrationType.Trim(), SOConstants.serviceUrl); MarketplaceWebServiceSellers.MarketplaceWebServiceSellers client = new MarketplaceWebServiceSellersClient(SOConstants.appName, SOConstants.version, setupview.AccessKey, setupview.SecretKey, msconfig); SOServiceCalls sample = new SOServiceCalls(client); ListMarketplaceParticipationsResponse response = null; response = sample.InvokeListMarketplaceParticipations(setupview.SellerId, setupview.AuthToken); if (response != null) { string integrationType = SOHelper.GetIntegrationType(setupview.IntegrationType.Trim(), SOConstants.domainName); foreach (Marketplace marketplace in response.ListMarketplaceParticipationsResult.ListMarketplaces.Marketplace) { if (!string.IsNullOrEmpty(marketplace.Name) && !string.IsNullOrEmpty(integrationType) && marketplace.Name.ToLower() == integrationType.ToLower() && !string.IsNullOrEmpty(setupview.MarketplaceId) && !string.IsNullOrEmpty(marketplace.MarketplaceId) && setupview.MarketplaceId.ToLower() == marketplace.MarketplaceId.ToLower()) { marketplaceIdExist = true; break; } } } } } catch (Exception ex) { throw new Exception(SOMessages.connectionFailed + Convert.ToString(ex.Message)); } if (marketplaceIdExist) // we need this condition check because if we try to raise PXOperationCompletedException inside try catch block , //the catch block gets executed and displays a success message with error icon. { throw new PXOperationCompletedException(SOMessages.connectionSuccess); } else { throw new PXOperationCompletedWithErrorException(SOMessages.connectionFailed + SOMessages.errorMsg); } }
private GetOrderResponse InvokeGetOrder(PXGraph graph, ServiceCallParameters objParams) { GetOrderResponse getOrderRes = new GetOrderResponse(); try { GetOrderRequest request = new GetOrderRequest(); request.SellerId = objParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; List <string> liAmazonOrderId = new List <string>(); if (!string.IsNullOrEmpty(objParams.amwOrderID)) { liAmazonOrderId.Add(objParams.amwOrderID); } request.AmazonOrderId = liAmazonOrderId; getOrderRes = this.clientOrder.GetOrder(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceOrdersException) { MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetOrder)); getOrderRes = InvokeGetOrder(graph, objParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(getOrderRes); }
public AmazonEnvelope InvokeServicesCalls(SubmitFeedParamaters objParams, string xmlFeedContent) { AmazonEnvelope resultEnvelope = null; try { MarketplaceWebService.MarketplaceWebService serviceConfig = this.Configurations(objParams.objSOAmazonSetup.IntegrationType.Trim(), objParams.objSOAmazonSetup.AccessKey, objParams.objSOAmazonSetup.SecretKey); if (serviceConfig != null) { SubmitFeedResponse feedresponse = null; feedresponse = new AMSubmitFeedServiceCall(serviceConfig).InvokeSubmitFeed(objParams, xmlFeedContent); if (feedresponse != null && feedresponse.SubmitFeedResult != null && feedresponse.SubmitFeedResult.FeedSubmissionInfo != null && !string.IsNullOrEmpty(feedresponse.SubmitFeedResult.FeedSubmissionInfo.FeedProcessingStatus) && feedresponse.SubmitFeedResult.FeedSubmissionInfo.FeedProcessingStatus.ToUpper().Trim('_') == SOConstants.Submitted) { string submissionFeedId = feedresponse.SubmitFeedResult.FeedSubmissionInfo.FeedSubmissionId; using (MemoryStream ms = new MemoryStream()) { new AMSubmitFeedServiceCall(serviceConfig).GetSubmitFeedResult(objParams, submissionFeedId, ms); XmlDocument xDocument = new XmlDocument(); xDocument.Load(ms); string xmlResultContent = SOHelper.ObjectToXMLConversion(xDocument, string.Empty, true); XmlSerializer deserializer = new XmlSerializer(typeof(AmazonEnvelope), new XmlRootAttribute(SOConstants.amazonEnvelope)); using (TextReader reader = new StringReader(xmlResultContent)) { resultEnvelope = (AmazonEnvelope)deserializer.Deserialize(reader); } return(resultEnvelope); } } } else { throw new PXException(SOConstants.credentialsinvalid); } } catch (Exception ex) { throw new PXException(ex.Message); } return(resultEnvelope); }
private RequestReportResponse InvokeRequestReport(PXGraph graph, ReportParameters reportParams) { RequestReportResponse reqReportResponse = new RequestReportResponse(); try { RequestReportRequest request = new RequestReportRequest(); DateTime? businessDateTime = PX.Common.PXTimeZoneInfo.Now; request.Merchant = reportParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = reportParams.objSOAmazonSetup.AuthToken; request.ReportType = SOConstants.amazonFulfilledShipmentData; request.StartDate = Convert.ToDateTime(reportParams.fromDate); request.EndDate = Convert.ToDateTime(reportParams.toDate).Date >= businessDateTime.Value.Date ? businessDateTime.Value.AddMinutes(-2) : Convert.ToDateTime(reportParams.toDate).AddDays(1); reqReportResponse = clientReports.RequestReport(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceException) { MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiRequestReport)); reqReportResponse = InvokeRequestReport(graph, reportParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(reqReportResponse); }
private ListOrderItemsResponse GetSalesOrderLineItems(PXGraph graph, ServiceCallParameters objParams) { ListOrderItemsResponse lineItemsRes = new ListOrderItemsResponse(); try { ListOrderItemsRequest request = new ListOrderItemsRequest(); request.SellerId = objParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; request.AmazonOrderId = objParams.amwOrderID; lineItemsRes = this.clientOrder.ListOrderItems(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceOrdersException) { MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetListOrderItems)); lineItemsRes = GetSalesOrderLineItems(graph, objParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(lineItemsRes); #endregion }
public ListOrdersByNextTokenResponse InvokeListOrdersByNextToken(PXGraph graph, ServiceCallParameters objParams) { ListOrdersByNextTokenRequest request = new ListOrdersByNextTokenRequest(); ListOrdersByNextTokenResponse responseOrderByNextToken = new ListOrdersByNextTokenResponse(); try { request.SellerId = objParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; request.NextToken = objParams.nextToken; responseOrderByNextToken = this.clientOrder.ListOrdersByNextToken(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceOrdersException) { MarketplaceWebServiceOrdersException exception = ex as MarketplaceWebServiceOrdersException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiListOrdersByNextToken)); responseOrderByNextToken = InvokeListOrdersByNextToken(graph, objParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(responseOrderByNextToken); }
public void InvokeGetReport(PXGraph graph, ReportParameters reportParams, MemoryStream ms) { try { GetReportRequest request = new GetReportRequest(); request.Merchant = reportParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = reportParams.objSOAmazonSetup.AuthToken; request.ReportId = reportParams.generatedReportId; request.Report = ms; clientReports.GetReport(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceException) { MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetReport)); InvokeGetReport(graph, reportParams, ms); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } }
private void GetSubmitFeedResult(SubmitFeedParamaters objParams, string submissionFeedId, MemoryStream ms) { try { GetFeedSubmissionResultRequest request = new GetFeedSubmissionResultRequest(); request.FeedSubmissionId = submissionFeedId; request.Merchant = objParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = objParams.objSOAmazonSetup.AuthToken; request.FeedSubmissionResult = ms; clientFeed.GetFeedSubmissionResult(request); } catch (Exception ex) { if (ex is MarketplaceWebServiceException) { MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOConstants.feedProcessingResultNotReady) { Thread.Sleep(SOHelper.DelayProcess(objParams.objPartialMaint, SOConstants.apiFeedResultWaiting)); GetSubmitFeedResult(objParams, submissionFeedId, ms); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } }
public virtual void LoadDataToGrid(SOImportProcess graph, OrdersParameters objOrderParams) { string integrationId = Filter.Current.IntegrationID == null ? objOrderParams.objSOAmazonSetup.IntegrationID : Filter.Current.IntegrationID; if (!SOHelper.CheckOrderExist(graph, integrationId, objOrderParams.objItem.AmazonOrderId)) { objOrderParams.processrecord = new SOProcessOrder(); objOrderParams.processrecord.ProcessID = objOrderParams.processID; objOrderParams.processrecord.AmazonOrderID = objOrderParams.objItem.AmazonOrderId; objOrderParams.processrecord.BuyerEmailID = objOrderParams.objItem.BuyerEmail; objOrderParams.processrecord.AmazonOrderDate = objOrderParams.objItem.PurchaseDate != null ? objOrderParams.objItem.PurchaseDate : (DateTime?)null; objOrderParams.processrecord.AmazonOrderLastUpdated = objOrderParams.objItem.LastUpdateDate != null ? objOrderParams.objItem.LastUpdateDate : (DateTime?)null; objOrderParams.processrecord.OrderAmount = objOrderParams.objItem.OrderTotal != null?Convert.ToDecimal(objOrderParams.objItem.OrderTotal.Amount) : 0m; objOrderParams.processrecord.AmazonStatus = objOrderParams.objItem.OrderStatus; objOrderParams.processrecord.SynDatetime = PX.Common.PXTimeZoneInfo.Now; objOrderParams.processrecord.IntegrationID = objOrderParams.integrationID; string xmlFeedContent = SOHelper.ListToXMLConverstion(objOrderParams.objItem); objOrderParams.processrecord.OrderSchema = xmlFeedContent; objOrderParams.processrecord.PrepareStatus = true; objOrderParams.processrecord.ImportStatus = false; graph.ImportOrderList.Cache.Insert(objOrderParams.processrecord); } }
public void PrepareAndImportAmazonRecords(SOScheduleProcess graph, List <SOPrepareAndImport> listOfPrepareAndImport) { objSyncOrderResponse = new InvokeServicesCallResponse(); amwOrders = new List <Order>(); amwLineItems = new List <OrderItem>(); SOAmazonSetup objSOAmazonSetup = null; SOPartialMaint logGraph = PXGraph.CreateInstance <SOPartialMaint>(); SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>(); ARPaymentEntry paymentGraph = PXGraph.CreateInstance <ARPaymentEntry>(); bool isErrorOccured = false; DateTime? businessDateTime = PX.Common.PXTimeZoneInfo.Now; List <string> liCarriers = PXSelect <Carrier> .Select(graph).RowCast <Carrier>().Select(c => c.CarrierID).ToList(); try { SOSetupAmazonExt objSOOSetupext = orderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>(); if (SOHelper.IsSOPreferencesDetailsExist(orderEntry, objSOOSetupext)) { foreach (SOPrepareAndImport currentRecord in listOfPrepareAndImport) { objSOAmazonSetup = null; if (SOHelper.MarketplaceConfigurations(graph, currentRecord.IntegrationID, out objSOAmazonSetup)) { objSyncOrderResponse = objSyncOrderResponse != null ? null : objSyncOrderResponse; if (amwOrders != null && amwOrders.Count > 0) { amwOrders.Clear(); } if (amwLineItems != null && amwLineItems.Count > 0) { amwLineItems.Clear(); } orderEntry.Clear(); logGraph.Clear(); paymentGraph.Clear(); objServiceCallParams = new ServiceCallParameters(); objServiceCallParams.objSOAmazonSetup = objSOAmazonSetup; objServiceCallParams.amwOrderID = string.Empty; objServiceCallParams.methodCall = SOConstants.invokeListOrders; objServiceCallParams.fromDate = currentRecord.LastSyncDate; objServiceCallParams.toDate = currentRecord.ToDate; // Prepare action is invoked objSyncOrderResponse = new SOOrdersServiceCall(clientOrder).InvokeServicesCalls(graph, objServiceCallParams); if (amwLineItems != null && amwLineItems.Count > 0) { amwLineItems.Clear(); } if (objSyncOrderResponse != null && objSyncOrderResponse.objListOrderResponse != null && objSyncOrderResponse.objListOrderResponse.ListOrdersResult != null && objSyncOrderResponse.objListOrderResponse.ListOrdersResult.Orders != null && objSyncOrderResponse.objListOrderResponse.ListOrdersResult.Orders.Count > 0) { amwOrders = objSyncOrderResponse.objListOrderResponse.ListOrdersResult.Orders.ToList(); // Saving the prepare action response objScheduleParams = new PrepareAndImportOrdersParams(); objScheduleParams.objSOPrepareAndImport = currentRecord; objScheduleParams.objSOAmazonSetup = objSOAmazonSetup; objScheduleParams.objSOOrderEntry = orderEntry; objScheduleParams.objSOPartialMaint = logGraph; objScheduleParams.businessDateTime = businessDateTime; objScheduleParams.paymentGraph = paymentGraph; objScheduleParams.listOfCarriers = liCarriers; objScheduleParams.amwOrders = amwOrders; SOHelper.PrepareRecord(graph, objScheduleParams, ref isErrorOccured); if (objSyncOrderResponse.objListOrderResponse.ListOrdersResult.NextToken != null) { objScheduleParams.objNextToken = objSyncOrderResponse.objListOrderResponse.ListOrdersResult.NextToken; objScheduleParams.paymentGraph = paymentGraph; GetAmazonOrdersbyNextToken(graph, objScheduleParams, ref isErrorOccured); } } else { SOLogService.LogImportCount(null, currentRecord.IntegrationID, logGraph, currentRecord.ProcessID, SOConstants.scheduleimportorders, true); } } else { throw new PXException(SOMessages.apidetailsMissing); } } } else { throw new PXException(SOMessages.configMissing); } } catch (Exception ex) { SOLogService.LogImportStatus(objScheduleParams, false, ex.Message); throw new PXException(ex.Message); } }
private ReportRequestInfo InvokeGetReportRequestList(PXGraph graph, ReportParameters reportParams) { GetReportRequestListResponse reqReportListResponse = new GetReportRequestListResponse(); reportParams.reportInfo = new ReportRequestInfo(); try { GetReportRequestListRequest request = new GetReportRequestListRequest(); request.Merchant = reportParams.objSOAmazonSetup.SellerId; request.MWSAuthToken = reportParams.objSOAmazonSetup.AuthToken; request.MaxCount = 1; if (!string.IsNullOrEmpty(reportParams.reportRequestId)) { IdList liReportIds = new IdList(); liReportIds.Id.Add(reportParams.reportRequestId); request.ReportRequestIdList = liReportIds; } TypeList liReportTypes = new TypeList(); liReportTypes.Type.Add(SOConstants.amazonFulfilledShipmentData); request.ReportTypeList = liReportTypes; StatusList liReportStatus = new StatusList(); liReportStatus.Status.Add(SOConstants.statusDone); request.ReportProcessingStatusList = liReportStatus; reqReportListResponse = clientReports.GetReportRequestList(request); if (reqReportListResponse != null && reqReportListResponse.GetReportRequestListResult != null && reqReportListResponse.GetReportRequestListResult.ReportRequestInfo != null && reqReportListResponse.GetReportRequestListResult.ReportRequestInfo.Count > 0) { liReportRequestInfo = reqReportListResponse.GetReportRequestListResult.ReportRequestInfo; foreach (ReportRequestInfo reportRequestInfoItem in liReportRequestInfo) { if (reportRequestInfoItem.GeneratedReportId == null && string.IsNullOrEmpty(reportRequestInfoItem.GeneratedReportId) && reportRequestInfoItem.ReportProcessingStatus == SOConstants.statusInProgress || reportRequestInfoItem.ReportProcessingStatus == SOConstants.statusSubmitted) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.getGeneratedReportID)); reportParams.reportInfo = InvokeGetReportRequestList(graph, reportParams); } else if (reportRequestInfoItem.GeneratedReportId != null && !string.IsNullOrEmpty(reportRequestInfoItem.GeneratedReportId) && reportRequestInfoItem.ReportProcessingStatus == SOConstants.statusDone) { reportParams.reportInfo = reportRequestInfoItem; break; } } } else { RequestAndGetReportData(graph, reportParams); } } catch (Exception ex) { if (ex is MarketplaceWebServiceException) { MarketplaceWebServiceException exception = ex as MarketplaceWebServiceException; if (!string.IsNullOrEmpty(exception.ErrorCode) && exception.ErrorCode.ToLower().Trim() == SOMessages.requestThrottled) { Thread.Sleep(SOHelper.DelayProcess(graph, SOConstants.apiGetRequestReportList)); reportParams.reportInfo = InvokeGetReportRequestList(graph, reportParams); } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } else { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } return(reportParams.reportInfo); }
public virtual void AmazonSubmitFeed(List <ProjectionShipmentDAC> list, SubmitFeedFilter currentFilter) { SOPartialMaint logGraph = PXGraph.CreateInstance <SOPartialMaint>(); int? processId = list.Count > 0 ? SOLogService.LogSubmitCount(logGraph, currentFilter.IntegrationID, list.Count) : null; if (!(processId > 0)) { return; } SubmitFeedParamaters objSubmitFeedParams = null; StringBuilder sbXmlFeedData = new StringBuilder(); objEnvelope = new AmazonEnvelope(); objHeader = new Header(); objHeader.DocumentVersion = SOConstants.documentVersion; objEnvelope.MessageType = SOConstants.orderFulfillment; objEnvelope.Header = objHeader; List <Message> liMsgContent = new List <Message>(); UTF8Encoding encoding = new UTF8Encoding(); double megaBytesLength = 0.0d; bool isErrorOccured = false; Regex xmlEmptytagsRemove = new Regex(@"(\s)*<(\w:\w|\w)*(\s)*/>"); AMSubmitFeedServiceCall.AmazonEnvelope resAMEnv = null; List <Item> listItems = null; foreach (ProjectionShipmentDAC currentRecord in list) { SOAmazonSetup objSOAmazonSetup = null; Item objitem = null; SOHelper.MarketplaceConfigurations(logGraph, currentFilter.IntegrationID, out objSOAmazonSetup); objHeader.MerchantIdentifier = objSOAmazonSetup.SellerId; objSubmitFeedParams = new SubmitFeedParamaters(); listItems = new List <Item>(); try { logGraph.Clear(); foreach (PXResult <SOShipment, SOShipLine, Carrier, SOPackageDetail> result in PXSelectJoin <SOShipment, InnerJoin <SOShipLine, On <SOShipment.shipmentType, Equal <SOShipLine.shipmentType>, And <SOShipment.shipmentNbr, Equal <SOShipLine.shipmentNbr> > >, InnerJoin <Carrier, On <SOShipment.shipVia, Equal <Carrier.carrierID> >, LeftJoin <SOPackageDetail, On <SOPackageDetail.shipmentNbr, Equal <SOShipLine.shipmentNbr> > > > >, Where <SOShipLine.shipmentNbr, Equal <Required <SOShipLine.shipmentNbr> > >, OrderBy <Desc <SOPackageDetail.lineNbr> > > .Select(logGraph, currentRecord.ShipmentNbr)) { SOShipment objShipment = (SOShipment)result; SOShipLine objShipLine = (SOShipLine)result; Carrier objCarrier = (Carrier)result; SOPackageDetail objPackageDetails = (SOPackageDetail)result; objitem = null; if (objShipment != null && objShipLine != null && objPackageDetails != null && objPackageDetails.Confirmed != null && objPackageDetails.Confirmed == true && !string.IsNullOrEmpty(objPackageDetails.TrackNumber)) { SOShipmentAmazonExt objShipmentExt = PXCache <SOShipment> .GetExtension <SOShipmentAmazonExt>(objShipment); objSubmitFeedParams.soType = objShipLine.OrigOrderType; objSubmitFeedParams.acmOrderNbr = objShipLine.OrigOrderNbr; objSubmitFeedParams.shipmentType = objShipment.ShipmentType; objSubmitFeedParams.shipmentNbr = objShipment.ShipmentNbr; objSubmitFeedParams.shipmentDate = objShipment.ShipDate; objSubmitFeedParams.carrierCode = !String.IsNullOrEmpty(objShipmentExt.UsrAmazonCarrierCode) ? objShipmentExt.UsrAmazonCarrierCode : objShipment.ShipVia; objSubmitFeedParams.shipVia = (objCarrier == null || String.IsNullOrEmpty(objCarrier.PluginMethod)) ? objShipment.ShipVia : objCarrier.PluginMethod; objSubmitFeedParams.trackingNbr = objPackageDetails.TrackNumber; SOShipLineAmazonExt objShLineExt = objShipLine.GetExtension <SOShipLineAmazonExt>(); objSubmitFeedParams.amazonOrderID = objShLineExt != null && !string.IsNullOrEmpty(objShLineExt.UsrAmazonOrderID) ? objShLineExt.UsrAmazonOrderID : string.Empty; objitem = new Item(); objitem.AmazonOrderItemCode = objShLineExt != null && !string.IsNullOrEmpty(objShLineExt.UsrAMOrderItemID) ? objShLineExt.UsrAMOrderItemID : string.Empty; objitem.Quantity = objShipLine != null?Convert.ToInt32(objShipLine.ShippedQty) : 0; listItems.Add(objitem); } else { throw new PXException(SOMessages.shipmentDetailsMissing); } } objSubmitFeedParams.objPartialMaint = logGraph; objSubmitFeedParams.indexOfCurrentOrder = list.IndexOf(currentRecord); objSubmitFeedParams.objSOAmazonSetup = objSOAmazonSetup; objSubmitFeedParams.processID = processId; if (listItems != null && listItems.Count > 0) { objSubmitFeedParams.liShipItem = listItems; } Message objMessage = GetListOfMessagesContent(objSubmitFeedParams); if (objMessage.MessageID != null) { liMsgContent.Add(objMessage); } } catch (Exception ex) { isErrorOccured = true; objSubmitFeedParams.feedMessage = ex.Message; objSubmitFeedParams.importOrderStatus = false; objSubmitFeedParams.xmlMessage = string.Empty; SOLogService.LogSubmitStatus(objSubmitFeedParams); PXProcessing <ProjectionShipmentDAC> .SetError(list.IndexOf(currentRecord), ex.Message); } } objEnvelope.MessageBody = SOConstants.messagebody; string resultFeed = SOHelper.ObjectToXMLConversion(objEnvelope, SOConstants.amazonEnvelope, false); if (liMsgContent.Count > 0) { foreach (Message listobj in liMsgContent) { if (megaBytesLength >= SOConstants.feedSize) { break; } sbXmlFeedData.Append(SOHelper.ObjectToXMLConversion(listobj, SOConstants.messageBody, true) + SOConstants.getNewLine); var byteData = encoding.GetBytes(sbXmlFeedData.ToString()); megaBytesLength = (byteData.Length / 1024f) / 1024f; } string xmlFeedContent = xmlEmptytagsRemove.Replace(resultFeed.Replace(SOConstants.msgbodyTag, Convert.ToString(sbXmlFeedData)), string.Empty); PXTrace.WriteInformation(xmlFeedContent); resAMEnv = new AMSubmitFeedServiceCall(clientFeed).InvokeServicesCalls(objSubmitFeedParams, xmlFeedContent); } if (resAMEnv != null && resAMEnv.Message != null && resAMEnv.Message.ProcessingReport != null && resAMEnv.Message.ProcessingReport.ProcessingSummary != null && resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesProcessed == resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesSuccessful && resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesWithError == 0) { foreach (ProjectionShipmentDAC currentRecord in list) { UpdateSubmitLogDetails(list, objSubmitFeedParams, currentRecord, null); } } else if (resAMEnv != null && resAMEnv.Message != null && resAMEnv.Message.ProcessingReport != null && (resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesWithError > 0 || resAMEnv.Message.ProcessingReport.ProcessingSummary.MessagesSuccessful > 0)) { bool isSubmitted; foreach (ProjectionShipmentDAC currentRecord in list) { isSubmitted = false; foreach (var item in resAMEnv.Message.ProcessingReport.Result.AsEnumerable().Where(x => x.MessageID == currentRecord.ShipmentNbr)) { isSubmitted = true; isErrorOccured = true; UpdateSubmitLogDetails(list, objSubmitFeedParams, currentRecord, item); } if (!isSubmitted) { UpdateSubmitLogDetails(list, objSubmitFeedParams, currentRecord, null); } } } if (isErrorOccured) { throw new PXException(SOMessages.showErrorMsgFeeds); } }
protected virtual void prepareRecords() { List <string> importedRecords = new List <string>(); SOImportFilter currentFilter = Filter.Current; PXLongOperation.StartOperation(this, delegate() { SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>(); SOImportProcess graph = PXGraph.CreateInstance <SOImportProcess>(); SOPartialMaint logGraph = PXGraph.CreateInstance <SOPartialMaint>(); if (currentFilter != null) { if ((string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == false) || (!string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true)) { throw new PXException(SOMessages.validationIntegrationIdandprocessall); } if (currentFilter.TODate.Value.Date > graph.Accessinfo.BusinessDate.Value.Date) { throw new PXException(SOMessages.validationTodateandBusinessDate); } if (currentFilter.LastSyncDate > currentFilter.TODate) { throw new PXException(SOMessages.validationFromandTodate); } try { orderEntry.Clear(); SOSetupAmazonExt objSOOSetupext = orderEntry.sosetup.Current.GetExtension <SOSetupAmazonExt>(); if (SOHelper.IsSOPreferencesDetailsExist(orderEntry, objSOOSetupext)) { SOAmazonSetup objSOAmazonSetupDetails = null; objOrdersParameters = new OrdersParameters(); SOProcessOrder processrecord = null; int?processedCount = 0; bool isValidConfiguration = SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objSOAmazonSetupDetails); // To Get the Max date & time if the same date is processed again //Dhiren-4/11/2019 - We need to revisit date range Delta logic. //SOProcessOrder objProcessOrder = new PXSelect<SOProcessOrder, Where<SOProcessOrder.integrationID, Equal<Required<SOProcessOrder.integrationID>>, // And<SOProcessOrder.amazonOrderDate, Between<Required<SOProcessOrder.amazonOrderDate>, Required<SOProcessOrder.amazonOrderDate>>>>, // OrderBy<Desc<SOProcessOrder.amazonOrderDate>>>(graph).SelectSingle(currentFilter.IntegrationID, currentFilter.LastSyncDate, currentFilter.TODate); //currentFilter.FromDate = objProcessOrder != null && objProcessOrder.AmazonOrderDate.HasValue ? objProcessOrder.AmazonOrderDate : currentFilter.LastSyncDate; currentFilter.FromDate = currentFilter.LastSyncDate; Filter.Cache.Update(currentFilter); if (currentFilter.IntegrationID != null && currentFilter.ProcessAllTypes == false) { if (isValidConfiguration) { int?processId = SOHelper.GetProcessID(graph); PrepareAllRecords(graph, importedRecords, currentFilter, out processrecord, objSOAmazonSetupDetails, processId, out processedCount, logGraph); if (processedCount > 0) { LogProcessCount(processedCount, currentFilter.IntegrationID, logGraph); } graph.Actions.PressSave(); } else { throw new PXException(SOMessages.apidetailsMissing); } } else if (string.IsNullOrEmpty(currentFilter.IntegrationID) && currentFilter.ProcessAllTypes == true) { ImportOrderList.Cache.Clear(); int?processId = SOHelper.GetProcessID(graph); foreach (SOAmazonSetup objSOAmazonSetup in PXSelectReadonly <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(graph)) { try { PrepareAllRecords(graph, importedRecords, currentFilter, out processrecord, objSOAmazonSetup, processId, out processedCount, logGraph); if (processedCount > 0) { LogProcessCount(processedCount, objSOAmazonSetup.IntegrationID, logGraph); } processId++; graph.Actions.PressSave(); } catch (Exception ex) { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } } } else { throw new PXException(SOMessages.configMissing); } } catch (Exception ex) { throw new PXException(!string.IsNullOrEmpty(ex.Message) ? ex.Message : ex.InnerException != null && ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : SOConstants.exceptionIsEmpty); } } }); }
public virtual void ImportAmazonRecords(SOImportProcess graph, List <SOProcessOrder> list, SOImportFilter currentFilter) { if (list.Count < 0) { return; } List <Order> amwOrder = null; List <OrderItem> amwLineItems = null; string amwOrderID = string.Empty; List <SOAmazonSetup> liSOAmazonSetup = new List <SOAmazonSetup>(); List <SOFieldMapping> liUsrMapping = new List <SOFieldMapping>(); SOAmazonSetup objamwSetup = null; SOOrderProcessLog objProcessLog = null; SOPartialMaint logGraph = PXGraph.CreateInstance <SOPartialMaint>(); if (currentFilter.ProcessAllTypes == true) { foreach (SOAmazonSetup objSetup in PXSelect <SOAmazonSetup, Where <SOAmazonSetup.status, Equal <True> > > .Select(graph)) { liSOAmazonSetup.Add(objSetup); } } else if (SOHelper.MarketplaceConfigurations(graph, currentFilter.IntegrationID, out objamwSetup)) { liSOAmazonSetup.Add(objamwSetup); } if (liSOAmazonSetup.Count > 0) { ARPaymentEntry docgraph = PXGraph.CreateInstance <ARPaymentEntry>(); SOOrderEntry orderEntry = PXGraph.CreateInstance <SOOrderEntry>(); orderEntry.RowUpdated.AddHandler <SOOrder>((sender, e) => { if (!sender.ObjectsEqual <SOOrder.orderDate>(e.Row, e.OldRow)) { SOOrder order = (SOOrder)e.Row; order.OrderDate = order.OrderDate.HasValue ? order.OrderDate.Value.Date : order.OrderDate; } }); InvokeServicesCallResponse objSyncOrderResponse = null; PrepareAndImportOrdersParams objScheduleParams = null; objProcessLog = new SOOrderProcessLog(); objProcessLog.ProcessDate = PX.Common.PXTimeZoneInfo.Now; objProcessLog.TotalRecordstoImport = list.Count; objProcessLog.Operation = SOConstants.btnImport; objProcessLog.ImportedRecordsCount = 0; objProcessLog.FailedRecordsCount = 0; bool isErrorOccured = false; List <string> liCarriers = PXSelect <Carrier> .Select(graph).RowCast <Carrier>().Select(c => c.CarrierID).ToList(); foreach (SOProcessOrder currentRecord in list) { try { orderEntry.Clear(); logGraph.Clear(); docgraph.Clear(); objProcessLog.IntegrationID = currentFilter.IntegrationID != null ? currentFilter.IntegrationID : currentRecord.IntegrationID; logGraph.OrderProcessLog.Insert(objProcessLog); logGraph.Actions.PressSave(); foreach (SOAmazonSetup objSOAmazonSetup in liSOAmazonSetup.Where(x => x.IntegrationID == currentRecord.IntegrationID)) { if (orderEntry.sosetup.Current != null) { if (!SOHelper.CheckOrderExist(graph, currentRecord.AmazonOrderID, currentRecord.IntegrationID)) { amwOrderID = currentRecord.AmazonOrderID; if (amwLineItems != null && amwLineItems.Count > 0) { amwLineItems.Clear(); } amwOrder = new List <Order>(); amwOrder.Add(SOHelper.SchemaDeserialization(graph, amwOrderID)); objServiceCallParams = new ServiceCallParameters(); objServiceCallParams.objSOAmazonSetup = objSOAmazonSetup; objServiceCallParams.amwOrderID = currentRecord.AmazonOrderID; objServiceCallParams.methodCall = SOConstants.invokeListOrderItems; objSyncOrderResponse = new InvokeServicesCallResponse(); objSyncOrderResponse = new SOOrdersServiceCall(clientOrder).InvokeServicesCalls(graph, objServiceCallParams); amwLineItems = objSyncOrderResponse != null && objSyncOrderResponse.objListOrderItemsResponse != null && objSyncOrderResponse.objListOrderItemsResponse.ListOrderItemsResult != null && objSyncOrderResponse.objListOrderItemsResponse.ListOrderItemsResult.OrderItems.Count > 0 ? objSyncOrderResponse.objListOrderItemsResponse.ListOrderItemsResult.OrderItems : amwLineItems; objScheduleParams = new PrepareAndImportOrdersParams(); objScheduleParams.objSOPartialMaint = logGraph; objScheduleParams.objSOAmazonSetup = objSOAmazonSetup; objScheduleParams.objSOOrderEntry = orderEntry; objScheduleParams.paymentGraph = docgraph; objScheduleParams.objSOProcessOrderRecord = currentRecord; objScheduleParams.ObjCurrentOrder = amwOrder[0]; objScheduleParams.objamwLineItems = amwLineItems; objScheduleParams.objliUsrMapping = liUsrMapping; objScheduleParams.listOfCarriers = liCarriers; objScheduleParams.CurrentOrderIndex = list.IndexOf(currentRecord); CreateSO.CreateSalesOrderandPayments(objScheduleParams); } else { isErrorOccured = true; SOLogService.LogImportStatus(objScheduleParams, true, SOMessages.recordAlreadyImported); PXProcessing <SOProcessOrder> .SetInfo(list.IndexOf(currentRecord), SOMessages.recordAlreadyImported); } } else { throw new PXException(SOMessages.configMissing); } } } catch (Exception ex) { isErrorOccured = true; SOLogService.LogImportStatus(objScheduleParams, false, ex.Message); PXProcessing <SOProcessOrder> .SetError(list.IndexOf(currentRecord), ex.Message); } } if (isErrorOccured) { throw new PXException(SOMessages.showErrorMsgOrders); } } }