Пример #1
0
        public static async Task LastHourIndex()
        {
            DateTime indexStart;
            string   targetTmp, pullPath;

            VariableSetup(out indexStart, out targetTmp, out pullPath);
            //DeleteDir(targetTmp);
            if (!Directory.Exists(pullPath) && !Directory.Exists(targetTmp))
            {
                // update first
                if (!Program.FullServerMode)
                {
                    Console.WriteLine("nothing to build indexes from, run again with option u first");
                }
                return;
            }
            // only copy the pull path if there is no temp work path yet
            if (!Directory.Exists(targetTmp))
            {
                Directory.Move(pullPath, targetTmp);
            }
            else
            {
                Console.WriteLine("Resuming work");
            }

            try
            {
                Console.WriteLine("working");

                var work       = PullData();
                var earlybreak = 100;
                foreach (var item in work)
                {
                    await ToDb(item);

                    if (earlybreak-- <= 0)
                    {
                        break;
                    }
                }

                Console.WriteLine($"Indexing done, Indexed: {count} Saved: {StorageManager.SavedOnDisc} \tcache: {StorageManager.CacheItems}  NameRequests: {Program.RequestsSinceStart}");

                if (!abort)
                {
                    // successful made this index save the startTime
                    FileController.SaveAs("lastIndex", indexStart);
                }
            }
            catch (System.AggregateException e)
            {
                // oh no an error occured
                Logger.Instance.Error($"An error occured while indexing, abording: {e.Message} {e.StackTrace}");
                return;
                //FileController.DeleteFolder("auctionpull");

                //Directory.Move(FileController.GetAbsolutePath("awork"),FileController.GetAbsolutePath("auctionpull"));
            }
            var saveTask = StorageManager.Save();

            saveTask.Wait();
            LastFinish = DateTime.Now;

            DeleteDir(targetTmp);
        }
Пример #2
0
        static void Main(string[] args)
        {
            StripeKey                  = SimplerConfig.Config.Instance["stripeKey"];
            StripeSigningSecret        = SimplerConfig.Config.Instance["stripeSecret"];
            StripeConfiguration.ApiKey = Program.StripeKey;

            Console.CancelKeyPress += delegate
            {
                Console.WriteLine("\nAbording");
                onStop?.Invoke();

                var cacheCount = StorageManager.CacheItems;
                StorageManager.Stop();
                Indexer.Stop();

                var t = StorageManager.Save();
                Console.WriteLine("Saving");
                t.Wait();
                Console.WriteLine($"Saved {cacheCount}");
            };

            if (args.Length > 0)
            {
                FileController.dataPaht = args[0];
                Directory.CreateDirectory(FileController.dataPaht);
                Directory.CreateDirectory(FileController.dataPaht + "/users");
                Directory.CreateDirectory(FileController.dataPaht + "/auctions");

                if (args.Length > 1)
                {
                    runSubProgram(args[1][0]);
                    return;
                }
            }

            displayMode = true;

            while (true)
            {
                //try {

                Console.WriteLine("1) List Auctions");
                Console.WriteLine("2) List Bids");
                Console.WriteLine("3) Display");
                Console.WriteLine("4) List Won Bids");
                Console.WriteLine("5) Search For auction");
                Console.WriteLine("6) Avherage selling price in the last 2 weeks");
                Console.WriteLine("9) End");

                var res = Console.ReadKey();
                if (runSubProgram(res.KeyChar))
                {
                    return;
                }

                //} catch(Exception e)
                //{
                //    Console.WriteLine("Error Occured: "+ e.Message);
                //    throw e;
                //}
            }
        }