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); }
private void AcceptChallenge(int i) { if (Ap.IsGameInProgress) { //MessageForm.Show(this.ParentForm, MsgE.ErrorRoomChange); ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Warning, ChatTypeE.OnlineClient, MsgE.ErrorRoomChange, 0); return; } if (dataGridView1["ChallengerID", i].Value.ToString() != Ap.CurrentUserID.ToString()) { if ((dataGridView1["Conditions", i].Value.ToString() == "true" || dataGridView1["Conditions", i].Value.ToString() == "Rated") && Ap.CurrentUser.IsGuest) { MessageForm.Show(this.ParentForm, MsgE.ErrorGuestAcceptChallenge); return; } if (dataGridView1["challengeStatusID", i].Value.ToString() == "1") { int challengeID = UData.ToInt32(dataGridView1[0, i].Value); InfinityChess.WinForms.MainOnline.LoadGameByChallengeID(challengeID); Ap.CanAutoChallenge = true; } } }
public EngineParameters(Game game) { // ValidValue // min,max // list 1,2,3,4 this.Game = game; EngineParameterData = UData.ToTable2("EngineParameterData", "Name", "Value", "Type", "Default", "ValidValue"); }
private void StartTournamentMatch(Kv kv) { if (Ap.IsGameInProgress) { return; } DataSet ds = UData.LoadDataSet(kv.Get("GameData")); MainOnline.ShowMainOnline(ds, false); }
public static int Login(Cxt cxt, string userName, string password) { DataSet ds = Login(cxt, userName, password, "", "", "", DateTime.Now); if (ds.Tables.Count > 1) { return(UData.ToInt32(ds.Tables[1].Rows[0]["UserId"])); } else { return(0); } }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { if (SelectPlayer != null) { int userID = UData.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); string userName = dataGridView1.SelectedRows[0].Cells[2].Value.ToString(); string userRank = dataGridView1.SelectedRows[0].Cells[14].Value.ToString(); SelectPlayer(userID, userName, userRank); } } }
public OnlineClient() { InitializeComponent(); if (!string.IsNullOrEmpty(KeyValues.Instance.GetKeyValue(KeyValueE.RefreshIntervalOnlineClient).Value)) { timer1.Interval = UData.ToInt32(KeyValues.Instance.GetKeyValue(KeyValueE.RefreshIntervalOnlineClient).Value); } if (!string.IsNullOrEmpty(KeyValues.Instance.GetKeyValue(KeyValueE.Heartbeat).Value)) { timerHeartbeat.Interval = UData.ToInt32(KeyValues.Instance.GetKeyValue(KeyValueE.Heartbeat).Value); } }
private void toolStripButtonDelete_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count != 0 && Ap.SelectedRoomID != (int)RoomE.HumanTournaments && Ap.SelectedRoomParentID != (int)RoomE.HumanTournaments) { int i = dataGridView1.CurrentRow.Index; int ChallengeID = UData.ToInt32(dataGridView1["ChallengeID", i].Value); int ChallengerID = UData.ToInt32(dataGridView1["ChallengerID", i].Value); ChallengeTypeE challengeType = (ChallengeTypeE)UData.ToInt32(dataGridView1["Type", i].Value); DataSet ds = SocketClient.DeleteChallenge(ChallengeID, ChallengerID, challengeType); if (ds != null && ds.Tables.Count > 0) { LoadChallenges(ds.Tables[0]); } } }
public void MovePrevious() { if (wrapPanel.Children.Count > 0) { TextBlock target = (TextBlock)wrapPanel.Children[SelectedIndex]; if (!string.IsNullOrEmpty(target.Tag.ToString())) { Move m = this.Game.Moves.GetById(UData.ToInt32(target.Tag)); if (m != null) { this.Game.MoveTo(MoveToE.Previous); } } } }
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 ViewGame(DataGridViewRow row) { if (row.Cells[9].Value.ToString() == "In progress") { if (Convert.ToInt32(row.Cells[3].Value) == Ap.CurrentUserID || Convert.ToInt32(row.Cells[6].Value) == Ap.CurrentUserID) { return; } } if (row.Cells[0].Value != null && !String.IsNullOrEmpty(row.Cells[0].Value.ToString()) && (Ap.CurrentUser.UserStatusIDE == UserStatusE.Blank || Ap.CurrentUser.UserStatusIDE == UserStatusE.Engine || Ap.CurrentUser.UserStatusIDE == UserStatusE.Centaur)) { int GameID = UData.ToInt32(row.Cells[0].Value); SocketClient.AddAudience(GameID); InfinityChess.WinForms.MainOnline.ShowMainOnline(GameID); } }
bool OpenBestBiltzGame() { bool isGameRunning = false; DataSet dsPlayer = SocketClient.HighestRankingPlayerGame(); if (dsPlayer.Tables.Count > 0) { if (dsPlayer.Tables[0].Rows[0]["GameID"] != System.DBNull.Value) { int GameID = UData.ToInt32(dsPlayer.Tables[0].Rows[0]["GameID"]); SocketClient.AddAudience(GameID); MainOnline.ShowMainOnline(GameID); isGameRunning = true; } } return(isGameRunning); }
private void toolStripButtonModify_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count != 0 && Ap.SelectedRoomID != (int)RoomE.HumanTournaments && Ap.SelectedRoomParentID != (int)RoomE.HumanTournaments) { int i = dataGridView1.CurrentRow.Index; if (UData.ToInt32(dataGridView1["ChallengerID", i].Value) != Ap.CurrentUserID && UData.ToInt32(dataGridView1["Type", i].Value) != (int)ChallengeTypeE.Seek) { ChallengeWindow frm = new ChallengeWindow(); frm.IsModify = true; frm.ChallengeID = UData.ToInt32(dataGridView1["ChallengeID", i].Value); frm.opponentUserID = UData.ToInt32(dataGridView1["ChallengerID", i].Value); frm.opponentUserName = dataGridView1["OpponentName", i].Value.ToString(); frm.ShowDialog(); } } }
public static Kv UpdateTournamentMatchStatus(Cxt cxt, int tournamentID, TournamentMatchStatusE tournamentMatchStatusID, TournamentMatches matches) { Kv kv = new Kv(); int result = 0; if (tournamentMatchStatusID == TournamentMatchStatusE.InProgress) { result = GetRoundInprogress(cxt, tournamentID, matches); if (result > 0) { kv.Set("Result", result); return(kv); } } DataTable dt = new DataTable("TournamentMatchResult"); dt.Columns.Add("Round", typeof(Int32)); dt.Columns.Add("TournamentMatchID", typeof(Int32)); dt.Columns.Add("Player1", typeof(Int32)); dt.Columns.Add("Player2", typeof(Int32)); for (int i = 0; i < matches.Count; i++) { result = 0; TournamentMatch item = matches[i]; if (tournamentMatchStatusID == TournamentMatchStatusE.InProgress) { result = IsPlayerAvailable(cxt, item); } if (result == 0) { UpdateTournamentMatchStatus(cxt, tournamentMatchStatusID, item); dt.Rows.Add(item.Round, item.TournamentMatchID, item.WhiteUserID, item.BlackUserID); } } kv.Set("TournamentMatchResult", UData.ToString(dt)); kv.Set("Result", result); return(kv); }
public static Game RestartGameByMoveID(Cxt cxt, int gameID, int moveID, int wMin, int wSec, int bMin, int bSec) { Game g = new Game(cxt, gameID); Moves moves = new Moves(g.GameXml); moves.TruncateAfter(moveID); Move ml = moves.Last; ml.MoveTimeWhite = wMin + wSec; ml.MoveTimeBlack = bMin + bSec; g.GameXml = GetGameXML(UData.ToString(moves.DataTable)); g.Save(); return(g); }
public UData createUser(string mid) { UData ud = new UData(); cmd = new SqlCeCommand("INSERT INTO users(uname,mxitid,state) VALUES ('" + mid + "','" + mid + "',0)", con); cmd.ExecuteNonQuery(); cmd = new SqlCeCommand("SELECT * FROM users WHERE mxitid='"+mid+"'",con); SqlCeDataReader reader = cmd.ExecuteReader(); reader.Read(); ud.id = reader.GetInt32(0); ud.uname = mid; ud.mxitid = mid; ud.state = -2; return ud; }
public UData GetUdata(string mid) { UData ud; int pos = FindInList(mid); if (pos == -1) { ud = new UData(); cmd = new SqlCeCommand("SELECT * FROM users WHERE mxitid='" + mid + "'", con); SqlCeDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { ud.id = reader.GetInt32(0); ud.uname = reader.GetString(1); ud.mxitid = reader.GetString(2); ud.state = reader.GetInt32(3); ud.level = reader.GetInt32(4); ud.exp = reader.GetInt32(5); ud.bank = reader.GetDecimal(6); ud.wallet = reader.GetDecimal(7); ud.atk = reader.GetInt32(8); ud.def = reader.GetInt32(9); ud.armour = reader.GetInt32(10); ud.gloves = reader.GetInt32(11); ud.helmet = reader.GetInt32(12); ud.weapon = reader.GetInt32(13); ud.fighting = reader.GetInt32(14); } else { ud.id = -1; } Program.ActiveUsers.Add(ud); } else { ud = Program.ActiveUsers[pos]; } return ud; }
private void btnOK_Click(object sender, EventArgs e) { UserFormulas.Instance = null; UserFormulaDataKv formula = new UserFormulaDataKv(); formula.UserID = Ap.CurrentUserID; formula.IsUnrated = chkUnrated.Checked; formula.IsRated = chkRated.Checked; formula.IsDucate = chkDucats.Checked; formula.IsNoComputer = chkNoComputer.Checked; formula.IsNoCentaur = chkNoCentaur.Checked; formula.IsFastInternetOnly = chkFastInternet.Checked; formula.MinElo = UData.ToInt32(numericMinElo.Value); formula.MaxElo = UData.ToInt32(numericMaxElo.Value); formula.MinTime = UData.ToInt32(numericMinTime.Value); formula.MaxTime = UData.ToInt32(numericMaxTime.Value); formula.MinGainPerMove = UData.ToInt32(numericMinGain.Value); formula.MaxGainPerMove = UData.ToInt32(numericMaxGain.Value); formula.RankID = UData.ToInt32(comboBoxMinRank.SelectedValue); formula.DucatesToOverride = UData.ToInt32(numericMinDucats.Value); formula.IsActive = chkActivate.Checked; try { DataSet ds = SocketClient.UpdateFormula(formula); if (ds != null && ds.Tables.Count > 0) { ChallengesUc.Instance.LoadChallenges(ds.Tables[0]); } } catch (Exception ex) { TestDebugger.Instance.WriteError(ex); } this.Close(); }
private void toolStripButtonDeleteDisable_Click(object sender, System.EventArgs e) { try { if (editor1.DocumentText == "clear") { editor1.DocumentText = ""; } else { DataSet ds = SocketClient.GetKeyValue(Ap.CurrentUser.PersonalNotes); editor1.Document.Body.InnerText = UData.ToString(ds); } } catch (Exception ex) { TestDebugger.Instance.WriteError(ex); } }
private void SaveGame(string P1, string P2, int MatchID) { App.Model.GameData _GameData = new App.Model.GameData(this.Game); // Players and Result _GameData.White1 = P1; _GameData.White2 = P1; _GameData.Black1 = P2; _GameData.Black2 = P2; _GameData.Tournament = Title; _GameData.TournamentGuid = TournamentGuid; _GameData.IsECO = false; _GameData.EcoCode = "344"; _GameData.IsEloWhite = false; _GameData.EloWhite = 0; _GameData.IsEloBlack = false; _GameData.EloBlack = 0; _GameData.Result = ""; _GameData.ResultSymbol = ""; _GameData.IsYear = false; _GameData.Year = 0; _GameData.IsMonth = false; _GameData.Month = 0; _GameData.IsDay = false; _GameData.Day = 0; _GameData.TournamentMatchID = MatchID; string gameXml = UData.ToString(_GameData.Kv.DataTable); string fileName = "uba.icd";// InfinityChess.Offline.Forms.GlobalSet.Default.CurrentGameFile; if (gameXml != "") { Ap.LoadDatabase(fileName); Ap.Database.AppendGame(gameXml); Ap.Database.Save(); } }
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 toolStripButtonDelete_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { DialogResult dr = MessageForm.Confirm(this.ParentForm, MsgE.ConfirmEmailDelete, ""); if (dr == DialogResult.Yes) { int messageId = UData.ToInt32(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); int statusIDTo = UData.ToInt32(dataGridView1.SelectedRows[0].Cells[10].Value.ToString()); DataSet ds = SocketClient.DeleteEmail(messageId, (int)StatusE.Deleted, statusIDTo); if (ds != null && ds.Tables.Count > 0) { this.LoadMessages(ds.Tables[0]); } else { this.LoadMessages(null); editor1.BodyHtml = ""; } } } }
private void rootPreviewMouseDown(object sender, RoutedEventArgs e) { if (!(e.OriginalSource.GetType() == typeof(TextBlock))) { return; } TextBlock target = (TextBlock)e.OriginalSource; target = CheckComments(target); if (target != null && target.Tag != null && !string.IsNullOrEmpty(target.Tag.ToString())) { Move m = this.Game.Moves.GetById(UData.ToInt32(target.Tag)); if (m != null) { this.Game.MoveTo(m); } } e.Handled = true; wrapPanel.Focus(); }
private void ChallengeGame(DataGridViewRow row) { if (Ap.IsGameInProgress) { return; } if (Ap.SelectedRoomID == (int)RoomE.HumanTournaments || Ap.SelectedRoomParentID == (int)RoomE.HumanTournaments || Ap.SelectedRoomID == (int)RoomE.EngineTournaments || Ap.SelectedRoomParentID == (int)RoomE.EngineTournaments) { return; } if (Convert.ToInt32(row.Cells[0].Value) == Ap.CurrentUserID) { MessageForm.Error(this.ParentForm, MsgE.ErrorChallangeYourself); return; } if (UData.ToInt32(row.Cells[20].Value.ToString()) == (int)UserStatusE.Blank || UData.ToInt32(row.Cells[20].Value.ToString()) == (int)UserStatusE.Engine || UData.ToInt32(row.Cells[20].Value.ToString()) == (int)UserStatusE.Centaur || UData.ToInt32(row.Cells[20].Value.ToString()) == (int)UserStatusE.Kibitzer) { if (!String.IsNullOrEmpty(row.Cells[21].Value.ToString()) && Convert.ToBoolean(row.Cells[21].Value.ToString())) { MessageForm.Show(this.ParentForm, MsgE.ChallengePauseUser, row.Cells[2].Value.ToString()); return; } //MessageForm.Show(dataGridView1[2, e.RowIndex].Value + " : " + UserStatusE.Idle.ToString()); ChallengeWindow frm = new ChallengeWindow(); frm.IsModify = false; frm.opponentUserID = SelectedUserId; frm.opponentUserName = SelectedUserName; frm.opponentRank = SelectedUserRank; frm.ShowDialog(); } }
private void GeUserImageBytes() { DataTable userImageTable = new DataTable("UserImageTable"); DataColumn nameColumn; nameColumn = new DataColumn(); nameColumn.DataType = System.Type.GetType("System.String"); nameColumn.ColumnName = "ImageName"; userImageTable.Columns.Add(nameColumn); DataColumn imageColumn; imageColumn = new DataColumn(); imageColumn.DataType = System.Type.GetType("System.Byte[]"); imageColumn.ColumnName = "ImageBytes"; userImageTable.Columns.Add(imageColumn); DataRow dr = userImageTable.NewRow(); dr["ImageName"] = "UserImage"; dr["ImageBytes"] = UserImage; userImageTable.Rows.Add(dr); Kv.UserImageType = ImageType; Kv.UserImage = UData.ToString(userImageTable); }
// GET: Track/5 public ActionResult Account(AccountViewModel Model, string ID) { Model.AccDetails = new UAccount(); try { Model.AccDetails.AccID = new Guid(ID); } catch { return(RedirectToAction("Index")); } List <int> RunningDifferenceFollowing = new List <int>(); List <int> RunningDifferenceFollowers = new List <int>(); using (SqlConnection dbConn = new SqlConnection()) { dbConn.ConnectionString = Configuration.DB; //dbConn.ConnectionString = ConfigurationManager.ConnectionStrings["Bloometa_DB"].ConnectionString; dbConn.Open(); SqlCommand RetrieveAccount = new SqlCommand("SELECT TOP(1) [Network], [Username], [Added] FROM UAccounts WHERE [AccID] = @AccID AND [Removed] = 0", dbConn); RetrieveAccount.Parameters.Add("@AccID", SqlDbType.UniqueIdentifier).Value = Model.AccDetails.AccID; using (SqlDataReader results = RetrieveAccount.ExecuteReader()) { if (results.HasRows) { ViewData["AccountFound"] = true; while (results.Read()) { Model.AccDetails.Network = (string)results["Network"]; Model.AccDetails.Username = (string)results["Username"]; Model.AccDetails.Added = (DateTime)results["Added"]; } } else { return(RedirectToAction("Index")); } } DateTime StartDate = DateTime.UtcNow.AddMonths(-1); SqlCommand RetrieveData = new SqlCommand(@" WITH ReportingPeriod AS ( SELECT Data.[AccID], CONVERT(DATETIME, CONVERT(DATE, Data.[Run])) as [Run], Data.[FollowCount], Data.[FollowerCount], ROW_NUMBER() OVER(PARTITION BY CONVERT(DATETIME, CONVERT(DATE, Data.[Run])) ORDER BY Data.[Run] DESC) as [RowKey] FROM UData Data WHERE Data.AccID = @AccID AND Data.[Run] BETWEEN @StartDate AND getutcdate() ) SELECT ReportingPeriod.* FROM ReportingPeriod WHERE ReportingPeriod.[RowKey] = 1 ORDER BY ReportingPeriod.[Run] ASC", dbConn); RetrieveData.Parameters.Add("@AccID", SqlDbType.UniqueIdentifier).Value = Model.AccDetails.AccID; RetrieveData.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = StartDate; Model.Reporting = new List <UData>(); Model.ReportingFollowers = new List <int>(); Model.ReportingFollowing = new List <int>(); Model.ReportingDays = new List <DateTime>(); using (SqlDataReader results = RetrieveData.ExecuteReader()) { int i = 0; while (results.Read()) { UData DataItem = new UData(); DataItem.Run = (DateTime)results["Run"]; DataItem.FollowCount = (int)results["FollowCount"]; DataItem.FollowerCount = (int)results["FollowerCount"]; Model.Reporting.Add(DataItem); Model.ReportingFollowers.Add(DataItem.FollowerCount); Model.ReportingFollowing.Add(DataItem.FollowCount); Model.ReportingDays.Add(DataItem.Run); if (i != 0) { Model.Reporting[i].FollowDifference = DataItem.FollowCount - Model.Reporting[i - 1].FollowCount; Model.Reporting[i].FollowerDifference = DataItem.FollowerCount - Model.Reporting[i - 1].FollowerCount; } else { Model.Reporting[i].FollowDifference = 0; Model.Reporting[i].FollowerDifference = 0; } RunningDifferenceFollowing.Add(Model.Reporting[i].FollowDifference); RunningDifferenceFollowers.Add(Model.Reporting[i].FollowerDifference); i++; } } } Model.Reporting.Reverse(); Model.MonthTotalFollowers = RunningDifferenceFollowers.Sum(); Model.MonthTotalFollowing = RunningDifferenceFollowing.Sum(); return(View(Model)); }
void but_add_Click(object sender, EventArgs e) { var dlg = new OpenFileDialog { CheckFileExists = true, Filter="Supported Images|*.png;*.jpg;*.bmp", Multiselect = true, RestoreDirectory = true, Title = "Select images to add as textures", InitialDirectory = _content.RootDirectory + (string.IsNullOrEmpty(_contentPath) ? "" : ("/" + _contentPath))}; dlg.ShowDialog(); foreach (var item in dlg.FileNames) { var name = Path.GetFileName(item); var tex = _content.Load<Texture2D>(string.IsNullOrEmpty(_contentPath) ? name : (_contentPath + "/"+name)); var t = new UData { Name = name, StoredRectangle = new Rectangle(0,0, tex.Width, tex.Height), StoredTexture = tex }; DataList.Add(t); } }
private void btnOK_Click(object sender, EventArgs e) { if (Ap.IsGameInProgress) { PlayingModeData.Instance.AutometicChallenges = chkAutomaticChallenges.Checked; PlayingModeData.Instance.AutometicAccepts = chkAutometicAccepts.Checked; this.Close(); } else { string engineName = string.Empty; UserStatusE userStatus; if (rbHuman.Checked) { if (selectedEngine != null) { selectedEngine.Close(); selectedEngine = null; } Ap.PlayingMode.ChessTypeID = 1; PlayingModeData.Instance.AutometicChallenges = false; PlayingModeData.Instance.AutometicAccepts = false; PlayingModeData.Instance.SendEvaluations = false; PlayingModeData.Instance.SendExpectedMoves = false; userStatus = UserStatusE.Blank; } else if (rbComputer.Checked) { if (selectedEngine == null) { MessageForm.Show(this, MsgE.InfoUploadEngine); return; } engineName = selectedEngine.EngineName; Ap.PlayingMode.ChessTypeID = 2; PlayingModeData.Instance.AutometicChallenges = chkAutomaticChallenges.Checked; PlayingModeData.Instance.AutometicAccepts = chkAutometicAccepts.Checked; PlayingModeData.Instance.SendEvaluations = chkSendEvaluations.Checked; PlayingModeData.Instance.SendExpectedMoves = chkSendExpectedMove.Checked; PlayingModeData.Instance.Time = UData.ToInt32(numericUpDown1.Value); PlayingModeData.Instance.GainPerMove = UData.ToInt32(numericUpDown2.Value); Ap.CurrentUser.UserStatusIDE = userStatus = UserStatusE.Engine; ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Info, ChatTypeE.OnlineClient, "'" + engineName + "' loaded successfully", 0); } else { Ap.PlayingMode.ChessTypeID = 3; PlayingModeData.Instance.AutometicChallenges = false; PlayingModeData.Instance.AutometicAccepts = false; PlayingModeData.Instance.SendEvaluations = false; PlayingModeData.Instance.SendExpectedMoves = false; Ap.CurrentUser.UserStatusIDE = userStatus = UserStatusE.Centaur; } SocketClient.SetUserEngine(engineName, userStatus); PlayingModeData.Instance.Pause = Ap.CurrentUser.IsPause; PlayingModeData.Instance.ChessTypeID = Ap.PlayingMode.ChessTypeID; PlayingModeData.Instance.Save(); Ap.PlayingMode.SelectedEngine = selectedEngine; Ap.PlayingMode.SelectedBook = selectedBook; this.Close(); } }
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex == 5 || e.ColumnIndex == 8 || e.ColumnIndex == 9 || e.ColumnIndex == 10 || e.ColumnIndex == 13) { if (dataGridView1["WhiteUserID", e.RowIndex].Value.ToString() != userID.ToString()) { switch (e.ColumnIndex) { case 5: e.Value = dataGridView1["WhiteUserName", e.RowIndex].Value; break; case 8: e.Value = dataGridView1["EloWhite", e.RowIndex].Value; break; case 9: if (dataGridView1["GameResultID", e.RowIndex].Value != null) { string result = string.Empty; GameResultE gameResult = (GameResultE)UData.ToInt32(dataGridView1["GameResultID", e.RowIndex].Value.ToString()); switch (gameResult) { case GameResultE.None: break; case GameResultE.InProgress: break; case GameResultE.WhiteWin: result = "0"; break; case GameResultE.WhiteLose: result = "1"; break; case GameResultE.Draw: result = "1/2"; break; case GameResultE.Absent: break; case GameResultE.NoResult: break; case GameResultE.WhiteBye: result = "1"; break; case GameResultE.BlackBye: result = "0"; break; case GameResultE.ForcedWhiteWin: result = "0"; break; case GameResultE.ForcedWhiteLose: result = "1"; break; case GameResultE.ForcedDraw: result = "1/2"; break; default: break; } e.Value = result; } break; case 10: e.Value = "White"; break; case 13: if (dataGridView1["WhiteUserCountry", e.RowIndex].Value != null && dataGridView1["WhiteUserCountry", e.RowIndex].Value.ToString() != "" && dataGridView1["WhiteUserCountry", e.RowIndex].Value.ToString() != "0") { Image item = Image.FromFile(App.Model.Ap.FolderImages + @"Flags\" + dataGridView1["WhiteUserCountry", e.RowIndex].Value + ".PNG"); e.Value = item; } else { Image item = Image.FromFile(App.Model.Ap.FolderImages + @"Flags\244.PNG"); e.Value = item; } break; } } else { switch (e.ColumnIndex) { case 5: e.Value = dataGridView1["BlackUserName", e.RowIndex].Value; break; case 8: e.Value = dataGridView1["EloBlack", e.RowIndex].Value; break; case 9: if (dataGridView1["GameResultID", e.RowIndex].Value != null) { string result = string.Empty; GameResultE gameResult = (GameResultE)UData.ToInt32(dataGridView1["GameResultID", e.RowIndex].Value.ToString()); switch (gameResult) { case GameResultE.None: break; case GameResultE.InProgress: break; case GameResultE.WhiteWin: result = "1"; break; case GameResultE.WhiteLose: result = "0"; break; case GameResultE.Draw: result = "1/2"; break; case GameResultE.Absent: break; case GameResultE.NoResult: break; case GameResultE.WhiteBye: result = "0"; break; case GameResultE.BlackBye: result = "1"; break; case GameResultE.ForcedWhiteWin: result = "1"; break; case GameResultE.ForcedWhiteLose: result = "0"; break; case GameResultE.ForcedDraw: result = "1/2"; break; default: break; } e.Value = result; } break; case 10: e.Value = "Black"; break; case 13: if (dataGridView1["BlackUserCountry", e.RowIndex].Value != null && dataGridView1["BlackUserCountry", e.RowIndex].Value.ToString() != "" && dataGridView1["BlackUserCountry", e.RowIndex].Value.ToString() != "0") { Image item = Image.FromFile(App.Model.Ap.FolderImages + @"Flags\" + dataGridView1["BlackUserCountry", e.RowIndex].Value + ".PNG"); e.Value = item; } else { Image item = Image.FromFile(App.Model.Ap.FolderImages + @"Flags\244.PNG"); e.Value = item; } break; } } } }
public static string[] GetRoles(int userID) { return((string[])UData.ToArray(GetRolesTable(userID), "RoleID")); }
public static string[] GetRoles(string userName) { DataTable table = BaseCollection.ExecuteSql(InfiChess.Role, "SELECT Role.RoleID FROM UserRole INNER JOIN Role ON UserRole.RoleID = Role.RoleID INNER JOIN[User] ON UserRole.UserID = [User].UserID WHERE (LOWER([User].UserName) = LOWER(@p1))", userName); return((string[])UData.ToArray(table, "RoleID")); }
public void SetDataByRoomId(DataSet ds, bool isFromTimer) { try { if (ds != null && ds.Tables.Count > 0) { if (ds.Tables["Room"] != null && ds.Tables["Room"].Rows.Count > 0) { Room room = new Room(Ap.Cxt, ds.Tables["Room"].Rows[0]); if (!string.IsNullOrEmpty(room.TournamentID.ToString())) { Ap.SelectedRoomParentID = room.ParentID; Ap.RoomTournamentID = room.TournamentID; isUrlBit = room.IsUrlBit; url = string.Empty; if (isUrlBit) { if (DBNull.Value.ToString() != room.Html && room.Html != string.Empty) { url = room.Html; } } if (LoadRoomInfoPage != null && !isFromTimer) { LoadRoomInfoPage(Ap.SelectedRoomID, Ap.RoomTournamentID, url); } } } if (ds.Tables["LoggedinUsers"].Rows.Count > 0) { if (!string.IsNullOrEmpty(ds.Tables["LoggedinUsers"].Rows[0]["LoggedinUser"].ToString())) { tsUserCounter.Text = ds.Tables["LoggedinUsers"].Rows[0]["LoggedinUser"].ToString(); } } if (ds.Tables.Count == 0) { return; } if (LoadPlayerGrid != null) { LoadPlayerGrid(ds.Tables["Users"]); } if (LoadGameGrid != null) { LoadGameGrid(ds.Tables["Games"]); } if (LoadChallengeGrid != null) { LoadChallengeGrid(ds.Tables["Challenges"]); } if (LoadUserMessages != null) { if (ds.Tables["UserMessages"] != null) { LoadUserMessages(ds.Tables["UserMessages"]); } } if (ds.Tables["RoomUsersCount"] != null) { if (ds.Tables["RoomUsersCount"].Rows.Count > 0) { if (treeView1.Nodes.Count > 0) { SetRoomUsersCount(ds); } } } if (ds.Tables["AcceptedChallenge"] != null) { if (ds.Tables["AcceptedChallenge"].Rows.Count > 0) { int challengeID = UData.ToInt32(ds.Tables["AcceptedChallenge"].Rows[0]["ChallengeID"]); InfinityChess.WinForms.MainOnline.ShowMainOnline(challengeID, ChallengeStatusE.Accepted, 0); Ap.CanAutoChallenge = true; return; } } //Only for human tounament rooms if (Ap.SelectedRoomID > (int)RoomE.EngineTournaments && Ap.SelectedRoomParentID != (int)RoomE.ComputerChess && Ap.SelectedRoomParentID != (int)RoomE.EngineTournaments) { if (Ap.IsGameInProgress || Ap.KibitzersCount > 0) { return; } Ap.CurrentUser.UserStatusIDE = UserStatusE.Blank; Ap.CurrentUser.EngineID = 1; Ap.PlayingMode.ChessTypeID = 1; PlayingModeData.Instance.ChessTypeID = 1; if (Ap.PlayingMode.SelectedEngine != null) { Ap.PlayingMode.SelectedEngine.Close(); Ap.PlayingMode.SelectedEngine = null; } SocketClient.SetUserEngine(string.Empty, Ap.CurrentUser.UserStatusIDE); } return; } else { return; } } catch (Exception ex) { TestDebugger.Instance.WriteError(ex); } }
private void toolStripButton1_Click(object sender, EventArgs e) { DataSet ds = SocketClient.GetKeyValue("select * from [User]"); MessageForm.Show(UData.ToString(ds)); }