Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack && !IsCallback)
     {
         service = new BJServiceRef.ServiceClient(new InstanceContext(new emptyCallback()),"HttpBinding");
     }
     if (Session["user"] == null)
         Server.Transfer("~/Default.aspx");
     currentUser = (UserWcf)Session["user"];
     if (!Page.IsCallback && !Page.IsPostBack)
     {
         selectedUser = currentUser;
         if (currentUser.isAdmin)
         {
             users = service.getUsers();
             rbl_users.DataSource = users;
             rbl_users.DataTextField = "Username";
             rbl_users.DataValueField = "Username";
             rbl_users.DataBind();
             Session["userlist"] = users;
         }
         populateFields();
     }
     if (Page.IsPostBack)
     {
         txt_username.Text = selectedUser.Username;
         selectedUser.money = int.Parse(txt_money.Text);
         selectedUser.numOfGames = int.Parse(txt_num_of_games.Text);
         selectedUser.isAdmin = chk_admin.Checked;
         
     }
     
     
     
 }
Ejemplo n.º 2
0
 public GameScreen(UserWcf me, String IP)
 {
     InitializeComponent();
     this.me = me;
     Connect(IP);
     myCards = new List<Card>();
     dealerCards = new List<Card>();
     service = new ServiceClient(new InstanceContext(new emptyCallback()), "HttpBinding");
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Function for using in a delegate for the Threaded login function with the callback
 /// required since the thread of the service cannot directly update the UI thread
 /// </summary>
 /// <param name="user"></param>
 public void loginCallback(UserWcf user)
 {
     me = user;
     if (me == null)
     {
         this.Invoke(rejectDelegate);
     }
     else
     {
         this.Invoke(continueDelegate);
     }
 }
Ejemplo n.º 4
0
 public GameChooser(UserWcf user)
 {
     InitializeComponent();
     service = new ServiceClient(new InstanceContext(this),"HttpBinding");
     me = user;
     GameWcf[] list = service.GetGames();
     if (list.Count<GameWcf>() != 0)
     {
         games.AddRange(list);
     }
     lstb_games.DataSource = games;
     lstb_games.DisplayMember = "IP";
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Starting Login with The wcf service using the data from the user
 /// </summary>
 private void login()
 {
     string username = txt_username.Text;
     string password = txt_password.Text;
     //new Thread( () => service.login(username,password)).Start(); // seems there is some problem with the message being lost between the threads
     btn_login.Enabled = false;
     me = service.loginWeb(username, password);
     if (me == null)
         rejected();
     else
         accepted();
     
 }
Ejemplo n.º 6
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     UserWcf u = service.getUser(txt_username.Text);
     if (u == null)
     {
         u = new UserWcf();
         u.Username = txt_username.Text;
         service.addUser(u, txt_password.Attributes["value"]);
         Response.Redirect("~/Default.aspx");
     }
     else
     {
         lbl_warning.Text = "User already exsits";
     }
 }
Ejemplo n.º 7
0
        public void loginCallback(UserWcf user)
        {

        }
Ejemplo n.º 8
0
 protected void submit_Click(object sender, EventArgs e)
 {
     //basicly there is no real check here i simply send an update request to the webservice
     UserWcf u = new UserWcf();
     u = new UserWcf();
     u.Username = txt_username.Text;
     u.isAdmin = chk_admin.Checked;
     // again not testing of values i can put here a regex but too tired or use tryparse;
     u.money = int.Parse(txt_money.Text);
     u.numOfGames = int.Parse(txt_num_of_games.Text);
     u.ID = selectedUser.ID;
     if (service.updateUser(u))
         notification.Text = "Updated user " + u.Username;
     users = service.getUsers();
     Session["userlist"] = users;
     rbl_users.DataBind();
 }
Ejemplo n.º 9
0
 protected void rbl_users_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (((RadioButtonList)sender).SelectedValue != selectedUser.Username)
     {
         notification.Text = "";
         if (Session["userlist"] != null)
         {
             users = (UserWcf[])Session["userlist"];
             selectedUser = users.Single<UserWcf>(x => x.Username == rbl_users.SelectedValue);
             populateFields();
         }
     }
 }