Пример #1
0
 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);
         }
     }
 }
Пример #2
0
        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);
            }
        }