Example #1
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 #2
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());
        }
        public async Task <IActionResult> FormSubmit(RegisterRequest request)
        {
            var client   = new Job.JobClient(_channel);
            var response = await client.RegisterAsync(request);

            return(RedirectToAction("TextDetails", response));
        }
Example #4
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 #5
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 #6
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 #7
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 #8
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 #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> Index(string JobId)
        {
            using var channel = GrpcChannel.ForAddress("http://localhost:" + _configuration["BackendApiPort"]);
            var client = new Job.JobClient(channel);
            var reply  = await client.GetProcessingResultAsync(new RegisterResponse { Id = JobId });

            return(View("Task", new TaskViewModel {
                Rank = reply.Response, Status = reply.Status, Id = JobId
            }));
        }
Example #11
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
            }));
        }
        public async Task <IActionResult> Index(string JobId)
        {
            using var channel = GrpcChannel.ForAddress("http://" + Environment.GetEnvironmentVariable("BACKEND_API_HOST") + ":5000");
            var client = new Job.JobClient(channel);
            var reply  = await client.GetProcessingResultAsync(new GetProcessingResultRequest { Id = JobId });

            return(View("Task", new TaskViewModel {
                Id = JobId, Rank = reply.Rank, Status = reply.Status
            }));
        }
Example #13
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 #14
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 #15
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 #16
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 #17
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));
        }
        public IActionResult TextDetails(RegisterResponse response)
        {
            var client           = new Job.JobClient(_channel);
            var processingResult = client.GetProcessingResult(response);

            var textDetails = new TextDetailsViewModel
            {
                Status = processingResult.Status,
                Rank   = processingResult.Rank
            };

            return(View("TextDetails", textDetails));
        }
Example #19
0
        public IActionResult TextDetails(Riderct id)
        {
            RegisterResponse reply = new RegisterResponse {
                Id = id.Resp
            };


            using var channel = GrpcChannel.ForAddress("http://localhost:5000");
            var client = new Job.JobClient(channel);
            var repl   = client.GetProcessingResult(reply);

            return(View("GetTask", repl));
        }
Example #20
0
        public async Task <IActionResult> Index(string JobId)
        {
            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.GetProcessingResultAsync(new GetProcessingResultRequest { Id = JobId });

            ViewBag.Id          = JobId;
            ViewBag.Text        = reply.Text;
            ViewBag.Description = reply.Description;
            ViewBag.Rank        = reply.Rank;
            ViewBag.Status      = reply.Status;

            return(View("Task"));
        }
Example #21
0
        public async Task <IActionResult> OnGetAsync()
        {
            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")}");
            string taskId = HttpContext.Request.Query["jobId"].ToString();
            var    client = new Job.JobClient(channel);
            var    reply  = await client.GetProcessingResultAsync(new RegisterResponse { Id = taskId });

            Rating = reply.Response;
            return(Page());
        }
Example #22
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 #24
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 #25
0
        public async Task <IActionResult> TextDetailsAsync(string jobId)
        {
            string status = String.Empty;

            using var channel = GrpcChannel.ForAddress($"http://localhost:{_config.GetValue<int>("BackendApiPort")}");
            var client = new Job.JobClient(channel);

            try
            {
                var reply = await client.GetProcessingResultAsync(new GetProcessingResultRequest { Id = jobId });

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

            return(View());
        }
Example #26
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 #27
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());
        }
Example #28
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));
        }
            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 #30
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
                }));
            }
        }