private void btnArchive_Click(object sender, EventArgs e) { HideButtons(); try { List <TSCEvents> localEvents = null; List <TSCQueue> localQueues = null; List <TSCEvents> remoteEvents = null; List <TSCQueue> remoteQueues = null; SingingClub scLocal = new SingingClub("Server=dmmlenovo1;Database=TheSingingClub;Integrated Security=true"); SingingClub scRemote = new SingingClub("Data Source=SQL5012.Smarterasp.net;Initial Catalog=DB_9BA515_LocalSingingClub;User Id=DB_9BA515_LocalSingingClub_admin;Password=Groovy52!;"); localEvents = GetEventList(scLocal); localQueues = GetQueueList(scLocal); remoteEvents = GetEventList(scRemote); remoteQueues = GetQueueList(scRemote); ArchiveData(localEvents, localQueues, "local"); ArchiveData(remoteEvents, remoteQueues, "remote"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception occurred"); } finally { UnHideButtons(); } }
private void SyncVenues(MvcList local, MvcList remote, SingingClub scRemote) { foreach (object o in local) { TSCVenues localitem = o as TSCVenues; if (localitem != null && localitem.VenueKey.Trim().Length > 0) { bool found = false; foreach (object oremote in remote) { TSCVenues remoteitem = oremote as TSCVenues; if (remoteitem != null && remoteitem.VenueKey.Trim().Length > 0) { if (localitem.KeyEquals(remoteitem) == true) { if (localitem.Equals(remoteitem) == false) { UpdateVenue(localitem, remoteitem, scRemote); } found = true; break; } } } if (found == false) { InsertVenue(localitem, scRemote); } } } foreach (object o in remote) { TSCVenues remoteitem = o as TSCVenues; if (remoteitem != null && remoteitem.VenueKey.Trim().Length > 0) { bool found = false; foreach (object olocal in local) { TSCVenues localitem = olocal as TSCVenues; if (localitem != null && localitem.VenueKey.Trim().Length > 0) { if (remoteitem.KeyEquals(localitem) == true) { found = true; break; } } } if (found == false) { DeleteVenue(remoteitem, scRemote); } } } }
private void SyncQueues(MvcList local, MvcList remote, SingingClub scRemote) { foreach (object o in local) { TSCQueue localitem = o as TSCQueue; if (localitem != null && localitem.EventKey.Trim().Length > 0 && localitem.SingerKey.Trim().Length > 0 && localitem.QueueRound > 0) { bool found = false; foreach (object oremote in remote) { TSCQueue remoteitem = oremote as TSCQueue; if (remoteitem != null && remoteitem.EventKey.Trim().Length > 0 && remoteitem.SingerKey.Trim().Length > 0 && remoteitem.QueueRound > 0) { if (localitem.KeyEquals(remoteitem) == true) { if (localitem.Equals(remoteitem) == false) { UpdateQueue(localitem, remoteitem, scRemote); } found = true; break; } } } if (found == false) { InsertQueue(localitem, scRemote); } } } foreach (object o in remote) { TSCQueue remoteitem = o as TSCQueue; if (remoteitem != null && remoteitem.EventKey.Trim().Length > 0 && remoteitem.SingerKey.Trim().Length > 0 && remoteitem.QueueRound > 0) { bool found = false; foreach (object olocal in local) { TSCQueue localitem = olocal as TSCQueue; if (localitem != null && localitem.EventKey.Trim().Length > 0 && localitem.SingerKey.Trim().Length > 0 && localitem.QueueRound > 0) { if (remoteitem.KeyEquals(localitem) == true) { found = true; break; } } } if (found == false) { DeleteQueue(remoteitem, scRemote); } } } }
private void btnRun_Click(object sender, EventArgs e) { HideButtons(); try { MvcList localVenues = null; MvcList localEvents = null; MvcList localSingers = null; MvcList localQueues = null; MvcList remoteVenus = null; MvcList remoteEvents = null; MvcList remoteSingers = null; MvcList remoteQueues = null; SingingClub scLocal = new SingingClub("Server=dmmlenovo1;Database=TheSingingClub;Integrated Security=true"); SingingClub scRemote = new SingingClub("Data Source=SQL5012.Smarterasp.net;Initial Catalog=DB_9BA515_LocalSingingClub;User Id=DB_9BA515_LocalSingingClub_admin;Password=Groovy52!;"); localVenues = GetVenues(scLocal); localEvents = GetEvents(scLocal); localSingers = GetSingers(scLocal); /* * string eventKey = GetLatestEventKey(); * if (eventKey.Trim().Length > 0) * { * TSCQueue q = new TSCQueue(); * q.EventKey = eventKey; * q.QueueRound = 1; * string r1xml = scRemote.GeneralStore(TableName.TSCQueue, TableAction.GET, q.GetDataXml()); * } */ localQueues = GetQueues(scLocal); remoteVenus = GetVenues(scRemote); remoteEvents = GetEvents(scRemote); remoteSingers = GetSingers(scRemote); remoteQueues = GetQueues(scRemote); SyncVenues(localVenues, remoteVenus, scRemote); SyncEvents(localEvents, remoteEvents, scRemote); SyncSingers(localSingers, remoteSingers, scRemote); SyncQueues(localQueues, remoteQueues, scRemote); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception occurred"); } finally { UnHideButtons(); } }
private List <TSCSingers> GetSingerList(SingingClub sc) { List <TSCSingers> list = new List <TSCSingers>(); string xml = sc.GeneralStore(TableName.TSCSingers, TableAction.GET, (new TSCSingers().GetDataXml())); if (xml.Trim().Length > 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList nodes = doc.SelectNodes("/Root/Data"); foreach (XmlNode node in nodes) { TSCSingers singers = new TSCSingers(node); list.Add(singers); } } return(list); }
private MvcList GetEvents(SingingClub sc) { MvcList list = new MvcList(); string xml = _eventsxml = sc.GeneralStore(TableName.TSCEvents, TableAction.GET, (new TSCEvents().GetDataXml())); if (xml.Trim().Length > 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList nodes = doc.SelectNodes("/Root/Data"); foreach (XmlNode node in nodes) { TSCEvents events = new TSCEvents(node); list.Add(events); } } return(list); }
private List <TSCQueue> GetQueueList(SingingClub sc) { List <TSCQueue> list = new List <TSCQueue>(); TSCQueue q = new TSCQueue(); q.QueueRound = -1; string xml = sc.GeneralStore(TableName.TSCQueue, TableAction.GET, (new TSCQueue().GetDataXml())); if (xml.Trim().Length > 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList nodes = doc.SelectNodes("/Root/Data"); foreach (XmlNode node in nodes) { TSCQueue queues = new TSCQueue(node); list.Add(queues); } } return(list); }
private void btnSongList_Click(object sender, EventArgs e) { HideButtons(); try { SingingClub scRemote = new SingingClub("Data Source=SQL5012.Smarterasp.net;Initial Catalog=DB_9BA515_LocalSingingClub;User Id=DB_9BA515_LocalSingingClub_admin;Password=Groovy52!;"); SingingClub scLocal = new SingingClub("Server=dmmlenovo1;Database=TheSingingClub;Integrated Security=true"); StreamReader sr = File.OpenText(@"C:\Users\dmooring\OneDrive\Karaoke\CDG_MP3\Index\Songlist.txt"); List <string> errs = new List <string>(); List <TSCSongListItem> songs = new List <TSCSongListItem>(); List <TSCSongListItem> dupes = new List <TSCSongListItem>(); //List<TSCSongListItem> dbsongs = scRemote.GetSongList(); while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line != null && line.Trim().Length > 0 && line.Contains('\t') == true) { string[] fields = line.Split('\t'); if (fields.Length >= 9) { string genericpath = GenericPath(Val(fields[8])); if (Val(fields[0]).Length > 0 && genericpath.Length > 0) { TSCSongListItem sli = new TSCSongListItem( Val(fields[0]), Val(fields[1]), Val(fields[2]), Val(fields[3]), Val(fields[4]), Val(fields[5]), Val(fields[6]), Val(fields[7]), genericpath); if (sli.Artist.Length == 0) { sli.Artist = "None"; } if (sli.Disk.Length == 0) { sli.Disk = "None"; } if (HasKey(songs, sli)) { dupes.Add(sli); } else { songs.Add(sli); scRemote.AddSong(sli); //scLocal.AddSong(sli); } } else { errs.Add("3"); } } else { errs.Add("2"); } } else { errs.Add("1"); } } sr.Close(); if (dupes.Count > 0 || errs.Count > 0) { string s = "hi"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception occurred"); } finally { UnHideButtons(); } }
private void DeleteQueue(TSCQueue remote, SingingClub scRemote) { _sb.AppendLine(string.Format("Delete: {0}.{1}.{2}", remote.EventKey, remote.SingerKey, remote.QueueRound)); scRemote.GeneralStore(TableName.TSCQueue, TableAction.DELETE, remote.GetDataXml()); }
private void InsertQueue(TSCQueue local, SingingClub scRemote) { _sb.AppendLine(string.Format("Insert: {0}.{1}.{2}", local.EventKey, local.SingerKey, local.QueueRound)); scRemote.GeneralStore(TableName.TSCQueue, TableAction.INSERT, local.GetDataXml()); }
private void UpdateQueue(TSCQueue local, TSCQueue remote, SingingClub scRemote) { _sb.AppendLine(string.Format("Update: {0}.{1}.{2}", local.EventKey, local.SingerKey, local.QueueRound)); scRemote.GeneralStore(TableName.TSCQueue, TableAction.UPDATE, local.GetDataXml()); }
private void DeleteSinger(TSCSingers remote, SingingClub scRemote) { _sb.AppendLine(string.Format("Delete: {0}", remote.SingerKey)); scRemote.GeneralStore(TableName.TSCSingers, TableAction.DELETE, remote.GetDataXml()); }
private void InsertSinger(TSCSingers local, SingingClub scRemote) { _sb.AppendLine(string.Format("Insert: {0}", local.SingerKey)); scRemote.GeneralStore(TableName.TSCSingers, TableAction.INSERT, local.GetDataXml()); }
private void UpdateSinger(TSCSingers local, TSCSingers remote, SingingClub scRemote) { _sb.AppendLine(string.Format("Update: {0}", local.SingerKey)); scRemote.GeneralStore(TableName.TSCSingers, TableAction.UPDATE, local.GetDataXml()); }