示例#1
0
        public Command(Entities.Command command)
        {
            Code        = command.Code;
            CommandInfo = new CommandInfo(command);

            EventAction();
        }
示例#2
0
 public CommandInfo(Entities.Command command)
 {
     CommandString = command.CommandString;
     EnqueueTime   = command.EnqueueTime;
     DequeueTime   = command.DequeueTime;
     Complete      = command.Complete;
 }
示例#3
0
        public X001(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X001ID=") != 0)
            {
                throw new InvalidOperationException();
            }

            PollId = UInt16.Parse(command.CommandString.Substring(7));
        }
示例#4
0
        public X006(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X006=") != 0)
            {
                throw new InvalidOperationException();
            }

            PresenterId = UInt16.Parse(command.CommandString.Substring(5));
        }
示例#5
0
        public X004(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X004=") != 0)
            {
                throw new InvalidOperationException();
            }

            Pak = UInt64.Parse(command.CommandString.Substring(5));
        }
示例#6
0
        public X010(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X010=") != 0)
            {
                throw new InvalidOperationException();
            }

            Message = command.CommandString.Substring(5);
        }
示例#7
0
        public X008(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X008=") != 0)
            {
                throw new InvalidOperationException();
            }

            SplashSource = command.CommandString.Substring(5);
        }
        public ActionResult <Command> Dequeue()
        {
            Entities.Command command = db.Commands.Where(c => !c.Complete).OrderBy(c => c.Id).FirstOrDefault();

            if (command == null)
            {
                return(BadRequest("No Commands found!"));
            }

            command.DequeueTime = DateTime.Now;
            command.Complete    = true;
            db.SaveChanges();

            Command result;

            try
            {
                switch (command.Code)
                {
                case "X001": result = new X001(command); break;

                case "X002": result = new X002(command); break;

                case "X003": result = new X003(command); break;

                case "X004": result = new X004(command); break;

                case "X005": result = new X005(command); break;

                case "X006": result = new X006(command); break;

                case "X007": result = new X007(command); break;

                case "X008": result = new X008(command); break;

                case "X009": result = new X009(command); break;

                case "X010": result = new X010(command); break;

                case "X011": result = new X011(command); break;

                case "X012": result = new X012(command); break;

                default: result = new UnknownCommand(command); break;
                }
                ;
            }
            catch (Exception e)
            {
                result = new UnknownCommand(command);
                Console.WriteLine(e);
            }


            return(result);
        }
        public ActionResult <Entities.Command> Enqueue([FromQuery] string comm)
        {
            Entities.Command command = new Entities.Command
            {
                Code          = comm.Substring(0, 4),
                CommandString = comm,
                EnqueueTime   = DateTime.Now
            };

            db.Add(command);
            db.SaveChanges();

            return(command);
        }
示例#10
0
        public X005(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X005=") != 0)
            {
                throw new InvalidOperationException();
            }

            string message = command.CommandString.Substring(5);

            if (message.Length >= 500)
            {
                message = message.Substring(0, 497) + "...";
            }

            Message = message;
        }
示例#11
0
        public X002(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X002ID=") != 0)
            {
                throw new InvalidOperationException();
            }

            string[] args = command.CommandString.Substring(5).Split("|");

            PollId = UInt16.Parse(args[0].Substring(2));
            V      = args[1].Substring(2) == "T" ? true : false;
            Q      = new uint[args.Length - 2];

            for (int i = 0; i < Q.Length; i++)
            {
                Q[i] = UInt32.Parse(args[i + 2].Substring(3));
            }
        }
示例#12
0
        public X007(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X007") != 0)
            {
                throw new InvalidOperationException();
            }

            string[] args = command.CommandString.Substring(4).Split("|");

            Media[] Media = new Media[args.Length];

            for (int i = 0; i < Media.Length; i++)
            {
                string[] arg = args[i].Split("=");
                Media[i] = new Media {
                    Id = arg[0], Source = arg[1]
                };
            }

            this.Media = Media;
        }
示例#13
0
        public X011(Entities.Command command) : base(command)
        {
            if (command.CommandString.IndexOf("X011") != 0)
            {
                throw new InvalidOperationException();
            }

            string[] args = command.CommandString.Substring(4).Split("|");

            LiveIcon[] LiveIcons = new LiveIcon[args.Length];

            for (int i = 0; i < LiveIcons.Length; i++)
            {
                string[] arg = args[i].Split("=");
                LiveIcons[i] = new LiveIcon
                {
                    Pak  = UInt64.Parse(arg[1]),
                    Live = arg[0].Equals("ON") ? true : false
                };
            }

            this.LiveIcons = LiveIcons;
        }
        public ActionResult <Entities.Command[]> Seed()
        {
            string[] SeedData =
            {
                "X001ID=1234",
                "X002ID=1234|V=T|Q1=123|Q2=456|Q3=789",
                "X003=http://www.workcast.co.uk/",
                "X004=55656636633",
                "X005=”Sorry, these is a problem with the event. Please refresh your browser”",
                "X006=12345",
                "X007MEDI1=http://www.workcast.net/media/1234.mp4|MEDI2=http://www.workcast.net/media/4567.mp4",
                "X008=http://www.workcast.net/images/123.jpg",
                "X009=12345",
                "X010=”Thanks Tom. I have a question on the 3rd point you made?”",
                "X011ON=677722341234|OFF=7384384734573845|ON=563647893904308478",
                "X012=http://www.workcast.net",
                "X487=something_random"
            };

            List <Entities.Command> commands = new List <Entities.Command>();

            foreach (string seed in SeedData)
            {
                Entities.Command command = new Entities.Command
                {
                    Code          = seed.Substring(0, 4),
                    CommandString = seed,
                };

                db.Add(command);
                commands.Add(command);
            }

            db.SaveChanges();

            return(commands.ToArray());
        }
示例#15
0
 public UnknownCommand(Entities.Command command) : base(command)
 {
     Code  = "X000";
     Error = "Unrecognised Command";
 }