コード例 #1
0
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;

                if (row != null)
                {
                    String sku            = row.GetColumn(Sku).Value;
                    String weightAsString = row.GetColumn(Weight).Value;
                    String volumeAsString = row.GetColumn(Volume).Value;

                    if (String.IsNullOrWhiteSpace(weightAsString) == false && String.IsNullOrWhiteSpace(volumeAsString) == false)
                    {
                        if (decimal.TryParse(weightAsString, out decimal weightAsLBS) &&
                            decimal.TryParse(volumeAsString, out decimal volumeAsCubicFeet))
                        {
                            decimal gramConversionFactor = (decimal)453.59237;

                            decimal weight = gramConversionFactor * weightAsLBS;

                            WeightCubicVolumeInformation wi = new WeightCubicVolumeInformation(weight, weightAsLBS, volumeAsCubicFeet);

                            MatchingRowIds.Add(sku, wi);

                            result = true;
                        }
                    }
                }
                return(result);
            }
コード例 #2
0
 public bool?HasBeenFiltered(IFilterRow row)
 {
     if (ShouldFilter == false)
     {
         return(null);
     }
     return(row?.FreeShipping);
 }
コード例 #3
0
 public bool?HasBeenFiltered(IFilterRow row)
 {
     if (ShouldFilter == false)
     {
         return(true);
     }
     return(MatchingRowIds.Contains(row?.Handle.Value));
 }
コード例 #4
0
            public bool?HasBeenFiltered(IFilterRow row)
            {
                if (ShouldFilter == false)
                {
                    return(null);
                }
                IFilterValue handle = row.GetColumn("Handle");

                return(MatchingRowIds.Contains(handle?.Value));
            }
コード例 #5
0
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;

                if (row != null)
                {
                    row.Handle = row.GetColumn(VariantSku);
                    MatchingRowIds.Add(row.Handle.Value);
                    result = true;
                }
                return(result);
            }
コード例 #6
0
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;



                IFilterValue weightString = row.GetColumn(Weight);
                IFilterValue lengthString = row.GetColumn(Length);
                IFilterValue widthString  = row.GetColumn(Width);
                IFilterValue heightString = row.GetColumn(Height);
                IFilterValue handle       = row.GetColumn("Handle");

                bool we = decimal.TryParse(weightString?.Value, out decimal weight);
                bool le = decimal.TryParse(lengthString?.Value, out decimal length);
                bool wi = decimal.TryParse(widthString?.Value, out decimal width);
                bool he = decimal.TryParse(heightString?.Value, out decimal height);

                if (le && wi && he)
                {
                    decimal cubicVolumeLength = Math.Round(length);
                    decimal cubicVolumeWidth  = Math.Round(width);
                    decimal cubicVolumeHeight = Math.Round(height);

                    decimal dimWeight = cubicVolumeLength * cubicVolumeWidth * cubicVolumeHeight / DimWeightDivisor;

                    if (dimWeight > weight)
                    {
                        weight = dimWeight;
                    }
                }

                if (we)
                {
                    result = (weight < 1);
                    if (result)
                    {
                        row.Handle        = handle;
                        row.UnderOnePound = true;
                        MatchingRowIds.Add(handle.Value);
                    }
                    else
                    {
                        row.Handle       = handle;
                        row.OverOnePound = true;
                        Console.WriteLine($"Product with Handle={handle?.Value} and weight={weight} exceeds threshold=0.23");
                    }
                }
                return(result);
            }
            public bool?HasBeenFiltered(IFilterRow row)
            {
                if (row == null)
                {
                    return(false);
                }
                IFilterValue upc = row.GetColumn(VariantBarcode);

                if (upc == null)
                {
                    return(false);
                }

                row.RecommendedAmazonUk = RecommendedAmazonUkRowIds.Contains(upc.Value);
                row.RecommendedAmazonUs = RecommendedAmazonUsRowIds.Contains(upc.Value);
                row.RecommendedeBayUs   = RecommendedeBayUsRowIds.Contains(upc.Value);
                row.Recommended         = RecommendedRowIds.Contains(upc.Value);

                return(row.Recommended);
            }
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;



                IFilterValue recommendedAmazonUs = row.GetColumn(RecommendedAmazonUs);
                IFilterValue recommendedAmazonUk = row.GetColumn(RecommendedAmazonUk);
                IFilterValue recommendedeBayUs   = row.GetColumn(RecommendedeBayUs);
                IFilterValue recommended         = row.GetColumn(Recommended);
                IFilterValue upc = row.GetColumn(OriginalSearchTerm);

                if (upc == null || recommended == null)
                {
                    return(result);
                }

                double upcNumber = double.Parse(upc.Value, CultureInfo.InvariantCulture);

                if (String.IsNullOrEmpty(recommended.Value) == false)
                {
                    if (recommended.Value.Trim().ToLower() == "yes")
                    {
                        RecommendedRowIds.Add(upc.Value);
                        if (recommendedAmazonUk.Value.Trim().ToLower() == "yes")
                        {
                            RecommendedAmazonUkRowIds.Add(upc.Value);
                        }
                        if (recommendedAmazonUs.Value.Trim().ToLower() == "yes")
                        {
                            RecommendedAmazonUsRowIds.Add(upc.Value);
                        }
                        if (recommendedeBayUs.Value.Trim().ToLower() == "yes")
                        {
                            RecommendedeBayUsRowIds.Add(upc.Value);
                        }
                        result = true;
                    }
                }
                return(result);
            }
