Exemplo n.º 1
0
        public override UserSchemaCollection GetUsers()
        {
            UserSchemaCollection users = new UserSchemaCollection();

            using (IPooledDbConnection conn = connectionPool.Request()) {
                using (IDbCommand command = conn.CreateCommand(@"SELECT DISTINCT user 
																from mysql.user where user != '';"                                                                )) {
                    try {
                        using (IDataReader r = command.ExecuteReader()) {
                            while (r.Read())
                            {
                                UserSchema user = new UserSchema(this);
                                user.Name = r.GetString(0);
                                users.Add(user);
                            }
                            r.Close();
                        }
                    } catch (Exception e) {
                        QueryService.RaiseException(e);
                    } finally {
                        conn.Release();
                    }
                }
            }
            return(users);
        }
        public void Initialize(NpgsqlSchemaProvider provider)
        {
            UserSchemaCollection       users       = provider.GetUsers();
            DatabaseSchemaCollection   databases   = provider.GetDatabases();
            NpgsqlEncodingCollection   encodings   = provider.GetEncodings();
            NpgsqlTablespaceCollection tablespaces = provider.GetTablespaces();

            foreach (UserSchema user in users)
            {
                ownersStore.AppendValues(user.Name, user);
            }

            foreach (DatabaseSchema db in databases)
            {
                templatesStore.AppendValues(db.Name, db);
            }

            foreach (NpgsqlEncoding enc in encodings)
            {
                StringBuilder encName = new StringBuilder(enc.Name);
                encName.AppendFormat(" - {0} - {1}", enc.Description, enc.Language);
                if (enc.Aliases != string.Empty)
                {
                    encName.AppendFormat(" ({0})", enc.Aliases);
                }
                encodingsStore.AppendValues(encName.ToString(), enc);
            }

            foreach (NpgsqlTablespace ts in tablespaces)
            {
                tablespacesStore.AppendValues(ts.Name, ts);
            }
        }
        private void BuildChildNodesThreaded(object state)
        {
            BaseNode     node    = state as BaseNode;
            ITreeBuilder builder = Context.GetTreeBuilder(state);

            UserSchemaCollection users = node.ConnectionContext.SchemaProvider.GetUsers();

            DispatchService.GuiDispatch(delegate {
                foreach (UserSchema user in users)
                {
                    builder.AddChild(new UserNode(node.ConnectionContext, user));
                }
                builder.Expanded = true;
            });
        }
 public override UserSchemaCollection GetUsers()
 {
     Console.WriteLine("start GetUsers");
     UserSchemaCollection users = new UserSchemaCollection ();
     /*
     using (IPooledDbConnection conn = connectionPool.Request ()) {
         Console.WriteLine("conn:"+conn.ToString());
         MongoDbConnection connection = (MongoDbConnection) conn.DbConnection;
         MongoCredentials cr = connection.getDataBaseCredentials();
         Console.WriteLine("trace cr:" + cr.ToString());
         if(cr != null) {
             UserSchema user = new UserSchema (this);
             user.Name = cr.Username;
             users.Add (user);
         }
     }
     */
     return users;
 }
		public override UserSchemaCollection GetUsers ()
		{
			UserSchemaCollection users = new UserSchemaCollection ();

			using (IPooledDbConnection conn = connectionPool.Request ()) {
				using (IDbCommand command = conn.CreateCommand (@"SELECT DISTINCT user 
																from mysql.user where user != '';")) {
					try {
						using (IDataReader r = command.ExecuteReader ()) {
							while (r.Read ()) {
								UserSchema user = new UserSchema (this);
								user.Name = r.GetString (0);
								users.Add (user);
							}
							r.Close ();
						}
					} catch (Exception e) {
						QueryService.RaiseException (e);
					} finally {
						conn.Release ();
					}					
				}
			}
			return users;
		}
Exemplo n.º 6
0
		public override UserSchemaCollection GetUsers ()
		{
			UserSchemaCollection users = new UserSchemaCollection ();
			using (IPooledDbConnection conn = connectionPool.Request ()) {
				using (IDbCommand command = conn.CreateCommand ("SELECT * FROM pg_user;")) {
					try {
						using (IDataReader r = command.ExecuteReader ()) {
							while (r.Read ()) {
								UserSchema user = new UserSchema (this);
								
								user.Name = r.GetString (0);
								user.UserId = String.Format ("{0}", r.GetValue (1));
								user.Expires = r.IsDBNull (6) ? DateTime.MinValue : r.GetDateTime (6);
								user.Password = r.GetString (5);
								
								StringBuilder sb = new StringBuilder ();
								sb.AppendFormat ("-- User: \"{0}\"\n\n", user.Name);
								sb.AppendFormat ("-- DROP USER {0};\n\n", user.Name);
								sb.AppendFormat ("CREATE USER {0}", user.Name);
								sb.AppendFormat ("  WITH SYSID {0}", user.UserId);
								if (user.Password != "********")
									sb.AppendFormat (" ENCRYPTED PASSWORD {0}", user.Password);
								if (user.Expires != DateTime.MinValue)
									sb.AppendFormat (" VALID UNTIL {0}", user.Expires);
								sb.Append (";");
								user.Definition = sb.ToString ();
								users.Add (user);
							}
							r.Close ();
						}
					} catch (Exception e) {
						QueryService.RaiseException (e);
					} finally {
						conn.Release ();
					}				
				}
			}
			return users;
		public virtual UserSchemaCollection GetUsers ()
		{
			UserSchemaCollection collection = new UserSchemaCollection ();
			
			IPooledDbConnection conn = connectionPool.Request ();
			try {
				//restrictions: name
				DataTable dt = conn.GetSchema (usersCollectionString);
				for (int r = 0; r < dt.Rows.Count; r++) {
					DataRow row = dt.Rows[r];
					collection.Add (GetUser (row));
				}
			} catch (Exception e) {
				QueryService.RaiseException (e);
			}
			conn.Release ();
			
			return collection;
		}