Beispiel #1
0
        ///<Summary>
        ///Select Latest 10 Mentions
        ///This method returns all data rows in the table TweetMentions
        ///</Summary>
        ///<returns>
        ///IList-DAOTweetMentions.
        ///</returns>
        ///<parameters>
        ///
        ///</parameters>
        public static IList <DAOTweetMentions> SelectDistinctTopics(string userId)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprTweetMentions_SelectDistinctTopics;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("TweetMentions");
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(command);

            try
            {
                command.Parameters.Add(new SqlParameter("@ErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, false, 10, 0, "", DataRowVersion.Proposed, null));
                command.Parameters.Add(new SqlParameter("@UserId", SqlDbType.NVarChar, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)userId ?? (object)DBNull.Value));

                staticConnection.Open();
                sqlAdapter.Fill(dt);

                int errorCode = (Int32)command.Parameters["@ErrorCode"].Value;
                if (errorCode > 1)
                {
                    throw new Exception("procedure ctprTweetMentions_SelectAll returned error code: " + errorCode);
                }

                List <DAOTweetMentions> objList = new List <DAOTweetMentions>();
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        DAOTweetMentions retObj = new DAOTweetMentions();
                        //retObj._id = Convert.IsDBNull(row["Id"]) ? (Int64?)null : (Int64?)row["Id"];
                        //retObj._time = Convert.IsDBNull(row["time"]) ? DateTime.MinValue : (DateTime)row["time"];
                        retObj._topic = Convert.IsDBNull(row["topic"]) ? null : (string)row["topic"];
                        //retObj._count = Convert.IsDBNull(row["count"]) ? (Int64?)null : (Int64?)row["count"];
                        //retObj._avg = Convert.IsDBNull(row["avg"]) ? (double?)null : Math.Round((double)row["avg"], 2);
                        //retObj._min = Convert.IsDBNull(row["min"]) ? (double?)null : (double?)row["min"];
                        //retObj._max = Convert.IsDBNull(row["max"]) ? (double?)null : (double?)row["max"];
                        //retObj._stdev = Convert.IsDBNull(row["stdev"]) ? (double?)null : (double?)row["stdev"];
                        objList.Add(retObj);
                    }
                }
                return(objList);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Beispiel #2
0
        ///<Summary>
        ///Select one row by primary key(s)
        ///This method returns one row from the table TweetMentions based on the primary key(s)
        ///</Summary>
        ///<returns>
        ///DAOTweetMentions
        ///</returns>
        ///<parameters>
        ///Int64? id
        ///</parameters>
        public static DAOTweetMentions SelectOne(Int64?id)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprTweetMentions_SelectOne;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            DataTable      dt         = new DataTable("TweetMentions");
            SqlDataAdapter sqlAdapter = new SqlDataAdapter(command);

            try
            {
                command.Parameters.Add(new SqlParameter("@Id", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 19, 0, "", DataRowVersion.Proposed, (object)id ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@ErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, false, 10, 0, "", DataRowVersion.Proposed, null));

                staticConnection.Open();
                sqlAdapter.Fill(dt);

                int errorCode = (Int32)command.Parameters["@ErrorCode"].Value;
                if (errorCode > 1)
                {
                    throw new Exception("procedure ctprTweetMentions_SelectOne returned error code: " + errorCode);
                }

                DAOTweetMentions retObj = null;
                if (dt.Rows.Count > 0)
                {
                    retObj        = new DAOTweetMentions();
                    retObj._id    = Convert.IsDBNull(dt.Rows[0]["Id"]) ? (Int64?)null : (Int64?)dt.Rows[0]["Id"];
                    retObj._time  = Convert.IsDBNull(dt.Rows[0]["time"]) ? DateTime.MinValue : (DateTime)dt.Rows[0]["time"];
                    retObj._topic = Convert.IsDBNull(dt.Rows[0]["topic"]) ? null : (string)dt.Rows[0]["topic"];
                    retObj._count = Convert.IsDBNull(dt.Rows[0]["count"]) ? (Int64?)null : (Int64?)dt.Rows[0]["count"];
                    retObj._avg   = Convert.IsDBNull(dt.Rows[0]["avg"]) ? (double?)null : (double?)dt.Rows[0]["avg"];
                    retObj._min   = Convert.IsDBNull(dt.Rows[0]["min"]) ? (double?)null : (double?)dt.Rows[0]["min"];
                    retObj._max   = Convert.IsDBNull(dt.Rows[0]["max"]) ? (double?)null : (double?)dt.Rows[0]["max"];
                    retObj._stdev = Convert.IsDBNull(dt.Rows[0]["stdev"]) ? (double?)null : (double?)dt.Rows[0]["stdev"];
                }
                return(retObj);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }
Beispiel #3
0
        ///<Summary>
        ///</Summary>
        ///<returns>
        ///Int32
        ///</returns>
        ///<parameters>
        ///DAOTweetMentions daoTweetMentions
        ///</parameters>
        public static Int32 SelectAllBySearchFieldsCount(DAOTweetMentions daoTweetMentions)
        {
            SqlCommand command = new SqlCommand();

            command.CommandText = InlineProcs.ctprTweetMentions_SelectAllBySearchFieldsCount;
            command.CommandType = CommandType.Text;
            SqlConnection staticConnection = StaticSqlConnection;

            command.Connection = staticConnection;

            try
            {
                command.Parameters.Add(new SqlParameter("@Id", SqlDbType.BigInt, 8, ParameterDirection.Input, false, 19, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Id ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@time", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Time ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@topic", SqlDbType.NVarChar, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Topic ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@count", SqlDbType.BigInt, 8, ParameterDirection.Input, true, 19, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Count ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@avg", SqlDbType.Float, 8, ParameterDirection.Input, true, 53, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Avg ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@min", SqlDbType.Float, 8, ParameterDirection.Input, true, 53, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Min ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@max", SqlDbType.Float, 8, ParameterDirection.Input, true, 53, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Max ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@stdev", SqlDbType.Float, 8, ParameterDirection.Input, true, 53, 0, "", DataRowVersion.Proposed, (object)daoTweetMentions.Stdev ?? (object)DBNull.Value));
                command.Parameters.Add(new SqlParameter("@ErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, false, 10, 0, "", DataRowVersion.Proposed, null));

                staticConnection.Open();
                Int32 retCount = (Int32)command.ExecuteScalar();

                int errorCode = (Int32)command.Parameters["@ErrorCode"].Value;
                if (errorCode > 1)
                {
                    throw new Exception("procedure ctprTweetMentions_SelectAllBySearchFieldsCount returned error code: " + errorCode);
                }

                return(retCount);
            }
            catch
            {
                throw;
            }
            finally
            {
                staticConnection.Close();
                command.Dispose();
            }
        }