private ClearProductsData DeleteSome(long storeId, int howMany) { var items = CatalogServices.Products.FindAllPagedWithCache(1, howMany); var totalCount = CatalogServices.Products.FindAllCount(storeId); if (items != null) { foreach (var p in items) { CatalogServices.DestroyProduct(p.Bvin, p.StoreId); } } var left = totalCount - howMany; if (left < 0) { left = 0; } var cleared = howMany; if (totalCount < howMany) { cleared = totalCount; } var result = new ClearProductsData(); result.ProductsCleared = cleared; result.ProductsRemaining = left; return(result); }
private void OrdersShipItems(OrderPackage package, Order order) { if (package.Items.Count == 0) { return; } foreach (var pi in package.Items) { var li = order.GetLineItem(pi.LineItemId); if (li == null || li.IsNonShipping) { continue; } // Prevent shipping more than ordered if order is not recurring if (!order.IsRecurring && pi.Quantity > li.Quantity - li.QuantityShipped) { pi.Quantity = li.Quantity - li.QuantityShipped; } if (pi.Quantity <= 0) { pi.Quantity = 0; } else { CatalogServices.InventoryLineItemShipQuantity(li, pi.Quantity); } } }
public bool DestroyAllProductsForStore(long storeId) { var bvins = CatalogServices.Products.FindAllBvinsForStore(storeId); foreach (var bvin in bvins) { CatalogServices.DestroyProduct(bvin, storeId); } return(true); }
public bool OrdersUnreserveInventoryForAllItems(Order o) { var result = true; foreach (var li in o.Items) { if (CatalogServices.InventoryLineItemUnreserveInventory(li) == false) { EventLog.LogEvent("Unreserve Inventory For All Items", "Unable to unreserve quantity of " + li.Quantity + " for product " + li.ProductId, EventLogSeverity.Debug); } } return(result); }
public bool DestroyAllCategories() { var current = DateTime.UtcNow; var availableUntil = CurrentRequestContext.CurrentStore.Settings.AllowApiToClearUntil; var compareResult = DateTime.Compare(current, availableUntil); if (compareResult >= 0) { return(false); } var all = CatalogServices.Categories.FindAll(); foreach (var snap in all) { CatalogServices.DestroyCategory(snap.Bvin); } return(true); }
// Orders public bool OrdersReserveInventoryForAllItems(Order o, List <string> errors) { var result = true; foreach (var li in o.Items) { li.QuantityReserved = CatalogServices.InventoryLineItemReserveInventory(li); if (li.QuantityReserved != li.Quantity) { if (errors != null) { errors.Add("Item " + li.ProductName + " did not have enough quantity to complete order."); } EventLog.LogEvent("Reserve Inventory For All Items", "Unable to reserve quantity of " + li.Quantity + " for product " + li.ProductId, EventLogSeverity.Debug); result = false; } } return(result); }
public bool OrdersUnshipItems(OrderPackage package, Order order) { if (order == null) { throw new NullReferenceException("order"); } if (package == null) { throw new NullReferenceException("package"); } var result = true; if (package.Items.Count == 0) { return(result); } foreach (var pi in package.Items) { var li = order.GetLineItem(pi.LineItemId); if (li == null || li.IsNonShipping) { continue; } // Prevent unshipping more than shipped if order is not recurring var quantityToUnship = pi.Quantity; if (!order.IsRecurring && pi.Quantity > li.QuantityShipped) { quantityToUnship = li.QuantityShipped; } CatalogServices.InventoryLineItemUnShipQuantity(li, quantityToUnship); } return(result); }
// Multi-Store Destroy public bool DestroyStore(long storeId) { EventLog.LogEvent("System", "Destroying Store " + storeId, EventLogSeverity.Debug); var result = true; var s = AccountServices.Stores.FindById(storeId); if (s == null) { return(false); } if (s.Id != storeId) { return(false); } DiskStorage.DestroyAllFilesForStore(storeId); //this.AccountServices.RemoveAllUsersFromStore(storeId); // Store Address var storeAddress = ContactServices.Addresses.FindStoreContactAddress(); if (storeAddress != null) { ContactServices.Addresses.Delete(storeAddress.Bvin); } // Get rid of URLs so they won't stop category/product deletes ContentServices.CustomUrls.DestoryAllForStore(storeId); // Catalog Services DestroyAllProductsForStore(storeId); DestroyAllCategoriesForStore(storeId); CatalogServices.ProductProperties.DestroyAllForStore(storeId); CatalogServices.ProductTypeDestoryAllForStore(storeId); CatalogServices.WishListItems.DestroyAllForStore(storeId); // Contact Services ContactServices.Affiliates.DestoryForStore(storeId); ContactServices.MailingLists.DestoryForStore(storeId); ContactServices.Manufacturers.DestoryAllForStore(storeId); ContactServices.PriceGroups.DestoryAllForStore(storeId); ContactServices.Vendors.DestoryAllForStore(storeId); // Content Services ContentServices.Columns.DestroyForStore(storeId); ContentServices.HtmlTemplates.DestroyAllForStore(storeId); // Customer Points CustomerPointsManager.DestroyAllForStore(storeId); // Membership MembershipServices.UserQuestions.DestroyAllForStore(storeId); MembershipServices.Customers.DestroyAllForStore(storeId); // Marketing MarketingServices.Promotions.DestroyAllForStore(storeId); // Metrics MetricsSerices.SearchQueries.DestoryAllForStore(storeId); // Orders OrderServices.Orders.DestoryAllForStore(storeId); OrderServices.ShippingMethods.DestoryAllForStore(storeId); OrderServices.ShippingZones.DestoryAllForStore(storeId); OrderServices.Taxes.DestoryAllForStore(storeId); OrderServices.TaxSchedules.DestoryAllForStore(storeId); OrderServices.Transactions.DestoryAllForStore(storeId); // Tasks ScheduleServices.QueuedTasks.DestoryAllForStore(storeId); // Account Services AccountServices.ApiKeys.DestoryAllForStore(storeId); AccountServices.Stores.Delete(storeId); if (result) { EventLog.LogEvent("System", "Finished Destroying Store " + storeId, EventLogSeverity.Debug); } else { EventLog.LogEvent("System", "Error Destroying Store " + storeId, EventLogSeverity.Warning); } return(result); }
public SystemOperationResult CheckForStockOnItems(LineItem item) { // Build a list of product quantities to check var products = new Dictionary <string, ProductIdCombo>(); var product = item.GetAssociatedProduct(this); if (product == null || product.Status == ProductStatus.Disabled) { var productNotAvailable = GlobalLocalization.GetFormattedString("ProductNotAvailable", product.ProductName); return(new SystemOperationResult(false, productNotAvailable)); } if (!product.IsBundle) { var combo = new ProductIdCombo { ProductId = item.ProductId, VariantId = item.VariantId, ProductName = item.ProductName, Quantity = item.Quantity, Product = product }; if (products.ContainsKey(combo.Key())) { products[combo.Key()].Quantity += combo.Quantity; } else { products.Add(combo.Key(), combo); } } else { foreach (var bundledProductAdv in product.BundledProducts) { var bundledProduct = bundledProductAdv.BundledProduct; if (bundledProduct == null) { continue; } var optionSelection = item.SelectionData.GetSelections(bundledProductAdv.Id); var variant = bundledProduct.Variants.FindBySelectionData(optionSelection, bundledProduct.Options); var variantId = variant != null ? variant.Bvin : string.Empty; var combo = new ProductIdCombo { ProductId = bundledProduct.Bvin, VariantId = variantId, ProductName = bundledProduct.ProductName, Quantity = bundledProductAdv.Quantity, Product = bundledProduct }; if (products.ContainsKey(combo.Key())) { products[combo.Key()].Quantity += combo.Quantity; } else { products.Add(combo.Key(), combo); } } } // Now check each quantity for the order foreach (var key in products.Keys) { var checkcombo = products[key]; var prod = checkcombo.Product; var data = CatalogServices.SimpleProductInventoryCheck(prod, checkcombo.VariantId, checkcombo.Quantity); if (!data.IsAvailableForSale) { if (data.Qty == 0) { var cartOutOfStock = GlobalLocalization.GetFormattedString("CartOutOfStock", prod.ProductName); return(new SystemOperationResult(false, cartOutOfStock)); } var message = GlobalLocalization.GetFormattedString("CartNotEnoughQuantity", prod.ProductName, data.Qty); return(new SystemOperationResult(false, message)); } } return(new SystemOperationResult(true, string.Empty)); }
public bool DestroyCategoryForStore(string bvin, long storeId) { return(CatalogServices.DestroyCategoryForStore(bvin, storeId)); }
public bool DestroyCategory(string bvin) { return(CatalogServices.DestroyCategory(bvin)); }
public bool DestroyProduct(string bvin, long storeId) { return(CatalogServices.DestroyProduct(bvin, storeId)); }
/// <summary> /// Main entry point for ImageVerifier application /// </summary> /// <param name="args">Represents path to tab delimited file or a single ImageID GUID</param> /// **TBD** Needs to be refactored to several classes. Option to compare images for a single imageId /// static void Main(string[] args) { List <string> imageIDs = new List <string>(); string line = null; //using (StreamReader file = new StreamReader(@"C:\Users\V-saeld\Desktop\Image\ImageID.txt")) using (StreamReader file = new StreamReader(@"..\..\999.txt")) { while ((line = file.ReadLine()) != null) { char[] delimiters = new char[] { '\t' }; string[] parts = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < parts.Length; i++) { imageIDs.Add(parts[i]); } } file.Close(); } string results = @"C:\Users\v-saeld\Desktop\results.log"; using (StreamWriter logWriter = new StreamWriter(results)) { foreach (string imageID in imageIDs) { logWriter.WriteLine("ImageID: {0}", imageID); Console.WriteLine("ImageID: {0}", imageID); CatalogServices cs = Constants.Proxy; ImageSearchRequest imageSearchRequest = new ImageSearchRequest(); List <ImageVerifier.ImInstDisplay> list = new List <ImageVerifier.ImInstDisplay>(); Dictionary <Guid, string> dictUrl = new Dictionary <Guid, string>(); ImageVerifier.MVAProxy.Image image = null; ImageVerifier.ImInstDisplay im = new ImageVerifier.ImInstDisplay(); im.ImageID = new Guid(imageID); image = cs.GetImage(im.ImageID); int OriginalImageSizeID = 0; int ThumbnailImageSizeID = 4; List <ImageVerifier.MVAProxy.ImageSize> imageSizes = ImageVerifier.MVAProxy.ImageSize.Get(); ImageVerifier.ImInstDisplay imInstDisplay = new ImageVerifier.ImInstDisplay(); int originalImageFileWidth = 0, originalImageFileHeight = 0, originalImageFileSize = 0; string originalImageFileExtension = string.Empty; bool originalFileAvailable = false; bool originalFileinSanAvailable = true; foreach (ImageInstance iminst in image.Instances) { if (iminst.ImageSizeId == OriginalImageSizeID) { im.OriginalFileGuid = iminst.Id; ImageFileHandler.GetImageFileProperty(iminst.Id, out originalImageFileWidth, out originalImageFileHeight, out originalImageFileSize, out originalImageFileExtension); if (originalImageFileWidth == 0 && originalImageFileHeight == 0 && originalImageFileSize == 0) { Console.WriteLine("ImageID: {0} - There is no image in San folder-{1}.", imageID, originalImageFileExtension); logWriter.WriteLine("ImageID: {0} - There is no image in San folder-{1}.", imageID, originalImageFileExtension); originalFileinSanAvailable = false; break; } else { originalFileAvailable = true; continue; } } else if (iminst.ImageSizeId == ThumbnailImageSizeID) { continue; } else { imInstDisplay.LiveURL = iminst.FileUrl; dictUrl.Add(iminst.Id, imInstDisplay.LiveURL.ToString()); } } Hashtable propImageList = new Hashtable(); foreach (ImageInstance iminst in image.Instances) { if (!originalFileinSanAvailable) { break; } string sourceImageFileExtension = string.Empty; int sourceImageFileWidth = 0, sourceImageFileHeight = 0, sourceImageFileSize = 0; int thumbNailImageSizeID = 4; if (!originalFileAvailable) { logWriter.WriteLine("ImageID: {0}-There is no original image.", imageID); Console.WriteLine("ImageID: {0}-There is no original image.", imageID); break; } ImageFileHandler.GetImageFileProperty(iminst.Id, out sourceImageFileWidth, out sourceImageFileHeight, out sourceImageFileSize, out sourceImageFileExtension); if (iminst.ImageSizeId == OriginalImageSizeID || iminst.ImageSizeId == thumbNailImageSizeID) { continue; } ImageSize imSize1 = new ImageSize(); imSize1.Id = iminst.ImageSizeId; imSize1.Width = sourceImageFileWidth; imSize1.Height = sourceImageFileHeight; propImageList.Add(iminst.Id, imSize1); } if (originalFileAvailable && originalFileinSanAvailable) { Dictionary <Guid, System.Drawing.Image> dictDestImages = ImageFileHandler.PropImage(image, propImageList, im.OriginalFileGuid); Dictionary <Guid, System.Drawing.Image> dictImages = new Dictionary <Guid, System.Drawing.Image>(); foreach (var pair in dictUrl) { System.Drawing.Image ima = ImageUtil.DownloadImage(pair.Value); dictImages.Add(pair.Key, ima); } foreach (KeyValuePair <Guid, System.Drawing.Image> Origkvp in dictImages) { foreach (KeyValuePair <Guid, System.Drawing.Image> kvp in dictDestImages) { if (Origkvp.Key == kvp.Key) { bool IsImageSame = ImageUtil.DiffImages(kvp.Value, Origkvp.Value); if (!IsImageSame) { logWriter.WriteLine("InstanceID: {0} Different image.", kvp.Key); Console.WriteLine("InstanceID: {0} Different image.", kvp.Key); } else { logWriter.WriteLine("InstanceID: {0} Same image.", kvp.Key); Console.WriteLine("InstanceID: {0} Same image.", kvp.Key); } } } } } } Console.ReadLine(); } }
public void ProductServices_Constructor_Should_Throw_ArgumentNullException_On_Null_Repository() { CatalogServices target = new CatalogServices(null); }