Esempio n. 1
0
        /// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/8/18 15:06:34</remarks>
        public bool Update(EuropeMatchEntity entity, DbTransaction trans)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_EuropeMatch_Update");

            database.AddInParameter(commandWrapper, "@MatchId", DbType.Int32, entity.MatchId);
            database.AddInParameter(commandWrapper, "@HomeName", DbType.AnsiString, entity.HomeName);
            database.AddInParameter(commandWrapper, "@AwayName", DbType.AnsiString, entity.AwayName);
            database.AddInParameter(commandWrapper, "@MatchDate", DbType.Date, entity.MatchDate);
            database.AddInParameter(commandWrapper, "@MatchTime", DbType.DateTime, entity.MatchTime);
            database.AddInParameter(commandWrapper, "@HomeGoals", DbType.Int32, entity.HomeGoals);
            database.AddInParameter(commandWrapper, "@AwayGoals", DbType.Int32, entity.AwayGoals);
            database.AddInParameter(commandWrapper, "@ResultType", DbType.Int32, entity.ResultType);
            database.AddInParameter(commandWrapper, "@States", DbType.Int32, entity.States);
            database.AddInParameter(commandWrapper, "@UpdateTime", DbType.DateTime, entity.UpdateTime);
            database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }

            entity.MatchId = (System.Int32)database.GetParameterValue(commandWrapper, "@MatchId");

            return(Convert.ToBoolean(results));
        }
Esempio n. 2
0
 protected void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         if (!CheckInput())
         {
             return;
         }
         string            homeName  = txtHomeName.Text.Trim();
         string            awayName  = txtAwayName.Text.Trim();
         DateTime          startTime = Convert.ToDateTime(txtStartTime.Text);
         EuropeMatchEntity entity    = new EuropeMatchEntity(0, homeName, awayName, startTime.Date, startTime, 0, 0,
                                                             0,
                                                             1, DateTime.Now, DateTime.Now);
         if (!EuropeMatchMgr.Insert(entity))
         {
             ShowMessage("发布失败");
         }
         else
         {
             ShowMessage("发布成功");
             BindData();
         }
     }
     catch (Exception ex)
     {
         ShowMessage("发布失败:" + ex);
     }
     txtHomeName.Text  = "";
     txtStartTime.Text = "";
     txtAwayName.Text  = "";
 }
Esempio n. 3
0
        /// <summary>
        /// 发布一场比赛
        /// </summary>
        /// <param name="homeName"></param>
        /// <param name="awayName"></param>
        /// <param name="matchTime"></param>
        /// <returns></returns>
        public MessageCodeResponse ReleaseMatch(string homeName, string awayName, DateTime matchTime)
        {
            EuropeMatchEntity entity = new EuropeMatchEntity(0, homeName, awayName, matchTime.Date, matchTime, 0, 0, 0,
                                                             1, DateTime.Now, DateTime.Now);

            if (!EuropeMatchMgr.Insert(entity))
            {
                return(ResponseHelper.Create <MessageCodeResponse>(MessageCode.NbUpdateFail));
            }
            return(ResponseHelper.CreateSuccess <MessageCodeResponse>());
        }
