Пример #1
0
        public KCDeltaSync(KCBulkProductMaint graph) : base(graph)
        {
            ImagePlacements = new PXSelect <KCImagePlacement,
                                            Where <KCImagePlacement.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > >(graph);

            AttributesMappings = new PXSelect <KCAttributesMapping,
                                               Where <KCAttributesMapping.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > >(graph);

            ClassificationMappings = new PXSelect <KNSIKCClassificationsMapping,
                                                   Where <KNSIKCClassificationsMapping.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > >(graph);

            RequiredRelation = new PXSelect <KNSIKCRelationship,
                                             Where <KNSIKCRelationship.itemClassId, Equal <Required <InventoryItem.itemClassID> >,
                                                    And <KNSIKCRelationship.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > > >(graph);

            KitProduct = new PXSelect <INKitSpecHdr,
                                       Where <INKitSpecHdr.kitInventoryID, Equal <Required <INKitSpecHdr.kitInventoryID> > > >(graph);

            StockKitComponents = new PXSelect <INKitSpecStkDet,
                                               Where <INKitSpecStkDet.kitInventoryID, Equal <Required <INKitSpecStkDet.kitInventoryID> >,
                                                      And <INKitSpecStkDet.revisionID, Equal <Required <INKitSpecStkDet.revisionID> >,
                                                           And <Where <INKitSpecStkDet.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > > > > >(graph);

            NonStockKitComponents = new PXSelect <INKitSpecNonStkDet,
                                                  Where <INKitSpecNonStkDet.kitInventoryID, Equal <Required <INKitSpecNonStkDet.kitInventoryID> >,
                                                         And <INKitSpecNonStkDet.revisionID, Equal <Required <INKitSpecNonStkDet.revisionID> >,
                                                              And <Where <INKitSpecNonStkDet.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > > > > >(graph);

            QuantityUpdate = new PXSelect <INTran,
                                           Where <INTran.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > >(graph);
        }
        protected List <string> HandleLabels(InventoryItem product, KCBulkProductMaint graph)
        {
            List <string>        bulkLabels = new List <string>();
            KNSIKCInventoryItem  kcProduct  = graph.KCInventoryItem.SelectSingle(product.InventoryID);
            IEnumerable <string> aLabels    = graph.ItemLabels.Select(product.InventoryID).RowCast <KNSIKCLabel>().Select(y => y.LabelName);
            IEnumerable <string> caLabels   = ApiHelper.GetProductLabels(kcProduct.UsrKCCAID).Select(x => x.Name);

            if (!aLabels.OrderBy(x => x).SequenceEqual(caLabels.OrderBy(x => x)))
            {
                IEnumerable <string> obsoleteLabels = caLabels.Where(x => aLabels.All(y => y != x));
                IEnumerable <string> newLabels      = aLabels.Where(x => caLabels.All(y => y != x));

                foreach (string oldLabel in obsoleteLabels)
                {
                    // 04/22/19 AT: When deleting label through FTP, ChannelAdvisor requires '-' before label to determine that it should be deleted
                    bulkLabels.Add("-" + oldLabel);
                }
                foreach (string newLabel in newLabels)
                {
                    bulkLabels.Add(newLabel);
                }
            }

            return(bulkLabels);
        }
Пример #3
0
        public static APIQuantityValue GetAPIQuantity(int?inventoryID, List <INLocationStatus> statuses = null, decimal?vendorQty = null)
        {
            KCBulkProductMaint         graph = PXGraph.CreateInstance <KCBulkProductMaint>();
            KCInventoryManagementMaint inventoryManagementGraph = PXGraph.CreateInstance <KCInventoryManagementMaint>();

            if (statuses == null)
            {
                var settingsGraph = PXGraph.CreateInstance <KCInventoryManagementMaint>();
                statuses = KCGeneralDataHelper.GetINLocationStatuses(graph, inventoryID).Where(x => settingsGraph.IsSiteMapped(x.SiteID)).ToList();
            }
            if (vendorQty == null)
            {
                vendorQty = KCGeneralDataHelper.GetVendorQty(inventoryID);
            }

            List <KCAPIQuantity> qtys = KCGeneralDataHelper.GetProductQtys(inventoryManagementGraph, inventoryID, statuses, vendorQty);

            return(new APIQuantityValue
            {
                Value = new APIUpdates()
                {
                    UpdateType = "InStock",
                    Updates = qtys
                }
            });
        }
        protected KCBasicBulkStrategy(KCBulkProductMaint graph)
        {
            Graph = graph;

            ProductsForUpdate = new PXSelectJoin <InventoryItem,
                                                  LeftJoin <KNSIKCInventoryItem, On <InventoryItem.inventoryID, Equal <KNSIKCInventoryItem.inventoryID> > >,
                                                  Where <KNSIKCInventoryItem.usrKCActiveOnCa, Equal <True> > >(graph);
            SiteMaster = Graph.SiteMaster.SelectSingle();
        }
