public static void SetCurrentUser(Kv kv1) { DataTable dtUser = kv1.GetDataTable("UserData"); DataTable dtRoles = kv1.GetDataTable("RolesData"); if (dtUser.Rows.Count > 0) { Ap.CurrentUser = new User(Cxt.Instance, dtUser.Rows[0]); UWeb.Principal = User.GetPrincipal(Ap.CurrentUser.UserName, dtRoles); } }
private void NewGame(Kv kv) { DataSet ds = new DataSet(); ds.Tables.Add(kv.GetDataTable("Challenge").Copy()); ds.Tables.Add(kv.GetDataTable("Game").Copy()); ds.Tables.Add(kv.GetDataTable("Users").Copy()); ds.Tables.Add(kv.GetDataTable("Engines").Copy()); base.Game.DbGame = App.Model.Db.Game.CreateGame(Ap.Cxt, ds); OfferReMatch.Enabled = false; EnableBarButtons(true); NewGame(); }
private void AddAudience(Kv kv) { DataTable dt = kv.GetDataTable("AudienceData"); if (dt.Rows.Count > 0) { AudienceUc.AddAudience(dt.Rows[0]); } }
public static int LoginMsg(Kv kv, bool isGuest) { DataTable dt = null; int msgID = 0; if (isGuest) { msgID = kv.GetInt32("Msg"); } else { Kv kv1 = new Kv(kv.GetDataTable("Msg")); dt = kv1.DataTable; msgID = Convert.ToInt32(dt.Rows[0][0]); } if (msgID < 0) { msgID = msgID * -1; MsgE msge = (MsgE)msgID; switch (msge) { case MsgE.Active: return((int)MsgE.Active); case MsgE.Disabled: case MsgE.Inactive: case MsgE.Deleted: case MsgE.BlockIp: return((int)MsgE.BlockIp); case MsgE.InfoBlockMachine: case MsgE.WrongIdPassowrd: return((int)MsgE.WrongIdPassowrd); case MsgE.NoRoles: return((int)MsgE.NoRoles); case MsgE.Ban: //MessageForm.Error(this, MsgE.ErrorBannedForever, Ap.CurrentUser.UserName); return((int)MsgE.Ban); } } else if (msgID == 0) { //MessageForm.Error(this, MsgE.InfoBaned, kv.GetDateTime("BanEndDateTime"), kv.GetDateTime("BanEndDateTime1")); return(0); } return(msgID); }
bool IsValidUser(Kv kv, int statusID) { bool isTrue = false; Kv kv1 = new Kv(kv.GetDataTable("Msg")); DataTable dt = kv1.DataTable; int msgID = Convert.ToInt32(dt.Rows[0][0]); string serverMaintainceDateTime = KeyValues.Instance.GetKeyValue(KeyValueE.ServerMaintainceDateTime).Value; if (statusID == 5) { MessageForm.Error(this, MsgE.ErrorBannedForever, Ap.CurrentUser.UserName); isTrue = true; } else if (statusID == 0) { DateTime dt1 = Convert.ToDateTime(dt.Rows[0][1]); DateTime dt2 = Convert.ToDateTime(dt.Rows[0][2]); MessageForm.Error(this, MsgE.InfoBaned, dt1.ToString(), dt2.ToString()); isTrue = true; } else if (statusID == 7) { MessageForm.Error(this, MsgE.WrongIdPassowrd); isTrue = true; } else if (statusID == 8) { MessageForm.Error(this, MsgE.NoRoles); } else if (serverMaintainceDateTime != string.Empty) { isTrue = true; MessageForm.Error(this.ParentForm, MsgE.ErrorServerMaintainceMode, serverMaintainceDateTime); } else if (statusID == 6) { MessageForm.Error(this, MsgE.BlockIp); isTrue = true; } else { isTrue = false; } return(isTrue); }
/// <summary> /// Below function is use in web site login /// </summary> /// <param name="kv"></param> /// <returns></returns> public static bool LoginUser(Kv kv) { DataTable dt = null; bool isLogin = false; Kv kv1 = new Kv(User.LoginKv(kv)); dt = kv1.GetDataTable("Msg"); if (dt.Rows.Count > 0) { int statusID = Convert.ToInt32(dt.Rows[0]["MsgId"]) * -1; if (statusID == (int)(MsgE.Active)) { return(true); } } return(isLogin); }