Exemplo n.º 1
0
        public ActionResult PageAddSaveRevert(SingerRound singerround)
        {
            int    round   = Utility.GetInt(Request.Form.Get("QueueRound"));
            string command = Request.Form.Get("command");

            singerround.round   = round;
            singerround.command = command;
            if (round > 0)
            {
                switch (command.ToLower())
                {
                case "revert":
                    XmlDocument doc    = SessionBag.Current.RoundXml as XmlDocument;
                    XmlDocument docref = SessionBag.Current.RoundXmlReference as XmlDocument;
                    if (doc != null && docref != null)
                    {
                        doc.LoadXml(docref.OuterXml);
                    }
                    break;

                case "save":
                    QueueGrid model = new QueueGrid(round);
                    model.QueueRound = round;
                    model.queues     = QueueRoundData.GetRounds(SessionBag.Current.RoundXml as XmlDocument, round);
                    model.queuesref  = QueueRoundData.GetRounds(SessionBag.Current.RoundXmlReference as XmlDocument, round);
                    string result    = model.Save();
                    string _RoundXml = "";
                    if (result != null && Utility.IsNumber(result) && int.Parse(result) > 0)
                    {
                        SingingClubClient client = new SingingClubClient();
                        client.Open();
                        string eventKey = SessionBag.Current.EventKey;
                        if (eventKey.Trim().Length > 0)
                        {
                            MVCQueue q = new MVCQueue();
                            q.EventKey   = eventKey;
                            q.QueueRound = -1;
                            _RoundXml    = client.GeneralStore("TSCQueue", "GET", q.GetDataXml());
                        }
                        client.Close();
                        XmlDocument RoundXml          = new XmlDocument();
                        XmlDocument RoundXmlReference = new XmlDocument();

                        RoundXml.LoadXml(_RoundXml);
                        RoundXmlReference.LoadXml(_RoundXml);

                        SessionBag.Current.RoundXml          = RoundXml;
                        SessionBag.Current.RoundXmlReference = RoundXmlReference;
                    }
                    break;

                case "add":
                    break;

                default:
                    break;
                }
            }
            return(View(singerround));
        }
Exemplo n.º 2
0
        public ActionResult SongTag(string title, string artist, string disk)
        {
            SingersGrid singers = new SingersGrid();

            singers.song = new TSCSongs();
            if (SessionBag.Current.SongsXml != null)
            {
                XmlDocument doc  = SessionBag.Current.SongsXml as XmlDocument;
                XmlNode     node = doc.SelectSingleNode(string.Format("/Root/Data[Title=\"{0}\" and Artist=\"{1}\" and Disk=\"{2}\"]", title, artist, disk));
                if (node != null)
                {
                    singers.song = new TSCSongs(node);
                }
            }

            Models.MvcList list = Controllers.QueueRoundData.GetRound(SessionBag.Current.RoundXml as XmlDocument, 1);
            foreach (object itm in list)
            {
                MVCQueue queue = itm as MVCQueue;
                if (queue != null)
                {
                    if (queue.SingerKey != null && queue.SingerKey.Trim().Length > 0)
                    {
                        MVCSingers singer = new MVCSingers();
                        singer.SingerKey = queue.SingerKey;
                        singers.singers.Add(singer);
                        singers.singersref.Add(singer);
                    }
                }
            }
            singers.Bind();
            ViewData.Model = singers;
            return(View());
        }
Exemplo n.º 3
0
        public string QueueData(string singerkey, string column, string data)
        {
            MVCQueue target          = null;
            MVCQueue targetreference = null;

            foreach (MVCQueue q in queues)
            {
                if (q.SingerKey == singerkey)
                {
                    target = q;
                    break;
                }
            }
            foreach (MVCQueue q in queuesref)
            {
                if (q.SingerKey == singerkey)
                {
                    targetreference = q;
                    break;
                }
            }
            if (target != null)
            {
                switch (column)
                {
                case "QueueState":
                    return(statestyle(target.QueueState, (targetreference == null) ? null : targetreference.QueueState));

                case "QueueSong":
                    return(util.textstyle(target.QueueSong, (targetreference == null) ? null : targetreference.QueueSong));

                case "QueueArtist":
                    return(util.textstyle(target.QueueArtist, (targetreference == null) ? null : targetreference.QueueArtist));

                case "QueueNote":
                    return(util.textstyle(target.QueueNote, (targetreference == null) ? null : targetreference.QueueNote));

                case "QueueLink":
                    return(util.textstyle(target.QueueLink, (targetreference == null) ? null : targetreference.QueueLink, true));

                default:
                    return(string.Format("<text>{0}</text>", data));
                }
            }
            else
            {
                return(string.Format("<text>{0}</text>", data));
            }
        }
