Ejemplo n.º 1
0
        public AdminUrl[] RetrieveAdminURLs(DbConnection connection, int processAgentID)
        {
            // create sql command
            // command executes the "RetrieveAdminURLs" stored procedure
            DbCommand cmd = FactoryDB.CreateCommand("AdminURLs_Retrieve", connection);
            cmd.CommandType = CommandType.StoredProcedure;

            // populate parameters
            cmd.Parameters.Add(FactoryDB.CreateParameter( "@processAgentID", processAgentID, DbType.Int32));

            // read the result
            ArrayList list = new ArrayList();
            DbDataReader dataReader = cmd.ExecuteReader();
            try
            {
                while (dataReader.Read())
                {
                    int id = (int)dataReader.GetInt32(0);
                    processAgentID = (int)dataReader.GetInt32(1);
                    string url = dataReader.GetString(2).Trim();
                    string ticketType = dataReader.GetString(3);

                    list.Add(new AdminUrl(id, processAgentID, url, ticketType));
                }
                dataReader.Close();
            }
            catch (DbException e)
            {
                Console.WriteLine(e);
                throw;
            }

            finally
            {
                // close the sql connection
                connection.Close();
            }

            AdminUrl dummy = new AdminUrl();
            AdminUrl[] urls = (AdminUrl[])list.ToArray(dummy.GetType());
            return urls;
        }
Ejemplo n.º 2
0
        public void DeleteAdminURL(AdminUrl adminURL)
        {
            if (!TicketTypes.TicketTypeExists(adminURL.TicketType.name))
                throw new Exception("\"" + adminURL.TicketType.name + "\" is not a valid ticket type.");
            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            try
            {
                connection.Open();
                DeleteAdminURL(connection, adminURL.ProcessAgentId, adminURL.Url, adminURL.TicketType.name);
            }

            catch (DbException e)
            {
                writeEx(e);
                throw;
            }

            finally
            {
                connection.Close();
            }
        }
Ejemplo n.º 3
0
 protected void repAdminURLs_ItemBound(object source, RepeaterItemEventArgs e)
 {
     if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
     {
         // get the current grant
         Object o = e.Item.DataItem;
         curAdminURL = (AdminUrl)o;
         Button curBtn = (Button)e.Item.FindControl("btnRemove");
         curBtn.CommandArgument = ((AdminUrl)o).Id.ToString();
     }
 }