コード例 #1
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)
        {
            navigationParameter = (Category)e.NavigationParameter;
            // TODO: Assign a collection of bindable groups to this.DefaultViewModel["Groups"]
            // Allow saved page state to override the initial item to display


            string FileData = await FileManagement.ReadFile("MissingPeople.json");

            string ResultJson = "[" + FileData + "]";

            List <MissingPerson> Mis = JsonData.MissingPeopleList("el", ResultJson, navigationParameter).OrderByDescending(x => x.DateMissing).ToList <MissingPerson>();

            if (Mis.Count() != 0)
            {
                string SkippedItemsString = AppStorage.SkippedItems.Get();

                String[] Skipped = SkippedItemsString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                if (Skipped.Count() != 0)
                {
                    foreach (var item in Skipped)
                    {
                        Int32 Intitem       = Convert.ToInt32(item);
                        var   stuffToRemove = Mis.SingleOrDefault(s => s.ID == Intitem);
                        if (stuffToRemove != null)
                        {
                            Mis.Remove(stuffToRemove);
                        }
                    }
                }

                oc = new ObservableCollection <MissingPerson>(Mis);

                itemsViewSource.Source = oc;
            }

            else
            {
                itemGridView.Visibility = Visibility.Collapsed;
                itemsViewSource.Source  = oc;

                txt.Width         = 400;
                txt.Height        = 400;
                txt.Foreground    = new SolidColorBrush(Colors.White);
                txt.TextWrapping  = TextWrapping.WrapWholeWords;
                txt.FontSize      = 26;
                txt.TextAlignment = TextAlignment.Center;

                if (Connectivity.Connectivity.ConnectedToTheInternet())
                {
                    txt.Text = "Δεν υπάρχουν αποθηκευμένες εξαφανίσεις. Πατήστε ανανέωση για να ενημερώσετε τα δεδομένα της εφαρμογής";
                }
                else
                {
                    txt.Text = "Δεν υπάρχουν αποθηκευμένες εξαφανίσεις. Συνδεθείτε στο διαδίκτυο και πατήστε ανανέωση για να ενημερώσετε τα δεδομένα της εφαρμογής";
                }

                Grid.SetRow(txt, 1);
                Grid.SetColumn(txt, 1);
                txt.Visibility = Visibility.Visible;
            }
        }
コード例 #2
0
        // Include code to be executed when the system has transitioned from the splash screen to the extended splash screen (application's first view).
        async void DismissedEventHandler(SplashScreen sender, object e)
        {
            dismissed = true;

            //AppStorage.ModificationDate.RemoveValue();
            //FileManagement.DeleteFile("MissingPeople.json");

            if (WindowsStore.Connectivity.Connectivity.ConnectedToTheInternet())
            {
                string UniqueID = AppStorage.UniqueAppID.SetValue(Guid.NewGuid().ToString());

                string ModificationDate = AppStorage.ModificationDate.GetValue();

                string result = "";

                try
                {
                    IMissingsService ms = new MissingsService(AzureUrl.GetUrl());

                    if (ModificationDate != "")
                    {
                        result = await ms.GetLatestMissings(ModificationDate);
                    }
                    else
                    {
                        result = await ms.GetLatestMissings();
                    }

                    var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

                    ReceivedInfo receivedInfo = JsonData.IncomingJson(result);

                    AppStorage.ModificationDate.SaveValue(receivedInfo.timestamp);


                    if (!receivedInfo.missings.Equals(null) && receivedInfo.missingsString != "")
                    {
                        FileManagement.SaveFile("MissingPeople.json", receivedInfo.missingsString);

                        List <string> ImagesList = receivedInfo.ImagesList;

                        if (ImagesList.Count() != 0)
                        {
                            foreach (var imageName in ImagesList)
                            {
                                string[] number = imageName.Split('.');
                                if (Convert.ToInt32(number[0]) >= 0 && Convert.ToInt32(number[0]) <= 37)
                                {
                                    FileManagement.SaveImageAsync(imageName);
                                }
                            }
                        }
                    }
                    if (receivedInfo.found.Count() != 0)
                    {
                        AppStorage.SkippedItems.Merge(receivedInfo.found);
                    }
                }
                catch (Exception)
                {
                }
            }
            else if (WindowsStore.Connectivity.Connectivity.ConnectedToTheInternet() == false)
            {
                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

                localSettings.Values["Popup"] = "true";
            }

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                rootFrame.Navigate(typeof(MainPage));
                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            });
        }
