void FillServerTime()
        {
            this.dtpLocalTimeB.ValueChanged  -= new System.EventHandler(this.dtpLocalTimeB_ValueChanged);
            this.dtpServerTimeB.ValueChanged -= new System.EventHandler(this.dtpServerTimeB_ValueChanged);
            this.dtpLocalTimeB.KeyDown       -= new KeyEventHandler(dtpLocalTimeB_KeyDown);
            this.dtpServerTimeB.KeyDown      -= new KeyEventHandler(this.dtpServerTimeB_KeyDown);

            Kv kv = new Kv();

            kv.Set("MethodName", (int)MethodNameE.GetServerTime);
            kv.Set(StdKv.CurrentUserID, Ap.CurrentUserID);
            DataSet ds = SocketClient.GetServerTime();

            if (ds.Tables.Count > 0)
            {
                Kv     kvServerTime = new Kv(ds.Tables[0]);
                string serverTime   = kvServerTime.Get("ServerTime");
                if (serverTime.Trim().Length > 0)
                {
                    dtpServerTimeA.Text = serverTime;
                    dtpServerTimeB.Text = serverTime;
                    tsServer            = dtpServerTimeA.Value.TimeOfDay;
                }
            }
            this.dtpLocalTimeB.KeyDown       += new KeyEventHandler(dtpLocalTimeB_KeyDown);
            this.dtpLocalTimeB.ValueChanged  += new System.EventHandler(this.dtpLocalTimeB_ValueChanged);
            this.dtpServerTimeB.ValueChanged += new System.EventHandler(this.dtpServerTimeB_ValueChanged);
            this.dtpServerTimeB.KeyDown      += new KeyEventHandler(this.dtpServerTimeB_KeyDown);
        }
        private void TimeIsExpired(Kv kv)
        {
            GameResultE result = (GameResultE)kv.GetInt32("GameResult");

            base.Game.TimeExpired(result, false);
            ClockUc.TimeExpired(result);
        }
        private void UserNewGame(Kv kv)
        {
            int      gameID  = kv.GetInt32("GameID");
            NewGameE newGame = (NewGameE)kv.GetInt32("NewGame");

            switch (newGame)
            {
            case NewGameE.Asked:
                if (MessageForm.Confirm(this, MsgE.ConfirmPlay) == DialogResult.Yes)
                {
                    AcceptNewGameOffer();
                }
                else
                {
                    RejectNewGameOffer();
                }
                break;

            case NewGameE.Accepted:
                NewGame(kv);
                break;

            case NewGameE.Decline:
                ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.InfoNewGameOffer, gameID);
                break;

            default:
                break;
            }
        }
Beispiel #4
0
 public void MergeFrom(Event other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Type != 0)
     {
         Type = other.Type;
     }
     if (other.kv_ != null)
     {
         if (kv_ == null)
         {
             kv_ = new global::Mvccpb.KeyValue();
         }
         Kv.MergeFrom(other.Kv);
     }
     if (other.prevKv_ != null)
     {
         if (prevKv_ == null)
         {
             prevKv_ = new global::Mvccpb.KeyValue();
         }
         PrevKv.MergeFrom(other.PrevKv);
     }
 }
        private void UserThreefoldRepetition(Kv kv)
        {
            string gameXml = kv.Get("GameXml");
            //SetGamePrameters(gameXml, false);

            //base.Game.ThreefoldRepetition(false);
        }
        private void BlockMachine(Kv kv)
        {
            String machineKey;

            BlockMachineE blockMachineE = (BlockMachineE)kv.GetInt32("BlockMachineE");

            switch (blockMachineE)
            {
            case BlockMachineE.Initialized:
                machineKey = WmiHelper.GetMachineKey();
                if (!String.IsNullOrEmpty(machineKey))
                {
                    MessageForm.Show(this, MsgE.InfoBlockMachine);
                    kv.Set("MachineKey", machineKey);
                    kv.Set("BlockMachine", (int)BlockMachineE.Done);
                }
                SocketClient.SendAvResponse(kv);
                break;

            case BlockMachineE.Done:
                machineKey = kv.Get("MachineKey");
                if (!String.IsNullOrEmpty(machineKey))
                {
                    MessageForm.Show(this, MsgE.ErrorBlockMachine);
                }
                break;
            }
        }
