示例#1
0
        protected override IList <TreeNodeBase> GetNodes()
        {
            var nodes           = new List <TreeNodeBase>();
            var schemasTreeNode = new SchemasTreeNode(DatabaseConnection, DatabaseInstance);

            nodes.Add(schemasTreeNode);

            return(nodes);

            //try
            //{


            //    var actionName = string.Format("Attempting to connect to {0} ...", DatabaseConnection.Name);
            //    _log.Debug(actionName);
            //    using (new WaitActionStatus(actionName))
            //    {
            //        _log.DebugFormat("Creating connection for {0} ...", DatabaseConnection.Name);
            //        using (var connection = DatabaseConnection.CreateNewConnection())
            //        {
            //            connection.OpenIfRequired();
            //            DatabaseConnection.Connect();
            //            _log.Debug("Connection is successful.");
            //            _log.Debug("Loading schemas ...");
            //            var infoProvider = DatabaseConnection.DatabaseServer.GetInfoProvider();
            //            Schemas.Clear();
            //            Schemas.AddRange(infoProvider.GetSchemas(connection));
            //            _log.DebugFormat("Loaded {0} schema(s).", Schemas.Count);

            //            _log.Debug("Creating nodes ...");
            //            var schemNodes =
            //                Schemas.Select(schema => new Db2SchemaTreeNode(schema, DatabaseConnection)).Cast<TreeNodeBase>().ToList();
            //            _log.Debug("Loading nodes finished.");
            //            return schemNodes;
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    DatabaseConnection.Disconnect();
            //    _log.ErrorFormat("Error opening connection and loading data.");
            //    _log.Error(ex.Message, ex);
            //    throw;
            //}
        }
        protected override IList <TreeNodeBase> GetNodes()
        {
            var nodes           = new List <TreeNodeBase>();
            var schemasTreeNode = new SchemasTreeNode(DatabaseConnection, DatabaseInstance);

            nodes.Add(schemasTreeNode);
            return(nodes);
//            try
//            {
//                var actionName = string.Format("Fetching databases for {0} ...", DatabaseConnection.Name);
//                using (new WaitActionStatus(actionName))
//                {
//                    using (var connection = DatabaseConnection.CreateNewConnection())
//                    {
//                        connection.OpenIfRequired();
//                        DatabaseConnection.Connect();
//                        _log.Debug("Connection is successful.");
//                        _log.Debug("Loading database instances ...");
//                        var infoProvider = DatabaseConnection.DatabaseServer.GetInfoProvider();
//                        var schemas = infoProvider.GetSchemas(connection, DatabaseInstance.Name);
//                        foreach (var schema in schemas)
//                        {
//                            schema.Parent = DatabaseInstance;
//                        }
//                        _log.DebugFormat("Loaded {0} database instance(s).", schemas.Count);
//
//                        _log.Debug("Creating nodes ...");
//                        var schemNodes =
//                            schemas.Select(schema => new SqlServerSchemaTreeNode(schema, DatabaseConnection, DatabaseInstance)).Cast<TreeNodeBase>().ToList();
//                        _log.Debug("Loading nodes finished.");
//                        return schemNodes;
//                    }
//                }
//            }
//            catch (Exception ex)
//            {
//                DatabaseConnection.Disconnect();
//                _log.ErrorFormat("Error fetching databases for {0}.", DatabaseConnection.Name);
//                _log.Error(ex.Message, ex);
//                throw;
//            }
        }