Esempio n. 1
0
        public List <LoginStatisticItem> QueryUniqueLoginStatistic(QueryLoginStatisticCriteria criteria)
        {
            if (criteria == null)
            {
                return(new List <LoginStatisticItem>());
            }
            var customCommand = DataCommandManager.CreateCustomDataCommandFromConfig("QueryUniqueLoginStatistic");

            using (var sqlBuilder = new DynamicQuerySqlBuilder(customCommand.CommandText, customCommand, new Framework.Entity.PagingInfoEntity(), "InDate DESC"))
            {
                if (criteria.DateFrom.HasValue)
                {
                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "InDate", DbType.DateTime,
                                                                 "@InDateFrom", QueryConditionOperatorType.MoreThanOrEqual,
                                                                 criteria.DateFrom.Value);
                }
                if (criteria.DateTo.HasValue)
                {
                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "InDate", DbType.DateTime,
                                                                 "@InDateTo", QueryConditionOperatorType.LessThan,
                                                                 criteria.DateTo.Value.AddDays(1));
                }

                customCommand.CommandText = sqlBuilder.BuildQuerySql();
                if (criteria.TopCount > 0)
                {
                    customCommand.ReplaceParameterValue("#TopCount#", string.Format(" TOP {0} ", criteria.TopCount.ToString()));
                }
                else
                {
                    customCommand.ReplaceParameterValue("#TopCount#", string.Empty);
                }
                return(customCommand.ExecuteEntityList <LoginStatisticItem>());
            }
        }
Esempio n. 2
0
        public List <LoginStatisticItem> QueryUniqueLoginStatistic(QueryLoginStatisticCriteria criteria)
        {
            List <LoginStatisticItem> result = new List <LoginStatisticItem>();
            var da = new StatisticDA();
            //由于数据库的数据没有连续的数据进行呈现,所以在没有数据的点,应该初始化成0
            List <LoginStatisticItem> items = da.QueryUniqueLoginStatistic(criteria);
            DateTime startDate = criteria.DateFrom.HasValue ? criteria.DateFrom.Value : DateTime.Now;
            DateTime endDate   = GetEndDate(criteria.DateTo);
            int      days      = (endDate.Date - startDate.Date).Days;

            if (startDate > endDate)
            {
                days = -1;
            }
            for (int i = 0; i <= days; i++)
            {
                LoginStatisticItem findResult = items.SingleOrDefault(item => item.InDate.Date.Equals(endDate.AddDays(-i).Date));
                if (findResult != null)
                {
                    result.Add(findResult);
                }
                else
                {
                    result.Add(new LoginStatisticItem
                    {
                        Count  = 0,
                        InDate = endDate.AddDays(-i)
                    });
                }
            }
            return(result);
        }
Esempio n. 3
0
        public List <LoginStatisticItem> QueryUniqueLoginStatistic(QueryLoginStatisticCriteria criteria)
        {
            var da = new StatisticBiz();

            return(da.QueryUniqueLoginStatistic(criteria));
        }