public async Task ResetTableMetadata(string connectionName, string tableName) { if (tableName.Equals("undefined")) { return; } var tablemetadata = await GetTableMetadata(connectionName, tableName); if (tablemetadata == null) { tablemetadata = new TableMetadata { Connection = connectionName, TableName = tableName }; } var sequenceList = await GetSequenceList(connectionName); tablemetadata.SequenceName = Util.FindBestMatch(tableName, sequenceList); if (tablemetadata.Id > 0) { _context.Update(tablemetadata); } else { _context.Add(tablemetadata); } await _context.SaveChangesAsync(); }
public async Task <IActionResult> Edit(long id, [Bind("Id,Name,Host")] CustomConnection customConnection) { if (id != customConnection.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customConnection); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomConnectionExists(customConnection.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customConnection)); }
public async Task <IActionResult> AddConnection(CustomConnection connection) { var info = Request.Form["process"]; Console.WriteLine(info); if (info == "test") { var connectionString = Util.GetConnectionString(connection); var oconn = new OracleConnection(connectionString); oconn.Open(); oconn.Dispose(); ViewBag.ConnectionSuccess = "Connection Success"; return(View(connection)); } if (ModelState.IsValid) { var tableList = await _util.GetTableList(connection); var sequenceList = await _util.GetSequenceList(connection); foreach (var table in tableList) { var tablemetadata = await _util.GetTableMetadata(connection.Name, table); if (tablemetadata == null) { tablemetadata = new TableMetadata(); } tablemetadata.Connection = connection.Name; tablemetadata.TableName = table; tablemetadata.SequenceName = Util.FindBestMatch(table, sequenceList); if (tablemetadata.Id > 0) { _context.Update(tablemetadata); } else { _context.Add(tablemetadata); } } if (connection.Id > 0) { _context.Update(connection); } else { _context.Add(connection); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(connection)); }