Exemple #1
0
        public static IDictionary <DateTime, int> ViewsByPostSingle(int postId, DateTime min, DateTime max)
        {
            DataProvider dp  = DataService.Provider;
            QueryCommand cmd = new QueryCommand(@"
                select " +
                                                dp.SqlYearFunction("ps.DateViewed") + " as dvYear, " +
                                                dp.SqlMonthFunction("ps.DateViewed") + " as dvMonth, " +
                                                dp.SqlDayFunction("ps.DateViewed") + " as dvDay, " +
                                                dp.SqlCountFunction("ps.Id") + @" as IdCount
                from
                    graffiti_Post_Statistics AS ps
                where
                    ps.DateViewed >= " + dp.SqlVariable("MinDate") + @" and ps.DateViewed < " + dp.SqlVariable("MaxDate") + @"
                    and ps.PostId = " + dp.SqlVariable("PostId") + @"
                group by " +
                                                dp.SqlYearFunction("ps.DateViewed") + ", " +
                                                dp.SqlMonthFunction("ps.DateViewed") + ", " +
                                                dp.SqlDayFunction("ps.DateViewed")
                                                );

            List <Parameter> parameters  = PostStatistic.GenerateParameters();
            Parameter        pDateViewed = PostStatistic.FindParameter(parameters, "DateViewed");

            cmd.Parameters.Add("MinDate", min, pDateViewed.DbType);
            cmd.Parameters.Add("MaxDate", max.AddDays(1), pDateViewed.DbType);
            cmd.Parameters.Add(PostStatistic.FindParameter(parameters, "PostId")).Value = postId;

            return(GetDateDictionary(cmd));
        }
Exemple #2
0
        public static int ViewsByPostSingleCount(int postId, DateTime min, DateTime max)
        {
            DataProvider dp  = DataService.Provider;
            QueryCommand cmd = new QueryCommand(@"
                select
                    " + dp.SqlCountFunction("ps.Id") + @" as IdCount
                from
                    graffiti_Post_Statistics AS ps
                where
                    ps.DateViewed >= " + dp.SqlVariable("MinDate") + @" and ps.DateViewed < " + dp.SqlVariable("MaxDate") + @"
                    and ps.PostId = " + dp.SqlVariable("PostId")
                                                );

            List <Parameter> parameters  = PostStatistic.GenerateParameters();
            Parameter        pDateViewed = PostStatistic.FindParameter(parameters, "DateViewed");

            cmd.Parameters.Add("MinDate", min, pDateViewed.DbType);
            cmd.Parameters.Add("MaxDate", max.AddDays(1), pDateViewed.DbType);
            cmd.Parameters.Add(PostStatistic.FindParameter(parameters, "PostId")).Value = postId;

            return((int)DataService.ExecuteScalar(cmd));
        }