Profiles.Edit.Utilities.DataIO.GetPubs C# (CSharp) Method

GetPubs() public method

public GetPubs ( int personid ) : List
personid int
return List
        public List<PublicationState> GetPubs(int personid)
        {
            SessionManagement sm = new SessionManagement();
            string connstr = ConfigurationManager.ConnectionStrings["ProfilesDB"].ConnectionString;

            SqlConnection dbconnection = new SqlConnection(connstr);
            SqlDataReader reader;

            SqlParameter[] param = null;
            List<PublicationState> pubs = new List<PublicationState>();
            string rownum = string.Empty;
            string reference = string.Empty;
            Int32 pmid = 0;
            string mpid = string.Empty;
            string category = string.Empty;
            string url = string.Empty;
            string pubdate = string.Empty;
            string frompubmed = string.Empty;

            try
            {

                dbconnection.Open();

                //For Output Parameters you need to pass a connection object to the framework so you can close it before reading the output params value.
                reader = GetDBCommand(dbconnection, "exec [Profile.Data].[Publication.GetPersonPublications] " + personid.ToString(), CommandType.Text, CommandBehavior.CloseConnection, param).ExecuteReader();

                while (reader.Read())
                {
                    rownum = reader["rownum"].ToString();
                    reference = reader["reference"].ToString();
                    if (reader["pmid"] != DBNull.Value)
                        pmid = Convert.ToInt32(reader["pmid"].ToString());

                    if (reader["pmid"] != DBNull.Value)
                        mpid = reader["mpid"].ToString();

                    if (reader["category"] != DBNull.Value)
                        category = reader["category"].ToString();

                    url = reader["url"].ToString();
                    pubdate = reader["pubdate"].ToString();
                    frompubmed = reader["frompubmed"].ToString();

                    pubs.Add(new PublicationState(rownum,
                        reference,
                        pmid,
                        mpid,
                        category,
                        url,
                        Convert.ToDateTime(pubdate),
                       Convert.ToBoolean(frompubmed)));
                }

                if (!reader.IsClosed)
                    reader.Close();

                if (dbconnection.State != ConnectionState.Closed)
                    dbconnection.Close();

            }
            catch (Exception e)
            {
                Framework.Utilities.DebugLogging.Log(e.Message + e.StackTrace);
                throw new Exception(e.Message);
            }

            return pubs;
        }