Пример #5
0
 public KCMapInventoryItem(KCRelationshipSetupMaint relationshipGraph,
                           KCClassificationsMappingMaint classificationsGraph,
                           KCBulkProductMaint bulkGraph,
                           KCIItemConversionDataMaint conversionGraph,
                           KCStore store,
                           KCLoggerProperties loggerProperties)
 {
     RelationshipGraph    = relationshipGraph;
     ClassificationsGraph = classificationsGraph;
     BulkGraph            = bulkGraph;
     ConversionGraph      = conversionGraph;
     Store            = store;
     LoggerProperties = loggerProperties;
 }
        protected string FormatQuantities(APIUpdates quantityUpdates, KCBulkProductMaint graph)
        {
            List <string> preparedQties = new List <string>();

            foreach (KCAPIQuantity apiQuantity in quantityUpdates.Updates)
            {
                var dcName = graph.DCById.SelectSingle(apiQuantity.DistributionCenterID);
                if (dcName != null)
                {
                    preparedQties.Add($"{dcName.Code}={apiQuantity.Quantity}");
                }
            }

            return(string.Join(",", preparedQties));
        }
Пример #7
0
        public KCCustomSync(KCBulkProductMaint graph, DateTime dateFrom, DateTime dateTo) : base(graph)
        {
            DateFrom = dateFrom.AddHours(-0);
            DateTo   = dateTo.AddHours(11);
            if (dateFrom.Date == DateTime.Now.Date)
            {
                DateTo = dateTo.AddHours(24);
            }
            ImagePlacements = new PXSelect <KCImagePlacement,
                                            Where <KCImagePlacement.lastModifiedDateTime, Greater <Required <KCImagePlacement.lastModifiedDateTime> >,
                                                   And <Where <KCImagePlacement.lastModifiedDateTime, Less <Required <KCImagePlacement.lastModifiedDateTime> > > > > >(graph);

            AttributesMappings = new PXSelect <KCAttributesMapping,
                                               Where <KCAttributesMapping.lastModifiedDateTime, Greater <Required <KCAttributesMapping.lastModifiedDateTime> >,
                                                      And <Where <KCAttributesMapping.lastModifiedDateTime, Less <Required <KCAttributesMapping.lastModifiedDateTime> > > > > >(graph);

            ClassificationMappings = new PXSelect <KNSIKCClassificationsMapping,
                                                   Where <KNSIKCClassificationsMapping.lastModifiedDateTime, Greater <Required <KNSIKCClassificationsMapping.lastModifiedDateTime> >,
                                                          And <Where <KNSIKCClassificationsMapping.lastModifiedDateTime, Less <Required <KNSIKCClassificationsMapping.lastModifiedDateTime> > > > > >(graph);

            RequiredRelation = new PXSelect <KNSIKCRelationship,
                                             Where <KNSIKCRelationship.itemClassId, Equal <Required <InventoryItem.itemClassID> >,
                                                    And <KNSIKCRelationship.lastModifiedDateTime, Greater <Required <KNSIKCRelationship.lastModifiedDateTime> >,
                                                         And <Where <KNSIKCRelationship.lastModifiedDateTime, Less <Required <KNSIKCRelationship.lastModifiedDateTime> > > > > > >(graph);

            KitProduct = new PXSelect <INKitSpecHdr,
                                       Where <INKitSpecHdr.kitInventoryID, Equal <Required <INKitSpecHdr.kitInventoryID> > > >(graph);

            StockKitComponents = new PXSelect <INKitSpecStkDet,
                                               Where <INKitSpecStkDet.kitInventoryID, Equal <Required <INKitSpecStkDet.kitInventoryID> >,
                                                      And <INKitSpecStkDet.revisionID, Equal <Required <INKitSpecStkDet.revisionID> >,
                                                           And <Where <INKitSpecStkDet.lastModifiedDateTime, Greater <Required <INKitSpecStkDet.lastModifiedDateTime> >,
                                                                       And <Where <INKitSpecStkDet.lastModifiedDateTime, Less <Required <INKitSpecStkDet.lastModifiedDateTime> > > > > > > > >(graph);

            NonStockKitComponents = new PXSelect <INKitSpecNonStkDet,
                                                  Where <INKitSpecNonStkDet.kitInventoryID, Equal <Required <INKitSpecNonStkDet.kitInventoryID> >,
                                                         And <INKitSpecNonStkDet.revisionID, Equal <Required <INKitSpecNonStkDet.revisionID> >,
                                                              And <Where <INKitSpecNonStkDet.lastModifiedDateTime, Greater <Required <INKitSpecNonStkDet.lastModifiedDateTime> >,
                                                                          And <INKitSpecNonStkDet.lastModifiedDateTime, Less <Required <INKitSpecNonStkDet.lastModifiedDateTime> > > > > > > >(graph);

            QuantityUpdate = new PXSelect <INTran,
                                           Where <INTran.lastModifiedDateTime, Greater <Required <KNSIKCInventoryItem.usrKCCASyncDate> > > >(graph);
        }
        private void Export(KCDataExchangeMaint graph, List <KeyValuePair <string, InventoryItem> > products, CancellationToken cancellationToken,
                            Dictionary <string, KCAPIInventoryItem> MSMQPrices = null, Dictionary <string, List <KCAPIQuantity> > MSMQQuantityUpdates = null)
        {
            KCBulkProductMaint bulkGraph    = PXGraph.CreateInstance <KCBulkProductMaint>();
            KCSiteMaster       connection   = graph.Connection.SelectSingle();
            KCARestClient      client       = new KCARestClient(connection);
            KCBulkUploader     bulkUploader = new KCBulkUploader(bulkGraph, logger.LoggerProperties, cancellationToken)
            {
                ApiHelper = new KCInventoryItemAPIHelper(client, logger.LoggerProperties),
                _strategy = new KCFullSync(bulkGraph)
            };
            List <KCBulkProduct> dtos = bulkUploader.HandleItems(products, MSMQPrices, MSMQQuantityUpdates);

            if (dtos.Count > 0)
            {
                string bulkFile        = bulkUploader.PrepareItemBulkFile(dtos);
                string productFilePath = bulkUploader.GenerateProductUploadPath(connection);
                bulkUploader.UploadFileToFTP(connection, bulkFile, productFilePath);
            }
        }
 public KCValidParentRule(KCBulkProductMaint graph)
 {
     Graph = graph;
 }