コード例 #3
0
        private async void RefreshBar_Click(object sender, RoutedEventArgs e)
        {
            if (WindowsStore.Connectivity.Connectivity.ConnectedToTheInternet())
            {
                string UniqueID         = AppStorage.UniqueAppID.SetValue(Guid.NewGuid().ToString());
                string ModificationDate = AppStorage.ModificationDate.GetValue();

                string result = "";

                try
                {
                    IMissingsService ms = new MissingsService(AzureUrl.GetUrl());

                    if (ModificationDate != "")
                    {
                        result = await ms.GetLatestMissings(ModificationDate);

                        //result = await ms.GetLatestMissings("2043");
                    }
                    else
                    {
                        result = await ms.GetLatestMissings();
                    }


                    ReceivedInfo receivedInfo = JsonData.IncomingJson(result);

                    AppStorage.ModificationDate.SaveValue(receivedInfo.timestamp);

                    if (!receivedInfo.missings.Equals(null) && receivedInfo.missingsString != "")
                    {
                        FileManagement.SaveFile("MissingPeople.json", receivedInfo.missingsString);

                        List <string> ImagesList = receivedInfo.ImagesList;

                        if (ImagesList.Count() != 0)
                        {
                            foreach (var imageName in ImagesList)
                            {
                                string[] number = imageName.Split('.');
                                if (Convert.ToInt32(number[0]) >= 0 && Convert.ToInt32(number[0]) <= 37)
                                {
                                    FileManagement.SaveImageAsync(imageName);
                                }
                            }
                        }
                    }
                    if (receivedInfo.found.Count() != 0)
                    {
                        AppStorage.SkippedItems.Merge(receivedInfo.found);
                    }

                    string ResultJson = "[" + receivedInfo.missingsString + "]";

                    List <MissingPerson> Mis = new List <MissingPerson>();

                    Mis = JsonData.MissingPeopleList("el", ResultJson, navigationParameter).OrderByDescending(x => x.DateMissing).ToList <MissingPerson>();


                    if (Mis.Count() != 0)
                    {
                        txt.Visibility          = Visibility.Collapsed;
                        itemGridView.Visibility = Visibility.Visible;
                        string SkippedItemsString = AppStorage.SkippedItems.Get();

                        String[] Skipped = SkippedItemsString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                        if (Skipped.Count() != 0)
                        {
                            foreach (var item in Skipped)
                            {
                                Int32 Intitem       = Convert.ToInt32(item);
                                var   stuffToRemove = Mis.SingleOrDefault(s => s.ID == Intitem);
                                if (stuffToRemove != null)
                                {
                                    Mis.Remove(stuffToRemove);
                                }
                            }
                        }
                        int i = 0;
                        foreach (MissingPerson item in Mis)
                        {
                            oc.Insert(i, item);
                            i++;
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            else if (WindowsStore.Connectivity.Connectivity.ConnectedToTheInternet() == false)
            {
                MessageDialog dialog = new MessageDialog("Δεν υπάρχει ενεργή σύνδεση στο διαδίκτυο.", "Σφάλμα σύνδεσης");
                await dialog.ShowAsync();
            }
        }
コード例 #4
0
        private async void RefreshBar_Click(object sender, RoutedEventArgs e)
        {
            if (WindowsStore.Connectivity.Connectivity.ConnectedToTheInternet() == true)
            {
                string UniqueID         = AppStorage.UniqueAppID.SetValue(Guid.NewGuid().ToString());
                string ModificationDate = AppStorage.ModificationDate.GetValue();

                string result = "";

                try
                {
                    IMissingsService ms = new MissingsService(AzureUrl.GetUrl());

                    if (ModificationDate != "")
                    {
                        result = await ms.GetLatestMissings(ModificationDate);
                    }
                    else
                    {
                        result = await ms.GetLatestMissings();
                    }


                    ReceivedInfo receivedInfo = JsonData.IncomingJson(result);

                    AppStorage.ModificationDate.SaveValue(receivedInfo.timestamp);

                    if (!receivedInfo.missings.Equals(null) && receivedInfo.missingsString != "")
                    {
                        FileManagement.SaveFile("MissingPeople.json", receivedInfo.missingsString);

                        List <string> ImagesList = receivedInfo.ImagesList;

                        if (ImagesList.Count() != 0)
                        {
                            foreach (var imageName in ImagesList)
                            {
                                string[] number = imageName.Split('.');
                                if (Convert.ToInt32(number[0]) >= 0 && Convert.ToInt32(number[0]) <= 37)
                                {
                                    FileManagement.SaveImageAsync(imageName);
                                }
                            }
                        }
                    }
                    if (receivedInfo.found.Count() != 0)
                    {
                        AppStorage.SkippedItems.Merge(receivedInfo.found);
                    }
                    EnableLiveTile.CreateLiveTile.ShowliveTile();
                }
                catch (Exception)
                {
                }
            }
            else if (WindowsStore.Connectivity.Connectivity.ConnectedToTheInternet() == false)
            {
                MessageDialog dialog = new MessageDialog("Δεν υπάρχει ενεργή σύνδεση στο διαδίκτυο.", "Σφάλμα σύνδεσης");
                await dialog.ShowAsync();
            }
        }