Ejemplo n.º 1
0
        public async Task <IActionResult> GetSqlTree([FromBody] Req <SqlSearchDto> request)
        {
            request.Data.AdminId = request.OperatorId;
            try {
                if (string.IsNullOrEmpty(request.Data.SearchType))
                {
                    var connDtos = await _sqlOnlineApplication.GetConnList(request.Data);

                    return(LayuiSuccess(GetSqlTree(connDtos, request.Data), request.PasswordString));
                }
                else if (request.Data.SearchType == "GetDatabaseNames")
                {
                    var databaseEntities = await _sqlOnlineApplication.GetDatabaseNames(request.Data);

                    return(LayuiSuccess(GetSqlTree(databaseEntities, request.Data), request.PasswordString));
                }
                else if (request.Data.SearchType == "GetTableNames")
                {
                    var tableEntities = await _sqlOnlineApplication.GetTableNames(request.Data);

                    return(LayuiSuccess(GetSqlTree(tableEntities, request.Data), request.PasswordString));
                }
                else if (request.Data.SearchType == "GetViewNames")
                {
                    var viewEntities = await _sqlOnlineApplication.GetViewNames(request.Data);

                    return(LayuiSuccess(GetSqlTree(viewEntities, request.Data), request.PasswordString));
                }
                else if (request.Data.SearchType == "GetProcedureNames")
                {
                    var procedureEntities = await _sqlOnlineApplication.GetProcedureNames(request.Data);

                    return(LayuiSuccess(GetSqlTree(procedureEntities, request.Data), request.PasswordString));
                }
                else if (request.Data.SearchType == "GetFunctionNames")
                {
                    var functionEntities = await _sqlOnlineApplication.GetFunctionNames(request.Data);

                    return(LayuiSuccess(GetSqlTree(functionEntities, request.Data), request.PasswordString));
                }
            } catch (Exception ex) {
                LogUtil.Error(ex);
            }
            return(LayuiError("系统出了个小差!"));
        }
        public async Task <IActionResult> OnGet(int sqlConnId, string databaseName)
        {
            ConnId       = sqlConnId;
            DatabaseName = databaseName;
            SqlSearchDto search = new SqlSearchDto()
            {
                AdminId   = AdminDto.Id,
                SqlConnId = sqlConnId,
                Database  = databaseName,
            };

            DatabaseEntities = await _sqlOnlineApplication.GetDatabaseNames(search);

            if (string.IsNullOrEmpty(DatabaseName))
            {
                if (DatabaseEntities.Count > 0)
                {
                    DatabaseName = DatabaseEntities[0].DatabaseName;
                }
            }
            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(int sqlConnId = 0, string database = null)
        {
            if (sqlConnId <= 0)
            {
                return(Redirect("/NotFound"));
            }
            ConnId           = sqlConnId;
            DatabaseName     = database;
            DatabaseEntities = await _sqlOnlineApplication.GetDatabaseNames(new Dtos.SqlSearchDto()
            {
                AdminId = AdminDto.Id, SqlConnId = sqlConnId
            });

            if (string.IsNullOrEmpty(DatabaseName))
            {
                if (DatabaseEntities.Count > 0)
                {
                    DatabaseName = DatabaseEntities[0].DatabaseName;
                }
            }
            return(Page());
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> OnGet(string action, int id, int sqlConnId, string database, string schema, string name)
        {
            ConnId       = sqlConnId;
            DatabaseName = database;
            SqlSearchDto search = new SqlSearchDto()
            {
                AdminId   = AdminDto.Id,
                SqlConnId = sqlConnId,
                Database  = database,
                Schema    = schema,
                Search    = name
            };
            SqlEditorDto r = null;

            if (action == "new")
            {
                r = await _sqlOnlineApplication.GetSql_New(search);
            }
            else if (action == "TableSelect100")
            {
                r = await _sqlOnlineApplication.GetSql_TableSelect100(search);
            }
            else if (action == "TableInsertSql")
            {
                r = await _sqlOnlineApplication.GetSql_TableInsert(search);
            }
            else if (action == "TableUpdateSql")
            {
                r = await _sqlOnlineApplication.GetSql_TableUpdate(search);
            }
            else if (action == "TableDeleteSql")
            {
                r = await _sqlOnlineApplication.GetSql_TableDelete(search);
            }
            else if (action == "ViewSelect100")
            {
                r = await _sqlOnlineApplication.GetSql_ViewSelect100(search);
            }
            else if (action == "ViewCreateSql")
            {
                r = await _sqlOnlineApplication.GetSql_ViewCreate(search);
            }
            else if (action == "ViewAlterSql")
            {
                r = await _sqlOnlineApplication.GetSql_ViewAlter(search);
            }
            else if (action == "FunctionSelectSql")
            {
                r = await _sqlOnlineApplication.GetSql_FunctionSelectSql(search);
            }
            else if (action == "FunctionCreateSql")
            {
                r = await _sqlOnlineApplication.GetSql_FunctionCreate(search);
            }
            else if (action == "FunctionAlterSql")
            {
                r = await _sqlOnlineApplication.GetSql_FunctionAlter(search);
            }
            else if (action == "ProcedureExecuteSql")
            {
                r = await _sqlOnlineApplication.GetSql_ProcedureExecuteSql(search);
            }
            else if (action == "ProcedureCreateSql")
            {
                r = await _sqlOnlineApplication.GetSql_ProcedureCreate(search);
            }
            else if (action == "ProcedureAlterSql")
            {
                r = await _sqlOnlineApplication.GetSql_ProcedureAlter(search);
            }
            else if (action == "openDoc")
            {
                var sqlDoc = await _sqlOnlineApplication.GetSelfSqlDoc(AdminDto.Id, id);

                if (sqlDoc == null)
                {
                    return(Redirect(UrlSetting.NotFoundUrl));
                }
                await _sqlOnlineApplication.OpenSqlDoc(AdminDto.Id, id);

                DocId            = sqlDoc.SqlDocId;
                Title            = sqlDoc.Title;
                SqlString        = sqlDoc.Content;
                DatabaseName     = sqlDoc.DatabaseName;
                ConnId           = sqlDoc.SqlConnId;
                search.SqlConnId = sqlDoc.SqlConnId;
                r = _sqlOnlineApplication.GetSql_New(sqlDoc.SqlType);
            }
            else if (action == "openDocTemp")
            {
                var sqlDoc = await _sqlOnlineApplication.GetSelfSqlDocTemp(AdminDto.Id, id);

                if (sqlDoc == null)
                {
                    return(Redirect(UrlSetting.NotFoundUrl));
                }
                TempId           = sqlDoc.Id;
                DocId            = sqlDoc.SqlDocId;
                Title            = sqlDoc.Title;
                SqlString        = sqlDoc.Content;
                DatabaseName     = sqlDoc.DatabaseName;
                ConnId           = sqlDoc.SqlConnId;
                search.SqlConnId = sqlDoc.SqlConnId;
                r = _sqlOnlineApplication.GetSql_New(sqlDoc.SqlType);
            }
            else if (action == "openDocShare")
            {
                var sqlDoc = await _sqlOnlineApplication.GetShareSqlDoc(AdminDto.Id, id);

                if (sqlDoc == null)
                {
                    return(Redirect(UrlSetting.NotFoundUrl));
                }
                Title            = sqlDoc.Title;
                SqlString        = sqlDoc.Content;
                DatabaseName     = sqlDoc.DatabaseName;
                ConnId           = sqlDoc.SqlConnId;
                search.SqlConnId = sqlDoc.SqlConnId;
                r = _sqlOnlineApplication.GetSql_New(sqlDoc.SqlType);
            }
            if (r == null)
            {
                return(Redirect(UrlSetting.NotFoundUrl));
            }
            JsMode = r.JsMode;
            if (string.IsNullOrEmpty(SqlString))
            {
                SqlString = r.SqlString;
            }


            DatabaseEntities = await _sqlOnlineApplication.GetDatabaseNames(search);

            if (string.IsNullOrEmpty(DatabaseName))
            {
                if (DatabaseEntities.Count > 0)
                {
                    DatabaseName = DatabaseEntities[0].DatabaseName;
                }
            }
            return(Page());
        }