Exemplo n.º 4
0
 // GET: EditQueue
 public ActionResult PageEditQueue(string SingerKey, int QueueRound)
 {
     if (SingerKey != null && SingerKey.Trim().Length > 0)
     {
         Models.MvcList list = Controllers.QueueRoundData.GetRound(SessionBag.Current.RoundXml as XmlDocument, QueueRound);
         foreach (object itm in list)
         {
             MVCQueue queue = itm as MVCQueue;
             if (queue != null)
             {
                 if (queue.SingerKey == SingerKey)
                 {
                     ViewData.Model = queue;
                     return(View(queue));
                 }
             }
         }
     }
     else
     {
         MVCQueue    model = new MVCQueue();
         XmlDocument doc   = SessionBag.Current.SingersXml;
         if (doc != null)
         {
             XmlNodeList nodes = doc.SelectNodes("/Root/Data/SingerKey");
             foreach (XmlNode node in nodes)
             {
                 string singer = node.InnerText;
                 if (singer != null && singer.Trim().Length > 0)
                 {
                     model.SingerList.Add(singer);
                 }
             }
         }
         model.QueueRound = QueueRound;
         return(View(model));
     }
     return(View());
 }
Exemplo n.º 5
0
        public string Save()
        {
            string            result         = "";
            int               recordschanged = 0;
            SingingClubClient client         = new SingingClubClient();

            client.Open();
            if (queues != null && queuesref != null)
            {
                List <MVCQueue> tobeadded = new List <MVCQueue>();
                foreach (MVCQueue q in queues)
                {
                    bool found = false;
                    foreach (MVCQueue qref in queuesref)
                    {
                        if (q.KeyEquals(qref) == true)
                        {
                            found = true;
                            if (MVCQueue.FieldsEqual(q, qref) == false)
                            {
                                result = client.GeneralStore("TSCQueue", "UPDATE", q.GetDataXml());
                                if (result != null && Utility.IsNumber(result) && int.Parse(result) > 0)
                                {
                                    recordschanged++;
                                }
                            }
                        }
                    }
                    if (found == false)
                    {
                        tobeadded.Add(q);
                    }
                }
                if (tobeadded.Count > 0)
                {
                    foreach (MVCQueue tba in tobeadded)
                    {
                        int    thisround = tba.QueueRound;
                        string thisstate = tba.QueueState;
                        for (int i = 1; i <= Utility.NumberOfRounds; i++)
                        {
                            tba.QueueRound = i;
                            if (i < thisround)
                            {
                                tba.QueueState = "Not Here";
                            }
                            else if (i > thisround)
                            {
                                tba.QueueState = "Pending";
                            }
                            else
                            {
                                tba.QueueState = thisstate;
                            }
                            result = client.GeneralStore("TSCQueue", "INSERT", tba.GetDataXml());
                            if (result != null && Utility.IsNumber(result) && int.Parse(result) > 0)
                            {
                                recordschanged++;
                            }
                        }
                    }
                }
            }
            client.Close();
            return(recordschanged.ToString());
        }
Exemplo n.º 6
0
        public ActionResult PageSetRound(MVCQueue model)
        {
            string state      = Request.Form["theQueueState"];
            string singerlist = Request.Form["SingerList"];
            int    maxorder   = 0;

            if (model.QueueRound > 0)
            {
                Models.MvcList sessionround = QueueRoundData.GetRound(SessionBag.Current.RoundXml, model.QueueRound);
                bool           found        = false;
                foreach (MVCQueue q in sessionround)
                {
                    if (q.QueueOrder > maxorder)
                    {
                        maxorder = q.QueueOrder;
                    }
                    if (q.SingerKey == model.SingerKey)
                    {
                        found = true;
                        if (MVCQueue.RoundsEqual(q, model) == false)
                        {
                            SetField("QueueSong", model.QueueSong, model.SingerKey, model.QueueRound);
                            SetField("QueueArtist", model.QueueArtist, model.SingerKey, model.QueueRound);
                            SetField("QueueNote", model.QueueNote, model.SingerKey, model.QueueRound);
                            SetField("QueueLink", model.QueueLink, model.SingerKey, model.QueueRound);
                            if (state != null && state.Trim().Length > 0)
                            {
                                SetField("QueueState", state, model.SingerKey, model.QueueRound);
                            }
                        }
                    }
                }
                if (found == false && singerlist != null && singerlist.Trim().Length > 0)
                {
                    XmlDocument doc = SessionBag.Current.SingersXml as XmlDocument;
                    if (doc != null)
                    {
                        XmlNode node = doc.SelectSingleNode(string.Format("/Root/Data[SingerKey='{0}']/SingerKey", singerlist.Trim()));
                        if (node != null)
                        {
                            doc = SessionBag.Current.RoundXml as XmlDocument;
                            if (doc != null && (SessionBag.Current.EventKey as string) != null && (SessionBag.Current.EventKey as string).Trim().Length > 0)
                            {
                                model.EventKey   = (SessionBag.Current.EventKey as string);
                                model.SingerKey  = singerlist.Trim();
                                model.QueueOrder = maxorder + 1;
                                if (state != null && state.Trim().Length > 0)
                                {
                                    model.QueueState = state;
                                }
                                else
                                {
                                    model.QueueState = "Pending";
                                }
                                model.AppendToDocument(doc);
                            }
                        }
                    }
                }
            }
            return(View(model));
        }