private List <Song> ReadSetListFile(string fileName) { List <Song> list = new List <Song>(); SetlistReader sr = new SetlistReader(); try { Setlist sl = sr.read(fileName); if (sl.Items.Count > 0) { foreach (var i in sl.Items) { var key = _songManager.GetKeyByTitle(i); if (key != null) { var s = _songManager.SongList[key].Song; list.Add(s); } else { list.Add(new Song() { Title = i }); log.WarnFormat("Song '{0}' from setlist '{1}' not found in song manager", i, fileName); } } } } catch (Exception err) { log.ErrorFormat("Unable to read setlist file {0}: {1}", fileName, err.Message); } return(list); }
private void Save(object sender, EventArgs e) { var IsFormValid = ValidateForm(); CancelClicked = false; if (!IsFormValid) { return; } if (Mode == SongSelect.Modes.Create) { Setlist = new Setlist(); Setlist.SetlistEntries = new List <SetlistEntry>(); } Setlist.Title = SetlistTitle.Text; Setlist.Band = SetlistBand.SelectedValue.ToString(); DetermineSetOrder(); /****************************************************/ // In a larger volume situation, it would make sense // to build three lists: Add, Removed and Reorder. // Here we're talking about a set list, which likely has // fewer than 20 entries. So let's just do the easy thing, // Remove all of them and just add everything back into the // database. /****************************************************/ RemoveExistingSongs(); AddSelectedSongs(); var recordsUpdated = SongLibrary.SaveChanges(); Close(); }
/// <summary> /// Returns the current version of a setlist. E.g. if you pass the id of a setlist that got edited since you last accessed it, you'll get the current version. /// </summary> /// <param name="setlistId">The setlist id.</param> /// <param name="page">Page number to fetch.</param> /// <returns>The setlist for the provided id.</returns> public Setlist Setlist(string setlistId) { string url = string.Format("/setlist/{0}", setlistId); Setlist setlist = Load <Setlist>(url); return(setlist); }
/// <summary> /// Returns a setlist for the given versionId. The setlist returned isn't necessarily the most recent version. /// E.g. if you pass the versionId of a setlist that got edited since you last accessed it, you'll get the same version as last time. /// </summary> /// <param name="versionId">The version ID.</param> /// <returns>The setlist for the provided versionId.</returns> public Setlist SetlistVersion(string versionId) { string url = string.Format("/setlist/version/{0}", versionId); Setlist setlist = Load <Setlist>(url); return(setlist); }
private IList <ISetlist> ParseSetlistResponse(JObject json) { IList <ISetlist> setlists = new List <ISetlist>(); if (json.Value <int>("error_code") == 0) { var response = json["response"]; var data = (JArray)response["data"]; foreach (var show in data) { // only parse Phish setlists int artistID = show.Value <int>("artistid"); if (artistID != 1) { continue; } Setlist setlist = new Setlist(); setlist.ShowID = show.Value <int>("showid"); setlist.ShowDate = show.Value <string>("showdate"); setlist.Url = show.Value <string>("url"); setlist.Venue = show.Value <string>("venue"); setlist.Location = show.Value <string>("location"); setlist.Sets = ParseSetlistDataResponse(show.Value <string>("setlistdata")); setlists.Add(setlist); } } return(setlists); }
public Form1() { InitializeComponent(); gv = new GlobeViewer.Classes.GlobeViewer(panel1); gv.BindMarkerClickedEvent(delegate(object sender, string location) { Setlist item = default; foreach (var i in lastSearch) { foreach (var j in i) { if (j.Id == location) { item = j; } } } if (item != null) { form = new SetListView(item); this.Invoke(new Action(() => form.Show())); } }); sam = new SetlistApi("7saSG593hLsZ-onjCeYCize9zoMMP59Vf7an"); }
private IList <ISetlist> ParseSetlistResponse(JObject json) { IList <ISetlist> setlists = new List <ISetlist>(); if (json.Value <bool>("success")) { var data = json["data"]; var venue = data["venue"]; Setlist setlist = new Setlist(); setlist.ShowID = data.Value <int>("id"); setlist.ShowDate = data.Value <string>("date"); setlist.Duration = data.Value <int>("duration"); setlist.Venue = venue.Value <string>("name"); setlist.Location = venue.Value <string>("location"); setlist.Url = string.Format("http://phish.in/{0}", setlist.ShowDate); setlist.Sets = ParseTracks((JArray)data["tracks"]); foreach (Set set in setlist.Sets) { set.Duration = set.Songs.Sum(s => s.Duration); } setlists.Add(setlist); } return(setlists); }
public Setlist read(string filename) { var xmlDoc = new XmlDocument(); xmlDoc.Load(filename); var xmlRoot = xmlDoc.DocumentElement; if (xmlRoot.Name != "setlist") { throw new Exception("Ungültige Setlist!"); } var sl = new Setlist(); if (xmlRoot["items"] != null) { sl.Items.Clear(); for (var i = 0; i < xmlRoot["items"].ChildNodes.Count; i++) { if (xmlRoot["items"].ChildNodes[i].Name == "item") { sl.Items.Add(xmlRoot["items"].ChildNodes[i].InnerText); } } } return(sl); }
public SetListView(Setlist setlists) { data = setlists; InitializeComponent(); labelArtist.Text = "Artista: " + data.Artist.Name; labelDate.Text = "Data: " + data.EventDate; }
private void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBox1.Text)) { if (!taskRunning) { if (form != null) { form.Close(); } button1.Enabled = false; textBox1.Enabled = false; Task.Run(() => { taskRunning = true; //Set up query Setlist query = new Setlist(); query.Artist = new Artist(textBox1.Text); List <Setlists> result = sam.SearchSetlists(query); lastSearch = result; this.Invoke(new Action(() => { textBox1.Enabled = true; button1.Enabled = true; })); //Send data to GlobeViewer IList <(string, string, string, string)> locations = new List <(string MarkerName, string Name, string X, string Y)>(); foreach (Setlists j in result) { foreach (Setlist i in j) { locations.Add((i.Id, i.Venue.City.State + " " + i.Venue.City.Name + " " + i.Venue.Name, i.Venue.City.Coords.Longitude.ToString(), i.Venue.City.Coords.Latitude.ToString())); } } try { gv.LoadMarkers(locations, out var _); } catch (Exception ex) { MessageBox.Show(ex.Message); } taskRunning = false; }); } } else { MessageBox.Show("Inserisci qualcosa nel campo"); } }
public void ActivateSetlist(Setlist setlist) { currentSetlist = setlist; currentSetlistIdx = 0; if (currentSetlistIdx < setlist.Songs.Count) { ActivateSong(setlist.Songs[currentSetlistIdx], 0); } }
private void LoadSetlist(Setlist Setlist, ListView listView) { if (Setlist == null) { return; } foreach (SetlistEntry s in Setlist.SetlistEntries) { listView.Items.Add(new ListViewItem(new[] { s.Song.Title, s.Song.Artist, s.Song.Instrument, s.Song.Id.ToString(), s.SetOrder.ToString() }, s.SetOrder)); } }
public Controller(IMIDI midi, int channel) { // Wrap the MIDI output device in a state-tracker: this.midi = (midi is MidiState) ? (MidiState)midi : new MidiState(midi); this.channel = channel; this.currentSongIdx = 0; this.currentSetlistIdx = 0; this.currentSetlist = null; this.currentSong = null; this.currentScene = 0; }
public void Write(string filename, Setlist list) { var xml = new XmlWriterHelper("setlist", "1.0"); xml.Root.AppendChild(xml.Doc.CreateElement("items")); foreach (string t in list.Items) { XmlNode nd = xml.Doc.CreateElement("item"); nd.InnerText = t; xml.Root["items"].AppendChild(nd); } xml.Write(filename); }
public Setlists Search(Setlist s) { Setlists result = sa.SearchSetlists(s); Setlists newResult; for (int i = 1; i < result.TotalPages; i++) { newResult = sa.SearchSetlists(s, i); foreach (Setlist j in newResult) { result.Add(j); } } return(result); }
public async Task <Setlist> GetSetlistById(Guid setlistId) { var item = await(from p in entities.Setlist .Include(q => q.SetlistScene) .ThenInclude(q => q.Scene) .ThenInclude(q => q.MediaFile) where p.SetlistId == setlistId select p).FirstOrDefaultAsync(); if (item == null) { item = new Setlist(); } item.SetlistScene = item.SetlistScene.OrderBy(q => q.Index).ToList(); return(item); }
public void LoadSetlist() { Setlist setlist = SongLibrary.Setlists .Include("SetlistEntries.Song") .Where(S => S.Id == SetlistId).FirstOrDefault(); if (setlist == null) { throw (new NotImplementedException()); } List <SetlistEntry> Set = setlist.SetlistEntries.ToList().OrderBy(s => s.SetOrder).ToList(); foreach (SetlistEntry sl in Set) { Song s = sl.Song; // The songs don't have a set order so we put in a dummy value. Makes moving items back and forth easier. listView1.Items.Add(new ListViewItem(new[] { s.Title, s.Key, s.FirstNote, s.Id.ToString(), sl.SetOrder.ToString() })); } }
private void DeleteSetlist(object sender, EventArgs e) { var lastSubItem = SetlistList.SelectedItems[0].SubItems.Count - 1; var SetlistId = int.Parse(SetlistList.SelectedItems[0].SubItems[lastSubItem].Text); Setlist setlist = SongLibrary.Setlists.Where(l => l.Id == SetlistId).FirstOrDefault(); var rc = MessageBox.Show("Are you sure you want to delete the library '" + setlist.Title + "'?", "Delete Setlist", MessageBoxButtons.YesNoCancel); if (rc == DialogResult.Yes) { foreach (var entry in setlist.SetlistEntries.ToList()) { SongLibrary.SetlistEntries.Remove(entry); } SongLibrary.Setlists.Remove(setlist); SongLibrary.SaveChanges(); } LoadSetlistList(); EnableButtons(sender, e); }
private void LoadSongs(Setlist Setlist) { var AllSongs = SongLibrary.Songs.OrderBy(S => S.Title); // First load all the songs that are in all the libraries. // Then get the ones in the selected setlist and the ones that aren't. if (Setlist != null) { Setlist.SetlistEntries = SongLibrary.SetlistEntries.Where(s => s.Id == Setlist.Id).ToList(); var SetlistSongs = Setlist.SetlistEntries.Select(s => s.Song).OrderBy(s => s.Title).AsEnumerable().ToList(); var RemainingSongs = AllSongs.AsEnumerable().Except <Song>(SetlistSongs).ToList(); LoadAvailableSongs(RemainingSongs, SongsAvailable); } else { LoadAvailableSongs(AllSongs.ToList(), SongsAvailable); } LoadSetlist(Setlist, SongsInSetlist); LoadSetlist(Setlist, SongsAtStart); }
public async Task <Setlist> UpdateSetlist(Setlist update) { var dest = await(from p in entities.Setlist where p.SetlistId == update.SetlistId select p).FirstOrDefaultAsync(); if (dest == null) { dest = new Setlist() { CreatedAt = DateTime.Now, IsActive = false, SetlistId = Guid.NewGuid() }; entities.Setlist.Add(dest); } dest.Name = update.Name; dest.Description = update.Description ?? string.Empty; await entities.SaveChangesAsync(); return(dest); }
/// <summary> /// Constructor. /// </summary> /// <param name="fetchedSetlist">The fetched setlist.</param> public FetchedSetlistViewModel(Setlist fetchedSetlist) { FetchedSetlist = fetchedSetlist; }
/// <summary> /// Constructor. /// </summary> /// <param name="fetchedSetlist">The fetched setlist.</param> public FetchedSetlistViewModel(Setlist fetchedSetlist) { _fetchedSetlist = fetchedSetlist ?? throw new ArgumentNullException(nameof(fetchedSetlist)); }
/// <summary> /// Search for setlists. /// </summary> /// <param name="searchFields"> /// You must provide a value for at least one of the following properties: /// <para>Tour, LastUpdated, EventDate (you could set only a year, e.g. <code>00-00-2007</code>),</para> /// <para>Artist.Name, Artist.MBID, Artist.TMID (set <code>TMIDSpecified = true</code>)</para> /// <para>Venue.Id, Venue.Name, Venue.City.Id, Venue.City.Name. Venue.City.State, Venue.City.State.Code, Venue.City.Country.Code</para> /// </param> /// <param name="page">Page number to fetch.</param> /// <returns>A list of matching setlists.</returns> public Setlists SearchSetlists(Setlist searchFields, int page = 1) { StringBuilder query = new StringBuilder(); if (searchFields != null) { if (!string.IsNullOrEmpty(searchFields.TourName)) { query.AppendFormat("tour={0}&", searchFields.Tour); } if (!string.IsNullOrEmpty(searchFields.LastUpdated)) { query.AppendFormat("lastUpdate={0}&", searchFields.LastUpdated); } if (!string.IsNullOrEmpty(searchFields.EventDate)) { if (searchFields.GetEventDateTime() != null) { query.AppendFormat("date={0}&", searchFields.EventDate); } else if (searchFields.GetYear() != 0) { query.AppendFormat("year={0}&", searchFields.GetYear()); } } if (searchFields.Artist != null) { if (!string.IsNullOrEmpty(searchFields.Artist.MBID)) { query.AppendFormat("artistMbid={0}&", searchFields.Artist.MBID); } if (searchFields.Artist.TMIDSpecified) { query.AppendFormat("artistTmid={0}&", searchFields.Artist.TMID); } if (!string.IsNullOrEmpty(searchFields.Artist.Name)) { query.AppendFormat("artistName={0}&", searchFields.Artist.Name); } } if (searchFields.Venue != null) { if (!string.IsNullOrEmpty(searchFields.Venue.Id)) { query.AppendFormat("venueId={0}&", searchFields.Venue.Id); } if (!string.IsNullOrEmpty(searchFields.Venue.Name)) { query.AppendFormat("venueName={0}&", searchFields.Venue.Name); } if (searchFields.Venue.City != null) { if (searchFields.Venue.City.Id != "0" && searchFields.Venue.City.Id != "") { query.AppendFormat("cityId={0}&", searchFields.Venue.City.Id); } if (!string.IsNullOrEmpty(searchFields.Venue.City.Name)) { query.AppendFormat("cityName={0}&", searchFields.Venue.City.Name); } if (!string.IsNullOrEmpty(searchFields.Venue.City.State)) { query.AppendFormat("state={0}&", searchFields.Venue.City.State); } if (!string.IsNullOrEmpty(searchFields.Venue.City.StateCode)) { query.AppendFormat("stateCode={0}&", searchFields.Venue.City.StateCode); } if (searchFields.Venue.City.Country != null) { if (!string.IsNullOrEmpty(searchFields.Venue.City.Country.Code)) { query.AppendFormat("countryCode={0}&", searchFields.Venue.City.Country.Code); } } } } } string url = string.Format("/search/setlists?{0}p={1}", query.ToString(), page.ToString()); Setlists setlists = Load <Setlists>(url); return(setlists); }
/// <summary> /// Search for setlists. /// </summary> /// <param name="searchFields"> /// You must provide a value for at least one of the following properties: /// <para>Tour, LastUpdated, EventDate (you could set only a year, e.g. <code>00-00-2007</code>),</para> /// <para>Artist.Name, Artist.MBID, Artist.TMID (set <code>TMIDSpecified = true</code>)</para> /// <para>Venue.Id, Venue.Name, Venue.City.Id, Venue.City.Name. Venue.City.State, Venue.City.State.Code, Venue.City.Country.Code</para> /// </param> /// <param name="page">Page number to fetch.</param> /// <returns>A list of matching setlists.</returns> public List <Setlists> SearchSetlists(Setlist searchFields) { StringBuilder query = new StringBuilder(); if (searchFields != null) { if (!string.IsNullOrEmpty(searchFields.TourName)) { query.AppendFormat("tour={0}&", searchFields.Tour); } if (!string.IsNullOrEmpty(searchFields.LastUpdated)) { query.AppendFormat("lastUpdate={0}&", searchFields.LastUpdated); } if (!string.IsNullOrEmpty(searchFields.EventDate)) { if (searchFields.GetEventDateTime() != null) { query.AppendFormat("date={0}&", searchFields.EventDate); } else if (searchFields.GetYear() != 0) { query.AppendFormat("year={0}&", searchFields.GetYear()); } } if (searchFields.Artist != null) { if (!string.IsNullOrEmpty(searchFields.Artist.MBID)) { query.AppendFormat("artistMbid={0}&", searchFields.Artist.MBID); } if (searchFields.Artist.TMIDSpecified) { query.AppendFormat("artistTmid={0}&", searchFields.Artist.TMID); } if (!string.IsNullOrEmpty(searchFields.Artist.Name)) { query.AppendFormat("artistName={0}&", searchFields.Artist.Name); } } if (searchFields.Venue != null) { if (!string.IsNullOrEmpty(searchFields.Venue.Id)) { query.AppendFormat("venueId={0}&", searchFields.Venue.Id); } if (!string.IsNullOrEmpty(searchFields.Venue.Name)) { query.AppendFormat("venueName={0}&", searchFields.Venue.Name); } if (searchFields.Venue.City != null) { if (searchFields.Venue.City.Id != "0" && searchFields.Venue.City.Id != "") { query.AppendFormat("cityId={0}&", searchFields.Venue.City.Id); } if (!string.IsNullOrEmpty(searchFields.Venue.City.Name)) { query.AppendFormat("cityName={0}&", searchFields.Venue.City.Name); } if (!string.IsNullOrEmpty(searchFields.Venue.City.State)) { query.AppendFormat("state={0}&", searchFields.Venue.City.State); } if (!string.IsNullOrEmpty(searchFields.Venue.City.StateCode)) { query.AppendFormat("stateCode={0}&", searchFields.Venue.City.StateCode); } if (searchFields.Venue.City.Country != null) { if (!string.IsNullOrEmpty(searchFields.Venue.City.Country.Code)) { query.AppendFormat("countryCode={0}&", searchFields.Venue.City.Country.Code); } } } } } string url = string.Format("/search/setlists?{0}p=1", query.ToString()); List <Setlists> setlists = new List <Setlists>(); setlists.Add(Load <Setlists>(url)); int cicli = setlists[0].TotalPages; for (int i = 2; i < cicli - 1; i++) { url = string.Format("/search/setlists?{0}p={1}", query.ToString(), i.ToString()); setlists.Add(Load <Setlists>(url)); } return(setlists); }