コード例 #1
0
        public int SyncAllSupplierInventories()
        {
            var count     = 0;
            var suppliers = WebServiceHelper.GetAllSuppliers();

            // NOTE: just pulling inventories for suppliers we have internal records for.
            //  Questionable - maybe this should be configurable?
            foreach (var supplier in suppliers.Where(s => !string.IsNullOrEmpty(s.OurContactInfo.OurSupplierNumber)))
            {
                var lgSupplierInventories = WebServiceHelper.GetSupplierInventory(supplier.Id).ToDictionary(si => si.ItemId);
                var command = new OleDbCommand($"SELECT * FROM {TableName} Where SupplierId = {supplier.Id}");
                var updatedSupplierInventories = GetRecords(command);
                foreach (var inventory in updatedSupplierInventories.Where(i => !string.IsNullOrEmpty(i.BuyerLinkedSku) && lgSupplierInventories.ContainsKey(i.ItemId)))
                {
                    var lgSupplierInventory = lgSupplierInventories[inventory.ItemId];
                    if (!string.IsNullOrEmpty(inventory.BuyerLinkedSku) && (lgSupplierInventory.BuyerLinkedSkus == null || !lgSupplierInventory.BuyerLinkedSkus.Any(sku => sku == inventory.BuyerLinkedSku)))
                    {
                        // this didn't come in from the web service
                        lgSupplierInventory.SupplierId = supplier.Id;
                        WebServiceHelper.UpdateSupplierInventory(lgSupplierInventory, inventory.BuyerLinkedSku);
                        count++;
                    }
                }
            }
            return(count);
        }
コード例 #2
0
        public void DownloadSupplierInventory()
        {
            var suppliers = WebServiceHelper.GetAllSuppliers();

            // NOTE: just pulling inventories for suppliers we have internal records for.
            //  Questionable - maybe this should be configurable?
            foreach (var supplier in suppliers.Where(s => !string.IsNullOrEmpty(s.OurContactInfo.OurSupplierNumber)))
            {
                var inventory = WebServiceHelper.GetSupplierInventory(supplier.Id);
                if (inventory != null)
                {
                    foreach (var item in inventory)
                    {
                        Insert(item, supplier);
                    }
                }
            }
        }
コード例 #3
0
        public int SyncAllSuppliers()
        {
            var count       = 0;
            var lgSuppliers = WebServiceHelper.GetAllSuppliers().ToDictionary(s => s.Id);

            IEnumerable <Supplier> updatedSuppliers;

            using (var command = new OleDbCommand($"SELECT * FROM {TableName}")) {
                updatedSuppliers = GetRecords(command);
            }

            foreach (var supplier in updatedSuppliers.Where(s => lgSuppliers.ContainsKey(s.Id)))
            {
                var lgSupplier = lgSuppliers[supplier.Id];
                WebServiceHelper.UpdateSupplierContactInfo(lgSupplier, supplier.OurContactInfo.OurSupplierNumber);
                count++;
            }

            return(count);
        }
コード例 #4
0
        private List <Supplier> GetAll()
        {
            var suppliers = WebServiceHelper.GetAllSuppliers();

            return(suppliers);
        }