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); }
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 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 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); } } }