public async Task <IActionResult> FormSubmit(RegisterRequest request)
        {
            var client   = new Job.JobClient(_channel);
            var response = await client.RegisterAsync(request);

            return(RedirectToAction("TextDetails", response));
        }
Example #2
0
            public async Task <IActionResult> FormSubmit(String description)
            
        {
            if (description == null)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = "Description must be filled"
                }));
            }

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

            string value = Environment.GetEnvironmentVariable("BACKEND_HOST");
            string host  = value == null ? "localhost" : value;

            using var channel = GrpcChannel.ForAddress("http://" + host + ":5000");

            var client   = new Job.JobClient(channel);
            var response = await client.RegisterAsync(new RegisterRequest { Description = description });

            return(View("Task", new TaskViewModel {
                Id = response.Id
            }));

                
        }
Example #3
0
        public async Task <IActionResult> SubmitFormAsync(string taskDescription, string taskData)
        {
            string taskResult = String.Empty;

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress($"http://localhost:{_config.GetValue<int>("BackendApiPort")}");
            var client = new Job.JobClient(channel);

            try
            {
                var reply = await client.RegisterAsync(
                    new RegisterRequest { Description = taskDescription, Data = taskData });

                taskResult = reply.Id;
            }
            catch (RpcException)
            {
                ViewBag.TaskResult = "Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение";
            }
            catch (ArgumentNullException)
            {
                ViewBag.TaskResult = "Описание задачи не может быть пустым";
            }

            return(RedirectToAction("TextDetails", new { jobId = taskResult }));
        }
Example #4
0
        public async Task <IActionResult> SubmitFormAsync(string taskDescription)
        {
            string taskResult = String.Empty;

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);

            try
            {
                var reply = await client.RegisterAsync(
                    new RegisterRequest { Description = taskDescription });

                taskResult         = reply.Id;
                ViewBag.TaskResult = "Задача создана с идентификатором: " + taskResult;
            }
            catch (RpcException)
            {
                ViewBag.TaskResult = "Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение";
            }
            catch (ArgumentNullException)
            {
                ViewBag.TaskResult = "Описание задачи не может быть пустым";
            }

            return(View());
        }
Example #5
0
        public async Task <RedirectToActionResult> GetID(string description, string data)
        {
            using var channel = GrpcChannel.ForAddress("http://" + Environment.GetEnvironmentVariable("API_HOST"));
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = description, Data = data });

            return(RedirectToAction("Index", "Task", new { JobId = reply.Id }));
        }
Example #6
0
 public async Task<IActionResult> GetID(string description)
 {
     using var channel = GrpcChannel.ForAddress("http://" + Environment.GetEnvironmentVariable("HOST") + ":5000");
     var client = new Job.JobClient(channel);
     var reply = await client.RegisterAsync(
                       new RegisterRequest { Description = description });
     return View("Task", new ViewModel { RequestId = reply.Id });
 }
Example #7
0
        public async Task <IActionResult> RegisterJob([Bind("Description")] RegisterRequest request)
        {
            using var channel = GrpcChannel.ForAddress("http://localhost:" + _configuration["port"]);
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(request);

            return(View("JobId", reply));
        }
Example #8
0
        public async Task <RedirectToActionResult> HandleFormSubmit(string description, string text)
        {
            using var channel = GrpcChannel.ForAddress("http://" + Environment.GetEnvironmentVariable("BACKEND_API_HOST") + ":5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = description, Data = text });

            return(RedirectToAction("Index", "TaskDetails", new { JobId = reply.Id }));
        }
Example #9
0
        public async Task <IActionResult> HandleFormSubmit(String description)
        {
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = description });

            return(View("Task", new TaskViewModel {
                Id = reply.Id
            }));
        }
Example #10
0
        public async Task <IActionResult> HandleFormSubmit(String description)
        {
            using var channel = GrpcChannel.ForAddress("http://" + Environment.GetEnvironmentVariable("BACKEND_API_HOST") + ":5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = description });

            return(View("Task", new TaskViewModel {
                Id = reply.Id
            }));
        }
Example #11
0
        static async Task Main(string[] args)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = "This is job" });

            Console.WriteLine("Job Id: " + reply.Id);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
Example #12
0
        async public Task <IActionResult> HandleAddTaskRequest(String description)
        {
            using var channel = GrpcChannel.ForAddress("http://" + Environment.GetEnvironmentVariable("BACKEND_API_HOST") + ":" + Environment.GetEnvironmentVariable("BACKEND_API_PORT"));
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = description });

            ViewBag.Id          = reply.Id;
            ViewBag.Description = description;

            return(View("Task"));
        }
Example #13
0
        async public Task <IActionResult> HandleAddTaskRequest(String description)
        {
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(new RegisterRequest { Description = description });

            ViewBag.Id          = reply.Id;
            ViewBag.Description = description;

            return(View("Task"));
        }
