コード例 #1
0
        private void CommitToDatabase(List <AsinProductData> asinData)
        {
            using (var db = new CheapeesEntities())
            {
                db.Configuration.AutoDetectChangesEnabled = false;
                db.Configuration.ValidateOnSaveEnabled    = false;

                for (int i = 0; i < asinData.Count; i++)
                {
                    var           a       = asinData[i];
                    AmazonListing dbEntry = new AmazonListing();
                    dbEntry.Asin               = a.Asin;
                    dbEntry.BuyBox             = a.BuyBoxTotalPrice;
                    dbEntry.CurrentlyOwnBuyBox = a.CurrentlyOwnBuyBox;
                    dbEntry.Date               = DateTime.Now;
                    dbEntry.SalesRank          = a.SalesRankTopLevel;

                    if (db.AmazonListings.Where(o => o.Asin.Equals(dbEntry.Asin) && o.Date.Equals(dbEntry.Date)).Count() == 0 && db.AmazonListings.Local.Where(o => o.Asin.Equals(dbEntry.Asin) && o.Date.Equals(dbEntry.Date)).Count() == 0)
                    {
                        db.AmazonListings.Add(dbEntry);
                    }

                    if (i % 1000 == 0)
                    {
                        this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({1}/{2})", i * 100.0 / asinData.Count, i, asinData.Count);
                        this.StatusPercentage  = i * 100 / asinData.Count;
                        db.SaveChanges();
                    }
                }

                db.SaveChanges();
            }
        }
コード例 #2
0
        private void CommitToDatabase(List <AsinPrepData> asinData)
        {
            using (var db = new CheapeesEntities())
            {
                db.Configuration.AutoDetectChangesEnabled = false;
                db.Configuration.ValidateOnSaveEnabled    = false;

                for (int i = 0; i < asinData.Count; i++)
                {
                    var a = asinData[i];
                    if (db.AmazonPrepInstructions.Where(o => o.Asin.Equals(a.Asin)).Count() == 0 && db.AmazonPrepInstructions.Local.Where(o => o.Asin.Equals(a.Asin)).Count() == 0)
                    {
                        AmazonPrepInstruction dbEntry = new AmazonPrepInstruction();
                        dbEntry.Asin         = a.Asin;
                        dbEntry.Labelling    = a.Labelling;
                        dbEntry.PrepRequired = a.Prep;

                        db.AmazonPrepInstructions.Add(dbEntry);
                    }
                    else
                    {
                        AmazonPrepInstruction dbEntry = db.AmazonPrepInstructions.Where(o => o.Asin.Equals(a.Asin)).SingleOrDefault();
                        if (dbEntry != null)
                        {
                            dbEntry.Labelling    = a.Labelling;
                            dbEntry.PrepRequired = a.Prep;
                        }
                    }

                    if (i % 1000 == 0)
                    {
                        this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({1}/{2})", i * 100.0 / asinData.Count, i, asinData.Count);
                        this.StatusPercentage  = i * 100 / asinData.Count;
                        db.SaveChanges();
                    }
                }

                db.SaveChanges();
            }
        }
コード例 #3
0
        private void CommitToDatabase(List <InventoryItem> inventory)
        {
            using (var db = new CheapeesEntities())
            {
                db.Configuration.AutoDetectChangesEnabled = false;
                db.Configuration.ValidateOnSaveEnabled    = false;

                for (int i = 0; i < inventory.Count; i++)
                {
                    var item   = inventory[i];
                    var entity = db.Inventories.Where(o => o.Sku.Equals(item.Sku)).FirstOrDefault();
                    if (entity == null)
                    {
                        entity       = new Inventory();
                        entity.Asin  = item.Asin;
                        entity.Sku   = item.Sku;
                        entity.Title = item.Title;

                        db.Inventories.Add(entity);
                    }
                    else
                    {
                        entity.Asin  = item.Asin;
                        entity.Sku   = item.Sku;
                        entity.Title = item.Title;
                    }

                    if (i % 1000 == 0)
                    {
                        // Save every 1000 records
                        this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({0}/{1})", i * 100.0 / inventory.Count, i, inventory.Count);
                        this.StatusPercentage  = (i * 100) / inventory.Count;
                        db.SaveChanges();
                    }
                }
                db.SaveChanges();
            }
        }
