Exemplo n.º 1
0
        /// <summary>
        /// 用户七天总量变化
        /// </summary>
        /// <returns></returns>
        public async Task <UserCountResult> GetUserChangeCountAsync()
        {
            UserCountResult result = new UserCountResult();

            string[] strCount = new string[7];
            string[] strTime  = new string[7];
            int      count    = 0;
            string   time     = string.Empty;

            for (int i = 0; i < 7; i++)
            {
                //rjy 2018年9月28日14:52:43 最近七天从早到晚 查询需要后一天 所在循环时 查询时间为当天后一天
                time       = DateTime.Now.AddDays(+(i - 5)).ToString("yyyy-MM-dd");
                strTime[i] = DateTime.Now.AddDays(+(i - 6)).ToString("yyyy-MM-dd");
                #region 旧版 注释
                //if (i == 0)
                //            {
                //                time = DateTime.Now.AddDays(+1).ToString("yyyy-MM-dd");
                //                strTime[i] = DateTime.Now.ToString("yyyy-MM-dd");
                //            }
                //            else
                //            {
                //                time = DateTime.Now.AddDays(-i + 1).ToString("yyyy-MM-dd");
                //                strTime[i] = DateTime.Now.AddDays(-i).ToString("yyyy-MM-dd"); ;
                //            }
                #endregion
                count = await LeadDataDataAccess.Instance.GetUserCountAsync(time);

                strCount[i] = count.ToString();
            }
            for (int i = 0; i < strTime.Length; i++)
            {
                try
                {
                    strTime[i] = Convert.ToDateTime(strTime[i]).ToString("MM-dd");
                }
                catch {}
            }
            result.date  = strTime;
            result.count = strCount;
            return(result ?? null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取某时间段每天的用户数。 rjy 2018年10月10日14:45:19
        /// </summary>
        /// <param name="timeType">1:周,2:月,3:季度</param>
        /// <returns></returns>
        public async Task <UserCountResult> GetNewUserChangeCountAsync(string timeType)
        {
            UserCountResult result = new UserCountResult();

            string[] strCount = null;
            string[] strTime  = null;
            int      count    = 0;
            string   time     = string.Empty;

            switch (timeType)
            {
            case "1":
            {
                strTime  = new string[7];
                strCount = new string[7];
                for (int i = 0; i < 7; i++)
                {
                    time       = DateTime.Now.AddDays(+(i - 5)).ToString("yyyy-MM-dd");
                    strTime[i] = DateTime.Now.AddDays(+(i - 6)).ToString("MM-dd");

                    count = await LeadDataDataAccess.Instance.GetUserCountAsync(time);

                    strCount[i] = count.ToString();
                }
                break;
            }

            case "2":
            {
                strTime  = new string[30];
                strCount = new string[30];
                for (int i = 0; i < 30; i++)
                {
                    time       = DateTime.Now.AddDays(+(i - 28)).ToString("yyyy-MM-dd");
                    strTime[i] = DateTime.Now.AddDays(+(i - 29)).ToString("MM-dd");

                    count = await LeadDataDataAccess.Instance.GetUserCountAsync(time);

                    strCount[i] = count.ToString();
                }
                break;
            }

            case "3":
            {
                strTime  = new string[90];
                strCount = new string[90];
                for (int i = 0; i < 90; i++)
                {
                    time       = DateTime.Now.AddDays(+(i - 88)).ToString("yyyy-MM-dd");
                    strTime[i] = DateTime.Now.AddDays(+(i - 89)).ToString("MM-dd");

                    count = await LeadDataDataAccess.Instance.GetUserCountAsync(time);

                    strCount[i] = count.ToString();
                }
                break;
            }
            }
            result.date  = strTime;
            result.count = strCount;
            return(result ?? null);
        }