コード例 #1
0
        private static void UpdateImportStatus(SOPartialMaint logGraph, SOProcessOrder currentRecord, bool importOrderStatus)
        {
            logGraph.ProcessOrder.Current = currentRecord;
            logGraph.ProcessOrder.Current.ImportStatus = importOrderStatus;
            logGraph.ProcessOrder.Update(logGraph.ProcessOrder.Current);
            logGraph.Actions.PressSave();
            SOOrderProcessLog processupdatecount = logGraph.UpdateImportProcessLog.Select();

            if (processupdatecount == null)
            {
                return;
            }
            int?importCount = processupdatecount.TotalRecordstoImport;

            processupdatecount.TotalRecordstoImport = importCount;
            if (importOrderStatus)
            {
                processupdatecount.ImportedRecordsCount = processupdatecount.ImportedRecordsCount + 1;
            }
            else
            {
                processupdatecount.FailedRecordsCount = processupdatecount.FailedRecordsCount + 1;
            }
            processupdatecount.ParentProcessID = currentRecord.ProcessID;
            logGraph.UpdateImportProcessLog.Update(processupdatecount);
            logGraph.Actions.PressSave();
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        private static void RecordImported(SOPartialMaint logGraph, SOProcessOrder currentRecord, string acmOrderId, string acmOrderType)
        {
            SOImportedRecords importedRecords = new SOImportedRecords();

            importedRecords.ProcessID          = currentRecord.ProcessID;
            importedRecords.AmazonOrderID      = currentRecord.AmazonOrderID;
            importedRecords.AcumaticaOrderID   = acmOrderId;
            importedRecords.AcumaticaOrderType = acmOrderType;
            importedRecords.ImportedDate       = logGraph.Accessinfo.BusinessDate;
            importedRecords.IntegrationID      = currentRecord.IntegrationID;
            logGraph.ImportedRecords.Insert(importedRecords);
            logGraph.Actions.PressSave();
        }
コード例 #4
0
        public static int?LogSubmitCount(SOPartialMaint logGraph, string integrationID, int?TotalRecordsToSubmit)
        {
            SOSubmitProcessLog processcount = new SOSubmitProcessLog();

            processcount.ProcessDate              = PX.Common.PXTimeZoneInfo.Now;
            processcount.TotalRecordstoProcess    = TotalRecordsToSubmit;
            processcount.SubmitRecordsCount       = 0;
            processcount.SubmitFailedRecordsCount = 0;
            processcount.IntegrationID            = integrationID;
            logGraph.SubmitProcesLog.Insert(processcount);
            logGraph.Actions.PressSave();
            SOSubmitProcessLog getProcessId = PXSelectGroupBy <SOSubmitProcessLog, Aggregate <Max <SOSubmitProcessLog.processID> > > .Select(logGraph);

            return(getProcessId != null && getProcessId.ProcessID != null ? getProcessId.ProcessID : 1);
        }
        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();
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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);
                    }
                }
            });
        }
コード例 #8
0
        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);
                }
            }
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
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);
            }
        }
コード例 #11
0
        public static void LogImportCount(SOImportProcess.SOImportFilter currentimportcount, string integrationId, SOPartialMaint logGraph, int?processId, string screenAction, bool isNoOrdersPrepared)
        {
            SOOrderProcessLog processcount = null;

            switch (screenAction)
            {
            case SOConstants.importorders:
                processcount                      = new SOOrderProcessLog();
                processcount.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                processcount.TotalRecordstoImport = isNoOrdersPrepared == true ? 0 : currentimportcount.TotalRecordsToImport;
                processcount.ImportedRecordsCount = currentimportcount.TotalImportedRecords;
                processcount.FailedRecordsCount   = currentimportcount.TotalFailedRecords;
                processcount.IntegrationID        = integrationId;
                processcount.Operation            = SOConstants.btnPrepare;
                logGraph.OrderProcessLog.Insert(processcount);
                logGraph.Actions.PressSave();
                logGraph.OrderProcessLog.Current.ParentProcessID = logGraph.OrderProcessLog.Current.ProcessID;
                logGraph.OrderProcessLog.Update(logGraph.OrderProcessLog.Current);
                logGraph.Actions.PressSave();
                break;

            case SOConstants.scheduleimportorders:
                processcount = PXSelectReadonly <SOOrderProcessLog, Where <SOOrderProcessLog.processID, Equal <Required <SOOrderProcessLog.processID> > > > .Select(logGraph, Convert.ToInt32(processId));

                if (processcount == null)
                {
                    processcount                      = new SOOrderProcessLog();
                    processcount.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                    processcount.Operation            = SOConstants.btnPrepareAndImport;
                    processcount.TotalRecordstoImport = isNoOrdersPrepared == true ? 0 : 1;
                    processcount.ImportedRecordsCount = 0;
                    processcount.FailedRecordsCount   = 0;
                    processcount.IntegrationID        = integrationId;
                    logGraph.OrderProcessLog.Insert(processcount);
                    logGraph.Actions.PressSave();
                    logGraph.OrderProcessLog.Current.ParentProcessID = logGraph.OrderProcessLog.Current.ProcessID;
                    logGraph.OrderProcessLog.Update(logGraph.OrderProcessLog.Current);
                    logGraph.Actions.PressSave();
                }
                else
                {
                    processcount.ProcessDate          = PX.Common.PXTimeZoneInfo.Now;
                    processcount.TotalRecordstoImport = processcount.TotalRecordstoImport + 1;
                    logGraph.OrderProcessLog.Update(processcount);
                    logGraph.Actions.PressSave();
                }
                break;
            }
        }
        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);
                }
            }
        }