public PendingChange [] GetPendingChanges(string login, string password)
        {
            IDbConnection conn = GetConnection();

            conn.Open();

            try
            {
                if (!IsAdmin(conn, login, password))
                {
                    return(new PendingChange [0]);
                }

                IDbCommand cmd     = conn.CreateCommand();
                ArrayList  results = new ArrayList();
                cmd.CommandText = "select status.person_id, serial, person.name from status, person where status=0 and person.person_id = status.person_id";
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        results.Add(new PendingChange((string)reader ["name"], (int)reader ["person_id"], (int)reader ["serial"]));
                    }
                }

                PendingChange [] ret = new PendingChange [results.Count];
                results.CopyTo(ret);
                return(ret);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
                return(null);
            }
            finally
            {
                conn.Close();
            }
        }
Beispiel #2
0
		public PendingChange [] GetPendingChanges (string login, string password)
		{
			IDbConnection conn = GetConnection();
			conn.Open ();
			
			try {
				if (!IsAdmin (conn, login, password)){
					return new PendingChange [0];
				}
				
				IDbCommand cmd = conn.CreateCommand();
				ArrayList results = new ArrayList ();
				cmd.CommandText = "select status.person_id, serial, person.name from status, person where status=0 and person.person_id = status.person_id";
				using (IDataReader reader = cmd.ExecuteReader ()){
					while (reader.Read ()){
						results.Add (new PendingChange ((string) reader ["name"], (int) reader ["person_id"], (int) reader ["serial"]));
					}
				}

				PendingChange [] ret = new PendingChange [results.Count];
				results.CopyTo (ret);
				return ret;
			} catch (Exception e){
				Console.Error.WriteLine (e);
				return null;
			} finally {
				conn.Close ();
			}
		}