Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Host")] CustomConnection customConnection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customConnection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customConnection));
        }
Exemplo n.º 3
0
        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));
        }