コード例 #1
0
            public async Task Execute(IJobExecutionContext context)
            {
                /*Industry ind = new Industry(await db.getJObjectAsync(auction.industryID, "industries"));
                 * ind.CompanyId = auction.currentWinner;
                 * await db.SetJObjectAsync(ind.SerializeIntoJObject(), "industries");
                 * string markchan = (string)await db.GetFieldAsync("MarketChannel", "channel", "system");
                 *
                 * await comm.deleteMessageTask(markchan, auction.messageID);
                 *
                 * await comm.PostMessageTask(markchan, $"Auction with ID {auction.id} has been accepted by <@{(string)await db.GetFieldAsync(auction.currentWinner, "name", "companies")}>!");
                 * await db.RemoveObjectAsync(auction.id, "transactions");*/
                IndustryAuction         auction = (IndustryAuction)context.JobDetail.JobDataMap.Get("auction");
                StockMarketService      market  = (StockMarketService)context.JobDetail.JobDataMap.Get("market");
                CommandHandlingService  comm    = (CommandHandlingService)context.JobDetail.JobDataMap.Get("command");
                DataBaseHandlingService db      = (DataBaseHandlingService)context.JobDetail.JobDataMap.Get("db");

                auction = new IndustryAuction(await db.getJObjectAsync(auction.id, "transactions"));
                Industry ind = new Industry(await db.getJObjectAsync(auction.industryID, "industries"));

                ind.CompanyId = auction.currentWinner;
                await db.SetJObjectAsync(ind.SerializeIntoJObject(), "industries");

                await db.RemoveObjectAsync(auction.id, "transactions");

                string markchan = (string)await db.GetFieldAsync("MarketChannel", "channel", "system");

                await comm.deleteMessageTask(markchan, auction.messageID);

                await comm.PostMessageTask(markchan, $"Auction with ID {auction.id} has been accepted by {(string)await db.GetFieldAsync(auction.currentWinner, "name", "companies")}!");
            }