Пример #1
0
        private void InsertQueueToSQL()
        {
            int song_id = -1;
            int artist_id = -1;
            int performer_id = -1;
            string firstname = "";
            string lastname = "";
            //if (this.is_SongDeleted == 1) CheckSongDeletion();
            try
            {
                for (int i = 0; i < this.songSyncList.Rows.Count; i++)
                {
                    // Get songList.Rows[i] ID, Artist ID, Performer ID for Insert songList.Rows[i]_queue

                    KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                    song_id = objClient.getSongIdInSyncTrack(this.songSyncList.Rows[i]["Title"].ToString(), "0", "", this.songSyncList.Rows[i]["Artist"].ToString());

                    artist_id = objClient.getArtistIdInSyncTrack(this.songSyncList.Rows[i]["Artist"].ToString());

                    string[] performerName = this.songSyncList.Rows[i]["Singer"].ToString().Split(',');
                    for (int j = 0; j < performerName.Length; j++)
                    {
                        if (j == 0 && performerName[0] != null) firstname = performerName[0];
                        if (j == 1 && performerName[1] != null) lastname = performerName[1];
                    }
                    performer_id = objClient.getPerformerIdInSyncTrack(VenueId, firstname, lastname);
                    System.Diagnostics.Debug.WriteLine("\nXXXXXXXXXXXXXXXXX" + this.songSyncList.Rows[i]["Title"].ToString() + " and IDs are : " + song_id + "***" + artist_id + "***" + performer_id + "\n");

                    //System.Diagnostics.Debug.WriteLine(songList.Rows[i]["Singer"].ToString() + "////" + songList.Rows[i]["Position"].ToString() + "////" + songList.Rows[i]["Title"].ToString() + "////" + songList.Rows[i]["Artist"].ToString());
                    //KaraoqDataAccess.KaraoqWebServiceSoapClient objClient3 = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                    objClient.InsertSongQueue(General.DJId, VenueId, artist_id, performer_id, this.songSyncList.Rows[i]["Singer"].ToString(), song_id, int.Parse(this.songSyncList.Rows[i]["Position"].ToString()), this.songSyncList.Rows[i]["Title"].ToString(), this.songSyncList.Rows[i]["Artist"].ToString(), "", this.songSyncList.Rows[i]["FileName"].ToString());
                    //Thread.Sleep(1000);
                }

            }
            catch (Exception exception1)
            {
                //ProjectData.SetProjectError(exception1);
                // ProjectData.ClearProjectError();
            }
            finally
            {
                this.previousSongSyncList = new DataTable();
                this.previousSongSyncList = this.songSyncList;
                this.songSyncList = new DataTable();
            }
        }
