コード例 #1
0
ファイル: AddOrderCommand.cs プロジェクト: megadude000/ipz
        public override void Execute(CommandSwitchValues values)
        {
            DateTime regtime = DateTime.Now;
            int cost = values.GetSwitchAsInt("-cost");
            string eventType = values.GetSwitch("-eventType");
            string status = values.GetOptionalSwitch("-status");
            string customerName = values.GetSwitch("-customerName");
            string customerEmail = values.GetSwitch("-customerEmail");
            int curentAmmount = values.GetSwitchAsInt("-currentAmmount");
            string customerPhoneNumber = values.GetSwitch("-customerPhoneNumber");

            string comment = values.GetOptionalSwitch("-comment");
            if(comment == null)
                comment = "-";

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.NewOrder(regtime,
                                        comment,
                                        eventType,
                                        customerName,
                                        customerEmail,
                                        customerPhoneNumber,
                                        cost,curentAmmount,
                                        status);
            }
        }
コード例 #2
0
 public override void Execute(CommandSwitchValues values)
 {
     using (var orderController = ControllerFactory.MakeOrderController())
     {
         ReportGenerator generator = new ReportGenerator(Console.Out);
         generator.DisplayOrders(orderController.GetAllOrders());
     }
 }
コード例 #3
0
 public override void Execute(CommandSwitchValues values)
 {
     using (var scriptController = ControllerFactory.MakeEventScriptController())
     {
         ReportGenerator generator = new ReportGenerator(Console.Out);
         generator.DisplayScripts(scriptController.GetAllScripts());
     }
 }
コード例 #4
0
 public override void Execute(CommandSwitchValues values)
 {
     using (var imageController = ControllerFactory.MakeImageController())
     {
         ReportGenerator generator = new ReportGenerator(Console.Out);
         generator.DisplayImages(imageController.GetAllImages());
     }
 }
コード例 #5
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newNumber = values.GetSwitch("-newNumber");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.ChangeCustomersPhoneNumber(id, newNumber);
            }
        }
コード例 #6
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            int newCost = values.GetSwitchAsInt("-newCost");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.ChangeEventCost(id, newCost);
            }
        }
コード例 #7
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newType = values.GetSwitch("-newType");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                scriptController.ChangeScriptType(id, newType);
            }
        }
コード例 #8
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayScript(scriptController.GetScriptbyId(id));
            }
        }
コード例 #9
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            int newDur = values.GetSwitchAsInt("-newDur");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                scriptController.ChangeScriptDurration(id, newDur);
            }
        }
コード例 #10
0
        public override void Execute(CommandSwitchValues values)
        {
            string type = values.GetSwitch("-eventType");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayOrders(orderController.ViewOrdersWithSimilarEvent(type));
            }
        }
コード例 #11
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newStatus = values.GetSwitch("-newStatus");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                orderController.ChangeStatus(id, newStatus);
            }
        }
コード例 #12
0
        public override void Execute(CommandSwitchValues values)
        {
            string name = values.GetSwitch("-name");

            using (var imageController = ControllerFactory.MakeImageController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayImages(imageController.ViewImagesWithSimilarName(name));
            }
        }
コード例 #13
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            string newName = values.GetSwitch("-newName");

            using (var imageController = ControllerFactory.MakeImageController())
            {
                imageController.ChangeImageName(id, newName);
            }
        }
コード例 #14
0
        public override void Execute(CommandSwitchValues values)
        {
            string type = values.GetSwitch("-type");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayScripts(scriptController.ViewScriptsWithSimilarType(type));
            }
        }
コード例 #15
0
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                ReportGenerator generator = new ReportGenerator(Console.Out);
                generator.DisplayScriptID(orderController.ShowAttachedScriptID(id));
            }
        }
コード例 #16
0
ファイル: AddFoundsCommand.cs プロジェクト: megadude000/ipz
        public override void Execute(CommandSwitchValues values)
        {
            int id = values.GetSwitchAsInt("-id");
            int newAmmount = values.GetSwitchAsInt("-newAmmount");

            using (var orderController = ControllerFactory.MakeOrderController())
            {
                OrderInfo order = orderController.GetOrderbyId(id);
                int totalAmmount = order._currentAmmount + newAmmount;
                orderController.UpdateTotalAmmount(id, totalAmmount);
            }
        }
