public IActionResult Download(Guid id) { var conexao = _conexaoRepository.Find(id); if (conexao == null) { return(NotFound()); } else { //Verifica se há inconsistência nos dados IniFileAssertion iniFileAssertion = new IniFileAssertion(conexao.Usuario, conexao.Senha); if (iniFileAssertion.Notifications.HasNotifications()) { Response.StatusCode = Microsoft.AspNetCore.Http.StatusCodes.Status500InternalServerError; return(new ObjectResult(iniFileAssertion.Notifications.Notify())); } } var stream = _conexaoRepository.DownloadIniFile(conexao.Usuario, conexao.Senha); var response = File(stream, "text/plain"); // FileStreamResult return(response); }
/*public override async Task OnConnectedAsync() * { * //await Clients.Client(Context.ConnectionId).InvokeAsync("SetUsersOnline", await GetUsersOnline()); * * await base.OnConnectedAsync(); * }*/ public async Task GetStatusDB(Guid id) { Models.Conexao conexao = _userRepository.Find(id); if (conexao != null) { TestConnectionAssertion testConnectionAssertion = new TestConnectionAssertion( conexao.Ip, conexao.Porta, conexao.NomeServidor, conexao.Usuario, conexao.Senha ); if (!testConnectionAssertion.Notifications.HasNotifications()) { string connectionString = Utils.Connection.GetConnectionString(conexao); string status = Utils.Connection.TestConnection(connectionString, _configuration["UrlStatusDb"]); conexao.DataStatus = DateTime.Now; conexao.Status = status; _userRepository.Update(conexao); await Clients.All.InvokeAsync("StatusDBResponse", conexao.Id, conexao.Status, conexao.DataStatus.ToString()); } } }