/// <summary> /// 获取作者按省份统计数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public IList<AuthorStatEntity> GetAuthorProvinceStat(QueryBase query) { IList<AuthorStatEntity> authorStatList = new List<AuthorStatEntity>(); string strSql = "SELECT b.Province,COUNT(DISTINCT b.AuthorID) AS Count FROM dbo.AuthorInfo a WITH(NOLOCK),dbo.AuthorDetail b WITH(NOLOCK) WHERE a.JournalID=@JournalID AND a.GroupID=2 AND a.JournalID=b.JournalID GROUP BY b.Province"; DbCommand cmd = db.GetSqlStringCommand(strSql); db.AddInParameter(cmd, "@JournalID", DbType.Int64, query.JournalID); using (IDataReader dr = db.ExecuteReader(cmd)) { while (dr.Read()) { AuthorStatEntity item = new AuthorStatEntity(); item.StatItem = dr.IsDBNull(dr.GetOrdinal("Province")) ? "未知地区" : dr["Province"].ToString(); if (string.IsNullOrEmpty(item.StatItem)) { item.StatItem = "未知地区"; } item.Count = TypeParse.ToInt(dr["Count"]); authorStatList.Add(item); } dr.Close(); } return authorStatList; }
/// <summary> /// 获取作者按性别统计数据 /// </summary> /// <param name="query"></param> /// <returns></returns> public IList<AuthorStatEntity> GetAuthorGenderStat(QueryBase query) { IList<AuthorStatEntity> authorStatList = new List<AuthorStatEntity>(); string strSql = "SELECT b.Gender,COUNT(DISTINCT b.AuthorID) AS Count FROM dbo.AuthorInfo a WITH(NOLOCK),dbo.AuthorDetail b WITH(NOLOCK) WHERE a.JournalID=@JournalID AND a.GroupID=2 AND a.JournalID=b.JournalID GROUP BY b.Gender"; DbCommand cmd = db.GetSqlStringCommand(strSql); db.AddInParameter(cmd, "@JournalID", DbType.Int64, query.JournalID); using (IDataReader dr = db.ExecuteReader(cmd)) { int Gender = 0; while (dr.Read()) { Gender = TypeParse.ToInt(dr["Gender"]); AuthorStatEntity item = new AuthorStatEntity(); if (Gender == 1) { item.StatItem = "男"; } else if (Gender == 2) { item.StatItem = "女"; } else { item.StatItem = "未知"; } item.Count = TypeParse.ToInt(dr["Count"]); authorStatList.Add(item); } dr.Close(); } return authorStatList; }