Beispiel #7
0
        public static void SaveTournamentMatch(Kv kv)
        {
            TournamentMatch TournamentMatch;
            int             tournamentMatchID = kv.GetInt32("TournamentMatchID");

            if (tournamentMatchID > 0) // update existing match
            {
                TournamentMatch = new TournamentMatch(kv.Cxt, tournamentMatchID);
            }
            else // add new match
            {
                TournamentMatch = new TournamentMatch(kv.Cxt, 0);
            }

            TournamentMatch.TournamentID            = kv.GetInt32("TournamentID");
            TournamentMatch.WhiteUserID             = kv.GetInt32("WhiteUserID");
            TournamentMatch.BlackUserID             = kv.GetInt32("BlackUserID");
            TournamentMatch.Round                   = kv.GetInt32("Round");
            TournamentMatch.TimeMin                 = kv.GetInt32("TimeMin");
            TournamentMatch.TimeSec                 = kv.GetInt32("TimeSec");
            TournamentMatch.MatchStartDate          = kv.GetDateTime("MatchStartDate");
            TournamentMatch.MatchStartTime          = kv.GetDateTime("MatchStartTime");
            TournamentMatch.ParentMatchID           = kv.GetInt32("ParentMatchID");
            TournamentMatch.TournamentMatchStatusID = kv.GetInt32("TournamentMatchStatusID");
            TournamentMatch.TournamentMatchTypeID   = kv.GetInt32("TournamentMatchTypeID");
            TournamentMatch.StatusID                = kv.GetInt32("StatusID");
            TournamentMatch.Save();
        }
