public void Run() { var pkService = new PKService(); var bonusService = new PKBonusService(); var betService = new BetService(); //var pk = pkService.GetCurrentPK(); var pks = pkService.GetNotCalculatePKs(); foreach (var pk in pks) { if (pk != null && string.IsNullOrEmpty(pk.Ranks)) { var now = DateTime.Now; if (now >= pk.BeginTime.AddSeconds(pk.OpeningSeconds))// 封盘 { // 计算名次 var rankList = betService.CalculateRanks(pk.PKId); var ranks = string.Join(",", rankList); pk.Ranks = ranks; var success = pkService.UpdateRanks(pk.PKId, ranks); if (success) { var msg = string.Format("Calculate Ranks - PKId : {0} - Ranks : {1} - Time : {2}", pk.PKId, ranks, now.ToString(DateFormatConst.yMd_Hms)); _logger.Info(msg); } else { var msg = string.Format("Calculate Ranks Failed, 已经生成过Ranks - PKId : {0} - Ranks : {1} - Time : {2}", pk.PKId, ranks, now.ToString(DateFormatConst.yMd_Hms)); _logger.Info(msg); } } } } // 更新Bet表已结算标志 betService.UpdateSettlementDone(); }