示例#1
0
        protected override async Task LoadSavedItemAsync()
        {
            if (!_isLoaded)
            {
                var categories = await FollowHelper.GetFollowedCategories();

                if (categories != null && categories.Count > 0)
                {
                    foreach (var cate in categories)
                    {
                        this.Items.Add(new FavoriteItem <Category> {
                            HasNew = false, Item = cate
                        });
                    }
                }

                _isLoaded = true;
            }
        }
示例#2
0
        private async void Init()
        {
            await BackgroundTaskHelper.Register();

#if WINDOWS_APP
            Logger.LogAgent.GetInstance().Register("MS-UAP", "CNBlogs-Win8.1");
#endif
#if WINDOWS_PHONE_APP
            Logger.LogAgent.GetInstance().Register("MS-UAP", "CNBlogs-WP8.1");

#if DEBUG
            try
            {
                channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

                channel.PushNotificationReceived += OnPushNotification;

                // check if this uri changed since last time, update to server if yes

                if (!string.Equals(CNBlogSettings.Instance.NotificationUri, channel.Uri))
                {
                    CNBlogSettings.Instance.NotificationUri = channel.Uri;

                    var server = "http://172.22.117.114/wns/api/uri";

                    // get fav authors
                    var authors = await FollowHelper.GetFollowedAuthors();

                    var parameters = new List <KeyValuePair <string, string> >();

                    parameters.Add(new KeyValuePair <string, string>("uuid", Functions.GetUniqueDeviceId()));
                    parameters.Add(new KeyValuePair <string, string>("uri", Uri.EscapeUriString(channel.Uri)));

                    foreach (var author in authors)
                    {
                        var blogApp = !string.IsNullOrWhiteSpace(author.BlogApp) ? author.BlogApp : Functions.ParseBlogAppFromURL(author.Uri);

                        parameters.Add(new KeyValuePair <string, string>("favAuthors", blogApp));
                    }

                    var categories = await FollowHelper.GetFollowedCategories();

                    foreach (var category in categories)
                    {
                        parameters.Add(new KeyValuePair <string, string>("favCategories", category.Href));
                    }

                    var content = new HttpFormUrlEncodedContent(parameters);
                    var request = new HttpRequestMessage(HttpMethod.Post, new Uri(server));
                    request.Content = content;

                    var client = new HttpClient();

                    var response = await client.SendRequestAsync(request);
                }
            }
            catch (Exception ex)
            {
            }
#endif
#endif
        }