示例#1
0
        public async Task CheckItemExists(string name, ItemType type, long cost, long weight, long space,
                                          Quality quality, string structuredDescription)
        {
            Console.WriteLine("Starting Job: CheckItemExists");

            var result = await this.marketCheckService.RequestMarketCheckWithDescription(name);

            if (result.orders != null && result.orders.Length > 0)
            {
                using var dbContext     = this.dbContextFactory();
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine($"Added Item: {name}");
                Debug.WriteLine($"Added Item: {name}");
                Console.ForegroundColor = ConsoleColor.White;
                RecurringJob.AddOrUpdate <ItemMarketCheck>(ItemMarketCheck.GetJobName(name),
                                                           (job) => job.DoItemMarketCheck(name), CronUtility.GetRandom12HourCron(), null, "update_mc");

                var item = new Item()
                {
                    Name                  = name,
                    Description           = result.description,
                    StructuredDescription = structuredDescription,
                    Cost                  = cost,
                    Type                  = type,
                    Weight                = weight,
                    Space                 = (int)space,
                    ScrapValue            = result.scrapValue,
                    Quality               = quality
                };

                dbContext.AddOrUpdateItem(item);
                await dbContext.SaveChangesAsync();
            }
            else
            {
                Debug.WriteLine($"Item not found - not adding to SSMB: {name}");
            }
        }
示例#2
0
        private void TimerOnElapsed(object sender, ElapsedEventArgs e)
        {
            using (var dbContext = this.dbContextFactory())
            {
                foreach (var name in dbContext.Items.Select(i => i.Name))
                {
                    RecurringJob.AddOrUpdate <ItemMarketCheck>(ItemMarketCheck.GetJobName(name),
                                                               (job) => job.DoItemMarketCheck(name), CronUtility.GetRandom12HourCron(), null, "update_mc");
                }

                RecurringJob.AddOrUpdate <FindItemsToCheckExist>("FindItemsToCheckExist", (job) => job.DoFindItemsToCheckExist(), Cron.Monthly, null, "gather_checkable");
            }
        }