public void LogProcessCount(int?processCount, string integrationId, SOPartialMaint logGraph)
 {
     Filter.Current.TotalImportedRecords = 0;
     Filter.Current.TotalRecordsToImport = processCount;
     Filter.Current.TotalFailedRecords   = 0;
     Filter.Update(Filter.Current);
     SOLogService.LogImportCount(Filter.Current, integrationId, logGraph, null, SOConstants.importorders, false);
 }
        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 static void UpdateSubmitLogDetails(List <ProjectionShipmentDAC> list, SubmitFeedParamaters objSubmitFeedParams, ProjectionShipmentDAC currentRecord, AMSubmitFeedServiceCall.Result item)
        {
            objSubmitFeedParams.acmOrderNbr   = currentRecord.OrderNbr;
            objSubmitFeedParams.amazonOrderID = currentRecord.AmazonOrderID;
            objSubmitFeedParams.objSOAmazonSetup.IntegrationID = currentRecord.IntegrationID;
            objSubmitFeedParams.shipmentNbr  = currentRecord.ShipmentNbr;
            objSubmitFeedParams.shipmentType = currentRecord.ShipmentType;

            if (item != null)
            {
                objSubmitFeedParams.importOrderStatus = false;
                objSubmitFeedParams.xmlMessage        = item.ResultDescription;
                objSubmitFeedParams.feedMessage       = item.ResultDescription;
                PXProcessing <ProjectionShipmentDAC> .SetError(list.IndexOf(currentRecord), item.ResultDescription);
            }
            else
            {
                objSubmitFeedParams.importOrderStatus = true;
                objSubmitFeedParams.xmlMessage        = SOConstants.feedSubmitted;
                objSubmitFeedParams.feedMessage       = SOConstants.feedSubmitted;
                PXProcessing <ProjectionShipmentDAC> .SetInfo(list.IndexOf(currentRecord), SOConstants.feedSubmitted);
            }
            SOLogService.LogSubmitStatus(objSubmitFeedParams);
        }
        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);
            }
        }
예제 #6
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);
            }
        }
예제 #7
0
        internal static void PrepareRecord(SOScheduleProcess graph, PrepareAndImportOrdersParams objScheduleParams, ref bool isErrorOccured)
        {
            SOProcessOrder objprocessorder = null;

            foreach (Order currentOrder in objScheduleParams.amwOrders)
            {
                try
                {
                    objScheduleParams.objSOOrderEntry.Clear();
                    objScheduleParams.objSOPartialMaint.Clear();
                    objScheduleParams.paymentGraph.Clear();
                    if (!CheckOrderExist(objScheduleParams.objSOOrderEntry, objScheduleParams.objSOPrepareAndImport.IntegrationID, currentOrder.AmazonOrderId))
                    {
                        objprocessorder           = new SOProcessOrder();
                        objprocessorder.ProcessID = objScheduleParams.objSOPrepareAndImport != null &&
                                                    objScheduleParams.objSOPrepareAndImport.ProcessID != null ? objScheduleParams.objSOPrepareAndImport.ProcessID : 1;
                        objprocessorder.IntegrationID = objScheduleParams.objSOPrepareAndImport != null &&
                                                        objScheduleParams.objSOPrepareAndImport.IntegrationID != null ? objScheduleParams.objSOPrepareAndImport.IntegrationID
                                                        : string.Empty;
                        objprocessorder.AmazonOrderID          = currentOrder.AmazonOrderId;
                        objprocessorder.BuyerEmailID           = currentOrder.BuyerEmail;
                        objprocessorder.AmazonOrderDate        = currentOrder.PurchaseDate != null ? currentOrder.PurchaseDate : (DateTime?)null;
                        objprocessorder.AmazonOrderLastUpdated = currentOrder.LastUpdateDate != null ? currentOrder.LastUpdateDate : (DateTime?)null;
                        objprocessorder.OrderAmount            = (currentOrder.OrderTotal != null && currentOrder.OrderTotal.Amount != null)
                                                         ? Convert.ToDecimal(currentOrder.OrderTotal.Amount) : 0m;
                        objprocessorder.AmazonStatus  = currentOrder.OrderStatus;
                        objprocessorder.SynDatetime   = objScheduleParams.businessDateTime;
                        objprocessorder.PrepareStatus = true;
                        objprocessorder.ImportStatus  = false;
                        string xmlFeedContent = ListToXMLConverstion(currentOrder);
                        objprocessorder.OrderSchema = xmlFeedContent;
                        objScheduleParams.objSOPartialMaint.ProcessOrder.Cache.Insert(objprocessorder);
                        objScheduleParams.objSOPartialMaint.Actions.PressSave();
                        SOLogService.LogImportCount(null, objprocessorder.IntegrationID, objScheduleParams.objSOPartialMaint, objprocessorder.ProcessID,
                                                    SOConstants.scheduleimportorders, false);

                        SOProcessOrder processRecord = PXSelect <SOProcessOrder,
                                                                 Where <SOProcessOrder.integrationID, Equal <Required <SOProcessOrder.integrationID> >,
                                                                        And <SOProcessOrder.processID, Equal <Required <SOProcessOrder.processID> >,
                                                                             And <SOProcessOrder.amazonOrderID, Equal <Required <SOProcessOrder.amazonOrderID> > > > >,
                                                                 OrderBy <Desc <SOProcessOrder.lineNumber> > > .Select(objScheduleParams.objSOOrderEntry,
                                                                                                                       objScheduleParams.objSOPrepareAndImport.IntegrationID,
                                                                                                                       objScheduleParams.objSOPrepareAndImport.ProcessID, currentOrder.AmazonOrderId);

                        objScheduleParams.amazonOrderID           = objprocessorder.AmazonOrderID;
                        objScheduleParams.ObjCurrentOrder         = currentOrder;
                        objScheduleParams.objSOProcessOrderRecord = processRecord;
                        GetAmazonOrderItems(graph, objScheduleParams);
                    }
                    else
                    {
                        SOLogService.LogImportCount(null, objScheduleParams.objSOAmazonSetup.IntegrationID, objScheduleParams.objSOPartialMaint, objScheduleParams.objSOPrepareAndImport.ProcessID,
                                                    SOConstants.scheduleimportorders, true);
                    }
                }
                catch (Exception ex)
                {
                    isErrorOccured = true;
                    SOLogService.LogImportStatus(objScheduleParams, false, ex.Message);
                }
            }
        }