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();
        }
Exemplo n.º 2
0
        internal static bool CheckOrderExist(PXGraph graph, string integrationId, string amazonOrderId)
        {
            SOProcessOrder recordExist = PXSelectReadonly <SOProcessOrder, Where <SOProcessOrder.integrationID, Equal <Required <SOProcessOrder.integrationID> >,
                                                                                  And <SOProcessOrder.amazonOrderID, Equal <Required <SOProcessOrder.amazonOrderID> > > > >
                                         .Select(graph, integrationId, amazonOrderId);

            return(recordExist != null);
        }
        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();
        }
        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());
        }
Exemplo n.º 5
0
        internal static Order SchemaDeserialization(PXGraph graph, string amazonOrderId)
        {
            Order          orderSchema     = null;
            SOProcessOrder objProcessOrder = PXSelect <SOProcessOrder, Where <SOProcessOrder.amazonOrderID, Equal <Required <SOProcessOrder.amazonOrderID> > > > .Select(graph, amazonOrderId);

            if (objProcessOrder != null)
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(Order), new XmlRootAttribute(SOConstants.orderTag));
                using (TextReader reader = new StringReader(objProcessOrder.OrderSchema))
                {
                    orderSchema = (Order)deserializer.Deserialize(reader);
                }
                if (orderSchema == null)
                {
                    throw new PXException(SOMessages.schemaDoesnotExist);
                }
            }
            return(orderSchema);
        }
Exemplo n.º 6
0
        protected virtual void SOSetup_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            SOSetup row = e.Row as SOSetup;

            if (row != null)
            {
                SOSetupAmazonExt objSOSetupExt = row.GetExtension <SOSetupAmazonExt>();
                PXUIFieldAttribute.SetVisible <SOSetupAmazonExt.usrInitialFromDateNote>(sender, row, objSOSetupExt != null && objSOSetupExt.UsrAmazonInitialFromDate != null);
                SOProcessOrder objSOOrder = PXSelect <SOProcessOrder> .Select(Base);

                if (objSOOrder != null)
                {
                    PXUIFieldAttribute.SetEnabled <SOSetupAmazonExt.usrAmazonInitialFromDate>(sender, row, false);
                }
                else
                {
                    PXUIFieldAttribute.SetEnabled <SOSetupAmazonExt.usrAmazonInitialFromDate>(sender, row, true);
                }
            }
        }
        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);
                    }
                }
            });
        }
Exemplo n.º 8
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);
                }
            }
        }