コード例 #4
0
        public void CommitToDatabase(List <FbaInventoryQuantity> fbaQuantities)
        {
            using (var db = new CheapeesEntities())
            {
                db.Configuration.AutoDetectChangesEnabled = false;
                db.Configuration.ValidateOnSaveEnabled    = false;

                // Clear table first
                db.AmazonFulfilledInventories.RemoveRange(db.AmazonFulfilledInventories);
                db.SaveChanges();

                for (int i = 0; i < fbaQuantities.Count; i++)
                {
                    var qty = fbaQuantities[i];
                    AmazonFulfilledInventory dbInv = new AmazonFulfilledInventory();
                    dbInv.Asin   = qty.Asin;
                    dbInv.FbaSku = qty.Sku;
                    dbInv.Fnsku  = qty.Fnsku;
                    dbInv.FulfillableQuantity      = qty.FulfillableQuantity;
                    dbInv.InboundReceivingQuantity = qty.InboundReceivingQuantity;
                    dbInv.InboundShippedQuantity   = qty.InboundShippedQuantity;
                    dbInv.InboundWorkingQuantity   = qty.InboundWorkingQuantity;
                    dbInv.TotalQuantity            = qty.TotalQuantity;

                    db.AmazonFulfilledInventories.Add(dbInv);

                    if (i % 1000 == 0)
                    {
                        this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({1}/{2})", i * 100.0 / fbaQuantities.Count, i, fbaQuantities.Count);
                        this.StatusPercentage  = i * 100 / fbaQuantities.Count;
                        db.SaveChanges();
                    }
                }

                db.SaveChanges();
            }
        }
コード例 #5
0
 public void CommitServiceStatus()
 {
     using (var db = new CheapeesEntities())
     {
         var entry = db.ServiceStatuses.Where(o => o.ServiceId.Equals(this.ServiceId)).SingleOrDefault();
         if (entry != null)
         {
             entry.LastSuccessfulUpdate = this.LastUpdated;
         }
         else
         {
             ServiceStatus status = new ServiceStatus();
             status.ServiceId            = this.ServiceId;
             status.LastSuccessfulUpdate = this.LastUpdated;
             db.ServiceStatuses.Add(status);
         }
         db.SaveChanges();
     }
 }
コード例 #6
0
        private void CommitToDatabase(List <ChannelAdvisorSale> sales)
        {
            using (var db = new CheapeesEntities())
            {
                foreach (var sale in sales)
                {
                    if (db.MerchantFulfilledSales.Local.Count(o => (o.Invoice.Equals(sale.Invoice) && o.Sku.Equals(sale.SKU))) == 0 && db.MerchantFulfilledSales.Count(o => (o.Invoice.Equals(sale.Invoice) && o.Sku.Equals(sale.SKU))) == 0)
                    {
                        MerchantFulfilledSale dbSale = new MerchantFulfilledSale();
                        dbSale.Invoice     = sale.Invoice;
                        dbSale.Marketplace = sale.Marketplace;
                        dbSale.OrderTime   = sale.OrderTime;
                        dbSale.Quantity    = sale.Quantity;
                        dbSale.Sku         = sale.SKU;
                        dbSale.UnitPrice   = sale.UnitPrice;

                        db.MerchantFulfilledSales.Add(dbSale);
                    }
                }
                db.SaveChanges();
            }
        }
コード例 #7
0
    private void CommitToDatabase(List<InventoryItem> inventory)
    {
      using (var db = new CheapeesEntities())
      {
        db.Configuration.AutoDetectChangesEnabled = false;
        db.Configuration.ValidateOnSaveEnabled = false;

        for (int i = 0; i < inventory.Count; i++)
        {
          var item = inventory[i];
          var entity = db.Inventories.Where(o => o.Sku.Equals(item.Sku)).FirstOrDefault();
          if (entity == null)
          {
            entity = new Inventory();
            entity.Asin = item.Asin;
            entity.Sku = item.Sku;
            entity.Title = item.Title;

            db.Inventories.Add(entity);
          }
          else
          {
            entity.Asin = item.Asin;
            entity.Sku = item.Sku;
            entity.Title = item.Title;
          }
          
          if (i % 1000 == 0)
          {
            // Save every 1000 records
            this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({0}/{1})", i * 100.0 / inventory.Count, i, inventory.Count);
            this.StatusPercentage = (i * 100) / inventory.Count;
            db.SaveChanges();
          }
        }
        db.SaveChanges();
      }
    }
コード例 #8
0
 public void CommitServiceStatus()
 {
   using (var db = new CheapeesEntities())
   {
     var entry = db.ServiceStatuses.Where(o => o.ServiceId.Equals(this.ServiceId)).SingleOrDefault();
     if (entry != null)
       entry.LastSuccessfulUpdate = this.LastUpdated;
     else
     {
       ServiceStatus status = new ServiceStatus();
       status.ServiceId = this.ServiceId;
       status.LastSuccessfulUpdate = this.LastUpdated;
       db.ServiceStatuses.Add(status);
     }
     db.SaveChanges();
   }
 }
