public virtual IEnumerable GetRecords() { SOAmazonSetup currentItem = (SOAmazonSetup)this._Graph.Views["setupview"].Cache.Current; if (currentItem == null) { return(null); } PXSelectBase <SOOrderType> ordertype = new PXSelectJoin <SOOrderType, InnerJoin <SOOrderTypeOperation, On <SOOrderTypeOperation.orderType, Equal <SOOrderType.orderType>, And <SOOrderTypeOperation.operation, Equal <SOOrderType.defaultOperation> > > > >(this._Graph); switch (currentItem.IntegrationType.Trim()) { case SOConstants.AMIntegrationType.FBA: case SOConstants.AMIntegrationType.CAFBA: case SOConstants.AMIntegrationType.UKFBA: case SOConstants.AMIntegrationType.JPFBA: case SOConstants.AMIntegrationType.DEFBA: case SOConstants.AMIntegrationType.INFBA: ordertype.WhereAnd <Where <SOOrderType.template, Equal <SOConstants.InvoiceType>, And <SOOrderType.aRDocType, Equal <ARDocType.invoice> > > >(); return(ordertype.Select()); case SOConstants.AMIntegrationType.FBM: ordertype.WhereAnd <Where <SOOrderType.template, Equal <SOConstants.SalesOrderType> > >(); return(ordertype.Select()); } return(null); }
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(); }
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 void PrepareAllRecords(SOImportProcess graph, List <string> importedRecords, SOImportFilter currentFilter, out SOProcessOrder processrecord, SOAmazonSetup objSOAmazonSetup, int?processID, out int?processedCount, SOPartialMaint logGraph) { processrecord = new SOProcessOrder(); InvokeServicesCallResponse objSyncOrderResponse = new InvokeServicesCallResponse(); List <ListOrderItems> liListOrderResponse = new List <ListOrderItems>(); objOrdersParameters.objSOAmazonSetup = objSOAmazonSetup; objOrdersParameters.objSOImportFilter = currentFilter; objOrdersParameters.processrecord = processrecord; objOrdersParameters.objSyncOrderResponse = objSyncOrderResponse; objOrdersParameters.processID = processID; objOrdersParameters.importedRecords = importedRecords; objOrdersParameters.liListOrderResponse = liListOrderResponse; objOrdersParameters.objSOPartialMaint = logGraph; ListOrders(graph, objOrdersParameters); processedCount = Convert.ToInt32(graph.ImportOrderList.Cache.Inserted.Count()); }
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); } } }
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); } }
public virtual InvokeReporstServicesCallResponse InvokeReportsServiceCalls(PXGraph graph, SOAmazonSetup objSOAmazonSetup, DateTime?fromDate, DateTime?toDate) { InvokeReporstServicesCallResponse objShipInfo = new InvokeReporstServicesCallResponse(); MarketplaceWebService.MarketplaceWebService serviceConfig = this.Configurations(objSOAmazonSetup.IntegrationType.Trim(), objSOAmazonSetup.AccessKey, objSOAmazonSetup.SecretKey); if (serviceConfig == null) { return(objShipInfo); } ReportRequestInfo reportInfo = new ReportRequestInfo(); List <ShipmentInformarion> liShipmentInfo = new List <ShipmentInformarion>(); reportParams = new ReportParameters(); reportParams.objSOAmazonSetup = objSOAmazonSetup; reportParams.reportRequestId = string.Empty; reportParams.reportInfo = reportInfo; reportParams.liShipmentInfo = liShipmentInfo; reportParams.serviceConfig = serviceConfig; reportInfo = new AMShipmentTrackingNumberServiceCall(reportParams.serviceConfig).InvokeGetReportRequestList(graph, reportParams); reportParams.fromDate = fromDate; reportParams.toDate = toDate; try { if (reportInfo != null && reportInfo.GeneratedReportId != null) { if (Convert.ToInt32((TimeZoneInfo.ConvertTimeToUtc(DateTime.Now) - TimeZoneInfo.ConvertTimeToUtc(reportInfo.CompletedDate)).TotalMinutes) <= SOConstants.limitForReports) { throw new PXException(SOMessages.errorReportInfo); } else { liShipmentInfo = RequestAndGetReportData(graph, reportParams); } objShipInfo.objShipmentResponse = liShipmentInfo; } else { liShipmentInfo = RequestAndGetReportData(graph, reportParams); } } 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); } return(objShipInfo); }
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); } }
internal static bool MarketplaceConfigurations(PXGraph graph, string integrationId, out SOAmazonSetup objSOAmazonSetup) { objSOAmazonSetup = PXSelect <SOAmazonSetup, Where <SOAmazonSetup.integrationID, Equal <Required <SOAmazonSetup.integrationID> >, And <SOAmazonSetup.status, Equal <True> > > > .Select(graph, integrationId); if (objSOAmazonSetup != null && !string.IsNullOrEmpty(objSOAmazonSetup.IntegrationID) && !string.IsNullOrEmpty(objSOAmazonSetup.AccessKey) && !string.IsNullOrEmpty(objSOAmazonSetup.SecretKey) && !string.IsNullOrEmpty(objSOAmazonSetup.SellerId) && !string.IsNullOrEmpty(objSOAmazonSetup.AuthToken) && !string.IsNullOrEmpty(objSOAmazonSetup.MarketplaceId) && !string.IsNullOrEmpty(objSOAmazonSetup.IntegrationType)) { return(true); } return(false); }
private static InvokeReporstServicesCallResponse GetShipmentInformation(PXGraph graph, SOTrackingReportFilter currentFilter, SOAmazonSetup objSOAmazonSetupDetails) { InvokeReporstServicesCallResponse liShipmentResponse = new InvokeReporstServicesCallResponse(); liShipmentResponse = new AMShipmentTrackingNumberServiceCall(clientReports).InvokeReportsServiceCalls(graph, objSOAmazonSetupDetails, currentFilter.FromDate, currentFilter.TODate); return(liShipmentResponse); }
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); } } }