Example #14
0
        public async Task <IActionResult> OnPostAsync(string description)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5005");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(
                new RegisterRequest { Description = description });

            TaskId = reply.Id;
            return(Page());
        }
Example #15
0
        public async Task <ActionResult> Create(string JobText)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(
                new RegisterRequest { Description = JobText });

            var text = "Job Id: " + reply.Id + " Job Description: " + JobText;

            return(Ok(text));
        }
Example #16
0
        public async Task <IActionResult> OnPostAsync(string description)
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            var config = new ConfigurationBuilder()
                         .SetBasePath(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName + "/config")
                         .AddJsonFile("config.json", optional: false)
                         .Build();

            using var channel = GrpcChannel.ForAddress($"http://localhost:{config.GetValue<int>("BackendAPI:port")}");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(
                new RegisterRequest { Description = description });

            TaskId = reply.Id;
            return(Page());
        }
            public async Task <IActionResult> FormSubmit(String description)
            
        {
            if (description == null)
            {
                return(View("Error", new ErrorViewModel()));
            }
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client   = new Job.JobClient(channel);
            var response = await client.RegisterAsync(new RegisterRequest { Description = description });

            return(View("Task", new TaskViewModel {
                Id = response.Id
            }));

                
        }
Example #18
0
        public async Task <IActionResult> HandleFormSubmit(String description, String data)
        {
            if (description == null)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = "Description can't be empty"
                }));
            }
            try {
                using var channel = GrpcChannel.ForAddress("http://localhost:" + _configuration["BackendApiPort"]);
                var client = new Job.JobClient(channel);
                var reply  = await client.RegisterAsync(new RegisterRequest { Description = description, Data = data });

                return(RedirectToAction("Index", "TaskDetails", new { JobId = reply.Id }));
            } catch (Grpc.Core.RpcException ex) {
                return(View("Error", new ErrorViewModel {
                    RequestId = ex.Message
                }));
            }
        }
Example #19
0
        public async Task <IActionResult> GetTask(string taskDescription, string data)
        {
            if (taskDescription == null)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = "No Task"
                }));
            }

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client             = new Job.JobClient(channel);
            RegisterResponse reply = await client.RegisterAsync(
                new RegisterRequest { Description = taskDescription, Data = data });

            Riderct id = new Riderct {
                Resp = reply.Id
            };

            return(RedirectToAction("TextDetails", id));
        }
Example #20
0
        public async Task <IActionResult> GetTask(String taskDescription)
        {
            if (taskDescription == null)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = "No Task"
                }));
            }
            string taskResult;

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(
                new RegisterRequest { Description = taskDescription });

            taskResult             = reply.Id;
            ViewData["TaskResult"] = taskResult;

            return(View());
        }
Example #21
0
        public async Task <IActionResult> SendRequestAsync(string requestDescription)
        {
            if (requestDescription == null)
            {
                ViewBag.TaskResult = "Отправлен пустой запрос";
                return(View());
            }

            string taskResult = "";

            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.RegisterAsync(
                new RegisterRequest { Description = requestDescription });

            taskResult         = reply.Id;
            ViewBag.TaskResult = taskResult;

            return(View());
        }
            public async Task <IActionResult> FormSubmit(String description)
            
        {
            if (description == null)
            {
                return(View("Error", new ErrorViewModel()));
            }

            string backendProtocol = Environment.GetEnvironmentVariable("BACKEND_PROTOCOL");
            string backendHost     = Environment.GetEnvironmentVariable("BACKEND_HOST");
            string backendPort     = Environment.GetEnvironmentVariable("BACKEND_PORT");

            using var channel = GrpcChannel.ForAddress(string.Format("{0}://{1}:{2}", backendProtocol, backendHost, backendPort));
            var client   = new Job.JobClient(channel);
            var response = await client.RegisterAsync(new RegisterRequest { Description = description });

            return(View("Task", new TaskViewModel {
                Id = response.Id
            }));

                
        }
Example #23
0
        public async Task <IActionResult> HandleFormSubmit(String description)
        {
            if (description == null)
            {
                return(View("Error", new ErrorViewModel {
                    RequestId = "Description can't be empty"
                }));
            }
            try {
                using var channel = GrpcChannel.ForAddress("http://localhost:" + _configuration["port"]);
                var client = new Job.JobClient(channel);
                var reply  = await client.RegisterAsync(new RegisterRequest { Description = description });

                return(View("Task", new TaskViewModel {
                    Id = reply.Id
                }));
            } catch (Grpc.Core.RpcException ex) {
                return(View("Error", new ErrorViewModel {
                    RequestId = ex.Message
                }));
            }
        }