Пример #2
0
        private void Parser(string msg)
        {
            RichTextBox rtbMessages;
            IEnumerator enumerator;
            IEnumerator enumerator2;
            IEnumerator enumerator4;
            IEnumerator enumerator6;
            IEnumerator enumerator8;
            IEnumerator enumerator10;
            IEnumerator enumerator12;
            IEnumerator enumerator14;
            XmlDocument document = new XmlDocument();
            try
            {
                document.LoadXml(msg.Replace("\0", ""));
            }
            catch (Exception exception1)
            {
                //ProjectData.SetProjectError(exception1);
                // rtbMessages = this.rtbMessages;
                //  rtbMessages.Text = rtbMessages.Text + "Error: String \"" + msg.Replace("\0", "") + "\" in not valid XML";
                //  this.rtbMessages.AppendText(Environment.NewLine);
                // ProjectData.ClearProjectError();
                return;
            }
            XmlNodeReader reader = new XmlNodeReader(document);
            XmlNodeList list = document.SelectNodes("//Msg");
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    XmlElement current = (XmlElement)enumerator.Current;
                    try
                    {
                        if (current.HasAttribute("Command"))
                        {
                            string str = current.Attributes["Command"].Value;
                            string str9 = str;
                            if (str9 == "GetTerminalID")
                            {
                                this.Send("<Msg Terminal=\"" + General.KariokiTerminalID + "\"/>");
                                str = "";
                            }
                            else if (str9 == "GetClientVersion")
                            {
                                this.Send("<Msg ClientVersion=\"" + Application.ProductVersion.ToString() + "\"/>");
                                str = "";
                            }
                            else if (str9 == "ShowPlugin")
                            {
                                this.Send("<Msg ShowPlugin=\"OK\"/>");
                                //this.tmrPopup.Enabled = true;
                                str = "";
                            }
                            else if (str9 == "ClosePlugin")
                            {
                                this.Send("<Msg ClosePlugin=\"OK\"/>");
                                //rtbMessages = this.rtbMessages;
                                // rtbMessages.Text = rtbMessages.Text + "**** Closing Down ****";
                                str = "";
                            }
                            else if (str9 == "Disconnect")
                            {
                                this.clientSocket.Close();
                            }
                            else if (str != "")
                            {
                                this.Send("<Msg Unknown=\"" + str + "\"/>");
                                str = "";
                            }
                        }
                        else if (current.HasAttribute("TSV_FileLocation"))
                        {
                            this.tsvLocation = current.Attributes["TSV_FileLocation"].Value;
                            getCaseAndExportTSV(this.tsvLocation);
                            //this.lblTSVFileLocation.Text = current.Attributes["TSV_FileLocation"].Value;
                        }
                        else if (current.HasAttribute("CaseFolderLocation"))
                        {
                            caseLocation = current.Attributes["CaseFolderLocation"].Value;
                            //this.lblCasesLocation.Text = current.Attributes["CaseFolderLocation"].Value;
                        }
                        else if (current.HasAttribute("MessageClientUser"))
                        {
                            string prompt = current.Attributes["MessageClientUser"].Value;
                            this.Send("<Response MessageClientUser=\"OK\"/>");
                            Application.DoEvents();
                            this.Activate();
                            Interaction.MsgBox(prompt, MsgBoxStyle.Information, "Message to the User");
                        }
                        else if (current.HasAttribute("GetQueueList"))
                        {
                            if (current.Attributes["GetQueueList"].Value == "End")
                            {
                                if (this.previousSongSyncList.Rows.Count != 0)
                                {
                                    combineTwoQueueList();
                                } else
                                {
                                    this.previousSongSyncList = this.songSyncList;
                                    this.combinedSongList = this.songSyncList;
                                    combineTwoQueueList();
                                }

                            }
                        }
                        else if (current.HasAttribute("QueueListChanged"))
                        {
                            if (current.Attributes["QueueListChanged"].Value == "Removed")
                            {
                                this.is_SongDeleted = 1;
                            }
                            if (current.Attributes["QueueListChanged"].Value == "Order")
                            {
                                this.is_SongQueuePositionChanged = 1;
                            }
                        }

                        if (current.HasAttribute("HostVersion"))
                        {
                            //this.lblServerBuild.Text = current.Attributes["HostVersion"].Value;
                        }
                        if (current.HasAttribute("AutoAccept"))
                        {
                            if (current.Attributes["AutoAccept"].Value.ToLower() == "true")
                            {
                                //this.chkAutoAccept.Checked = true;
                            }
                            else
                            {
                                //this.chkAutoAccept.Checked = false;
                            }
                        }
                        continue;
                    }
                    catch (Exception exception2)
                    {
                        //ProjectData.SetProjectError(exception2);
                        //ProjectData.ClearProjectError();
                        continue;
                    }
                }
            }
            finally
            {
                //if (enumerator is IDisposable)
                //{
                //    (enumerator as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//Request/Song");
            try
            {
                enumerator2 = list.GetEnumerator();
                while (enumerator2.MoveNext())
                {
                    IEnumerator enumerator3;
                    XmlNode node = (XmlNode)enumerator2.Current;
                    try
                    {
                        enumerator3 = list.GetEnumerator();
                        while (enumerator3.MoveNext())
                        {
                            XmlElement element2 = (XmlElement)enumerator3.Current;
                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator3 is IDisposable)
                        //{
                        //    (enumerator3 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator2 is IDisposable)
                //{
                //    (enumerator2 as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//SingerListItem");
            try
            {
                enumerator4 = list.GetEnumerator();

                while (enumerator4.MoveNext())
                {
                    IEnumerator enumerator5;
                    XmlNode node2 = (XmlNode)enumerator4.Current;
                    try
                    {
                        enumerator5 = list.GetEnumerator();
                        while (enumerator5.MoveNext())
                        {
                            XmlElement element3 = (XmlElement)enumerator5.Current;
                            string str7 = "";
                            string str4 = "";
                            string str8 = "";
                            string str6 = "";
                            string str5 = "";
                            if (element3.HasAttribute("Singer"))
                            {
                                str7 = element3.Attributes["Singer"].Value;
                            }
                            if (element3.HasAttribute("Title"))
                            {
                                str8 = element3.Attributes["Title"].Value;
                            }
                            if (element3.HasAttribute("Artist"))
                            {
                                str4 = element3.Attributes["Artist"].Value;
                            }
                            if (element3.HasAttribute("Position"))
                            {
                                str6 = element3.Attributes["Position"].Value;
                            }
                            if (element3.HasAttribute("FileName"))
                            {
                                str5 = element3.Attributes["FileName"].Value;
                            }
                            this.songSyncList.Rows.Add(new object[] { str7, str8, str4, str6, str5 });
                            this.Send("<Response SingerListItem=\"OK\"/>");

                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator5 is IDisposable)
                        //{
                        //    (enumerator5 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator4 is IDisposable)
                //{
                //    (enumerator4 as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//NowPerforming");
            try
            {
                enumerator6 = list.GetEnumerator();
                while (enumerator6.MoveNext())
                {
                    IEnumerator enumerator7;
                    XmlNode node3 = (XmlNode)enumerator6.Current;
                    try
                    {
                        enumerator7 = list.GetEnumerator();
                        while (enumerator7.MoveNext())
                        {
                            XmlElement element4 = (XmlElement)enumerator7.Current;
                            if (element4.HasAttribute("Singer"))
                            {
                                // this.lblNowPerformingSinger.Text = element4.Attributes["Singer"].Value;
                            }
                            if (element4.HasAttribute("Title"))
                            {
                                // this.lblNowPerformingTitle.Text = element4.Attributes["Title"].Value;
                            }
                            if (element4.HasAttribute("Artist"))
                            {
                                //  this.lblNowPerformingArtist.Text = element4.Attributes["Artist"].Value;
                            }
                            if (element4.HasAttribute("FileName"))
                            {
                                //  this.lblNowPerformingFileName.Text = element4.Attributes["FileName"].Value;
                            }
                            KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                            objClient.UpdateNowPerforming(General.DJId, VenueId);
                            this.Send("<Response NowPerforming=\"OK\"/>");
                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator7 is IDisposable)
                        //{
                        //    (enumerator7 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator6 is IDisposable)
                //{
                //    (enumerator6 as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//NextUp");
            try
            {
                enumerator8 = list.GetEnumerator();
                while (enumerator8.MoveNext())
                {
                    IEnumerator enumerator9;
                    XmlNode node4 = (XmlNode)enumerator8.Current;
                    try
                    {
                        enumerator9 = list.GetEnumerator();
                        while (enumerator9.MoveNext())
                        {
                            XmlElement element5 = (XmlElement)enumerator9.Current;
                            if (element5.HasAttribute("Singer"))
                            {
                                //this.lblNextUpSinger.Text = element5.Attributes["Singer"].Value;
                            }
                            if (element5.HasAttribute("Title"))
                            {
                                ///this.lblNextUpTitle.Text = element5.Attributes["Title"].Value;
                            }
                            if (element5.HasAttribute("Artist"))
                            {
                                //this.lblNextUpArtist.Text = element5.Attributes["Artist"].Value;
                            }
                            if (element5.HasAttribute("FileName"))
                            {
                                // this.lblNextUpFileName.Text = element5.Attributes["FileName"].Value;
                            }
                            this.Send("<Response Nextup=\"OK\"/>");
                            //this.SingerList.Rows.Clear();
                            this.Send("<Msg Command=\"GetQueueList\"/>");
                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator9 is IDisposable)
                        //{
                        //    (enumerator9 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator8 is IDisposable)
                //{
                //    (enumerator8 as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//PlayerStatus");
            try
            {
                enumerator10 = list.GetEnumerator();
                while (enumerator10.MoveNext())
                {
                    IEnumerator enumerator11;
                    XmlNode node5 = (XmlNode)enumerator10.Current;
                    try
                    {
                        enumerator11 = list.GetEnumerator();
                        while (enumerator11.MoveNext())
                        {
                            XmlElement element6 = (XmlElement)enumerator11.Current;
                            if (element6.HasAttribute("State"))
                            {
                                // this.lblStatus.Text = element6.Attributes["State"].Value;
                            }
                            if (element6.HasAttribute("FileName"))
                            {
                                // this.lblLoadedFile.Text = element6.Attributes["FileName"].Value;
                            }
                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator11 is IDisposable)
                        //{
                        //    (enumerator11 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator10 is IDisposable)
                //{
                //    (enumerator10 as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//MakeSongbookTSV_Done");
            try
            {
                enumerator12 = list.GetEnumerator();
                while (enumerator12.MoveNext())
                {
                    IEnumerator enumerator13;
                    XmlNode node5 = (XmlNode)enumerator12.Current;
                    try
                    {
                        enumerator13 = list.GetEnumerator();
                        while (enumerator13.MoveNext())
                        {
                            XmlElement element6 = (XmlElement)enumerator13.Current;
                            if (element6.HasAttribute("Completed"))
                            {
                                // this.lblStatus.Text = element6.Attributes["State"].Value;
                            }
                            if (element6.HasAttribute("FileName"))
                            {
                                this.tsvLocation = element6.Attributes["FileName"].Value;
                                getCaseAndExportTSV(this.tsvLocation);
                            }
                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator11 is IDisposable)
                        //{
                        //    (enumerator11 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator10 is IDisposable)
                //{
                //    (enumerator10 as IDisposable).Dispose();
                //}
            }
            list = document.SelectNodes("//Response");
            try
            {
                enumerator14 = list.GetEnumerator();
                while (enumerator14.MoveNext())
                {
                    IEnumerator enumerator15;
                    XmlNode node5 = (XmlNode)enumerator14.Current;
                    try
                    {
                        enumerator15 = list.GetEnumerator();
                        while (enumerator15.MoveNext())
                        {
                            XmlElement element6 = (XmlElement)enumerator15.Current;
                            if (element6.HasAttribute("ExtortToTSV"))
                            {
                                if (element6.Attributes["ExtortToTSV"].Value == "OK")
                                {
                                    this.Send("<Msg Command=\"GetCaseFolderLocation\" />");
                                }
                                // this.lblStatus.Text = element6.Attributes["State"].Value;
                            }
                        }
                        continue;
                    }
                    finally
                    {
                        //if (enumerator11 is IDisposable)
                        //{
                        //    (enumerator11 as IDisposable).Dispose();
                        //}
                    }
                }
            }
            finally
            {
                //if (enumerator10 is IDisposable)
                //{
                //    (enumerator10 as IDisposable).Dispose();
                //}
            }
        }
Пример #3
0
        // This method get all the cases (and all songs) in the Kraoki Library
        private void getCaseAndExportTSV(String tsvLocation)
        {
            Thread.Sleep(2000);
            //System.Diagnostics.Debug.WriteLine(tsvLocation);
            using (StreamReader reader = new StreamReader(tsvLocation))
            {
                String line;
                bool lineOne = true;

                while ((line = reader.ReadLine()) != null)
                {
                    if (!lineOne)
                    {
                        // Reading each line from the TSV file, and split with TAB
                        string[] a = line.Split('\n');
                        foreach (var eachSong in a)
                        {
                            //System.Diagnostics.Debug.WriteLine(eachSong);
                            String[] fields = eachSong.Split('\t');

                            KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                            int trackId = objClient.getSongIdInSyncTrack(fields[2] != null ? fields[2] : "", fields[4] != null ? fields[4] : "", "", fields[1] != null ? fields[1] : "");
                            // saving in SQL database, do not have existing method to get song_id, dj_id, artist_id. There are still confusion about the fields.
                            System.Diagnostics.Debug.WriteLine(fields[0] + "**" + fields[1] + "**" + fields[2] + "**" + fields[3] + "**" + fields[4] + "**" + fields[5] + "**" + fields[6]);
                            objClient.InsertSynqTracks(VenueId, General.DJId, Convert.ToInt32(Properties.Settings.Default.DJPlaybackTool), trackId, fields[1] != null ? fields[1] : "", fields[2] != null ? fields[2] : "", fields[1] != null ? fields[1] : "", fields[4] != null ? fields[4] : "", fields[2] != null ? fields[2] : "", fields[5] != null ? fields[5] : "", fields[3] != null ? fields[3] : "", fields[6] != null ? fields[6] : "", fields[0] != null ? fields[0] : "");
                            //Thread.Sleep(1000);
                        }
                    }
                    lineOne = false;
                }
            }
            syncQueueBetweenSocketAndSQLServer();
        }
Пример #4
0
        private void combineTwoQueueList()
        {
            tempSongTable = new DataTable();
            for (int i = 0; i < this.previousSongSyncList.Rows.Count; i++)
            {
                int checkSame = 0;
                for (int j = 0; j < this.songSyncList.Rows.Count; j++)
                {

                    if (this.previousSongSyncList.Rows[i]["Singer"] == this.songSyncList.Rows[j]["Singer"] && this.previousSongSyncList.Rows[i]["Artist"] == this.songSyncList.Rows[j]["Artist"] && this.previousSongSyncList.Rows[i]["Title"] == this.songSyncList.Rows[j]["Title"])
                    {
                        checkSame = 1;
                        //this.combinedsongSyncList.Rows.Add(this.songSyncList.Rows[i]);
                    }
                    else if (j == this.songSyncList.Rows.Count - 1 && checkSame != 1)
                    {
                        tempSongTable.Rows.Add(this.songSyncList.Rows[i]);
                    }
                }
            }
            for (int k = 0; k < tempSongTable.Rows.Count; k++)
            {
                int song_id = -1;
                int artist_id = -1;
                int performer_id = -1;
                string firstname = "";
                string lastname = "";
                KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                song_id = objClient.getSongIdInSyncTrack(tempSongTable.Rows[k]["Title"].ToString(), "0", "", tempSongTable.Rows[k]["Artist"].ToString());

                artist_id = objClient.getArtistIdInSyncTrack(tempSongTable.Rows[k]["Artist"].ToString());

                string[] performerName = tempSongTable.Rows[k]["Singer"].ToString().Split(',');
                for (int j = 0; j < performerName.Length; j++)
                {
                    if (j == 0 && performerName[0] != null) firstname = performerName[0];
                    if (j == 1 && performerName[1] != null) lastname = performerName[1];
                }
                performer_id = objClient.getPerformerIdInSyncTrack(VenueId, firstname, lastname);
                objClient.UpdateSongQueueIsDeleted(General.DJId, VenueId, 1, performer_id, song_id, artist_id, "");
                Thread.Sleep(1000);
            }
            InsertQueueToSQL();
        }
Пример #5
0
 /// <summary>
 /// When Back ground work completed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void bwVenueSync_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     CurrentSteps = "Step 3/3 (Importing Songs Queue)";
     klblCurrentImport.Text = CurrentSteps;
     try
     {
         KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
     }
     catch
     {
     }
     finally
     {
         tmSync.Start();
     }
 }
Пример #6
0
        /// <summary>
        /// Event is invoked when Do work
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bwVenueSync_DoWork(object sender, DoWorkEventArgs e)
        {
            if (IsConnected)
            {
                CurrentSteps = "Step 1/3 (Importing song_queues)";
                KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                SongList = new DataTable();
                SongList = objClient.GetSongRequestedList(VenueId, DateTime.MinValue);
                CurrentProgressbarTotal = SongList.Rows.Count;
                for (int i = 0; i < SongList.Rows.Count; i++)
                {
                }
                this.songSyncList = new DataTable();
                this.songSyncList.Columns.Add("Singer", typeof(String));
                this.songSyncList.Columns.Add("Title", typeof(String));
                this.songSyncList.Columns.Add("Artist", typeof(String));
                this.songSyncList.Columns.Add("Position", typeof(String));
                this.songSyncList.Columns.Add("Filename", typeof(String));

                string existSong = "<Msg Command=\"MakeMasterTSV\"/>";
                this.Send(existSong);
            }
        }
Пример #7
0
        // This method is for syncing song_queue between Kraoki and SQL db
        private void syncQueueBetweenSocketAndSQLServer()
        {
            try
            {
                // Get existing SongList from SQL database
                KaraoqDataAccess.KaraoqWebServiceSoapClient objClient = new KaraoqDataAccess.KaraoqWebServiceSoapClient();
                this.existingSongList = objClient.GetSongListForDJ(General.DJId, VenueId);
                if (previousSavedSongList.Rows.Count != 0)
                {
                    this.previousSavedSongList = this.currentSavedSongList;
                    this.currentSavedSongList = this.existingSongList;
                    //combineTwoSongList();
                }
                else
                {
                    this.previousSavedSongList = this.existingSongList;
                    this.currentSavedSongList = this.existingSongList;
                }
                // Call socket stream to get SongList from Karaoki

            }
            catch (Exception exception1)
            {
                //ProjectData.SetProjectError(exception1);
                // ProjectData.ClearProjectError();
            }
            finally
            {
                syncQueueWithExistingData();

            }
        }