private void DeletePodcast(object obj) { Podcast podcast = (Podcast)obj; Podcasts.Remove(podcast); SaveSubscribedPodcasts(); }
public bool AddNew(Podcasts NewPodcast, string InserUser) { bool rpta = false; try { DynamicParameters Parm = new DynamicParameters(); Parm.Add("@InsertUser", InserUser); Parm.Add("@Title", NewPodcast.Title.Trim()); Parm.Add("@Description", NewPodcast.Description.Trim()); Parm.Add("@Banner", NewPodcast.BannerPath); Parm.Add("@MinisterID", NewPodcast.MinisterID); Parm.Add("@InsertDate", NewPodcast.InsertDate); SqlCon.Open(); SqlCon.Execute("[adm].[uspAddPodcast]", Parm, commandType: CommandType.StoredProcedure); rpta = true; } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(rpta); }
private async void AddFeed() { var dialog = new Views.AddURLDialog(); bool result = await _app.ShowDialog("Add URL...", dialog, DialogButtons.OkCancel); if (result) { try { var feed = await DownloadFeed(dialog.Url); _db.Podcasts.Save(new PodcastUri { Name = feed.Title.Text, Uri = dialog.Url }); Podcasts.UpdateWith(_db.Podcasts.GetAll()); Feed.UpdateWith(ParseFeed(feed)); } catch (Exception ex) { await _app.ShowMessageBox("Error", "Can't download or parse given url", DialogButtons.Ok); _app.Log.Exception(ex); } } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Podcasts.Clear(); var podcasts = await Database.Main.Table <Podcast>().ToListAsync(); Podcasts = new ObservableCollection <Podcast>(podcasts); foreach (var podcast in Podcasts) { podcast.Episodes = await Database.Main.Table <Episode>().Where(e => e.PodcastId == podcast.Id).ToListAsync(); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private ProcessorResult ProcessPodcastsElements(XmlReader reader) { var result = ProcessorResult.Processed; var elementName = reader.LocalName; switch (elementName) { case "global": XmlSerializationHelper.ProcessElement(reader, "global", ProcessGlobalElements); break; case "podcast": var newPodcast = new PodcastInfo(this); newPodcast.ReadXml(reader); Podcasts.Add(newPodcast); break; default: result = ProcessorResult.Ignored; break; } return(result); }
public async Task ExecuteGetPodcastsCommand() { if (IsBusy) { return; } try { IsBusy = true; var client = new HttpClient(); // Request from server podcast xml var podcastString = await client.GetStringAsync(PodcastUrl); // Parse Xml into data model and load into list var casts = ParseXml(podcastString); foreach (var cast in casts) { Podcasts.Add(cast); FilteredPodcasts.Add(cast); } } catch (Exception ex) { Debug.WriteLine("Unable to get podcasts: " + ex); } finally { IsBusy = false; } }
private async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { using (var httpClient = new HttpClient()) { var feed = "http://www.theguardian.com/football/series/footballweekly/rss"; var responseString = await httpClient.GetStringAsync(feed); Podcasts.Clear(); var items = await ParseFeed(responseString); foreach (var item in items) { podcasts.Add(item); } } } catch (Exception) { var page = new ContentPage(); page.DisplayAlert("Error", "Unable to load Pods.", "OK", null); } IsBusy = false; }
public async Task <IActionResult> Edit(int id, [Bind("PodcastId,Title,Link,Language,Copyright,Author,Description,Type,OwnerName,OwnerEmail,Image,Category,EmplicitBool")] Podcasts podcasts) { if (id != podcasts.PodcastId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(podcasts); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PodcastsExists(podcasts.PodcastId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(podcasts)); }
private void RemoveFeed(int obj) { var seledted = Podcasts[obj]; _db.Podcasts.Delete(seledted.Name); Podcasts.UpdateWith(_db.Podcasts.GetAll()); }
async Task ExecuteLoadPodcasts() { if (IsBusy) { return; } try { IsBusy = true; var pods = await DataService.GetPodcastsAsync(false); if (Podcasts.Count > 0) { Podcasts.ReplaceRange(pods); } else { Podcasts.AddRange(pods); } //OnPropertyChanged(nameof(Podcasts)); } catch (Exception ex) { #if DEBUG await App.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); #endif } finally { IsBusy = false; } }
private void SaveSubscribedPodcasts() { XmlSerializer writer = new XmlSerializer(typeof(Podcast[])); StreamWriter file = new StreamWriter(PodcastsFileLocation); writer.Serialize(file, Podcasts.ToArray()); file.Close(); }
public void Update(int id, Podcasts model) { var podcast = _ctx.podcast.Find(id); podcast.name = model.name; podcast.path = model.path; podcast.description = model.description; _ctx.SaveChanges(); }
public override void Initialize(IConfigurationManager configManager) { base.Initialize(configManager); if (IsValid) { List <String> podcastNames = Podcasts.Select(info => info.Name).ToList(); XmlGrammar grammar = GrammarUtility.CreateGrammarFromList(ConfigManager.GetPathForFile("PodcastGrammar.grxml", GetType()), "PodcastName", podcastNames); Provider = new GrammarProvider(grammar); } }
public void DeletePodcast(int id) { var podcast = Podcasts.SingleOrDefault(x => x.Id == id); if (podcast != null) { Podcasts.Remove(podcast); } this.SaveChanges(); }
public async Task <IActionResult> Create([Bind("PodcastId,Title,Link,Language,Copyright,Author,Description,Type,OwnerName,OwnerEmail,Image,Category,EmplicitBool")] Podcasts podcasts) { if (ModelState.IsValid) { _context.Add(podcasts); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(podcasts)); }
private void SerachPodcast() { Podcasts.Add(new Podcast() { Name = "Podcast Name", Description = "Podcast Description usually few lines with all kind of stuff going on there pretty cool stuff advertisment etc...", LogoUrl = new Uri("http://is1.mzstatic.com/image/thumb/Music1/v4/80/19/99/8019999e-738b-530e-8de4-2e970048bd02/source/100x100bb.jpg"), PodcastId = 1, RssFeed = new Uri("http://feeds.wnyc.org/radiolab"), }); }
public void UpdatePodcast(int id, Podcast updatedPodcast) { var podcast = Podcasts.SingleOrDefault(x => x.Id == id); if (podcast != null) { podcast.Title = updatedPodcast.Title; podcast.Authors = updatedPodcast.Authors; podcast.Length = updatedPodcast.Length; } this.SaveChanges(); }
public void ExecuteFilterPodcastCommand(string text) { text = text.ToLower(); FilteredPodcasts.Clear(); var filtered = Podcasts.Where(podcast => podcast.Description.ToLower().Contains(text) || podcast.Name.ToLower().Contains(text)); foreach (var cast in filtered) { FilteredPodcasts.Add(cast); } OnPropertyChanged("FilteredPodcasts"); }
protected override void GivenThat() { Playlist = mocks.DynamicMock <IPlaylist>(); base.GivenThat(); Podcasts.Clear(); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "Hanselminutes" }); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "This Developers Life" }); Podcasts[0].Pattern.Value = "*.mp3"; Podcasts[1].Pattern.Value = "*.wma"; var podcastFiles1 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; podcastFiles1[0].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\001.mp3"); podcastFiles1[1].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\002.mp3"); var podcastFiles2 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; // add them so they need sorting podcastFiles2[0].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\997.wma"); podcastFiles2[1].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\999.wma"); podcastFiles2[2].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\998.wma"); Finder.Stub(f => f.GetFiles(@"c:\destination\Hanselminutes", "*.mp3")) .Return(podcastFiles1); Finder.Stub(f => f.GetFiles(@"c:\destination\This Developers Life", "*.wma")) .Return(podcastFiles2); using (mocks.Ordered()) { Playlist.Expect(x => x.AddTrack(@".||Hanselminutes||001.mp3")).Return(true); Playlist.Expect(x => x.AddTrack(@".||Hanselminutes||002.mp3")).Return(true); Playlist.Expect(x => x.AddTrack(@".||This Developers Life||997.wma")).Return(true); Playlist.Expect(x => x.AddTrack(@".||This Developers Life||998.wma")).Return(true); Playlist.Expect(x => x.AddTrack(@".||This Developers Life||999.wma")).Return(true); } Playlist.Replay(); }
public Podcasts Details(int NewID) { Podcasts details = new Podcasts(); try { SqlCon.Open(); var SqlCmd = new SqlCommand("[config].[uspReadPodcasts]", SqlCon) { CommandType = CommandType.StoredProcedure }; SqlParameter pNewID = new SqlParameter { ParameterName = "@PodcastID", SqlDbType = SqlDbType.Int, Value = NewID }; SqlCmd.Parameters.Add(pNewID); using (var dr = SqlCmd.ExecuteReader()) { dr.Read(); if (dr.HasRows) { details.PodcastID = Convert.ToInt32(dr["PodcastID"]); details.Title = dr["Title"].ToString(); details.Description = dr["Description"].ToString(); details.BannerPath = dr["BannerPath"].ToString(); details.MinisterID = Convert.ToInt32(dr["MinisterID"]); details.MinisterName = dr["MinisterName"].ToString(); details.ActiveFlag = Convert.ToBoolean(dr["ActiveFlag"]); details.InsertDate = Convert.ToDateTime(dr["Date"]); details.NewYear = dr["Year"].ToString(); details.NewMonth = dr["Month"].ToString(); details.NewDay = dr["Day"].ToString(); details.Slide = Convert.ToInt32(dr["Slide"]); } } } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(details); }
private void ExecuteAddPodcastCommand(object parameter) { var dataObject = parameter as IDataObject; var newPodcast = (dataObject != null) ? CreateNewPodcast(_dataObjectUriExtractor.GetUri(dataObject)) : CreateNewPodcast(_clipboardService.GetText()); var newPodcastViewModel = new PodcastViewModel(newPodcast); if (EditPodcast(newPodcastViewModel)) { Podcasts.Add(newPodcastViewModel); } }
public List <Podcasts> List() { List <Podcasts> List = new List <Podcasts>(); try { SqlCon.Open(); var SqlCmd = new SqlCommand("[config].[uspReadPodcasts]", SqlCon) { CommandType = CommandType.StoredProcedure }; using (var dr = SqlCmd.ExecuteReader()) { while (dr.Read()) { var detail = new Podcasts { PodcastID = Convert.ToInt32(dr["PodcastID"]), Title = dr["Title"].ToString(), Description = dr["Description"].ToString(), BannerPath = dr["BannerPath"].ToString(), MinisterID = Convert.ToInt32(dr["MinisterID"]), MinisterName = dr["MinisterName"].ToString(), ActiveFlag = Convert.ToBoolean(dr["ActiveFlag"]), InsertDate = Convert.ToDateTime(dr["Date"]), NewYear = dr["Year"].ToString(), NewMonth = dr["Month"].ToString(), NewDay = dr["Day"].ToString(), Slide = Convert.ToInt32(dr["Slide"]) }; List.Add(detail); } } } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(List); }
private void UpdatePodcasts(NotifyCollectionChangedEventArgs e) { CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; UIThread.Dispatch(() => { if (e == null) { Podcasts.Clear(); Podcasts.AddAll(Data.Podcasts.Select((podcast) => new PodcastSummaryViewModel(podcast, ServiceContext))); return; } if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var item in e.NewItems) { Podcast podcast = item as Podcast; if (podcast != null) { Podcasts.Add(new PodcastSummaryViewModel(podcast, ServiceContext)); } else { foreach (Podcast podcastItem in (IEnumerable <Podcast>)item) { Podcasts.Add(new PodcastSummaryViewModel(podcastItem, ServiceContext)); } } } return; } if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (Podcast podcast in e.OldItems) { Podcasts.RemoveFirst((podcastViewModel) => podcastViewModel.Data.Id == podcast.Id); } } }); }
private void LoadPodcasts() { var maxItems = 5; // Min:1 - max:200 var country = "nl"; // Two-letter country code (ISO 3166-1 alpha-2) var finder = new iTunesPodcastFinder.PodcastFinder(); var results = finder.SearchPodcastsAsync("microsoft", maxItems); foreach (var item in results.Result) { Podcasts.Add( new Podcast { Title = item.Name, Description = item.Summary, Url = item.FeedUrl, ImageUrl = item.ArtWork, }); } }
public void SubscribeToPodcast(string link) { IsLoading = true; try { rss Rss; try { Rss = _deserialisedRssProvider.Deserialise(link); } catch (Exception e) { DisplayError(e.Message); return; } Podcast podcast = new Podcast { Title = Rss.channel.title, Url = link, }; if (Podcasts.Contains(podcast)) { DisplayError("Already subscribed to podcast"); return; //todo highlight or jump to/display } Podcasts.Add(podcast); SaveSubscribedPodcasts(); } finally { IsLoading = false; } }
protected override void GivenThat() { base.GivenThat(); Podcasts.Clear(); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "Hanselminutes" }); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "This Developers Life" }); Podcasts[0].Pattern.Value = "*.mp3"; Podcasts[1].Pattern.Value = "*.wma"; var podcastFiles1 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; podcastFiles1[0].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\001.mp3"); podcastFiles1[1].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\002.mp3"); var podcastFiles2 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; podcastFiles2[0].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\997.wma"); podcastFiles2[1].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\998.wma"); podcastFiles2[2].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\999.wma"); Finder.Stub(f => f.GetFiles(@"c:\destination\Hanselminutes", "*.mp3")) .Return(podcastFiles1); Finder.Stub(f => f.GetFiles(@"c:\destination\This Developers Life", "*.wma")) .Return(podcastFiles2); }
public bool Update(Podcasts NewPodcast, string InsertUser) { bool rpta = false; try { SqlCon.Open(); var SqlCmd = new SqlCommand("[adm].[uspUpdatePodcast]", SqlCon) { CommandType = CommandType.StoredProcedure }; //Insert Parameters SqlParameter pNewID = new SqlParameter { ParameterName = "@PodcastID", SqlDbType = SqlDbType.Int, Value = NewPodcast.PodcastID }; SqlCmd.Parameters.Add(pNewID); SqlParameter pInsertUser = new SqlParameter { ParameterName = "@InsertUser", SqlDbType = SqlDbType.VarChar, Size = 100, Value = InsertUser }; SqlCmd.Parameters.Add(pInsertUser); SqlParameter pActionType = new SqlParameter { ParameterName = "@ActionType", SqlDbType = SqlDbType.VarChar, Size = 10, Value = NewPodcast.ActionType }; SqlCmd.Parameters.Add(pActionType); SqlParameter pInsertDate = new SqlParameter { ParameterName = "@InsertDate", SqlDbType = SqlDbType.DateTime, Value = NewPodcast.InsertDate }; SqlCmd.Parameters.Add(pInsertDate); SqlParameter pTitle = new SqlParameter { ParameterName = "@Title", SqlDbType = SqlDbType.VarChar, Size = 50, Value = NewPodcast.Title }; SqlCmd.Parameters.Add(pTitle); SqlParameter pDescription = new SqlParameter { ParameterName = "@Description", SqlDbType = SqlDbType.VarChar, Value = NewPodcast.Description }; SqlCmd.Parameters.Add(pDescription); SqlParameter Photo = new SqlParameter { ParameterName = "@Banner", SqlDbType = SqlDbType.VarChar, Size = 500, Value = NewPodcast.BannerPath }; SqlCmd.Parameters.Add(Photo); SqlParameter pMinisterID = new SqlParameter { ParameterName = "@MinisterID", SqlDbType = SqlDbType.Int, Value = NewPodcast.MinisterID }; SqlCmd.Parameters.Add(pMinisterID); //EXEC Command SqlCmd.ExecuteNonQuery(); rpta = true; } catch (Exception ex) { throw ex; } if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } return(rpta); }
/// <summary> /// Copy podcasts from download location to USB key /// </summary> /// <param name="downloadFolder">folder podcasts are downloaded to</param> /// <param name="destinationFolder">folder podcasts are copied to</param> public void Copy(string downloadFolder, string destinationFolder) { //does the download folder exist? if (!Directory.Exists(downloadFolder)) { throw new FileNotFoundException("Specified download folder does not exist"); } //does the destination folder exist? if (!Directory.Exists(destinationFolder)) { throw new FileNotFoundException("Specified destination folder does not exist"); } //get folders in download folder var folders = Directory.GetDirectories(downloadFolder); var index = 0; //copy files in each folder to destination //if file exists, skip foreach (var folder in folders) { index += 1; OnSubscriptionCopying(index, folders.Length); var podcastName = folder.Substring(folder.LastIndexOf(@"\", StringComparison.Ordinal) + 1); OnPodcastCopying(podcastName); var files = Directory.GetFiles(folder); //reorder files if needed if (Podcasts == null || Podcasts.Count == 0) { Podcasts = GetPodcasts(); } var podcast = (Podcasts.Find(p => p.Name == podcastName)); if (podcast?.Order == Podcast.EpisodeOrder.Chronological) { //order should be reverse of how they were downloaded //Array.Reverse(files); //Array.Reverse reorders the array but USB clients (home receiver and car) seem to be listing in alpha (despite car docs indicating write order) } //count files as they are processed var fileIndex = 0; foreach (var file in files) { //get source path var filename = Path.GetFileName(file) ?? "IDK"; //get destination path var podcastFolder = Path.Combine(destinationFolder, podcastName); //destination filename is used by player to organize //default filename is number prefix containing download order //if want downloaded last (first podcast) to be first, need to reverse order here var destination = filename; if (podcast?.Order == Podcast.EpisodeOrder.Chronological) { //reset destination to the reverse number order, same prefix destination = (files.Length - fileIndex).ToString("000") + "_" + filename.Substring(4); } //if the destination has leading zero, trim it if (files.Length < 100) { destination = destination.Substring(1); } //replace underscore with space destination = destination.Replace('_', ' '); //append path to destination destination = Path.Combine(podcastFolder, destination); try { if (!File.Exists(destination)) { VerifyFolderExists(podcastFolder); OnEpisodeCopying(podcastName, file, destination); File.Copy(file, destination, false); OnEpisodeCopied(podcastName, file, destination); } } catch (Exception) { OnEpisodeCopyFailed(filename, destination); #if (DEBUG) { throw; } #endif } finally { fileIndex += 1; } } OnPodcastCopied(podcastName); } OnSubscriptionCopied(); }
public void DeletePodcast() { Podcasts.Remove(SelectedPodcast); podcastService.SaveToDisk(Podcasts); }
public void Insert(Podcasts model) { _ctx.podcast.Add(model); _ctx.SaveChanges(); }