Exemple #1
0
        // Public Methods
        public int execute(CreateCommand command)
        {
            // delay
            this.delay();

            if (this.isFrozen)
            {
                this.frozenCommands.Add(command);
                return(0);
            }
            else
            {
                Console.WriteLine("Recieved " + command.getType() + " command from " + command.getIssuerId());
                this.createMeeting(command.getIssuerId(), command.getMeetingProposal());
                return(1);
            }
        }
        public CreateCommand parseCreateCommand(string[] instruction, string issuerId)
        {
            string topic         = instruction[1];
            int    min_attendees = Int32.Parse(instruction[2]);
            int    nr_slots      = Int32.Parse(instruction[3]);
            int    nr_invitees   = Int32.Parse(instruction[4]);

            List <Slot> slots = new List <Slot>();

            for (int i = 0; i < nr_slots; i++)
            {
                string   slot_info  = instruction[i + 5];
                char[]   delimiter  = { ',' };
                string[] slot_infos = slot_info.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                string   location   = slot_infos[0];
                DateTime date       = DateTime.Parse(slot_infos[1]);
                slots.Add(new Slot(location, date));
            }

            List <string> invitees = new List <string>();

            if (nr_invitees == 0)
            {
                invitees = null;
            }

            else
            {
                invitees = new List <string>();
            }

            CreateCommand command = new CreateCommand(topic, min_attendees, nr_slots, nr_invitees, slots, invitees);

            command.getMeetingProposal().setCoordinator(issuerId);
            return(command);
        }