Beispiel #8
0
        private void FillWinners(DataTable dtResults)
        {
            if (Tournament.TournamentTypeE != TournamentTypeE.Knockout)
            {
                return;
            }
            if (Tournament.MaxWinners == 0)
            {
                return;
            }

            int     lastRound = Convert.ToInt32(dtResults.Compute("Max(Round)", ""));
            DataSet ds        = SocketClient.IsKnockOutTournamentCompleted(Tournament.TournamentID, lastRound + 1);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        // tournament not yet completed, so no winners could decided here...
                        return;
                    }
                }
            }

            dgvWinners.Visible    = true;
            dgvWinners.DataSource = LoadWinners(dtResults, lastRound);
            if (dgvWinners.Columns.Contains("WinnerId"))
            {
                dgvWinners.Columns["WinnerId"].Visible = false;
            }
        }
        private void DownloadUpgrades()
        {
            try
            {
                DataSet ds = UpdateUtility.GetAvailablePatches(Config.Version);
                if (ds != null && ds.Tables.Count > 0)
                {
                    Kv   kv         = new Kv(ds.Tables[0]);
                    long patchSize  = kv.GetInt32("PatchSize");
                    long setupSize  = kv.GetInt32("SetupSize");
                    int  multiplier = 6;
                    if (patchSize >= (setupSize * multiplier))
                    {
                        if (MessageForm.Confirm(null, MsgE.ConfirmPatchSizeDownload, patchSize + " MB", setupSize + " MB") == DialogResult.No)
                        {
                            return;
                        }
                    }
                    string newVersion      = kv.Get("PatchFile1").Replace(".zip", "");
                    string currentPatchUrl = KeyValues.Instance.GetKeyValue(KeyValueE.PatchUrl).Value;
                    this.Invoke(new UpdateClient.BeginUpdateDelegateKv(UpdateClient.BeginUpdate), kv, currentPatchUrl, newVersion);
                }
            }

            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
Beispiel #10
0
        public static DataTable LogoffUser(Cxt cxt, int userID)
        {
            Kv             Kv = new Kv();
            SqlTransaction t  = null;

            try
            {
                t = SqlHelper.BeginTransaction(Config.ConnectionString);
                Challenges.UpdateChallengesStatus(t, userID);
                User item = new User(cxt, userID);
                item.UserStatusIDE = UserStatusE.Gone;
                //item.StatusIDE = item.IsGuest ? StatusE.Inactive : item.StatusIDE;
                item.EngineID = 1;
                item.IsIdle   = false;
                item.IsPause  = false;
                item.Save(t); //Transaction also commited in this method
                Kv.Set("LogedOff", true);
            }
            catch (Exception ex)
            {
                SqlHelper.RollbackTransaction(t);
                throw ex;
            }

            return(Kv.DataTable);
        }
Beispiel #11
0
        public static int IsCorrectSchTournamentUserCount(int tournamentID)
        {
            DataTable dt = BaseCollection.ExecuteSql("select COUNT(tu.userid) Counter, tu.teamid FROM tournamentuser tu INNER JOIN tournament t ON t.tournamentid = tu.tournamentid INNER JOIN team on tu.teamid = team.teamid WHERE tu.tournamentid = " + tournamentID + " and tu.statusid <> 4 GROUP BY tu.teamid");

            int counter = 0;
            Kv  kv      = new Kv();

            if (dt.Rows.Count > 0)
            {
                counter = Convert.ToInt32(dt.Rows[0][0]);
            }
            else
            {
                return((int)MsgE.ErrorTournamentTeamCount);
            }

            foreach (DataRow item in dt.Rows)
            {
                if (counter != Convert.ToInt32(item[0]))
                {
                    return((int)MsgE.ErrorTournamentTeamCount);
                }
            }

            return(0);
        }
Beispiel #12
0
        private static Kv GetGuest(Cxt cxt, string applicationCode)
        {
            User item = new User();

            item.UserName      = "******" + applicationCode;
            item.Password      = "******";
            item.FirstName     = "Guest";
            item.HumanRankIDE  = RankE.Guest;
            item.EngineID      = 1;
            item.UserStatusIDE = UserStatusE.Blank;
            item.RoomID        = 3;
            item.DateLastLogin = DateTime.Now;
            item.StatusIDE     = StatusE.Active;
            item.Save();

            item.UserName = "******" + item.ID;
            item.Save();

            DataTable roles = User.GetRolesTable(item.UserID);

            Kv kv1 = new Kv();

            kv1.Set("Msg", -1);
            kv1.Set("UserData", UData.ToString(item.DataRow.Table));
            kv1.Set("RolesData", UData.ToString(roles.Copy()));

            return(kv1);
        }
Beispiel #13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            double amount = 0;

            if (!Double.TryParse(txtAmount.Text.Trim(), out amount))
            {
                MessageForm.Error("Please enter correct amount.");
                return;
            }

            Kv kv = new Kv();

            kv.Set("TournamentID", this.Tournament.TournamentID);
            kv.Set("PrizePosition", GetPrizeIndex(cmbPrize.Text));
            kv.Set("TournamentPrizeCategoryID", Convert.ToInt32(cmbCategory.SelectedValue));
            kv.Set("PrizeAmount", amount);

            DataSet ds = SocketClient.AddPrize(kv);

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                TournamentPrize = new TournamentPrize(Ap.Cxt, ds.Tables[0].Rows[0]);
            }
            txtAmount.Text = "";
            RefreshGrid();
        }
        private void FillWinners(DataTable dtResults)
        {
            if (Tournament.MaxWinners == 0)
            {
                LoadWinners(null);
                return;
            }

            int     lastRound = Convert.ToInt32(dtResults.Compute("Max(Round)", ""));
            DataSet ds        = SocketClient.IsKnockOutTournamentCompleted(Tournament.TournamentID, lastRound + 1);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        // tournament not yet completed, so no winners could decided here...
                        LoadWinners(null);
                        return;
                    }
                }
            }

            DataTable dtWinners = LoadWinners(dtResults, lastRound);

            LoadWinners(dtWinners);
        }
        private void SetGamePositionByFen(Kv kv)
        {
            string fen = kv.Get("Fen");

            base.Game.Flags.IsChallengerSendsGame = false;
            ChessBoardUc.SetFen(fen);
        }
        private void RestartGameWithSetupAsked(Kv kv)
        {
            Ap.Game.Pause();

            int moveID = kv.GetInt32("MoveID");
            int wMin   = kv.GetInt32("WhiteMin");
            int wSec   = kv.GetInt32("WhiteSec");
            int bMin   = kv.GetInt32("BlackMin");
            int bSec   = kv.GetInt32("BlackSec");

            DialogResult dr = SetupMatch.Show(this.ParentForm, moveID, base.Game.DbGame.TournamentMatchID, kv.GetInt32("SenderUserID"), kv.GetInt32("ReceiverUserID"), wMin, wSec, bMin, bSec, false);

            ResetGameE reset = ResetGameE.Decline;

            if (dr == DialogResult.OK)
            {
                reset = ResetGameE.Accepted;
            }

            SocketClient.RestartGameWithSetup(reset, base.Game.DbGame.GameID, moveID, kv.GetInt32("SenderUserID"), base.Game.DbGame.OpponentUserID, wMin, wSec, bMin, bSec, false);

            if (reset == ResetGameE.Decline)
            {
                Ap.Game.Resume();
            }
        }
