Пример #1
0
        public override void Save()
        {
            System.Data.SqlClient.SqlTransaction t = SqlHelper.BeginTransaction(Config.ConnectionString);

            try
            {
                if (GameResultIDE != GameResultE.InProgress && GameResultIDE != GameResultE.None && GameResultIDE != GameResultE.NoResult)
                {
                    if (GameResultIDE != GameResultE.WhiteBye || GameResultIDE != GameResultE.BlackBye)
                    {
                        Elo e = new Elo(this);
                        e.Update(t);
                    }

                    if (this.Challenge.Stake > 0 && this.Challenge.Flate != 0)
                    {
                        UserFini.UpdateFiniTransfer(t, base.Cxt, this, this.Challenge.Stake, this.Challenge.Flate);
                    }

                    if (this.IsTournamentMatch)
                    {
                        if (this.GameResultIDE == GameResultE.Draw)
                        {
                            this.TournamentMatch.TournamentMatchStatusE = TournamentMatchStatusE.Draw;
                            this.TournamentMatch.GameResultID           = this.GameResultID;
                            this.TournamentMatch.Save(t);
                        }
                        else
                        {
                            string matchID = this.TournamentMatch.TournamentMatchID.ToString();
                            this.TournamentMatch.GameResultID = this.GameResultID;
                            TournamentMatches.UpdateStatus(t, base.Cxt, TournamentMatchStatusE.Finsihed, matchID, this.GameResultIDE);
                        }

                        this.TournamentMatch.UpdateUserPoints(t);
                    }
                }

                base.Save(t);

                SqlHelper.CommitTransaction(t);
                if (IsFinished)
                {
                    TournamentMatch.CreateChildMatchIfRequired(Cxt, this.TournamentMatch, null);
                }
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(t);
                Log.Write(Cxt, ex);
            }
        }
Пример #2
0
        public override void Save()
        {
            SqlTransaction trans = null;

            this.DtTournamentUsersMatch = TournamentUsers.GetTournamentUsersByTournamentID(StatusE.Active, this.Tournament.TournamentID);

            try
            {
                for (int i = 0; i < this.Count; i++)
                {
                    trans = SqlHelper.BeginTransaction(Config.ConnectionString);

                    TournamentMatch tournamentMatch = this[i];
                    this.Save(trans);
                    Challenge Challenge = CreateChallenge(tournamentMatch);
                    Challenge.Save(trans);

                    Game Game = null;

                    //if (this.teamLooseStatusE != TeamLooseStatusE.None)
                    //{
                    // Game = CreateGame(this, Challenge);
                    Game.Save(trans);
                    //}

                    if (this.Tournament.TournamentStartDate == new DateTime())
                    {
                        this.Tournament.TournamentStartDate = DateTime.Now;
                        this.Tournament.TournamentStartTime = DateTime.Now;
                        this.Tournament.Save(trans);
                    }
                    SqlHelper.CommitTransaction(trans);
                    trans = SqlHelper.BeginTransaction(Config.ConnectionString);
                    //if (this.teamLooseStatusE != TeamLooseStatusE.None)
                    //{
                    Elo Elo = new Elo(Game);
                    if (Game.IsEloWhiteUpated && Game.IsEloBlackUpated)
                    {
                        Elo.Update(trans);
                    }
                    //}

                    SqlHelper.CommitTransaction(trans);
                }
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(trans);
                Log.Write(base.Cxt, ex);
            }
        }