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); }
public static DataTable LoginKv(Kv kv) { DataSet ds = Login(kv.Cxt, kv.Get("LoginID"), kv.Get("Password"), kv.Get("AccessCode"), kv.Get("Ip"), kv.Get("MachineCode"), Convert.ToDateTime(kv.Get("ServerDate"))); int msgId = UData.ToInt32(ds.Tables[0].Rows[0]["MsgId"]); kv = new Kv(); kv.Set("Msg", UData.ToString(ds.Tables[0])); if (ds.Tables.Count > 1) { kv.Set("UserData", UData.ToString(ds.Tables[1])); kv.Set("RolesData", UData.ToString(ds.Tables[2])); } return(kv.DataTable); }
private void UserThreefoldRepetition(Kv kv) { string gameXml = kv.Get("GameXml"); //SetGamePrameters(gameXml, false); //base.Game.ThreefoldRepetition(false); }
private void SetGamePositionByFen(Kv kv) { string fen = kv.Get("Fen"); base.Game.Flags.IsChallengerSendsGame = false; ChessBoardUc.SetFen(fen); }
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 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; } }
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); } }
private void RestartGameResetAsked(Kv kv) { Ap.Game.Pause(); Ap.MsgQueue.Clear(this.Game.DbGame.GameID); Ap.Game.Flags.IsReady = false; //send back with Done SocketClient.RestartGame(kv.GetInt32("TournamentID"), kv.Get("GameID"), 0, kv.GetInt32("SenderUserID"), kv.GetInt32("ReceiverUserID"), ResetGameE.ResetDone, kv.GetBool("IsResetFromLastMove"), kv.Get("GameXml")); }
private void StartTournamentMatch(Kv kv) { if (Ap.IsGameInProgress) { return; } DataSet ds = UData.LoadDataSet(kv.Get("GameData")); MainOnline.ShowMainOnline(ds, false); }
private void ResetGameAccepted(Kv kv) { NewGame(); Ap.Game.Flags.IsReady = true; if (kv.GetBool("IsResetFromLastMove") && !string.IsNullOrEmpty(kv.Get("GameXml"))) { SetGamePrameters(kv.Get("GameXml"), true); } if (kv.GetInt32("TournamentDirectorID") > 0) { ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.InfoRestartTournamentMatch, base.Game.DbGame.GameID); } else { ChatClient.Write(ChatTypeE.GameWindow, ChatMessageTypeE.Info, ChatTypeE.GameWindow, MsgE.InfoTournamentMatchStarted, base.Game.DbGame.GameID); } }
private void BanUser(Kv kv) { kv.Get("BanStartDate"); string banDate = kv.Get("BanEndDate").Trim(); if (banDate != string.Empty) { DateTime dt = Convert.ToDateTime(banDate); if (dt == new DateTime()) { MessageForm.Show(this, MsgE.ErrorBaned, Ap.CurrentUser.UserName); } else { MessageForm.Show(this, MsgE.InfoBaned, kv.Get("BanStartDate"), kv.Get("BanEndDate")); } } //Application.Exit(); CloseAllWindows(); }
public static DataTable LoginGuest(Kv kv) { DataSet ds = Login(kv.Cxt, kv.Get("LoginID"), kv.Get("Password"), kv.Get("AccessCode"), kv.Get("Ip"), kv.Get("MachineCode"), DateTime.Now); int msgId = UData.ToInt32(ds.Tables[0].Rows[0]["MsgId"]); Kv kvOut = new Kv(); kvOut.Cxt = kv.Cxt; kvOut.Set("MsgId", msgId); kvOut.Set("ServerDateTime", DateTime.Now.ToString()); if ((SignInMsgE)msgId == SignInMsgE.UserNotFound) { kvOut = GetGuest(kvOut.Cxt, kv.Get("AccessCode")); } else { if (ds.Tables.Count > 1) { kvOut.Set("UserData", UData.ToString(ds.Tables[1])); kvOut.Set("RolesData", UData.ToString(ds.Tables[2])); } } System.Diagnostics.Debug.WriteLine("**************** S T A R T **************"); string s = UData.ToString(ds); if (String.IsNullOrEmpty(s)) { System.Diagnostics.Debug.WriteLine("<EMPTY DATASET>"); } else { System.Diagnostics.Debug.WriteLine("ROWS=" + kvOut.DataTable.Rows.Count); } return(kvOut.DataTable); }
private void ResetGameAsked(Kv kv) { Ap.Game.Pause(); ResetGameE reset = ResetGameE.Decline; if (MessageForm.Confirm(this, MsgE.ConfirmRestartTournamentMatch) == DialogResult.Yes) { reset = ResetGameE.Accepted; } else { Ap.Game.Resume(); } SocketClient.RestartGame(kv.GetInt32("TournamentID"), kv.Get("MatchIDs"), kv.GetInt32("TournamentDirectorID"), kv.GetInt32("SenderUserID"), kv.GetInt32("ReceiverUserID"), reset, kv.GetBool("IsResetFromLastMove"), kv.Get("GameXml")); }
private void CloseInProgressGameWindow(Kv kv) { DataTable dt = kv.DataTable; if (dt != null) { if (dt.Rows.Count > 0) { if (base.Game.DbGame.ID == Convert.ToInt32(kv.Get("GameID"))) { base.Game.GameResultID = GameResultE.ForcedWhiteLose; base.Close(); } } } }
private void DownloadItem() { currentPatchNo++; string fileUrl = kv.Get("PatchFile" + currentPatchNo); if (string.IsNullOrEmpty(fileUrl)) { SetProgressBar(pbItems, totalItems, currentPatchNo - 1); DownloadingCompleted(); } else { SetLabelText(lblCurrentItem, currentPatchNo.ToString()); SetProgressBar(pbItems, totalItems, currentPatchNo - 1); fileUrl = patchPath + "/" + fileUrl; DownloadItem(fileUrl); } }
private void BanUserUc_Load(object sender, EventArgs e) { rbDate.Checked = true; 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) { lblServerTime.Text = serverTime; dtServerTime = Convert.ToDateTime(lblServerTime.Text); dtpStartDate.Text = Convert.ToDateTime(lblServerTime.Text).ToShortDateString(); dtpStartTime.Text = Convert.ToDateTime(lblServerTime.Text).ToLongTimeString(); dtpEndDate.Text = Convert.ToDateTime(lblServerTime.Text).ToShortDateString(); dtpEndTime.Text = Convert.ToDateTime(lblServerTime.Text).ToShortTimeString(); } } }
public static void StartChat(DataTable dt) { Kv kv = new Kv(dt); string chatType; int fromUserId = kv.GetInt32("FromUserID"); int toUserId = kv.GetInt32("ToUserID"); string fromUserName = kv.Get("FromUserName"); AvChatTypeE chatTypeE = (AvChatTypeE)kv.GetInt32("AvChatType"); if (chatTypeE == AvChatTypeE.Audio) { chatType = "audio"; } else { chatType = "video"; } if (MessageForm.Confirm(ActiveForm, MsgE.InfoAvChatRequested, chatType, fromUserName) == DialogResult.No) { kv.Set("AvChat", (int)AvChatE.Declined); SocketClient.SendAvResponse(kv); return; } state = AvChatStateE.Talking; initiatedChat = false; ChatType = chatTypeE; FromUserId = fromUserId; FromUserName = fromUserName; ToUserId = toUserId; if (avPlayer != null) { avPlayer.Dispose(); avPlayer = null; } StringBuilder connectionString = new StringBuilder("rtmp://"); connectionString.Append(Config.AvServerIp); connectionString.Append(":"); connectionString.Append(Config.AvServerPort); connectionString.Append("/videochat"); try { avPlayer = new AvPlayer(); if (ChatType == AvChatTypeE.Video) { ShowPlayer(); } string chatTypeString = ((int)ChatType + 1).ToString(); avPlayer.player.CallFunction("<invoke name=\"StartChat\" returntype=\"xml\"><arguments><string>" + connectionString.ToString() + "</string><string>" + FromUserId + "</string><string>" + ToUserId + "</string><number>" + chatTypeString + "</number></arguments></invoke>"); if (OnAvChatBegan != null) { OnAvChatBegan.Invoke(typeof(AvPlayer), new AvChatEventArgs(ChatType)); } } catch (AccessViolationException ex) { TestDebugger.Instance.WriteError(ex); StopChat(); MessageForm.Show(null, MsgE.ErrorAvNoCamera, MessageBoxButtons.OK, MessageBoxIcon.Error, ex); } catch (COMException e) { TestDebugger.Instance.WriteError(e); if (e.Message.Substring(0, 20) == "Class not registered") { MessageForm.Show(null, MsgE.ErrorAvNoPlayer, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void WriteChatMessage(Kv kv) { int gameID = kv.GetInt32("GameID"); ChatClient.Write(ChatTypeE.GameWindow, (ChatMessageTypeE)kv.GetInt32("MessageType"), (ChatTypeE)kv.GetInt32("ChatType"), kv.Get("Message"), gameID); }
private void WriteChatMessage(Kv kv) { if ((ChatTypeE)kv.GetInt32("ChatType") == ChatTypeE.AllWindows) { ChatClient.Write(ChatTypeE.GameWindow, (ChatMessageTypeE)kv.GetInt32("MessageType"), ChatTypeE.GameWindow, kv.Get("Message"), 0); ChatClient.Write(ChatTypeE.OnlineClient, (ChatMessageTypeE)kv.GetInt32("MessageType"), ChatTypeE.OnlineClient, kv.Get("Message"), 0); } else { ChatClient.Write(ChatTypeE.OnlineClient, (ChatMessageTypeE)kv.GetInt32("MessageType"), (ChatTypeE)kv.GetInt32("ChatType"), kv.Get("Message"), 0); } }
private void RestartGameWithSetupAccepted(Kv kv) { ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Info, ChatTypeE.OnlineClient, MsgE.InfoResetTournamentGame, 0); NewGame(); SetGamePrameters(kv.Get("GameXml"), true); }
private void AvChat(Kv kv) { AvChatE avChat = (AvChatE)kv.GetInt32("AvChat"); switch (avChat) { case AvChatE.Asked: if (!AvPlayer.IsIdle()) { kv.Set("AvChat", (int)AvChatE.Busy); SocketClient.SendAvResponse(kv); return; } this.Invoke(new AvPlayer.StartChatDelegate(AvPlayer.StartChat), kv.DataTable); break; case AvChatE.Accepted: this.Invoke(new AvPlayer.PlayChatDelegate(AvPlayer.PlayChat)); break; case AvChatE.Declined: this.Invoke(new AvPlayer.StopChatDelegate(AvPlayer.StopChat)); ChatClient.Write((ChatTypeE)kv.GetInt32("ClientWindow"), ChatMessageTypeE.Error, (ChatTypeE)kv.GetInt32("ClientWindow"), Msg.GetMsg(MsgE.ErrorAvChatDenied, kv.Get("ToUserName")), 0); break; case AvChatE.Busy: this.Invoke(new AvPlayer.StopChatDelegate(AvPlayer.StopChat)); ChatClient.Write((ChatTypeE)kv.GetInt32("ClientWindow"), ChatMessageTypeE.Error, (ChatTypeE)kv.GetInt32("ClientWindow"), Msg.GetMsg(MsgE.ErrorAvChatBusy, kv.Get("ToUserName")), 0); break; case AvChatE.NoService: this.Invoke(new AvPlayer.StopChatDelegate(AvPlayer.StopChat)); ChatClient.Write((ChatTypeE)kv.GetInt32("ClientWindow"), ChatMessageTypeE.Error, (ChatTypeE)kv.GetInt32("ClientWindow"), MsgE.InfoNoAvService, 0); break; default: break; } }
private void SetGamePrameters(Kv kv) { SetGamePrameters(kv.Get("GameXml"), false); }
//public static bool ChangePassword(Cxt cxt, int userID, string password) //{ // User item = new User(Cxt.Instance, userID); // item.Password = password; // //item.PasswordHint = passwordHint; // item.Save(); // MailVerifyResult mvr = EmailTemplate.Send(EmailTemplateE.ChangePassword, item); // if (mvr == MailVerifyResult.Ok) // { // return true; // //Msg.Text = "Your password has been changed successfully."; // } // return false; //} public static DataTable ChangePassword(Cxt cxt, Kv kv) { return(User.ChangePassword(cxt, kv.GetInt32("UserID"), kv.Get("Password"), kv.Get("PasswordHint")).Copy()); }