Beispiel #17
0
        private void LoginUser(string loginId, string password)
        {
            try
            {
                if (!String.IsNullOrEmpty(txtLoginId.Text) && !String.IsNullOrEmpty(txtPassword.Text))
                {
                    DataSet ds = SocketClient.LoginUser(loginId, password, Options.Instance.ApplicationCode);

                    if (ds != null && ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);

                        int statusID = User.LoginMsg(kv, false);

                        Srv.SetCurrentUser(kv);

                        if (IsValidUser(kv, statusID))
                        {
                            return;
                        }

                        if (Ap.CurrentUser.UserStatusIDE != UserStatusE.Gone)
                        {
                            UserStatus frm = new UserStatus();
                            frm.ShowDialog();
                            return;
                        }

                        SocketClient.LoginUser(Ap.CurrentUserID, UserStatusE.Blank);

                        if (chkRemindPassword.Checked)
                        {
                            Options.Instance.LoginID  = loginId;
                            Options.Instance.Password = password;
                        }
                        else
                        {
                            Options.Instance.LoginID  = "";
                            Options.Instance.Password = "";
                        }
                        Options.Instance.Save();

                        LoadOnlineClient();
                    }
                    else
                    {
                        MessageForm.Error(this, MsgE.ErrorServerConnection);
                    }
                }
                else
                {
                    MessageForm.Error(this, MsgE.ErrorEmptyIdPassword);
                }
            }
            catch (Exception ex)
            {
                TestDebugger.Instance.WriteError(ex);
                MessageForm.Show(ex);
            }
        }
        public static MsgE GetMessage(DataSet ds)
        {
            MsgE msgID = MsgE.CreditCardValid;

            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.Get("Message") == "0")
                    {
                        msgID = MsgE.CreditCardValid;
                    }
                    else if (kv.Get("Message") == "1")
                    {
                        msgID = MsgE.CardAlreadyCheckedout;
                    }
                    else if (kv.Get("Message") == "2")
                    {
                        msgID = MsgE.VoucherInvalid;
                    }
                }
            }
            return(msgID);
        }
        void UpdateReplacePlayer()
        {
            int userID2 = 0;

            userID2 = ValidateReplacePlayer();

            if (userID2 == -1 || userID2 == 0)
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorReplacePlayerSelection, "");
                return;
            }

            DataSet ds = SocketClient.UpdateReplacePlayer(this.Tournament.TournamentID, this.UserID, userID2);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    Kv kv = new Kv(ds.Tables[0]);
                    if (kv.GetInt32("Result") > 0)
                    {
                        MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                        return;
                    }
                }
            }

            TournamentRegisterPlayer TournamentRegisterPlayer = (TournamentRegisterPlayer)this.ParentForm;

            TournamentRegisterPlayer.DialogResult = DialogResult.OK;
        }
