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 })); }
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)); }
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 })); }
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 }); }
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)); }
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 })); }
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 })); }
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 })); }
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 })); }
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 })); }
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(); }
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")); }
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")); }
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()); }
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)); }
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)); }
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")); }
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()); }
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 })); }
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 })); } }
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()); }
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()); }
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> 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 })); }
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 })); } }