Пример #1
0
        private void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UserMobile m = new UserMobile();
                m.UserName = EmailAddress.Text;
                m.Password = Password.Text;
                progressIndicator.IsVisible = true;
                Task.Run(new Action(() =>
                    {
                        try
                        {
                            var user = UserMobileWP.Login(m);
                            if (user.IsLoggedIn)
                            {
                                user.LastMobileLoginDate = DateTime.UtcNow;
                                SqlFactory fact = new SqlFactory();
                                fact.DeleteProfile();
                                fact.InsertProfile(new SqlAccount(user));
                                var json = fact.GetNotificationSettings();
                                if (json != null)
                                {
                                    json.MemberId = user.MemberId.ToString();
                                    NotificationMobileJsonWP.SendNotificationId(json);
                                }
                                Dispatcher.BeginInvoke(delegate
                                {
                                    progressIndicator.IsVisible = false;
                                    NavigationService.Navigate(new Uri("/View/MyLeague/MyLeague.xaml", UriKind.Relative));

                                });
                            }
                            else
                            {
                                Dispatcher.BeginInvoke(delegate
                                {
                                    progressIndicator.IsVisible = false;
                                    warning.Text = "There was an error logging in, Please try again.";
                                });

                            }
                        }
                        catch (Exception exception)
                        {
                            ErrorHandler.Save(exception, MobileTypeEnum.WP8);
                        }
                        Dispatcher.BeginInvoke(delegate
                        {
                            progressIndicator.IsVisible = false;

                        });
                    }));
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.WP8);
            }
        }