Пример #1
0
 private string GetQueue(int Round)
 {
     if (_queuerForm != null && _queuerForm.cmb_events.Text != null && _queuerForm.cmb_events.Text.Trim().Length > 0)
     {
         TSCQueue q = new TSCQueue();
         q.EventKey   = _queuerForm.cmb_events.Text;
         q.QueueRound = Round;
         return(_scc.GeneralStore("TSCQueue", "GET", q.GetDataXml()));
     }
     return("");
 }
Пример #2
0
        private void SingerHistory_Load(object sender, EventArgs e)
        {
            if (_scc != null)
            {
                try
                {
                    TSCQueue template = new TSCQueue();
                    template.SingerKey  = _singer;
                    template.QueueRound = -1;
                    string singerxml = template.GetDataXml();

                    /*XmlDocument d = new XmlDocument();
                     * d.LoadXml(singerxml);
                     * XmlNodeList keys = d.SelectNodes("/Root/Data/KEYS/COLUMN_NAME");
                     * if (keys != null && keys.Count == 3)
                     * {
                     *      keys[0].InnerText = "SingerKey";
                     *      keys[2].InnerText = "EventKey";
                     * }
                     * singerxml = d.OuterXml;*/
                    string xml = _scc.GeneralStore("TSCQueue", "GET", singerxml);
                    Dictionary <string, SingerHistoryStore> singerhistory = new Dictionary <string, SingerHistoryStore>();
                    if (xml != null && xml.Trim().Length > 0)
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(xml);
                        XmlNodeList nodelist = doc.SelectNodes("/Root/Data");
                        foreach (XmlNode node in nodelist)
                        {
                            string tscevent = Utility.GetXmlString(node, "EventKey");
                            string singer   = Utility.GetXmlString(node, "SingerKey");
                            string status   = Utility.GetXmlString(node, "QueueState");
                            string song     = Utility.GetXmlString(node, "QueueSong");
                            string artist   = Utility.GetXmlString(node, "QueueArtist");
                            string note     = Utility.GetXmlString(node, "QueueNote");
                            string link     = Utility.GetXmlString(node, "QueueLink");

                            if ((singer != null && singer.Trim().Length > 0 && status != null && status.Trim().ToLower() == "finished" && ((song != null && song.Trim().Length > 0) || (link != null && link.Trim().Length > 0))))
                            {
                                SingerHistoryRecord singerrecord = new SingerHistoryRecord(tscevent, singer, song, artist, note, link);
                                if (singerhistory.ContainsKey(singer) == true)
                                {
                                    singerhistory[singer].history.Add(singerrecord);
                                }
                                else
                                {
                                    SingerHistoryStore shs = new SingerHistoryStore(singer);
                                    shs.history.Add(singerrecord);
                                    singerhistory.Add(singer, shs);
                                }
                            }
                        }
                    }
                    if (singerhistory.Count > 0)
                    {
                        var list = singerhistory.Keys.ToList();
                        list.Sort();
                        foreach (var key in list)
                        {
                            if (singerhistory[key].history.Count > 0)
                            {
                                foreach (SingerHistoryRecord shr in singerhistory[key].history)
                                {
                                    int irow = dataGridViewHistory.Rows.Add();
                                    dataGridViewHistory.Rows[irow].Cells["TSCEvent"].Value = shr.TSCEvent;
                                    dataGridViewHistory.Rows[irow].Cells["Singer"].Value   = shr.SingerKey;
                                    dataGridViewHistory.Rows[irow].Cells["Song"].Value     = shr.Song;
                                    dataGridViewHistory.Rows[irow].Cells["Artist"].Value   = shr.Artist;
                                    dataGridViewHistory.Rows[irow].Cells["Note"].Value     = shr.Note;
                                    dataGridViewHistory.Rows[irow].Cells["Link"].Value     = shr.Link;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #3
0
        private void Reload()
        {
            if (cmbEvent.Text != null && cmbEvent.Text.Trim().Length > 0)
            {
                for (int i = 1; i < 7; i++)
                {
                    TSCQueue templateQueue = new TSCQueue();
                    templateQueue.EventKey   = cmbEvent.Text;
                    templateQueue.QueueRound = i;
                    switch (i)
                    {
                    case 1:
                        controlTag.queue1Xml = scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        break;

                    case 2:
                        controlTag.queue2Xml = scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        break;

                    case 3:
                        controlTag.queue3Xml = scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        break;

                    case 4:
                        controlTag.queue4Xml = scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        break;

                    case 5:
                        controlTag.queue5Xml = scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        break;

                    case 6:
                        controlTag.queue6Xml = scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        break;
                    }
                }
            }

            /*
             * string s = "";
             * StringBuilder sb = new StringBuilder();
             * s = startdoc();
             * s = s.Replace("{event}", cmbEvent.Text.Trim());
             * sb.Append(s);
             * Directory.CreateDirectory(@"C:\Temp\Foo\" + cmbEvent.Text.Trim());
             * StreamWriter sw = File.CreateText(@"C:\Temp\Foo\" + cmbEvent.Text.Trim() + @"\TSCQueue.xml");
             * for (int i = 1; i < 7; i++)
             * {
             *      s = startround();
             *      s = s.Replace("{round}", i.ToString());
             *      sb.Append(s);
             *      XmlDocument doc = new XmlDocument();
             *      if (i == 1)
             *              doc.LoadXml(controlTag.queue1Xml);
             *      else if (i == 2)
             *              doc.LoadXml(controlTag.queue2Xml);
             *      else if (i == 3)
             *              doc.LoadXml(controlTag.queue3Xml);
             *      else if (i == 4)
             *              doc.LoadXml(controlTag.queue4Xml);
             *      else if (i == 5)
             *              doc.LoadXml(controlTag.queue5Xml);
             *      else if (i == 6)
             *              doc.LoadXml(controlTag.queue6Xml);
             *      else
             *              break;
             *      XmlNodeList nodes = doc.SelectNodes("/Root/Data");
             *      if (nodes.Count > 0)
             *      {
             *              foreach (XmlNode node in nodes)
             *              {
             *                      XmlNode QueueOrder = node.SelectSingleNode("QueueOrder");
             *                      XmlNode QueueSong = node.SelectSingleNode("QueueSong");
             *                      XmlNode QueueArtist = node.SelectSingleNode("QueueArtist");
             *                      XmlNode QueueNote = node.SelectSingleNode("QueueNote");
             *                      XmlNode QueueLink = node.SelectSingleNode("QueueLink");
             *                      XmlNode QueueState = node.SelectSingleNode("QueueState");
             *                      XmlNode SingerKey = node.SelectSingleNode("SingerKey");
             *                      if (SingerKey != null && SingerKey.InnerText.Trim().Length > 0)
             *                      {
             *                              s = singerdoc();
             *                              s = s.Replace("{singer}", SingerKey.InnerText.Trim());
             *                              if (QueueOrder != null && QueueOrder.InnerText.Trim().Length > 0)
             *                                      s = s.Replace("{order}", QueueOrder.InnerText.Trim());
             *                              else
             *                                      s = s.Replace("{order}", "");
             *                              if (QueueSong != null && QueueSong.InnerText.Trim().Length > 0)
             *                                      s = s.Replace("{song}", XmlUtility.Utility.XmlEscape(QueueSong.InnerText.Trim()));
             *                              else
             *                                      s = s.Replace("{song}", "");
             *                              if (QueueArtist != null && QueueArtist.InnerText.Trim().Length > 0)
             *                                      s = s.Replace("{artist}", XmlUtility.Utility.XmlEscape(QueueArtist.InnerText.Trim()));
             *                              else
             *                                      s = s.Replace("{artist}", "");
             *                              if (QueueNote != null && QueueNote.InnerText.Trim().Length > 0)
             *                                      s = s.Replace("{note}", XmlUtility.Utility.XmlEscape(QueueNote.InnerText.Trim()));
             *                              else
             *                                      s = s.Replace("{note}", "");
             *                              if (QueueLink != null && QueueLink.InnerText.Trim().Length > 0)
             *                                      s = s.Replace("{link}", XmlUtility.Utility.XmlEscape(QueueLink.InnerText.Trim()));
             *                              else
             *                                      s = s.Replace("{link}", "");
             *                              if (QueueState != null && QueueState.InnerText.Trim().Length > 0)
             *                                      s = s.Replace("{state}", XmlUtility.Utility.XmlEscape(QueueState.InnerText.Trim()));
             *                              else
             *                                      s = s.Replace("{state}", "");
             *                              sb.Append(s);
             *                      }
             *              }
             *              sb.Append(endround());
             *      }
             * }
             * sb.Append(enddoc());
             * sw.Write(sb.ToString());
             * sw.Close();
             */
        }
Пример #4
0
        public void Save()
        {
            int recordsadded   = 0;
            int recordschanged = 0;
            int recordsremoved = 0;

            if (IsValid())
            {
                foreach (TSCQueue queue in gd_tscqueue)
                {
                    SetState(queue, db_tscqueue);
                }
                foreach (TSCQueue queue in db_tscqueue)
                {
                    SetState(queue, gd_tscqueue);
                }
                foreach (TSCQueue queue in gd_tscqueue)
                {
                    if (queue.state == 'I')
                    {
                        string xml    = queue.GetDataXml();
                        string result = _scc.GeneralStore("TSCQueue", "INSERT", xml);
                        if (!(result != null && IsNumber(result) && int.Parse(result) > 0))
                        {
                            MessageBox.Show("Save error: " + QueueKey(queue) + " - " + result);
                        }
                        else
                        {
                            recordsadded++;
                        }
                    }
                    else if (queue.state == 'U')
                    {
                        string xml    = queue.GetDataXml();
                        string result = _scc.GeneralStore("TSCQueue", "UPDATE", xml);
                        if (!(result != null && IsNumber(result) && int.Parse(result) > 0))
                        {
                            MessageBox.Show("Save error: " + QueueKey(queue) + " - " + result);
                        }
                        else
                        {
                            recordschanged++;
                        }
                    }
                }
                foreach (TSCQueue queue in db_tscqueue)
                {
                    if (queue.state == 'D')
                    {
                        string xml    = queue.GetDataXml();
                        string result = _scc.GeneralStore("TSCQueue", "DELETE", xml);
                        if (!(result != null && IsNumber(result) && int.Parse(result) > 0))
                        {
                            MessageBox.Show("Delete error: " + QueueKey(queue) + " - " + result);
                        }
                        else
                        {
                            recordsremoved++;
                        }
                    }
                }
                if (_queuerForm != null && (recordsadded > 0 || recordschanged > 0 || recordsremoved > 0))
                {
                    db_tscqueue.Clear();
                    gd_tscqueue.Clear();
                    TSCQueue templateQueue = new TSCQueue();
                    templateQueue.EventKey   = _queuerForm.cmb_events.Text;
                    templateQueue.QueueRound = _round;
                    switch (_round)
                    {
                    case 1:
                        _queuerForm.controlTag.queue1Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        LoadTSCQueue(_queuerForm.controlTag.queue1Xml);
                        break;

                    case 2:
                        _queuerForm.controlTag.queue2Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        LoadTSCQueue(_queuerForm.controlTag.queue2Xml);
                        break;

                    case 3:
                        _queuerForm.controlTag.queue3Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        LoadTSCQueue(_queuerForm.controlTag.queue3Xml);
                        break;

                    case 4:
                        _queuerForm.controlTag.queue4Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        LoadTSCQueue(_queuerForm.controlTag.queue4Xml);
                        break;

                    case 5:
                        _queuerForm.controlTag.queue5Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        LoadTSCQueue(_queuerForm.controlTag.queue5Xml);
                        break;

                    case 6:
                        _queuerForm.controlTag.queue6Xml = _scc.GeneralStore("TSCQueue", "GET", templateQueue.GetDataXml());
                        LoadTSCQueue(_queuerForm.controlTag.queue6Xml);
                        break;
                    }

                    RefreshGrid();
                    if (_queuerForm != null)
                    {
                        _queuerForm.controlTag.RefreshQueue(gd_tscqueue);
                        if (_queuerForm.controlTag != null)
                        {
                            _queuerForm.controlTag.SetNext();
                        }
                        _queuerForm.SetNext();
                    }
                }
            }
        }