///<Summary> ///Select all rows ///This method returns all data rows in the table TweetCount ///</Summary> ///<returns> ///IList-DAOTweetCount. ///</returns> ///<parameters> /// ///</parameters> public static IList <DAOTweetCount> SelectAll(string userId) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprTweetCount_SelectAll; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("TweetCount"); 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 ctprTweetCount_SelectAll returned error code: " + errorCode); } List <DAOTweetCount> objList = new List <DAOTweetCount>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAOTweetCount retObj = new DAOTweetCount(); retObj._id = Convert.IsDBNull(row["Id"]) ? (Int64?)null : (Int64?)row["Id"]; retObj._topic = Convert.IsDBNull(row["Topic"]) ? null : (string)row["Topic"]; retObj._sentimentScore = Convert.IsDBNull(row["SentimentScore"]) ? (Int32?)null : (Int32?)row["SentimentScore"]; retObj._placeTimeZone = Convert.IsDBNull(row["PlaceTimeZone"]) ? null : (string)row["PlaceTimeZone"]; retObj._tweetText = Convert.IsDBNull(row["TweetText"]) ? null : (string)row["TweetText"]; retObj._retweeted = Convert.IsDBNull(row["Retweeted"]) ? (Int32?)null : (Int32?)row["Retweeted"]; retObj._retweetCount = Convert.IsDBNull(row["RetweetCount"]) ? (Int32?)null : (Int32?)row["RetweetCount"]; retObj._createdAt = Convert.IsDBNull(row["CreatedAt"]) ? (DateTime?)null : (DateTime?)row["CreatedAt"]; objList.Add(retObj); } } return(objList); } catch (Exception ex) { throw ex; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///</Summary> ///<returns> ///IList-DAOTweetCount. ///</returns> ///<parameters> ///DAOTweetCount daoTweetCount ///</parameters> public static IList <DAOTweetCount> TweetCountGetTopics() { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprTweetCount_SelectAllTopics; command.CommandType = CommandType.Text; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("TweetCount"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { 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 ctprTweetCount_SelectAllBySearchFields returned error code: " + errorCode); } List <DAOTweetCount> objList = new List <DAOTweetCount>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { DAOTweetCount retObj = new DAOTweetCount(); retObj._topic = Convert.IsDBNull(row["Topic"]) ? null : (string)row["Topic"]; retObj._totalCount = Convert.IsDBNull(row["Count"]) ? (Int32)0 : (Int32)row["Count"]; objList.Add(retObj); } } return(objList); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }
///<Summary> ///</Summary> ///<returns> ///Int32 ///</returns> ///<parameters> ///DAOTweetCount daoTweetCount ///</parameters> public static Int32 SelectAllBySearchFieldsCount(DAOTweetCount daoTweetCount) { SqlCommand command = new SqlCommand(); command.CommandText = InlineProcs.ctprTweetCount_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)daoTweetCount.Id ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Topic", SqlDbType.NVarChar, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.Topic ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@SentimentScore", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.SentimentScore ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@PlaceTimeZone", SqlDbType.NVarChar, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.PlaceTimeZone ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@TweetText", SqlDbType.NVarChar, 4000, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.TweetText ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@Retweeted", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.Retweeted ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@RetweetCount", SqlDbType.Int, 4, ParameterDirection.Input, true, 10, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.RetweetCount ?? (object)DBNull.Value)); command.Parameters.Add(new SqlParameter("@CreatedAt", SqlDbType.DateTime, 8, ParameterDirection.Input, true, 0, 0, "", DataRowVersion.Proposed, (object)daoTweetCount.CreatedAt ?? (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 ctprTweetCount_SelectAllBySearchFieldsCount returned error code: " + errorCode); } return(retCount); } catch { throw; } finally { staticConnection.Close(); command.Dispose(); } }