Example #1
0
        private async void Logout_Click(object sender, RoutedEventArgs e)
        {
            LoginHelper.MobileServicesLogout();
            this.ClearUI();
            await LoginHelper.MobileServiceAuthenticate(true);

            this.ProgressBar.Visibility = Visibility.Visible;
            LocalStoreHelper.SyncAndRefreshUI();
        }
Example #2
0
        /// <summary>
        /// Saves the selected preferences value into local storage
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            //Hide Error Messages
            this.ShowErrorMessage(string.Empty, false);

            this.ShowProgressBar(true);

            if (this.StorageModeToggleSwitch.IsOn)
            {
                string errorMessage = await this.Validate();

                ApplicationData.Current.LocalSettings.Values[Constants.Settings.StorageMode] = this.StorageModeToggleSwitch.OnContent;

                if (!string.IsNullOrEmpty(errorMessage))
                {
                    this.ShowErrorMessage(errorMessage, true);
                    this.ShowProgressBar(false);
                    return;
                }

                var previousMobileServiceUrl = ApplicationData.Current.LocalSettings.Values[Constants.Settings.MobileServiceUrl].ToString();
                var previousMobileServiceKey = ApplicationData.Current.LocalSettings.Values[Constants.Settings.MobileServiceAccessKey].ToString();
                ApplicationData.Current.LocalSettings.Values[Constants.Settings.MobileServiceUrl]       = this.MobileServiceURL.Text;
                ApplicationData.Current.LocalSettings.Values[Constants.Settings.MobileServiceAccessKey] = this.MobileServiceAccessKey.Text;
                ApplicationData.Current.LocalSettings.Values[Constants.Settings.ImageBlobLocationUrl]   = this.ImageBlobLocationURL.Text;

                if (!previousMobileServiceUrl.Equals(this.MobileServiceURL.Text, StringComparison.OrdinalIgnoreCase) ||
                    !previousMobileServiceKey.Equals(this.MobileServiceAccessKey.Text, StringComparison.OrdinalIgnoreCase))
                {
                    // If we changed the mobile service, we need to refresh the data
                    LocalStoreHelper.SyncAndRefreshUI();
                }
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values[Constants.Settings.StorageMode] = this.StorageModeToggleSwitch.OffContent;
            }

            this.ShowStatusMessage(string.Empty, false);
            this.ShowProgressBar(false);

            this.Hide();
        }
Example #3
0
 private void RefreshJobs_Click(object sender, RoutedEventArgs e)
 {
     LocalStoreHelper.SyncAndRefreshUI();
 }
Example #4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            this.ProgressBar.Visibility = Visibility.Visible;

            if (ApplicationData.Current.LocalSettings.Values[Constants.Settings.StorageMode].ToString() == Constants.Offline)
            {
                if (ConnectionHelper.IsInternetConnectionAvailable())
                {
                    ApplicationData.Current.LocalSettings.Values[Constants.Settings.StorageMode] = Constants.Online;
                }
            }
            //Checking for internet connection in online mode.
            //If not available then showing pop-up and switching to offline mode.
            else if (ApplicationData.Current.LocalSettings.Values[Constants.Settings.StorageMode].ToString() == Constants.Online)
            {
                if (!ConnectionHelper.IsInternetConnectionAvailable())
                {
                    await ShowSwitchingToOfflineDialog();
                }
            }
            await Utilities.LoginHelper.MobileServiceAuthenticate();

            if (!AzureDataServices.MobileServiceClient.SyncContext.IsInitialized)
            {
                if (ApplicationData.Current.LocalSettings.Values[Constants.Settings.LoggedInUserId] != null)
                {
                    await LocalStoreHelper.InitializeLocalStore(ApplicationData.Current.LocalSettings.Values[Constants.Settings.LoggedInUserId].ToString());
                }
                else
                {
                    await LocalStoreHelper.InitializeLocalStore("dummyUser");
                }
            }
            await Utilities.PushHelper.RegisterForPush();

            // Fetch the groups of Job Cards and assign them as the items source for the gridview displaying all Jobs
            App app = Application.Current as App;
            await DataManager.JobDataSource.GetAllJobs();

            if (AzureDataServices.RefreshJobsListPage)
            {
                await DataManager.JobDataSource.GetAllJobs(true);

                AzureDataServices.RefreshJobsListPage = false;
            }

            ObservableCollection <JobGroup> allGroups = new ObservableCollection <JobGroup>(await DataManager.JobDataSource.GetJobGroupsAsync());

            this.DefaultViewModel["PendingJobs"]        = allGroups.Single(x => x.Title.Equals(Constants.PendingStatus)).Jobs;
            this.DefaultViewModel["PendingJobsCount"]   = (this.DefaultViewModel["PendingJobs"] as List <Job>).Count;
            this.DefaultViewModel["CompletedJobs"]      = allGroups.Single(x => x.Title.Equals(Constants.CompletedStatus)).Jobs;
            this.DefaultViewModel["CompletedJobsCount"] = (this.DefaultViewModel["CompletedJobs"] as List <Job>).Count;
            this.DefaultViewModel["CurrentJob"]         = allGroups.Single(x => x.Title.Equals(Constants.CurrentStatus)).Jobs;
            this.DefaultViewModel["CurrentJobCount"]    = (this.DefaultViewModel["CurrentJob"] as List <Job>).Count;
            this.DefaultViewModel["TotalJobsCount"]     = allGroups.Sum(x => x.Jobs.Count);
            this.DefaultViewModel["CurrentUser"]        = AzureDataServices.LoggedInUser;

            var zoomedOutItems = new List <Tuple <string, string> >
            {
                Tuple.Create("Quick Stats", string.Empty),
                Tuple.Create("In Progress", this.DefaultViewModel["CurrentJobCount"].ToString()),
                Tuple.Create("Not Started", this.DefaultViewModel["PendingJobsCount"].ToString()),
                Tuple.Create("Completed", this.DefaultViewModel["CompletedJobsCount"].ToString())
            };

            this.DefaultViewModel["ZoomedOutItems"] = zoomedOutItems;

            this.ProgressBar.Visibility = Visibility.Collapsed;

            // Check the window size and update the Visual State
            this.UpdateVisualState(Window.Current.Bounds.Width);
        }