Пример #1
0
        public static void LaunchSubtractionMenu()
        {
            while (true)
            {
                UserInterface.PrintSubtractionMenu();
                int number1 = ControllersUtils.ReadIntegerInput("Introduce el primer número");
                int number2 = ControllersUtils.ReadIntegerInput("Introduce el segundo número");
                int result  = number1 - number2;
                System.Console.WriteLine("El total de la resta es: " + result);
                UserInterface.PrintSubtractionSubmenu();
                int option = UserInterface.ReadMenuOption(0, 2);
                switch (option)
                {
                case 0:
                    System.Console.Clear();
                    return;

                case 1:
                    break;

                case 2:
                    System.Console.Clear();
                    break;
                }
            }
        }
Пример #2
0
        public async Task <IActionResult> PostToCreateNewControllerAsync()
        {
            request       = new ControllersUtils();
            controller    = new CreateControllerModel();
            strController = new CreateControllerWithStringModel();
            log           = new RequestToFile();

            using (StreamReader reader = new StreamReader(Request.Body))
            {
                string body = await reader.ReadToEndAsync();

                string name = log.GetPrefix() + "_create";
                log.ToFile(body, name);

                try {
                    controller = controller.Deserialize(body);
                    request.CreateControllerFile(controller.ControllerName.ToLower(), body);
                }
                catch
                {
                    strController = strController.Deserialize(body);
                    request.CreateControllerFile(strController.ControllerName.ToLower(), body);
                }
            }

            return(StatusCode(201));
        }
Пример #3
0
        public async Task <IActionResult> PostToGetResponseFromControllerAsync(string controllerId, string catchAll)
        {
            request       = new ControllersUtils();
            controller    = new CreateControllerModel();
            strController = new CreateControllerWithStringModel();
            log           = new RequestToFile();

            using (StreamReader reader = new StreamReader(Request.Body))
            {
                string body = await reader.ReadToEndAsync();

                body = Request.Path.ToString() + Environment.NewLine + body;
                string name = log.GetPrefix() + "_" + controllerId;
                log.ToFile(body, name);
            }

            string responseString = "";


            try
            {
                //responseString = Regex.Unescape(request.ReadControllerFile(controllerId.ToLower())); //only works with json
                responseString = request.ReadControllerFile(controllerId.ToLower()); //only works with xml/string
                strController  = strController.Deserialize(responseString);          //if json -> throws exception


                if (strController.ResponseBody.Contains("?xml") || strController.ResponseBody.Contains("CDATA"))
                {
                    //responseString = request.ReadControllerFile(controllerId.ToLower());
                    //strController = strController.Deserialize(responseString);
                    var doc = XDocument.Parse(strController.ResponseBody);
                    return(StatusCode(strController.StatusCode, strController.ResponseBody));
                }
                else
                {
                    responseString = Regex.Unescape(request.ReadControllerFile(controllerId.ToLower()));
                    controller     = controller.Deserialize(responseString);
                    return(StatusCode(controller.StatusCode, controller.ResponseBody));
                }
            }
            //if ResponseBody is string
            catch
            {
                //if ResponseBody string is JSON
                try
                {
                    responseString = Regex.Unescape(request.ReadControllerFile(controllerId.ToLower()));
                    controller     = controller.Deserialize(responseString);
                    return(StatusCode(controller.StatusCode, controller.ResponseBody));
                }
                //if ResponseBody string is just a string
                catch
                {
                    strController = strController.Deserialize(responseString);
                    return(StatusCode(strController.StatusCode, strController.ResponseBody));
                }
            }
        }
Пример #4
0
        //private IMongoDatabase _mongoDatabase;
        public MongoDbContext(MongoClient mongoClient)
        {
            MongoDatabaseBase _mongoDatabase = (ControllersUtils.GetDatabase(mongoClient)) as MongoDatabaseBase;

            Conexoes      = (_mongoDatabase.GetCollection <Conexao>("Conexao")) as MongoCollectionBase <Conexao>;
            Contatos      = (_mongoDatabase.GetCollection <Contato>("Contato")) as MongoCollectionBase <Contato>;
            Passos        = (_mongoDatabase.GetCollection <Passo>("Passo")) as MongoCollectionBase <Passo>;
            Scripts       = (_mongoDatabase.GetCollection <Script>("Script")) as MongoCollectionBase <Script>;
            Campos        = (_mongoDatabase.GetCollection <Campo>("Campo")) as MongoCollectionBase <Campo>;
            ScriptGerados = (_mongoDatabase.GetCollection <ScriptGerado>("ScriptGerado")) as MongoCollectionBase <ScriptGerado>;
            PassoGerados  = (_mongoDatabase.GetCollection <PassoGerado>("PassoGerado")) as MongoCollectionBase <PassoGerado>;
            Ifxerrors     = (_mongoDatabase.GetCollection <IfxError>("IfxError")) as MongoCollectionBase <IfxError>;
        }
Пример #5
0
        //Addition function controller
        //This function manages the addition menu loop, and their options

        public static void LaunchSubadditionMenu(int Accumuled)
        {
            while (true)
            {
                UserInterface.PrintAdditionMenu();
                int number = ControllersUtils.ReadIntegerInput("Introduce el número a acumular");
                Accumuled += number;
                System.Console.WriteLine("El número acumulado es " + Accumuled);
                UserInterface.PrintAdditionSubmenu();
                switch (UserInterface.ReadMenuOption(0, 2))
                {
                case 0:
                case 2:
                    System.Console.Clear();
                    return;
                }
            }
        }