コード例 #9
0
    private void CommitToDatabase(List<AsinProductData> asinData)
    {
      using (var db = new CheapeesEntities())
      {
        db.Configuration.AutoDetectChangesEnabled = false;
        db.Configuration.ValidateOnSaveEnabled = false;

        for (int i = 0; i < asinData.Count; i++)
        {
          var a = asinData[i];
          AmazonListing dbEntry = new AmazonListing();
          dbEntry.Asin = a.Asin;
          dbEntry.BuyBox = a.BuyBoxTotalPrice;
          dbEntry.CurrentlyOwnBuyBox = a.CurrentlyOwnBuyBox;
          dbEntry.Date = DateTime.Now;
          dbEntry.SalesRank = a.SalesRankTopLevel;
          
          if (db.AmazonListings.Where(o => o.Asin.Equals(dbEntry.Asin) && o.Date.Equals(dbEntry.Date)).Count() == 0 && db.AmazonListings.Local.Where(o => o.Asin.Equals(dbEntry.Asin) && o.Date.Equals(dbEntry.Date)).Count() == 0)
          {
            db.AmazonListings.Add(dbEntry);
          }

          if (i % 1000 == 0)
          {
            this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({1}/{2})", i * 100.0 / asinData.Count, i, asinData.Count);
            this.StatusPercentage = i * 100 / asinData.Count;
            db.SaveChanges();
          }

        }

        db.SaveChanges();
      }
    }
コード例 #10
0
    private void CommitToDatabase(List<ChannelAdvisorSale> sales)
    {
      using (var db = new CheapeesEntities())
      {
        foreach (var sale in sales)
        {
          if (db.MerchantFulfilledSales.Local.Count(o => (o.Invoice.Equals(sale.Invoice) && o.Sku.Equals(sale.SKU))) == 0 && db.MerchantFulfilledSales.Count(o => (o.Invoice.Equals(sale.Invoice) && o.Sku.Equals(sale.SKU))) == 0)
          {
            MerchantFulfilledSale dbSale = new MerchantFulfilledSale();
            dbSale.Invoice = sale.Invoice;
            dbSale.Marketplace = sale.Marketplace;
            dbSale.OrderTime = sale.OrderTime;
            dbSale.Quantity = sale.Quantity;
            dbSale.Sku = sale.SKU;
            dbSale.UnitPrice = sale.UnitPrice;

            db.MerchantFulfilledSales.Add(dbSale);
          }

        }
        db.SaveChanges();
      }
    }
コード例 #11
0
    public void CommitToDatabase(List<FbaInventoryQuantity> fbaQuantities)
    {
      using (var db = new CheapeesEntities())
      {
        db.Configuration.AutoDetectChangesEnabled = false;
        db.Configuration.ValidateOnSaveEnabled = false;

        // Clear table first
        db.AmazonFulfilledInventories.RemoveRange(db.AmazonFulfilledInventories);
        db.SaveChanges();

        for (int i = 0; i < fbaQuantities.Count; i++)
        {
          var qty = fbaQuantities[i];
          AmazonFulfilledInventory dbInv = new AmazonFulfilledInventory();
          dbInv.Asin = qty.Asin;
          dbInv.FbaSku = qty.Sku;
          dbInv.Fnsku = qty.Fnsku;
          dbInv.FulfillableQuantity = qty.FulfillableQuantity;
          dbInv.InboundReceivingQuantity = qty.InboundReceivingQuantity;
          dbInv.InboundShippedQuantity = qty.InboundShippedQuantity;
          dbInv.InboundWorkingQuantity = qty.InboundWorkingQuantity;
          dbInv.TotalQuantity = qty.TotalQuantity;

          db.AmazonFulfilledInventories.Add(dbInv);

          if (i % 1000 == 0)
          {
            this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({1}/{2})", i * 100.0 / fbaQuantities.Count, i, fbaQuantities.Count);
            this.StatusPercentage = i * 100 / fbaQuantities.Count;
            db.SaveChanges();
          }

        }

        db.SaveChanges();
      }
    }
コード例 #12
0
    private void CommitToDatabase(List<AsinPrepData> asinData)
    {
      using (var db = new CheapeesEntities())
      {
        db.Configuration.AutoDetectChangesEnabled = false;
        db.Configuration.ValidateOnSaveEnabled = false;

        for (int i = 0; i < asinData.Count; i++)
        {
          var a = asinData[i];
          if (db.AmazonPrepInstructions.Where(o => o.Asin.Equals(a.Asin)).Count() == 0 && db.AmazonPrepInstructions.Local.Where(o => o.Asin.Equals(a.Asin)).Count() == 0)
          {
            AmazonPrepInstruction dbEntry = new AmazonPrepInstruction();
            dbEntry.Asin = a.Asin;
            dbEntry.Labelling = a.Labelling;
            dbEntry.PrepRequired = a.Prep;

            db.AmazonPrepInstructions.Add(dbEntry);
          }
          else
          {
            AmazonPrepInstruction dbEntry = db.AmazonPrepInstructions.Where(o => o.Asin.Equals(a.Asin)).SingleOrDefault();
            if (dbEntry != null)
            {
              dbEntry.Labelling = a.Labelling;
              dbEntry.PrepRequired = a.Prep;
            }
          }

          if (i % 1000 == 0)
          {
            this.StatusDescription = string.Format("Committing to database - {0:0.00}% ({1}/{2})", i * 100.0 / asinData.Count, i, asinData.Count);
            this.StatusPercentage = i * 100 / asinData.Count;
            db.SaveChanges();
          }

        }

        db.SaveChanges();
      }
    }