Beispiel #20
0
 public void MergeFrom(Event other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Type != 0)
     {
         Type = other.Type;
     }
     if (other.kv_ != null)
     {
         if (kv_ == null)
         {
             kv_ = new global::Mvccpb.KeyValue();
         }
         Kv.MergeFrom(other.Kv);
     }
     if (other.prevKv_ != null)
     {
         if (prevKv_ == null)
         {
             prevKv_ = new global::Mvccpb.KeyValue();
         }
         PrevKv.MergeFrom(other.PrevKv);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
        private new void Update()
        {
            if (String.IsNullOrEmpty(txtOldPassword.Text))
            {
                MessageForm.Error(this, MsgE.ErrorEmptyOldPassword);
                return;
            }
            else if (UCrypto.Encrypt(txtOldPassword.Text) != Ap.CurrentUser.Password)
            {
                MessageForm.Error(this, MsgE.ErrorWrongOldPassword);
                return;
            }

            DataSet ds     = SocketClient.ChangePassword(txtPassword.Text, txtPasswordHint.Text);
            bool    update = false;

            if (ds != null && ds.Tables.Count > 0)
            {
                Kv kv = new Kv(ds.Tables[0]);
                update = kv.GetBool("Updated");
            }

            if (update)
            {
                MessageForm.Show(this, MsgE.InfoUpdatePassword);

                Ap.CurrentUser.Password     = UCrypto.Encrypt(txtPassword.Text);
                Ap.CurrentUser.PasswordHint = txtPasswordHint.Text;
            }
            else
            {
                MessageForm.Error(this, MsgE.ErrorUpdatePassword);
            }
            this.Close();
        }
        public void GetWithValueTuple()
        {
            var kv = Kv.Create(VtpSrc);

            kv.Key.Is(VtpSrc.Item1);
            kv.Value.Is(VtpSrc.Item2);
        }
        public void GetWithKeyValuePair()
        {
            var kv = Kv.Create(KvpSrc);

            kv.Key.Is(KvpSrc.Key);
            kv.Value.Is(KvpSrc.Value);
        }
        public void GetWithSpecifiedParameters()
        {
            var kv = Kv.Create("test", 66);

            kv.Key.Is("test");
            kv.Value.Is(66);
        }
        private void UpdateMatchStatus(TournamentMatchStatusE tournamentMatchStatusID, string matchStatus)
        {
            if (this.Tournament == null)
            {
                return;
            }
            if (this.Tournament.TournamentID == 0)
            {
                return;
            }

            string matchIDs = string.Empty;

            foreach (DataGridViewRow row in dgvMatches.Rows)
            {
                if (row.Cells["Select"].Value != null)
                {
                    if ((bool)row.Cells["Select"].Value)
                    {
                        if (GridTable.Rows[row.Index]["WhiteUserID"].ToString() != "2" && GridTable.Rows[row.Index]["BlackUserID"].ToString() != "2")
                        {
                            matchIDs += "," + GridTable.Rows[row.Index]["TournamentMatchID"].ToString();
                        }
                    }
                }
            }

            if (matchIDs.Length > 0)
            {
                matchIDs = matchIDs.Remove(0, 1);

                if (MessageForm.Confirm(this.ParentForm, MsgE.ConfirmItemTask, "update match status to ", matchStatus) != DialogResult.Yes)
                {
                    return;
                }

                ProgressForm frmProgress = ProgressForm.Show(this, "Updating match status...");
                DataSet      ds          = SocketClient.UpdateTournamentMatchStatus(tournamentMatchStatusID, this.Tournament.TournamentID, matchIDs);
                frmProgress.Close();

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        Kv kv = new Kv(ds.Tables[0]);
                        if (kv.GetInt32("Result") > 0)
                        {
                            MessageForm.Error(this.ParentForm, (MsgE)kv.GetInt32("Result"));
                            return;
                        }
                    }
                }
                RefreshGrid();
            }
            else
            {
                MessageForm.Error(this.ParentForm, MsgE.ErrorTournamentMatchStartRequest);
            }
        }
Beispiel #26
0
        public override global::System.Data.DataSet Clone()
        {
            Kv cln = ((Kv)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
 public UpdateClient(Kv kv, String patchUrl, String currentVersionNo)
 {
     InitializeComponent();
     this.kv               = kv;
     this.patchUrl         = patchUrl;
     this.currentVersionNo = currentVersionNo;
     patchPath             = patchUrl.Substring(0, patchUrl.LastIndexOf("/"));
 }
Beispiel #28
0
        void IMsgQueueConsumer.ConsumeMessage(Kv kv)
        {
            ISynchronizeInvoke synchronizer = this;

            MsgQueue.SyncConsumeMessage s = new MsgQueue.SyncConsumeMessage(SynchronizeConsumeMessage);

            synchronizer.Invoke(s, new object[] { kv });
        }
        public void GetWithValueTupleWithNamedProperty()
        {
            (int k, string v)vtp = (100, "test");
            var kv = Kv.Create(vtp);

            kv.Key.Is(vtp.k);
            kv.Value.Is(vtp.v);
        }
        private void LoadCombos()
        {
            Kv kv = new Kv(KvType.Country);

            cmbNotation.DataSource    = kv.DataTable;
            cmbNotation.DisplayMember = "k";
            cmbNotation.ValueMember   = "k";
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            Kv k=new Kv();
            DataTable dt = BG_PolicyLogic.GetAllPolicy();
            for (int i = 0; i < 100; i++)
            {
                  dt.Rows[0]["PTitle"]= k.Key + i;
                  dt.Rows[0]["PTitle"] = k.Val + i;

            }

            Store store = this.GridPanel1.GetStore();
            store.DataSource = dt;
            store.DataBind();
        }
    }