示例#1
0
        public ModelView.StatisticsModel GetStatisticsModel(IConnectionHandler connectionHandler, string url)
        {
            try
            {
                var model = new ModelView.StatisticsModel();
                if (string.IsNullOrEmpty(url))
                {
                    return(model);
                }
                var logBo = new LogBO();

                if (url.ToUpper().StartsWith("WWW"))
                {
                    var lenght = url.Split('.')[0].Length + 1;
                    url = url.Substring(lenght, url.Length - lenght);
                }

                if (url.ToUpper().StartsWith("HTTP"))
                {
                    var lenght = url.Split('/')[0].Length + 2;
                    url = url.Substring(lenght, url.Length - lenght);
                    if (url.ToUpper().StartsWith("WWW"))
                    {
                        var lenght1 = url.Split('.')[0].Length + 1;
                        url = url.Substring(lenght1, url.Length - lenght1);
                    }
                }

                model.TodaySesstionCount         = logBo.GetDateSesstionCount(connectionHandler, url, FixData(DateTime.Now));
                model.YesterDaySesstionViewCount = logBo.GetDateSesstionCount(connectionHandler, url, FixData(DateTime.Now.AddDays(-1)));
                var last7Day = DateTime.Now.AddDays(-7);
                var now      = DateTime.Now;
                model.Last7DaysSesstionViewCount = logBo.GetSesstionCountBetweenDate(connectionHandler, url, FixData(last7Day), FixData(now));
                var firstMonth = getShamsiStartMonthDate(DateTime.Now);
                var lastMonth  = getShamsiEndMonthDate(DateTime.Now);
                model.CurrentMonthSessionViewCount = logBo.GetSesstionCountBetweenDate(connectionHandler, url, FixData(firstMonth), FixData(lastMonth));
                model.TotalSesstionCount           = logBo.GetTotalSesstionCount(connectionHandler, url);
                return(model);
            }
            catch (KnownException ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
            catch (Exception ex)
            {
                Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
                throw new KnownException(ex.Message, ex);
            }
        }
示例#2
0
 public ModelView.StatisticsModel GetStatisticsModel(string url)
 {
     try
     {
         var model = new ModelView.StatisticsModel();
         if (string.IsNullOrEmpty(url))
         {
             return(model);
         }
         var logBo = new LogBO();
         return(logBo.GetStatisticsModel(ConnectionHandler, url));
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }