private async Task UpdateSubscriptionStatusAsync(TvDbSeries series) { var subs = await subscribed.Value; var isSubscribed = subs.Any(s => series.Id == s.Id); series.IsSubscribed = isSubscribed; }
public void Save(TvDbSeries series) { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { var directory = string.Format(@"{0}\{1}", SubscriptionsFolderName, series.Id); using (new MutexLock(directory)) { if (!storage.DirectoryExists(directory)) { storage.CreateDirectory(directory); } } var filename = string.Format(@"{0}\data.xml", directory); using (new MutexLock(filename)) { using (var file = new IsolatedStorageFileStream(filename, FileMode.Create, storage)) { try { Serializer.Serialize(file, series); } catch (Exception e) { Debug.WriteLine(e.Message); OnStorageFailure( new StorageFailureEventArgs( "Failed to save data to local storage. Any modifications or updates will be lost, sorry! :(")); } } } } }
public async Task SaveAsync(TvDbSeries series) { using (await ioLock.DisposableWaitAsync()) { await Task.Factory.StartNew(() => storageManager.Save(series)); } }
public async Task UnsubscribeAsync(TvDbSeries series) { using (await ioLock.DisposableWaitAsync()) { var subscriptions = await subscribed.Value; subscriptions.RemoveAllThatMatch(m => series.Id == m.Id); series.IsSubscribed = false; OnUnsubscribed(new SubscriptionChangedEventArgs(series)); await Task.Factory.StartNew(() => storageManager.Remove(series)); } }
public async Task SubscribeAsync(TvDbSeries series) { using (await ioLock.DisposableWaitAsync()) { var subscriptions = await subscribed.Value; subscriptions.Add(series); series.IsSubscribed = true; OnSubscribed(new SubscriptionChangedEventArgs(series)); await Task.Factory.StartNew(() => storageManager.Save(series)); } }
public void Remove(TvDbSeries series) { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { var filename = string.Format(@"{0}\{1}\data.xml", SubscriptionsFolderName, series.Id); using (new MutexLock(filename)) { if (!storage.FileExists(filename)) { return; } storage.DeleteFile(filename); } } }
private async Task UpdateSeriesIfNecessaryAsync(TvDbSeries series) { bool ownsTask = false; Task update = null; using (await ioLock.DisposableWaitAsync()) { if (updates.ContainsKey(series)) { update = updates[series]; } var needsUpdating = (series.Updated == null) || (DateTime.Now - series.Updated > TimeSpan.FromHours(3)); if (needsUpdating) { update = UpdateSeriesAsync(series); updates.Add(series, update); ownsTask = true; } } if (update != null) { await update; if (ownsTask) { using (await ioLock.DisposableWaitAsync()) { updates.Remove(series); if (series.IsSubscribed) { storageManager.Save(series); } } } } }
public void SaveSeen(TvDbSeries series) { Save(series); }
public async Task UnmarkSeenAsync(TvDbSeries series, TvDbSeriesEpisode episode) { episode.IsSeen = false; await SaveAsync(series); }
public async Task MarkSeenAsync(TvDbSeries series, TvDbSeriesEpisode episode) { episode.IsSeen = true; await SaveAsync(series); }
private Task UpdateSeriesAsync(TvDbSeries series) { return(Task.WhenAll(new[] { tvDb.UpdateData(series), UpdateSubscriptionStatusAsync(series) })); }
public SubscriptionChangedEventArgs(TvDbSeries series) { Series = series; }
public SeriesDisplayWindow(TvDbSeries series) { this.series = series; InitializeComponent(); this.searchResultsListBox.ItemsSource = new List<TvDbSeries> { series }; }