//renames columns inside binded table with data to more readable text for user private void RenameColumns() { //hide columns wich user shouldent see,used for internal logic int colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "createDate"); if (colIndex != -1) { WebSiteManager.renameColumn(ref gamesGV, colIndex, "Create Date"); } colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "gameName"); if (colIndex != -1) { WebSiteManager.renameColumn(ref gamesGV, colIndex, "Game Name"); } colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "hostPlayerName"); if (colIndex != -1) { WebSiteManager.renameColumn(ref gamesGV, colIndex, "Hosting Player"); } colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "joinPlayerName"); if (colIndex != -1) { WebSiteManager.renameColumn(ref gamesGV, colIndex, "Joined Player"); } }
protected void OnExistGameClick(object sender, EventArgs e) { //rest start game message if exists GeneralErrorStartGame.Text = ""; DTO_GamePlay selectedGame = ((DTO_GamePlay[])Session[WebSiteManager.WATING_GAMES_LIST_SESSION])[gamesGV.SelectedRow.RowIndex]; DTO_ACCOUNT loggedInAccount = (DTO_ACCOUNT)(Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]); DTO_Player joiningPlayer = loggedInAccount.players[PlayerList2.SelectedIndex]; if (selectedGame.hostPlayerID == joiningPlayer.Id) { GeneralError.ForeColor = Color.Red; GeneralError.Text = "You are owner of this game,You allowed to close the game"; } else if (selectedGame.joinedPlayerID != joiningPlayer.Id) { GeneralError.ForeColor = Color.Red; GeneralError.Text = "You are not player in this game"; } else { WebSiteManager.ExistGame(selectedGame.Key); loadWatingGames(); // first time page loades we color the tabel for player at index 0 ColorGamesTableRows(PlayerList2.SelectedIndex); gamesGridViewPanel.Update(); } }
//hides columns wich user shouldent see,used for internal logic private void HideColumns() { int colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "hostPlayerAccountEmail"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref gamesGV, colIndex); } colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "hostPlayerID"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref gamesGV, colIndex); } colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "joinedPlayerID"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref gamesGV, colIndex); } colIndex = WebSiteManager.GetColumnIndexByName(gamesGV, "Status"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref gamesGV, colIndex); } }
protected void loadDomainName() { foreach (WebSite item in WebSiteManager.GetAllWebSiteByRegisterId(oepr.Account.AccountId)) { ddlDomainName.Items.Add(new ListItem(item.DomainName, item.DomainName)); } }
protected void CreateUser_Click(object sender, EventArgs e) { List <DTO_Player> accountPLayers = (List <DTO_Player>)Session["accountPLayers"]; // check if players added if no show error message if (accountPLayers.Count == 0) { playersError.Style["display"] = "inline"; return; } else if (WebSiteManager.IsEmailExist(Email.Text)) { GeneralError.Text = "Email allready in exists."; return; } else { // create new user and add to db , in case faild validation errors will be on page. try { if (IsValid) { // register account to DB // create Hash from user password string hashedPassword = WebSiteManager.CreateHash(Password.Text, WebSiteManager.PASSWORD_HASH_SALT); // create account entitiy DTO_ACCOUNT a = new DTO_ACCOUNT { EMAIL = Email.Text, PASSWORD = hashedPassword, NAME = nickname.Text }; // this players not include there ids from db a.players = accountPLayers.ToArray(); // add to db WebSiteManager.RegisterAccount(a); // getaccount players with there ids from db a.players = WebSiteManager.GetPlayers(a.EMAIL); // store logged in account and transfer to homepage Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] = new DTO_ACCOUNT { EMAIL = a.EMAIL, PASSWORD = a.PASSWORD, NAME = a.NAME, players = a.players }; Server.Transfer("../Default.aspx", true); } } catch (WebException ex) { using (WebResponse response = ex.Response) { var httpResponse = (HttpWebResponse)response; using (Stream data = response.GetResponseStream()) { StreamReader sr = new StreamReader(data); GeneralError.Text = sr.ReadToEnd(); } } } } }
protected void OnJoinGameClick(object sender, EventArgs e) { // rest start game messages if exist GeneralErrorStartGame.Text = ""; // set join game messages color GeneralError.ForeColor = Color.Red; // get joining player id DTO_ACCOUNT loggedInAccount = (DTO_ACCOUNT)(Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]); DTO_Player joiningPlayer = loggedInAccount.players[PlayerList2.SelectedIndex]; DTO_GamePlay selectedGameInTable; // check if there is game selected if (gamesGV.SelectedRow == null) { GeneralError.Text = "Please Select Game"; return; } else { selectedGameInTable = ((DTO_GamePlay[])Session[WebSiteManager.WATING_GAMES_LIST_SESSION])[gamesGV.SelectedRow.RowIndex]; } //validate that user not hosting game allready or not joined to other game if (isPlayerHostingOrJoinedGame(joiningPlayer.Id)) { GeneralError.Text = "You allready registarted to game"; } // check if game is full else if (selectedGameInTable.joinedPlayerID != null) { GeneralError.Text = "The Game is full"; } // check that selected game host player is not joining player (we wont join to ourself game) else if (joiningPlayer.Id == selectedGameInTable.hostPlayerID) { GeneralError.Text = "Cannot join to own game"; } // check that joinng player not playing vs own group of players else if (joiningPlayer.AccountEmail == selectedGameInTable.hostPlayerAccountEmail) { GeneralError.Text = "This game statred by your team members,Cannot play vs your own team"; } else { // updated database games table with joined player to this game int gameKey = WebSiteManager.JoinGame(selectedGameInTable.hostPlayerID.ToString(), joiningPlayer.Id.ToString()); loadWatingGames(); // first time page loades we color the tabel for player at index 0 ColorGamesTableRows(PlayerList2.SelectedIndex); gamesGridViewPanel.Update(); GeneralError.ForeColor = Color.Green; GeneralError.Text = "Successfully joined game, Key : " + gameKey; } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); Application.Current.DispatcherUnhandledException += App_DispatcherUnhandledException; // TODO: modify url with link and edit button to change it to http label + 2 textboxes // TODO: filesystemwatch on applicationhost.config to monitor changes and reload sites list // TODO: check which sites are running at startup var appHostPath = IISExpress.ApplicationHostConfigDefaultPath; var webSiteManager = new WebSiteManager(appHostPath); Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; // TODO: extract in a startup manager if (!webSiteManager.IsIISExpressInstalled()) { MessageBoxButton buttons = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Error; var message = string.Format("IISExpress is not installed in the following path:\r\n\r\n{0}\r\n\r\nThe application cannot Start.", webSiteManager.IISPath); MessageBox.Show(message, "Application ShutDown", buttons, icon); Application.Current.Shutdown(); return; } if (!webSiteManager.ApplicationHostConfigExists()) { var initViewModel = new InitializationViewModel(appHostPath); var dialog = new InitializationView(); dialog.DataContext = initViewModel; if (dialog.ShowDialog() == false) { MessageBox.Show("Cannot Start IIS Express GUI", "Application ShutDown", MessageBoxButton.OK, MessageBoxImage.Warning); Application.Current.Shutdown(); return; } } Current.ShutdownMode = ShutdownMode.OnMainWindowClose; // Create the ViewModel to which the main window binds. var viewModel = new MainWindowViewModel(webSiteManager); MainWindow window = new MainWindow(); // When the ViewModel asks to be closed, close the window. EventHandler handler = null; handler = delegate { viewModel.RequestClose -= handler; window.Close(); }; viewModel.RequestClose += handler; // Allow all controls in the window to bind to the ViewModel by setting the // DataContext, which propagates down the element tree. window.DataContext = viewModel; window.Show(); }
private void loadWatingGames() { DTO_GamePlay[] watingGames = WebSiteManager.GetWatingGames(); // store wating games Session[WebSiteManager.WATING_GAMES_LIST_SESSION] = watingGames; gamesGV.DataSource = watingGames; gamesGV.DataBind(); }
//域名发生改变时 protected void drpDomainName_SelectedIndexChanged(object sender, EventArgs e) { WebSite wst = WebSiteManager.GetWebSiteByDomainName(this.drpDomainName.SelectedValue); if (wst != null) { AddIcoLocation(wst.IcoLocation); AddBannerStyle(wst.IconStyle); AddInviteStyle(wst.InviteStyle); AddChatStyle(wst.ChatStyle); } }
static void Main(string[] args) { var mgr = new WebSiteManager(); var sites = mgr.GetWebsites(); foreach (var site in sites) { Console.WriteLine(site); } //mgr.StopPool(Int16.Parse(Console.ReadLine())); Console.ReadKey(); }
public List <string> GetAccountDomains() { checkAuthentication(); List <WebSite> wss = WebSiteManager.GetAllWebSiteByRegisterId(OperatorService.GetOperatorById(Authentication.OperatorId).AccountId); List <string> ds = new List <string>(); foreach (WebSite item in wss) { ds.Add(item.DomainName); } return(ds); }
//上传主动邀请图片 protected void Button5_Click(object sender, EventArgs e) { Label2.Visible = false; string bgStyle = this.FileUpload3.FileName; string okbtn = this.FileUpload4.FileName; string nobtn = this.FileUpload5.FileName; if (string.IsNullOrEmpty(bgStyle) || string.IsNullOrEmpty(okbtn) || string.IsNullOrEmpty(nobtn)) { Label2.Text = "请选择上传图片"; this.ModalPopupExtender2.Show(); return; } if (!string.IsNullOrEmpty(LoadImageType(bgStyle)) || !string.IsNullOrEmpty(LoadImageType(okbtn)) || !string.IsNullOrEmpty(LoadImageType(nobtn))) { Label2.Text = "图片,请上传格式为jpg,gif,png,bmp图片"; this.ModalPopupExtender2.Show(); return; } WebSite wst = WebSiteManager.GetWebSiteByDomainName(this.drpDomainName.SelectedValue); if (wst != null) { if (Session["User"] != null) { oper = (Operator)Session["User"]; string path = ConfigurationManager.AppSettings["UserDefinedPath"] + "\\" + oper.Account.AccountNumber + "\\" + drpDomainName.SelectedValue; Directory.CreateDirectory(path); string aa = LiveSupport.BLL.WebSiteManager.WebSite_UserDefined; string inviteBGimg = "invite_bg" + aa + Path.GetExtension(bgStyle); string inviteOKimg = "btn_ok" + aa + Path.GetExtension(okbtn); string inviteNOimg = "btn_no" + aa + Path.GetExtension(nobtn); FileUpload3.SaveAs(path + "\\" + inviteBGimg); FileUpload4.SaveAs(path + "\\" + inviteOKimg); FileUpload5.SaveAs(path + "\\" + inviteNOimg); wst.InviteStyle = aa + "|" + inviteBGimg + "|" + inviteOKimg + "|" + inviteNOimg; WebSiteManager.Update(wst); AddIcoLocation(wst.IcoLocation); AddBannerStyle(wst.IconStyle); AddInviteStyle(wst.InviteStyle); AddChatStyle(wst.ChatStyle); } else { Response.Redirect("../Index.aspx"); } } else { Response.Write("<script>alert('请选择上传到那个域名!');</script>"); } }
protected void OnSelectedIndexChangeShowPlayerForGame(object sender, EventArgs e) { DTO_Player[] playersByGameID = WebSiteManager.GetPlayersByGameID(((DTO_GamePlay[])Session["AllGames"])[GamesList.SelectedIndex - 1].Key); Session["tableData"] = playersByGameID; tableGV.DataSource = playersByGameID; tableGV.DataBind(); tableGridViewPanel.Update(); try { HideColumns(); } catch (Exception) { } }
protected void OnSelectedIndexChangeShowAllPlayerPlayedGames(object sender, EventArgs e) { DTO_GamePlay[] gamesByID = WebSiteManager.GetGamesByPlayerID(((DTO_Player[])Session["AllPlayers"])[PlayerList.SelectedIndex - 1].Id); Session["tableData"] = gamesByID; tableGV.DataSource = gamesByID; tableGV.DataBind(); tableGridViewPanel.Update(); try { HideColumns(); } catch (Exception) { } }
//上传聊天页面图片 protected void Button6_Click(object sender, EventArgs e) { string bgStyle = ConfigurationManager.AppSettings["UserDefinedPath"] + "\\Default\\chat_bg0.gif"; string rightimg = this.FileUpload7.FileName; string topimg = this.FileUpload8.FileName; if (string.IsNullOrEmpty(bgStyle) || string.IsNullOrEmpty(rightimg) || string.IsNullOrEmpty(topimg)) { Label3.Text = "请选择上传图片"; this.ModalPopupExtender3.Show(); return; } if (!string.IsNullOrEmpty(LoadImageType(bgStyle)) || !string.IsNullOrEmpty(LoadImageType(rightimg)) || !string.IsNullOrEmpty(LoadImageType(topimg))) { Label3.Text = "图片,请上传格式为jpg,gif,png,bmp图片"; this.ModalPopupExtender3.Show(); return; } WebSite wst = WebSiteManager.GetWebSiteByDomainName(this.drpDomainName.SelectedValue); if (wst != null) { if (Session["User"] != null) { oper = (Operator)Session["User"]; string path = ConfigurationManager.AppSettings["UserDefinedPath"] + "\\" + oper.Account.AccountNumber + "\\" + drpDomainName.SelectedValue; Directory.CreateDirectory(path); string aa = LiveSupport.BLL.WebSiteManager.WebSite_UserDefined; string chatBGimg = "chat_bg" + aa + Path.GetExtension(bgStyle); string chatRightimg = "chat_right" + aa + Path.GetExtension(rightimg); string leaveTopimg = "leave_top" + aa + Path.GetExtension(topimg); File.Copy(bgStyle, path + "\\" + chatBGimg, true); FileUpload7.SaveAs(path + "\\" + chatRightimg); FileUpload8.SaveAs(path + "\\" + leaveTopimg); wst.ChatStyle = aa + "|" + chatBGimg + "|" + chatRightimg + "|" + leaveTopimg; WebSiteManager.Update(wst); AddIcoLocation(wst.IcoLocation); AddBannerStyle(wst.IconStyle); AddInviteStyle(wst.InviteStyle); AddChatStyle(wst.ChatStyle); } else { Response.Redirect("../Index.aspx"); } } else { Response.Write("<script>alert('请选择上传到那个域名!');</script>"); } }
private void loadAllGamesDDL() { DTO_GamePlay[] games = WebSiteManager.GetAllGames(); List <string> gameNames = new List <string>(); gameNames.Add("Select Game"); Session["AllGames"] = games; foreach (DTO_GamePlay gp in games) { gameNames.Add(gp.gameName); } GamesList.DataSource = gameNames; GamesList.DataBind(); }
private void loadAllPlayersDDL() { DTO_Player[] players = WebSiteManager.GetAllPlayers(); List <string> playerNames = new List <string>(); playerNames.Add("Select Player"); Session["AllPlayers"] = players; foreach (DTO_Player pl in players) { playerNames.Add(pl.FirstName + " " + pl.LastName); } PlayerList.DataSource = playerNames; PlayerList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { // in case user not logged in and somehow got to game page, redirect him. if (Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] == null) { Server.Transfer("../Default.aspx", true); return; } if (!IsPostBack) { loadAccountPlayersLB(WebSiteManager.GetPlayers(((DTO_ACCOUNT)Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]).EMAIL).ToList()); loadAccountGamesLB(WebSiteManager.GetAllGamesByAccountEmail(((DTO_ACCOUNT)Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]).EMAIL).ToList()); Session[WebSiteManager.PLAYERS_4_DELETE_SESSION] = new List <int>(); Session[WebSiteManager.GAMES_4_DELETE_SESSION] = new List <int>(); } }
public void GetChatPageStyle() { LiveSupport.BLL.NewWebSite nwst = WebSiteManager.GetNewWebSiteByDomainName(CurrentVisitor.CurrentSession.DomainRequested);//用堿名取一行数 if (nwst == null || nwst.chatpage == null) { return; } string chatImageUrl = null; if (nwst.chatpage.State == LiveSupport.BLL.WebSiteManager.WebSite_UserDefined) { chatImageUrl = "Images/" + AccountService.GetAccountById(CurrentVisitor.AccountId).AccountNumber + "/" + nwst.domainName + "/"; } else { chatImageUrl = "Images/Default/"; } this.ChatPageOfflineTopImage.ImageUrl = chatImageUrl + nwst.chatpage.LeavePageTopImg; this.chatPageRightImg.ImageUrl = chatImageUrl + nwst.chatpage.ChatPageRightImg; }
//添加域名 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (Session["User"] != null) { oepr = (Operator)Session["User"]; if (WebSiteManager.GetWebSiteByDomainName(this.txtDomainName.Text) != null) { ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script>alert('域名存在');</script>"); return; } LiveSupport.BLL.NewWebSite nwst = new LiveSupport.BLL.NewWebSite(); LiveSupport.BLL.Banner bnr = new LiveSupport.BLL.Banner(); bnr.State = LiveSupport.BLL.WebSiteManager.WebSite_Default; bnr.Offline = "offline0.JPG"; bnr.Online = "online0.JPG"; LiveSupport.BLL.Invite ivt = new LiveSupport.BLL.Invite(); ivt.State = LiveSupport.BLL.WebSiteManager.WebSite_Default; ivt.Bgimg = "invite_bg0.gif"; ivt.Noimg = "btn_no0.jpg"; ivt.Okimg = "btn_ok0.jpg"; LiveSupport.BLL.ChatPage cpg = new LiveSupport.BLL.ChatPage(); cpg.State = LiveSupport.BLL.WebSiteManager.WebSite_Default; cpg.ChatPageBGImg = "chat_bg0.gif"; cpg.ChatPageRightImg = "right_column_0.jpg"; cpg.LeavePageTopImg = "topmove1.gif"; nwst.banners = bnr; nwst.invites = ivt; nwst.chatpage = cpg; nwst.accountId = oepr.Account.AccountId; nwst.icoLocation = "0"; nwst.domainName = this.txtDomainName.Text; if (WebSiteManager.AddNewWebSite(nwst)) { Response.Redirect("GetCode.aspx?domain=" + this.txtDomainName.Text); } } else { Response.Redirect("../Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { AddDefaultStyle(); if (!IsPostBack) { if (Session["User"] != null) { oper = (Operator)Session["User"]; List <WebSite> list = WebSiteManager.GetAllWebSiteByRegisterId(oper.Account.AccountId); int selectIndex = 0; if (Request.QueryString["domain"] != null) { for (int i = 0; i < list.Count; i++) { if (list[i].DomainName == Request.QueryString["domain"].ToString()) { selectIndex = i; break; } } } this.drpDomainName.DataSource = list; this.drpDomainName.DataTextField = "DomainName"; this.drpDomainName.DataValueField = "DomainName"; this.drpDomainName.DataBind(); this.drpDomainName.SelectedIndex = selectIndex; this.drpDomainName.SelectedValue = list[selectIndex].DomainName; AddIcoLocation(list[selectIndex].IcoLocation); //位置 AddBannerStyle(list[selectIndex].IconStyle); // 图片 AddInviteStyle(list[selectIndex].InviteStyle); //主动邀请 AddChatStyle(list[selectIndex].ChatStyle); //聊天页面 } else { Response.Redirect("../Login.aspx?redirect=" + HttpContext.Current.Request.Url.PathAndQuery); } } }
protected void OnStartGameClick(object sender, EventArgs e) { if (isPlayerHostingOrJoinedGame(((DTO_ACCOUNT)Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]).players[PlayerList.SelectedIndex].Id)) { GeneralErrorStartGame.ForeColor = Color.Red; GeneralErrorStartGame.Text = "You Allready registared to game"; return; } try { DTO_ACCOUNT loggedInAccount = (DTO_ACCOUNT)(Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]); DTO_Player hostGamePlayer = loggedInAccount.players[PlayerList.SelectedIndex]; DTO_GamePlay game = new DTO_GamePlay { gameName = GameNameTB.Text, hostPlayerID = hostGamePlayer.Id, createDate = DateTime.Now.ToLocalTime() }; int gameKey = WebSiteManager.AddGame(game); // load the wating games from db and bind to girdview table loadWatingGames(); // first time page loades we color the tabel for player at index 0 ColorGamesTableRows(PlayerList2.SelectedIndex); gamesGridViewPanel.Update(); GeneralErrorStartGame.ForeColor = Color.Green; GeneralErrorStartGame.Text = "Game successfully registared, Key : " + gameKey; } catch (WebException ex) { using (WebResponse response = ex.Response) { var httpResponse = (HttpWebResponse)response; using (Stream data = response.GetResponseStream()) { StreamReader sr = new StreamReader(data); } } } }
private void HideColumns() { //hide columns wich user shouldent see,used for internal logic int colIndex = WebSiteManager.GetColumnIndexByName(tableGV, "type"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref tableGV, colIndex); } colIndex = WebSiteManager.GetColumnIndexByName(tableGV, "hostPlayerAccountEmail"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref tableGV, colIndex); } colIndex = WebSiteManager.GetColumnIndexByName(tableGV, "isDeleted"); if (colIndex != -1) { WebSiteManager.hideColumnByIndex(ref tableGV, colIndex); } }
protected void OnSaveClick(object sender, EventArgs e) { DTO_ACCOUNT loggedInAccount = (DTO_ACCOUNT)Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION]; List <DTO_Player> players = (List <DTO_Player>)Session["AllAccountPlayers"]; if (players.Count() == 0) { ErrorMessage.Text = "You Must leav at least one player,please refresh the page and start over"; return; } string oldPassword = WebSiteManager.CreateHash(OldPassword.Text, WebSiteManager.PASSWORD_HASH_SALT); if (IsValid && oldPassword.Equals(loggedInAccount.PASSWORD)) { loggedInAccount.EMAIL = Email.Text; loggedInAccount.PASSWORD = WebSiteManager.CreateHash(NewPassword.Text, WebSiteManager.PASSWORD_HASH_SALT); loggedInAccount.NAME = nickname.Text; Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] = loggedInAccount; WebSiteManager.UpdateAccount(new DTO_ACCOUNT { EMAIL = loggedInAccount.EMAIL, NAME = loggedInAccount.NAME, PASSWORD = loggedInAccount.PASSWORD }); // Update cockie with new password if changed // Create the cookie and set its value to the username and a hash of the logged in account HttpCookie cookie = new HttpCookie(WebSiteManager.REMEMBER_LOGIN_COOCKIE); cookie.Value = loggedInAccount.EMAIL + "," + loggedInAccount.PASSWORD; Response.Cookies.Add(cookie); WebSiteManager.RemovePlayers(((List <int>)Session[WebSiteManager.PLAYERS_4_DELETE_SESSION])); WebSiteManager.RemoveGames(((List <int>)Session[WebSiteManager.GAMES_4_DELETE_SESSION])); } else { ErrorMessage.Text = "Old Password not match"; } }
protected void Page_Init(object sender, EventArgs e) { // check if remmber me cockie is set, if is set get logged in account if (Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] == null && Request.Cookies[WebSiteManager.REMEMBER_LOGIN_COOCKIE] != null && Request.Cookies[WebSiteManager.REMEMBER_LOGIN_COOCKIE].Value.Length > 0) { var accountLoginInfo = Request.Cookies[WebSiteManager.REMEMBER_LOGIN_COOCKIE].Value; string[] values = accountLoginInfo.Split(','); // Retrieve the username and hash from the split values. string email = values[0]; string password = values[1]; // get logged in account from db DTO_ACCOUNT loggedInAccount = WebSiteManager.Login(email, password); // get logged in account players from db DTO_Player[] players = WebSiteManager.GetPlayers(email); loggedInAccount.players = players; // save logged in account to current session Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] = loggedInAccount; } SetLoggedInBar(); }
protected void LogIn(object sender, EventArgs e) { // if (IsPostBack && Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] != null) return; if (IsValid) { try { // first of all check if email exist if (!WebSiteManager.IsEmailExist(Email.Text)) { FailureText.Text = "Email not exist"; ErrorMessage.Visible = true; return; } else { // generate hash from password for comparing password in db string passwordhashed = WebSiteManager.CreateHash(Password.Text, WebSiteManager.PASSWORD_HASH_SALT); DTO_ACCOUNT loggedInAccount = WebSiteManager.Login(Email.Text, passwordhashed); if (loggedInAccount != null) { DTO_Player[] players = WebSiteManager.GetPlayers(Email.Text); loggedInAccount.players = players; // is remmber me if (RememberMe.Checked) { // Create the cookie and set its value to the username and a hash of the logged in account HttpCookie cookie = new HttpCookie(WebSiteManager.REMEMBER_LOGIN_COOCKIE); cookie.Value = loggedInAccount.EMAIL + "," + loggedInAccount.PASSWORD; Response.Cookies.Add(cookie); } Session[WebSiteManager.LOGGEDIN_ACCOUNT_SESSION] = loggedInAccount; Server.Transfer("../Default.aspx", true); } else { FailureText.Text = "Wrong Login Information"; ErrorMessage.Visible = true; } } } catch (WebException ex) { using (WebResponse response = ex.Response) { var httpResponse = (HttpWebResponse)response; using (Stream data = response.GetResponseStream()) { StreamReader sr = new StreamReader(data); FailureText.Text = sr.ReadToEnd(); ErrorMessage.Visible = true; } } } } }
protected void OnClickShowAllPlayersInformation(object sender, EventArgs e) { DTO_Player[] players = WebSiteManager.GetAllPlayers(); Session["tableData"] = players; }
protected void OnClickGetAllGames(object sender, EventArgs e) { DTO_GamePlay[] games = WebSiteManager.GetAllGames(); Session["tableData"] = games; }
protected void OnClickGetPlayerNGames(object sender, EventArgs e) { List <DTO_PLAYER_GAMES> playerNGames = WebSiteManager.GetForEachPlayerNGames(); Session["tableData"] = playerNGames; }