void next2(LoginOutput result)
 {
     if (result != null)
         System.Diagnostics.Debug.WriteLine(result.status+" "+result.sid+" "+result.sid);
     else
         System.Diagnostics.Debug.WriteLine("Unable to connect to server");
 }
 void next2(LoginOutput result)
 {
     if (result != null)
     {
         System.Diagnostics.Debug.WriteLine(result.status + " " + result.sid + " " + result.sid);
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Unable to connect to server");
     }
 }
        private void loginCallback(LoginOutput output)
        {
            this.Dispatcher.BeginInvoke(delegate()
            {
                setControlEnabled(true);
                if (output.status == "ok")
                {
                    var servers = new ObservableCollection<Server>(from Server s in MDEDB.Servers where s.serverName == serverNameBox.Text select s);
                    Server server;
                    if (servers.Count() > 0)
                    {
                        //We are here right after registration. We should only add sid.
                        server = servers[0];
                        server.sid = output.sid;
                        MDEDB.SubmitChanges();
                        NavigationService.GoBack();
                    }
                    else
                    {
                        server = new Server();
                        MDEDB.Servers.InsertOnSubmit(server);
                        server.serverName = serverNameBox.Text;
                        server.address = serverAddressBox.Text;
                        server.login = loginBox.Text;
                        server.pass = passwordBox.Password;
                        server.sid = output.sid;

                        MDEDB.SubmitChanges();

                        string url = serverUrl + "/api/account/getdata/" + loginBox.Text + "/" + output.sid;
                        new HttpGetRequest<PersonalDataOutput>(url, personalDataCallback);

                        MessageBox.Show("Logged in on server.");
                        NavigationService.GoBack();
                    }
                }
                else
                {
                    MessageBox.Show("Unable to login on server:\n" + output.reason);
                }
            });
        }
        private void loginCallback(LoginOutput output)
        {
            this.Dispatcher.BeginInvoke(delegate()
            {
                if (output.status == "ok")
                {
                    server.sid = output.sid;
                    MDEDB.SubmitChanges();

                    MessageBox.Show("Logged in on server.");
                    NavigationService.GoBack();
                }
                else
                {
                    MessageBox.Show("Login or password incorrect.");
                }
            });
        }