public isPodcastInDB ( string subscriptionRssUrl ) : bool | ||
subscriptionRssUrl | string | |
리턴 | bool |
async private void wc_DownloadPodcastRSSCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null || e.Cancelled) { try { string foo = e.Result; } catch (WebException ex) { if (needsAuthentication(ex)) { if (MessageBox.Show("Subscribing to this podcast requires authentication. Do you want to give username and password to continue?", "Attention", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { SubscriptionManagerArgs authArgs = new SubscriptionManagerArgs(); authArgs.podcastFeedRSSUri = ex.Response.ResponseUri; OnPodcastChannelRequiresAuthentication(this, authArgs); return; } } } PodcastSubscriptionFailedWithMessage("Could not fetch the podcast feed."); return; } string podcastRss = e.Result; PodcastSubscriptionModel podcastModel = PodcastFactory.podcastModelFromRSS(podcastRss); if (podcastModel == null) { PodcastSubscriptionFailedWithMessage("Podcast feed is invalid."); return; } AddSubscriptionOptions options = e.UserState as AddSubscriptionOptions; string rssUrl = options.rssUrl; bool importingFromExternalService = options.isImportingFromExternalService; bool isPodcastInDB = false; using (var db = new PodcastSqlModel()) { isPodcastInDB = db.isPodcastInDB(rssUrl); } if (isPodcastInDB) { if (!importingFromExternalService) { PodcastSubscriptionFailedWithMessage("You have already subscribed to that podcast."); } if (importingFromExternalService) { m_activeExternalImportsCount--; if (m_activeExternalImportsCount <= 0) { if (OnExternalServiceImportFinished != null) { OnExternalServiceImportFinished(this, null); } } } return; } podcastModel.CachedPodcastRSSFeed = podcastRss; podcastModel.PodcastLogoLocalLocation = localLogoFileName(podcastModel); podcastModel.PodcastRSSUrl = rssUrl; if (String.IsNullOrEmpty(options.username) == false) { podcastModel.Username = options.username; } if (String.IsNullOrEmpty(options.password) == false) { podcastModel.Password = options.password; } using (var db = new PodcastSqlModel()) { db.addSubscription(podcastModel); } await podcastModel.fetchChannelLogo(); SubscriptionManagerArgs addArgs = new SubscriptionManagerArgs(); addArgs.subscription = podcastModel; addArgs.isImportingFromExternalService = importingFromExternalService; OnPodcastChannelAddFinished(this, addArgs); OnPodcastChannelAdded(podcastModel); }
async private void wc_DownloadPodcastRSSCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null || e.Cancelled) { try { string foo = e.Result; } catch (WebException ex) { if (needsAuthentication(ex)) { if (MessageBox.Show("Subscribing to this podcast requires authentication. Do you want to give username and password to continue?", "Attention", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { SubscriptionManagerArgs authArgs = new SubscriptionManagerArgs(); authArgs.podcastFeedRSSUri = ex.Response.ResponseUri; OnPodcastChannelRequiresAuthentication(this, authArgs); return; } } } PodcastSubscriptionFailedWithMessage("Could not fetch the podcast feed."); return; } string podcastRss = e.Result; PodcastSubscriptionModel podcastModel = PodcastFactory.podcastModelFromRSS(podcastRss); if (podcastModel == null) { PodcastSubscriptionFailedWithMessage("Podcast feed is invalid."); return; } AddSubscriptionOptions options = e.UserState as AddSubscriptionOptions; string rssUrl = options.rssUrl; bool importingFromExternalService = options.isImportingFromExternalService; bool isPodcastInDB = false; using (var db = new PodcastSqlModel()) { isPodcastInDB = db.isPodcastInDB(rssUrl); } if (isPodcastInDB) { if (!importingFromExternalService) { PodcastSubscriptionFailedWithMessage("You have already subscribed to that podcast."); } if (importingFromExternalService) { m_activeExternalImportsCount--; if (m_activeExternalImportsCount <= 0) { if (OnExternalServiceImportFinished != null) { OnExternalServiceImportFinished(this, null); } } } return; } podcastModel.CachedPodcastRSSFeed = podcastRss; podcastModel.PodcastLogoLocalLocation = localLogoFileName(podcastModel); podcastModel.PodcastRSSUrl = rssUrl; if (String.IsNullOrEmpty(options.username) == false) { podcastModel.Username = options.username; } if (String.IsNullOrEmpty(options.password) == false) { podcastModel.Password = options.password; } using (var db = new PodcastSqlModel()) { db.addSubscription(podcastModel); } await podcastModel.fetchChannelLogo(); SubscriptionManagerArgs addArgs = new SubscriptionManagerArgs(); addArgs.subscription = podcastModel; addArgs.isImportingFromExternalService = importingFromExternalService; OnPodcastChannelAddFinished(this, addArgs); OnPodcastChannelAdded(podcastModel); }