示例#1
0
        public AdminUrl(int urlId, int processAgentId, string url, string ticketType)
        {
            if (!TicketTypes.TicketTypeExists(ticketType))
                throw new Exception("\"" + ticketType + "\" is not a legal ticket type.");

            this.id = urlId;
            this.processAgentId = processAgentId;
            this.url = url;
            this.ticketType = TicketTypes.GetTicketType(ticketType);
        }
示例#2
0
        /// <summary>
        /// Retrieve all the ticket types present in the DB
        /// </summary>
        /// <returns>Array of ticket type objects</returns>
        public TicketType[] RetrieveTicketTypes()
        {
            ArrayList ticketTypesList = new ArrayList();
            TicketType ticketType = null;

            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            // create sql command
            // command executes the "RetrieveTicketsByType" stored procedure
            DbCommand cmd = connection.CreateCommand();
            cmd.CommandText = "RetrieveTicketTypes";
            cmd.CommandType = CommandType.StoredProcedure;

            // execute the command
            DbDataReader dataReader = null;
            try
            {
                connection.Open();
                dataReader = cmd.ExecuteReader();

                while (dataReader.Read())
                {
                    ticketType = new TicketType();
                    // read ticket type id
                    ticketType.ticketTypeId = (int)dataReader.GetInt32(0);
                    // read ticket type name
                    ticketType.name = dataReader.GetString(1);
                    // read ticket type short description
                    ticketType.shortDescription = dataReader.GetString(2);
                    // read abstact
                    ticketType.isAbstract = dataReader.GetBoolean(3);

                    // add to tickets list
                    ticketTypesList.Add(ticketType);
                }
            }
            catch (DbException e)
            {
                writeEx(e);
                throw;
            }

            finally
            {
                connection.Close();
            }

            // sort list in ascending order of ticket short description
            ticketTypesList.Sort(new TicketTypeComparer());

            // create array from list
            TicketType[] ticketTypes = (TicketType[])ticketTypesList.ToArray(ticketType.GetType());
            return ticketTypes;
        }