Esempio n. 4
0
 public void SendGamblePrize(EuropeMatchEntity match)
 {
     try
     {
         if (match == null || match.States != (int)EnumEuropeStatus.MatchEnd || match.ResultType == 0)
         {
             return;
         }
         SendPrize(match);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("欧洲杯发奖", ex);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 将IDataReader的当前记录读取到EuropeMatchEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public EuropeMatchEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new EuropeMatchEntity();

            obj.MatchId    = (System.Int32)reader["MatchId"];
            obj.HomeName   = (System.String)reader["HomeName"];
            obj.AwayName   = (System.String)reader["AwayName"];
            obj.MatchDate  = (System.DateTime)reader["MatchDate"];
            obj.MatchTime  = (System.DateTime)reader["MatchTime"];
            obj.HomeGoals  = (System.Int32)reader["HomeGoals"];
            obj.AwayGoals  = (System.Int32)reader["AwayGoals"];
            obj.ResultType = (System.Int32)reader["ResultType"];
            obj.States     = (System.Int32)reader["States"];
            obj.UpdateTime = (System.DateTime)reader["UpdateTime"];
            obj.RowTime    = (System.DateTime)reader["RowTime"];

            return(obj);
        }
Esempio n. 6
0
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="matchId">matchId</param>
        /// <returns>EuropeMatchEntity</returns>
        /// <remarks>2016/8/18 15:06:34</remarks>
        public EuropeMatchEntity GetById(System.Int32 matchId)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_EuropeMatch_GetById");

            database.AddInParameter(commandWrapper, "@MatchId", DbType.Int32, matchId);


            EuropeMatchEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Esempio n. 7
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 /// <remarks>2016/8/18 15:06:34</remarks>
 public bool Update(EuropeMatchEntity entity)
 {
     return(Update(entity, null));
 }
Esempio n. 8
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="trans">The trans.</param>
 /// <returns></returns>
 /// <remarks>2016/8/18 15:06:34</remarks>
 public bool Insert(EuropeMatchEntity entity)
 {
     return(Insert(entity, null));
 }
Esempio n. 9
0
        public void SendPrize(EuropeMatchEntity match)
        {
            DateTime date = DateTime.Now;
            //获取未发奖的竞猜
            var sendPrizeList = EuropeGamblerecordMgr.GetNotPrize(match.MatchId);

            foreach (var item in sendPrizeList)
            {
                if (item.IsSendPrize)
                {
                    continue;
                }
                item.IsSendPrize = true;
                item.UpdateTime  = date;
                MailBuilder        mail       = null;
                EuropeGambleEntity gambleInfo = null;
                bool isInsertInfo             = false;
                if (item.GambleType == match.ResultType) //竞猜正确
                {
                    item.IsGambleCorrect = true;
                    item.ReturnPoint     = item.Point * 2;
                    //发邮件
                    mail = new MailBuilder(item.ManagerId, EnumMailType.Europe, item.ReturnPoint, match.HomeName,
                                           match.AwayName);
                    gambleInfo = EuropeGambleMgr.GetById(item.ManagerId);
                    if (gambleInfo == null)
                    {
                        isInsertInfo = true;
                        gambleInfo   = new EuropeGambleEntity(item.ManagerId, 1, "0,0,0,0", date, date, this.Season);
                    }
                    else
                    {
                        if (gambleInfo.SeasonId != this.Season)
                        {
                            //插入记录
                            EuropeRecordMgr.Insert(new EuropeRecordEntity(0, gambleInfo.ManagerId, gambleInfo.SeasonId,
                                                                          gambleInfo.CorrectNumber, gambleInfo.PrizeRecord, date));
                            //更新活动
                            gambleInfo.CorrectNumber = 0;
                            gambleInfo.PrizeRecord   = "0,0,0,0";
                            gambleInfo.SeasonId      = this.Season;
                        }
                        gambleInfo.CorrectNumber++;
                        gambleInfo.UpdateTime = date;
                    }
                }
                else
                {
                    item.IsGambleCorrect = false;
                }
                using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault()))
                {
                    transactionManager.BeginTransaction();
                    MessageCode code = MessageCode.FailUpdate;
                    do
                    {
                        if (mail != null)
                        {
                            if (!mail.Save(transactionManager.TransactionObject))
                            {
                                break;
                            }
                        }
                        if (gambleInfo != null)
                        {
                            if (isInsertInfo)
                            {
                                if (!EuropeGambleMgr.Insert(gambleInfo, transactionManager.TransactionObject))
                                {
                                    break;
                                }
                            }
                            else
                            {
                                if (!EuropeGambleMgr.Update(gambleInfo, transactionManager.TransactionObject))
                                {
                                    break;
                                }
                            }
                        }
                        if (!EuropeGamblerecordMgr.Update(item, transactionManager.TransactionObject))
                        {
                            break;
                        }
                        code = MessageCode.Success;
                    } while (false);

                    if (code != MessageCode.Success)
                    {
                        transactionManager.Rollback();
                    }
                    else
                    {
                        transactionManager.Commit();
                    }
                }
            }
        }
Esempio n. 10
0
        public static bool Update(EuropeMatchEntity europeMatchEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new EuropeMatchProvider(zoneId);

            return(provider.Update(europeMatchEntity, trans));
        }
Esempio n. 11
0
        /// <summary>
        /// 获取比赛列表
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="matchDate">比赛日期</param>
        /// <returns></returns>
        public GetEuropeMatchListResponse GetMatchList(Guid managerId, DateTime matchDate, int isDefault)
        {
            GetEuropeMatchListResponse response = new GetEuropeMatchListResponse();

            try
            {
                DateTime date = DateTime.Now;
                var      list = EuropeConfig.Instance.GetMatchDay(matchDate);
                List <EuropeMatchEntity> matchList = new List <EuropeMatchEntity>();
                if (isDefault == 1)
                {
                    var notMatchList = list.FindAll(r => r.MatchTime > date);
                    for (int i = 0; i < 5; i++)
                    {
                        if (notMatchList.Count > 0)
                        {
                            break;
                        }
                        matchDate    = matchDate.AddDays(1);
                        notMatchList = EuropeConfig.Instance.GetMatchDay(matchDate);
                    }
                    matchList.AddRange(notMatchList);
                }
                else
                {
                    matchList.AddRange(list);
                }
                var gambleRecord = EuropeGamblerecordMgr.GambleRecord(managerId);
                List <EuropeMatchEntity> resultList = new List <EuropeMatchEntity>();
                foreach (var item in matchList)
                {
                    var entity = new EuropeMatchEntity();
                    entity.AwayGoals       = item.AwayGoals;
                    entity.AwayLogo        = item.AwayLogo;
                    entity.AwayName        = item.AwayName;
                    entity.HomeGoals       = item.HomeGoals;
                    entity.HomeLogo        = item.HomeLogo;
                    entity.HomeName        = item.HomeName;
                    entity.IsAlreadyGamble = false;
                    entity.MatchDate       = item.MatchDate;
                    entity.MatchId         = item.MatchId;
                    entity.MatchTimeTick   = item.MatchTimeTick;
                    entity.ResultType      = item.ResultType;
                    entity.States          = item.States;
                    if (gambleRecord.Exists(r => r.MatchId == item.MatchId))
                    {
                        entity.IsAlreadyGamble = true;
                    }
                    resultList.Add(entity);
                }
                response.Data               = new GetEuropeMatchList();
                response.Data.MatchList     = resultList;
                response.Data.MatchDateTick = ShareUtil.GetTimeTick(matchDate);
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("获取欧洲杯比赛列表", ex);
                response.Code = (int)MessageCode.NbParameterError;
            }
            return(response);
        }