Пример #10
0
 public KCFullSync(KCBulkProductMaint graph) : base(graph)
 {
 }
 public KCClassificationRule(KCBulkProductMaint graph)
 {
     Graph = graph;
 }
Пример #12
0
 public KCActiveRule(KCBulkProductMaint graph)
 {
     Graph = graph;
 }
 public KCBulkUploader(KCBulkProductMaint graph, KCLoggerProperties loggerProperties, CancellationToken cancellationToken)
 {
     Graph  = graph;
     logger = new KCLoggerProvider(loggerProperties);
     this.cancellationToken = cancellationToken;
 }
        protected List <(string imagePlacement, string imageUrl)> HandleImages(InventoryItem product, KCBulkProductMaint graph)
        {
            List <(string, string)>        images = new List <(string, string)>();
            PXResultset <KCImagePlacement> mappedImagePlacements = graph.MappedImagePlacements.Select(product.NoteID);

            foreach (PXResult <KCImagePlacement> mappedImagePlacement in mappedImagePlacements)
            {
                KCImagePlacement image     = mappedImagePlacement.GetItem <KCImagePlacement>();
                CSAnswers        attribute = mappedImagePlacement.GetItem <CSAnswers>();

                images.Add((image.ImagePlacement, attribute.Value));
            }

            return(images);
        }
Пример #15
0
 public KCNumberPerBundleRule(KCBulkProductMaint graph)
 {
     Graph = graph;
 }
Пример #16
0
 public KCValidChildrenRule(KCBulkProductMaint graph)
 {
     Graph = graph;
 }