示例#1
0
        private async Task RefreshItaList()
        {
            var client = new My2chClient();

            try
            {
                var categories = await client.GetItaList();

                var store   = new StoreToFiles();
                var changed = await store.AddOrUpdateCategories(categories);

                if (changed.Count > 0)
                {
                    string changedText = "";
                    foreach (var ita in changed)
                    {
                        changedText += (ita.Name + ", ");
                    }
                    var dialog = new MessageDialog(changedText, "以下の板のURLが変更されました。");
                    await dialog.ShowAsync();
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message, "板一覧の取得中にエラーが発生しました。");
                await dialog.ShowAsync();
            }
        }
示例#2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.NavigationMode != NavigationMode.Back)
            {
                viewModel = new ItaListPageViewModel(MainFlip);
                var categoryFlip = new CategoryFlipModel(MainFlip);
                viewModel.FlipList.Add(categoryFlip);

                var store      = new StoreToFiles();
                var categories = await store.LoadCategories();

                var list = new ObservableCollection <Category>();
                if (categories == null || categories.Count == 0)
                {
                    var client = new My2chClient();
                    try
                    {
                        var getcategory = await client.GetItaList();

                        await store.AddCategories(getcategory);
                    }
                    catch (Exception ex)
                    {
                        var message = new MessageDialog("板一覧を取得するため、インターネットに接続できる状態で起動してください。", "初回起動ですか");
                        await message.ShowAsync();

                        return;
                    }
                }

                foreach (var category in categories)
                {
                    list.Add(category);
                }
                categoryFlip.CategoryList = list;

                MainGrid.DataContext = viewModel;
            }
        }