Пример #1
0
        private async void RefreshNewsFeed()
        {
            if (_isUpdaterRunning == false)
            { 
                _isUpdaterRunning = true;
                var uapi = new UserApi("5940771a096a5bf6e36f530769a6ba2f");
                try
                {
                    _newsFeed = await uapi.ApiNews(TempAppData.CurrentTown.id);
                    foreach (var town in _newsFeed)
                    {
                        town.bodyClean = Regex.Replace(town.body, "<[^<]+?>", String.Empty);
                        town.bodyCleanShort = (town.bodyClean.Substring(1, 200) + " ...");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error accessing LocalD services, we can not fetch news at this time", ":(",
                                    MessageBoxButton.OK);
                }
                _isUpdaterRunning = false;

                NewsFeedBox.ItemsSource = _newsFeed;
            }
        }
Пример #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            status.Text = "Getting Geo Location";
            Description.Text = "";
            var ugeo = new UserGeo();
            try
            {
                FilingCabinet.UserPos = await ugeo.GetGeoposition();
            }
            catch (Exception ex)
            {

            }

            status.Text = "Updating Towns";
            Description.Text = "";
            var uapi = new UserApi("5940771a096a5bf6e36f530769a6ba2f");
            try
            {
                FilingCabinet.TownsList = await uapi.ApiTown();
                NavigationService.Navigate(new Uri("/Pages/UserLogin.xaml", UriKind.Relative));

            }
            catch (Exception ex)
            {
                status.Text = ":(";
                Description.Text = ("Error accessing the LocalD services\nPlease check your network connection");
            }

        }
Пример #3
0
        private async void UserToSubmit_OnClick(object sender, RoutedEventArgs e)
        {
            UserHasInputControl(false);

            var uapi = new UserApi("5940771a096a5bf6e36f530769a6ba2f");

            //todo REGEX
            if (string.IsNullOrWhiteSpace(UserEmail.Text) ||
                string.IsNullOrWhiteSpace(UserUsername.Text) ||
                string.IsNullOrWhiteSpace(UserPwd.Password) ||
                !(UserPwd.Password.Length > 3) ||
                !(UserUsername.Text.Length > 3) ||
                !(UserEmail.Text.Length > 6) ||
                !UserEmail.Text.Contains("@") ||
                !UserEmail.Text.Contains("."))
            {
                MessageBox.Show(
                    "One or more of he fields contains an invalid entry.\nPasswords must be between 3 and 20 alphanumeric characters",
                    ":(", MessageBoxButton.OK);
            }
            else
            {
                try
                {
                    var y = await uapi.ApiReg(UserPwd.Password, UserUsername.Text, UserEmail.Text, FilingCabinet.TownsList.Find(i => i.name == (UserTown.SelectedItem.ToString())).id);

                    if (y.success.Contains("Account created") || y.success.Contains("Account Created") || y.success.Contains("account created"))
                    {
                        MessageBox.Show("Registration successful. Account Created", ":)", MessageBoxButton.OK);

                        NavigationService.Navigate(new Uri("/Pages/UserLogin.xaml", UriKind.Relative));
                    }
                    else
                    {
                        MessageBox.Show("Registration unsuccessful.\nComputer says: " + y.success, ":(", MessageBoxButton.OK);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("We could not sign you up at this time, please check details and try again.", ":(",
                                    MessageBoxButton.OK);
                }
            }
            UserHasInputControl(true);
        }
Пример #4
0
        private async void UserToLogin_OnClick(object sender, RoutedEventArgs e)
        {
            ProgressBar.Visibility = Visibility.Visible;
            UserHasInputControl(false);
            
            var uapi = new UserApi("5940771a096a5bf6e36f530769a6ba2f");

            if (string.IsNullOrEmpty(UserUsername.Text) || string.IsNullOrEmpty(UserPwd.Password))
            {
                ProgressBar.Visibility = Visibility.Collapsed;
                UserPwd.Password = "";
                MessageBox.Show(
                    "The credentials entered are either blank or not in a valid format. Try again.",
                    ":(", MessageBoxButton.OK);
            }
            else
            {
                try
                {
                    var y = await uapi.ApiLogin(UserPwd.Password, UserUsername.Text);
                    if (y.success.Contains("logged in") || y.success.Contains("Logged In"))
                    {
                        FilingCabinet.CurrentUserCredentials.Consumerkey = y.consumerkey;
                        FilingCabinet.CurrentUserCredentials.Consumersecret = y.consumersecret;
                        FilingCabinet.CurrentUserCredentials.UserTown = "514628d17fa6866d15000038"; //todo !DEBUG! NEEDS TO UPDATE

                        TempAppData.CurrentTown = FilingCabinet.TownsList.Find(i => i.id == (FilingCabinet.CurrentUserCredentials.UserTown));

                        NavigationService.Navigate(new Uri("/Pages/MainHub.xaml", UriKind.Relative));
                    }
                    else
                    {
                        MessageBox.Show("Login unsuccessful.\nComputer says: " + y.success, ":(", MessageBoxButton.OK);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("We could not sign you in at this time, please check details and try again.", ":(",
                                    MessageBoxButton.OK);
                } 
            }
           UserHasInputControl(true);
        }