Exemplo n.º 1
0
        private async void ImportData_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker picker = new FileOpenPicker
            {
                SuggestedStartLocation = PickerLocationId.MusicLibrary
            };

            picker.FileTypeFilter.Add(".json");
            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                MainPage.Instance.Loader.ShowIndeterminant("ProcessRequest");
                try
                {
                    string json = await FileIO.ReadTextAsync(file);

                    Settings settings   = JsonFileHelper.Convert <Settings>(json);
                    bool     successful = await UpdateMusicLibrary();

                    MainPage.Instance.Loader.Hide();
                    MainPage.Instance.ShowLocalizedNotification(successful ? "DataImported" : "ImportDataCancelled");
                }
                catch (Exception ex)
                {
                    MainPage.Instance.Loader.Hide();
                    MainPage.Instance.ShowLocalizedNotification("ImportDataFailed" + ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        public static async Task Init()
        {
            if (AlbumInfoList != null)
            {
                return;
            }
            var albums = JsonFileHelper.Convert <List <AlbumInfo> >(await JsonFileHelper.ReadAsync(JsonFilename));

            if (albums == null)
            {
                AlbumInfoList = new List <AlbumInfo>();
            }
            else
            {
                AlbumInfoList = albums;
            }
        }
Exemplo n.º 3
0
 public static async Task Init()
 {
     Log = JsonFileHelper.Convert <UpdateLog>(await JsonFileHelper.ReadAsync(JsonFileName)) ?? new UpdateLog();
 }