Example #1
0
        private static void generateListForWarehouse(Arguments arguments)
        {
            if (!arguments.HasArgument("gwl"))
            {
                "You need to supply an output filepath (which should be an xlsx) to write the list to".ConsoleWriteLine();
            }
            else if (!arguments.ArgumentDictionary.TryGetValue("gwl", out var filename) || string.IsNullOrEmpty(filename?.ToString()))
            {
                "No file name provided for generating warehouse list".ConsoleWriteLine();
            }
            else if (!File.Exists(filename.ToString()))
            {
                $"Could not find file '{filename.ToString()}' as source for generating warehouse list".ConsoleWriteLine();
            }
            else
            {
                filename.ToString().ConsoleWriteLine();
                var lines = File.ReadLines(filename.ToString())
                            .Select(x => x.Split(','))
                            .Select(x => (Id: x[0].Replace("-", string.Empty), Quantity: int.Parse(x[1])))
                            .ToList();

                var records = KeepaAPI.GetDetailsForIdentifiers(lines.Select(x => x.Id).ToArray());

                lines.Select(x =>
                {
                    records.TryGetValue(x.Id, out var rec);
                    return(x.Id, x.Quantity, rec);
                })
                .WriteWarehouseFile(arguments.GetArgument("gwl"));
            }
        }
Example #2
0
        private static void keepaLookupPrimeRecords()
        {
            var items = SalesBinderAPI.Inventory.Where(x => !string.IsNullOrEmpty(x.BarCode))
                        .Where(x => KeepaAPI.LastLookupTime(x.BarCode) == null);

            if (!items.Any())
            {
                $"Have already tried to get keepa records for all items in inventory".ConsoleWriteLine();
            }
            else
            {
                var ids = items.Take(100).Select(x => x.BarCode).Distinct().ToArray();
                KeepaAPI.GetDetailsForIdentifiers(ids);
            }
        }
Example #3
0
        private static void keepaLookupRefreshCurrentInventory()
        {
            var items = SalesBinderAPI.Inventory.Where(x => x.Quantity > 0 && !string.IsNullOrEmpty(x.BarCode))
                        .Select(x => (Book: x, LastLookup: KeepaAPI.LastLookupTime(x.BarCode)))
                        .Where(x => x.LastLookup == null || (DateTime.Now - x.LastLookup.Value).TotalDays > 1)
                        .Select(x => x.Book)
                        .ToArray();

            // only want to do 100 as don't want to blow limits on keepa
            if (!items.Any())
            {
                "Nothing to do - have been updated or attempted to be updated at least once in the last 24 hours"
                .ConsoleWriteLine();
            }
            else
            {
                var ids = items.Take(100).Select(x => x.BarCode).Distinct().ToArray();
                KeepaAPI.GetDetailsForIdentifiers(ids, forceRefresh_: true);
            }
        }