コード例 #9
0
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;

                IFilterValue inventoryString = row.GetColumn(Inventory);
                IFilterValue handle          = row.Handle ?? row.GetColumn("Handle");


                if (handle == null || inventoryString == null)
                {
                    return(result);
                }

                int  inventory = -1;
                bool i         = int.TryParse(inventoryString.Value, out inventory);

                if (i && String.IsNullOrEmpty(handle.Value) == false)
                {
                    if (MinimumInventoryThreshold > 0 && MaximumInventoryThreshold > MinimumInventoryThreshold)
                    {
                        result = inventory >= MinimumInventoryThreshold && inventory <= MaximumInventoryThreshold;
                    }
                    else if (MinimumInventoryThreshold == MaximumInventoryThreshold)
                    {
                        result = inventory > MinimumInventoryThreshold;
                    }

                    if (result)
                    {
                        row.Handle = handle;
                        MatchingRowIds.Add(handle.Value);
                    }
                    else
                    {
                        row.Handle = handle;
                        Console.WriteLine($"Product with Handle={handle} and no inventory.");
                    }
                }
                return(result);
            }
コード例 #10
0
            public bool ApplyFilter(IFilterRow row)
            {
                bool result = false;


                if (row != null)
                {
                    String volumeAsString = row.GetColumn("cubic_volume (in.)").Value;

                    String weightAsString           = row.GetColumn(Weight).Value;
                    String priceAsString            = row.GetColumn(Price).Value;
                    String msrpAsString             = row.GetColumn(Msrp).Value;
                    String mapAsString              = row.GetColumn(Map).Value;
                    String sku                      = row.GetColumn(Sku).Value;
                    WeightCubicVolumeInformation wi = null;

                    decimal.TryParse(msrpAsString, out decimal msrp);
                    decimal.TryParse(weightAsString, out decimal weight);
                    decimal.TryParse(volumeAsString, out decimal volume);
                    decimal.TryParse(mapAsString, out decimal map);

                    if (String.IsNullOrWhiteSpace(weightAsString) == false &&
                        String.IsNullOrWhiteSpace(volumeAsString) == false)
                    {
                        if (decimal.TryParse(weightAsString, out decimal weightAsLBS) &&
                            decimal.TryParse(volumeAsString, out decimal volumeAsCubicFeet))
                        {
                            decimal gramConversionFactor = (decimal)453.59237;

                            weight = gramConversionFactor * weightAsLBS;

                            wi = new WeightCubicVolumeInformation(weight, weightAsLBS, volumeAsCubicFeet);
                        }
                    }

                    decimal.TryParse(priceAsString, out decimal price);

                    decimal costPerItem = price;

                    price = (price * (decimal)ProfitMargin);
                    if (price > (decimal)3.0)
                    {
                        price = (Math.Floor(price) + (decimal)0.47);
                    }

                    if (price < costPerItem)
                    {
                        price = (costPerItem * (decimal)ProfitMargin);
                    }

                    if (String.IsNullOrWhiteSpace(mapAsString) == false)
                    {
                        if (price < map)
                        {
                            price = Math.Floor(map) + (decimal)0.49;
                        }
                    }

                    if (msrp > 0)
                    {
                        if (price > msrp)
                        {
                            price = msrp;
                        }
                    }
                    else
                    {
                        msrp = price + (price * (decimal)0.20);
                    }

                    IFilterValue storage = row.GetColumn("storage");
                    if (storage != null && string.IsNullOrWhiteSpace(storage.Value) == false &&
                        (storage.Value == Refrigerated || storage.Value == Frozen))
                    {
                        price += (decimal)ShippingSurcharge;
                    }

                    decimal volumeShippingCost = 0;
                    decimal weightShippingCost = 0;
                    if (wi != null && ShouldAddShipping)
                    {
                        (volumeShippingCost, weightShippingCost) = ShippingCost.Get(wi);

                        if (volumeShippingCost < weightShippingCost)
                        {
                            price += weightShippingCost;
                        }
                        else
                        {
                            price += volumeShippingCost;
                        }
                    }

                    PriceInformation pi = new PriceInformation(msrp.ToString("C2"), msrp.ToString("C2"), costPerItem.ToString("C2"), price.ToString("C2"));

                    MatchingRowIds.Add(row.GetColumn(Sku).Value, pi);

                    result = true;
                }
                return(result);
            }
コード例 #11
0
 public bool?HasBeenFiltered(IFilterRow row)
 {
     return(MatchingRowIds.ContainsKey(row?.Handle.Value));
 }
コード例 #12
0
 public bool?HasBeenFiltered(IFilterRow row)
 {
     return(row?.UnderOnePound);
 }
コード例 #13
0
 public bool ApplyFilter(IFilterRow row)
 {
     return(false);
 }
コード例 #14
0
            public bool?HasBeenFiltered(IFilterRow row)
            {
                IFilterValue?handle = row?.Handle;

                return(MatchingRowIds.ContainsKey(handle?.Value));
            }
コード例 #15
0
 public bool?HasBeenFiltered(IFilterRow row)
 {
     return(row?.Under023CubicVolume);
 }