コード例 #17
0
        public override void Execute(CommandSwitchValues values)
        {
            string name = values.GetSwitch("-name");
            int dur = values.GetSwitchAsInt("-dur");
            string body = values.GetSwitch("-body");
            string eventType = values.GetSwitch("-eventType");

            using (var scriptController = ControllerFactory.MakeEventScriptController())
            {
                scriptController.NewScript(name,body,dur,eventType);
            }
        }
コード例 #18
0
ファイル: AddImageCommand.cs プロジェクト: megadude000/ipz
        public override void Execute(CommandSwitchValues values)
        {
            string name = values.GetSwitch("-name");
            string description = values.GetOptionalSwitch("-description");
            string imageURL = values.GetSwitch("-imageURL");
            string eventType = values.GetSwitch("-eventType");

            using (var imageController = ControllerFactory.MakeImageController())
            {
                imageController.NewImage(name, description, imageURL, eventType);
            }
        }
コード例 #19
0
ファイル: CommandHandler.cs プロジェクト: megadude000/ipz
        public void ProcessCommandLine(string commandLine)
        {
            string[] parts = commandLine.Trim().Split(' ', '\t');
            if (parts.Length == 0)
                return;

            string commandName = parts[0];
            if (commandName.Length == 0)
                return;

            Command command;
            if (!commands.TryGetValue(commandName, out command))
                throw new Exception("CommandSyntax: unknown command");

            var values = new CommandSwitchValues();
            for (int i = 1; i < parts.Length; i++)
            {
                string switchName = parts[i];
                CommandSwitch sw = command.FindSwitch(switchName);
                if (sw == null)
                    throw new Exception("CommandSyntax: unsupported switch " + switchName);

                switch (sw.Mode)
                {
                    case CommandSwitch.ValueMode.Unexpected:
                        values.SetSwitch(switchName, "true");
                        break;

                    case CommandSwitch.ValueMode.ExpectSingle:
                        values.SetSwitch(switchName, parts[i + 1]);
                        ++i;
                        break;

                    case CommandSwitch.ValueMode.ExpectMultiple:
                        values.AppendSwitch(switchName, parts[i + 1]);
                        ++i;
                        break;

                    default:
                        throw new Exception("CommandSyntax: unexpected switch value mode");
                }
            }

            foreach (string switchName in command.SwitchNames)
            {
                CommandSwitch sw = command.FindSwitch(switchName);
                if (!sw.Optional && !values.HasSwitch(switchName))
                    throw new Exception("CommandSyntax: switch " + switchName + " must be specified.");
            }

            command.Execute(values);
        }
コード例 #20
0
ファイル: HelpCommand.cs プロジェクト: megadude000/ipz
        public override void Execute(CommandSwitchValues values)
        {
            string commandName = values.GetOptionalSwitch("-command");
            if (commandName != null)
            {
                Command command = handler.FindCommand(commandName);
                if (command == null)
                    throw new Exception("help: command " + commandName + " not found");

                ShowHelpFor(command);
            }

            else
            {
                foreach (string name in handler.CommandNames)
                    ShowHelpFor(handler.FindCommand(name));
            }
        }
コード例 #21
0
        public override void Execute(CommandSwitchValues values)
        {
            int orderid = values.GetSwitchAsInt("-orderid");
            if (orderid <= 0)
                throw new SystemException("ID value must be more than 0");

            int scriptid = values.GetSwitchAsInt("-scriptid");
            if (scriptid <= 0)
                throw new SystemException("ID value must be more than 0");

            using(var scriptController = ControllerFactory.MakeEventScriptController())
            {
                if (scriptController.ScriptExist(scriptid))
                {
                    using (var orderController = ControllerFactory.MakeOrderController())
                    {
                        ReportGenerator generator = new ReportGenerator(Console.Out);
                        orderController.AttachScriptID(orderid, scriptid);
                        Console.WriteLine("Success!");
                    }
                }
            }
        }
コード例 #22
0
ファイル: QuitCommand.cs プロジェクト: megadude000/ipz
 public override void Execute(CommandSwitchValues values)
 {
     Output.WriteLine("Good Bye!");
     Environment.Exit(0);
 }