http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 2429|回复: 0

[其他] 统计数据库的用户数量的问题!

[复制链接]
发表于 2013-12-6 17:47:53 | 显示全部楼层 |阅读模式
本帖最后由 ゞ⑧鸢の翔 于 2013-12-6 19:20 编辑

想统计一下在00:00-01:00内收看比如湖南卫视的用户数。写了如下程序不过统计有误,不知道错在哪里!求老大指点!
55.jpg
[Bash shell] 纯文本查看 复制代码
  public int[] PerChannelCount(string str,string Time)
        {
            int[] PerUserCount = new int[27];     
            int[] Channel_1 = new int[27];
            DB db = new DB();
            DataTable dt = db.reDt(str);
            int TimeStart = 0;
            int TimeEnd = 0;
            //时间选择,每小时
            #region
            switch (Time)
            {
                case "00:00-01:00": TimeStart = 1; TimeEnd = 12; break; //00:00-00:55
                case "01:00-02:00": TimeStart = 13; TimeEnd = 24; break;
                case "02:00-03:00": TimeStart = 25; TimeEnd = 36; break;
                case "03:00-04:00": TimeStart = 37; TimeEnd = 48; break;
                case "04:00-05:00": TimeStart = 49; TimeEnd = 60; break;
                case "05:00-06:00": TimeStart = 61; TimeEnd = 72; break;
                case "06:00-07:00": TimeStart = 73; TimeEnd = 84; break;//06:00-06:55
                case "07:00-08:00": TimeStart = 85; TimeEnd = 104; break;//07:00-07:57
                case "08:00-09:00": TimeStart = 105; TimeEnd = 124; break;
                case "09:00-10:00": TimeStart = 125; TimeEnd = 144; break;
                case "10:00-11:00": TimeStart = 145; TimeEnd = 164; break;
                case "11:00-12:00": TimeStart = 165; TimeEnd = 184; break;
                case "12:00-13:00": TimeStart = 185; TimeEnd = 204; break;
                case "13:00-14:00": TimeStart = 205; TimeEnd = 224; break;
                case "14:00-15:00": TimeStart = 225; TimeEnd = 244; break;
                case "15:00-16:00": TimeStart = 245; TimeEnd = 264; break;
                case "16:00-17:00": TimeStart = 265; TimeEnd = 284; break;
                case "17:00-18:00": TimeStart = 285; TimeEnd = 304; break;
                case "18:00-19:00": TimeStart = 305; TimeEnd = 324; break;//18:00-18:57
                case "19:00-20:00": TimeStart = 325; TimeEnd = 384; break;//19:00-19:59
                case "20:00-21:00": TimeStart = 385; TimeEnd = 444; break;
                case "21:00-22:00": TimeStart = 445; TimeEnd = 504; break;
                case "22:00-23:00": TimeStart = 505; TimeEnd = 564; break;//22:00-22:59
                case "23:00-00:00": TimeStart = 565; TimeEnd = 576; break;//23:00-23:55
            }
            #endregion
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                for(int j=TimeStart;j<=TimeEnd;j++)
                {
                    switch (dt.Rows[i][j].ToString())
                    {
                        #region
                        case "CCTV-1": Channel_1[0]++; break;
                        case "CCTV-2": Channel_1[1]++; break;
                        case "CCTV-3": Channel_1[2]++; break;
                        case "CCTV-4": Channel_1[3]++; break;
                        case "CCTV-5": Channel_1[4]++; break;
                        case "CCTV-6": Channel_1[5]++; break;
                        case "CCTV-7": Channel_1[6]++; break;
                        case "CCTV-8": Channel_1[7]++; break;
                        case "CCTV-9": Channel_1[8]++; break;
                        case "浙江卫视": Channel_1[9]++; break;
                        case "东方卫视": Channel_1[10]++; break;
                        case "安徽卫视": Channel_1[11]++; break;
                        case "北京卫视": Channel_1[12]++; break;
                        case "辽宁卫视": Channel_1[13]++; break;
                        case "山东卫视": Channel_1[14]++; break;
                        case "天津卫视": Channel_1[15]++; break;
                        case "宁夏卫视": Channel_1[16]++; break;
                        case "河南卫视": Channel_1[17]++; break;
                        case "湖北卫视": Channel_1[18]++; break;
                        case "四川卫视": Channel_1[19]++; break;
                        case "江西卫视": Channel_1[20]++; break;
                        case "贵州卫视": Channel_1[21]++; break;
                        case "广东卫视": Channel_1[22]++; break;
                        case "吉林卫视": Channel_1[23]++; break;
                        case "河北卫视": Channel_1[24]++; break;
                        case "重庆卫视": Channel_1[25]++; break;
                        case "广西卫视": Channel_1[26]++; break;
                        default: break;
                        #endregion
                    }                
                } 
///////不知道这儿写的对不对!!!!
                for (int k = 0; k < 27; k++)
                {    
                    if (Channel_1[k] > 0)
                    {
PerUserCount [k]++;
                    }
                    else 
                    {
}
                }
            }
return PerUserCount;
}


谢谢!


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-11-23 16:28

© 2014-2021

快速回复 返回顶部 返回列表