コード例 #1
0
        private async void UpdateChat(string connecting)
        {
            try
            {
                EventViewModel data;

                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    data        = DataContext as EventViewModel;
                    data.Chat  += connecting + "\n";
                    DataContext = data;
                }).AsTask().Wait();
                //DataContext.Chat += connecting + "\n";

                while (true)
                {
                    string s = await rtc.ReadAsync();

                    if (s[0] == '1')
                    {
                        var args = s.Split(':');
                        if (args[1] == "queue_request")
                        {
                            queueAccept = args[2] + ":" + args[3];
                            Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                this.UserNameBlock.Text = args[2] + ": " + args[3] + " wants to join the queue.";
                                this.DisplayUserQueueInfoDialog();
                            }).AsTask().Wait();
                        }
                        else if (args[1] == "queue_add")
                        {
                            //string newUser = args[2];
                            var stuff = await client.GetUserAsync(args[2]);

                            Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                var tmp = DataContext as EventViewModel;
                                tmp.AddQueueMember(new QueueMember(args[3], stuff.Avatar));
                            }).AsTask().Wait();
                        }
                    }
                    else
                    {
                        Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            data        = DataContext as EventViewModel;
                            data.Chat  += s + "\n";
                            DataContext = data;
                        }).AsTask().Wait();
                    }
                }
            }
            catch (Exception e)
            { }
        }
コード例 #2
0
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            this.LoginButton.IsEnabled = false;
            Database_Service.SchedServiceClient client = new Database_Service.SchedServiceClient();
            string testString;

            if (s == "")
            {
                testString = await client.LoginCheckAsync(this.EmailTextBox.Text.Trim(), this.PasswordTextBox.Password.Trim());
            }
            else
            {
                testString = await client.LoginCheckAsync(this.EmailTextBox.Text.Trim(), s);
            }

            if (testString == "Login Successful")
            {
                var user = await client.GetUserAsync(this.EmailTextBox.Text.Trim());

                Models.User_Account account = new Models.User_Account()
                {
                    clientID    = user.ClientID,
                    username    = user.UserName,
                    avatarImage = user.Avatar,
                    firstName   = user.FirstName,
                    lastName    = user.LastName,
                    phoneNumber = user.Phone,
                    address     = user.Address,
                    email       = user.Email
                };
                Application.Current.Resources.Add("User", account);
                this.DisplaySuccessDialog();
            }
            else
            {
                this.ErrorMessage.Text     = Login_Page.ErrorMessageText;
                this.LoginButton.IsEnabled = true;
            }
        }