public bool AddIssueViewLog(IssueViewLogEntity issueViewLogEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("@JournalID");
            sqlCommandText.Append(", @ContentID");
            sqlCommandText.Append(", @AuthorID");
            sqlCommandText.Append(", @Daytime");
            sqlCommandText.Append(", @Year");
            sqlCommandText.Append(", @Month");
            sqlCommandText.Append(", @IP");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.IssueViewLog ({0}) VALUES ({1})", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString()));

            db.AddInParameter(cmd, "@JournalID", DbType.Int64, issueViewLogEntity.JournalID);
            db.AddInParameter(cmd, "@ContentID", DbType.Int64, issueViewLogEntity.ContentID);
            db.AddInParameter(cmd, "@AuthorID", DbType.Int64, issueViewLogEntity.AuthorID);
            db.AddInParameter(cmd, "@Daytime", DbType.Int32, issueViewLogEntity.Daytime);
            db.AddInParameter(cmd, "@Year", DbType.Int32, issueViewLogEntity.Year);
            db.AddInParameter(cmd, "@Month", DbType.Int32, issueViewLogEntity.Month);
            db.AddInParameter(cmd, "@IP", DbType.AnsiString, issueViewLogEntity.IP);
            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch (SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Esempio n. 2
0
        /// <summary>
        /// 查看期刊
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public ActionResult Show(long ID)
        {
            IIssueFacadeService service = ServiceContainer.Instance.Container.Resolve<IIssueFacadeService>();
            IssueContentQuery contentQuery = new IssueContentQuery();
            contentQuery.JournalID = JournalID;
            contentQuery.contentID = ID;
            IssueContentEntity contentEntity = service.GetIssueContentModel(contentQuery);
            if (contentEntity == null)
            {
                contentEntity = new IssueContentEntity();
            }
            else
            {
                service.UpdateIssueContentHits(contentQuery);

                # region 记录浏览日志

                if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["RecodeViewLog"]))
                {
                    try
                    {
                        IssueViewLogEntity issueLogEntity = new IssueViewLogEntity();
                        issueLogEntity.ContentID = ID;
                        issueLogEntity.JournalID = JournalID;
                        issueLogEntity.IP = Utils.GetRealIP();
                        issueLogEntity.Daytime = TypeParse.ToInt(DateTime.Now.ToString("yyyyMMdd"));
                        issueLogEntity.Year = DateTime.Now.Year;
                        issueLogEntity.Month = DateTime.Now.Month;
                        issueLogEntity.AuthorID = 0;
                        service.SaveViewLog(issueLogEntity);
                    }
                    catch
                    {
                    }
                }
                # endregion
            }
            return View(contentEntity);
        }
Esempio n. 3
0
 public ExecResult SaveViewLog(IssueViewLogEntity model)
 {
     ExecResult exeResult = new ExecResult();
     IIssueViewLogService service = ServiceContainer.Instance.Container.Resolve<IIssueViewLogService>();
     try
     {
         bool flag = service.AddIssueViewLog(model);
         if (flag)
         {
             exeResult.result = EnumJsonResult.success.ToString();
         }
         else
         {
             exeResult.result = EnumJsonResult.failure.ToString();
             exeResult.msg = "保存浏览日志失败";
         }
     }
     catch (Exception ex)
     {
         exeResult.result = EnumJsonResult.error.ToString();
         exeResult.msg = "保存浏览日志异常:" + ex.Message;
     }
     return exeResult;
 }
Esempio n. 4
0
        /// <summary>
        /// 获取期刊浏览次数
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public Pager<IssueViewLogEntity> GetIssueViewLogPageList(IssueViewLogQuery query)
        {
            //            string tableSql = @"SELECT a.JournalID,a.ContentID,c.CNumber,b.Title,c.AuthorID,d.RealName,d.LoginName,d.Mobile,a.DownLoadCount FROM (
            //                                  SELECT ContentID,JournalID,COUNT(1) as DownLoadCount
            //                                  FROM dbo.IssueDownLog with(nolock)
            //                                  WHERE JournalID={0} GROUP BY ContentID,JournalID
            //                              ) a INNER JOIN dbo.IssueContent b with(nolock) ON a.JournalID=b.JournalID and a.ContentID=b.ContentID
            //                              INNER JOIN dbo.ContributionInfo c with(nolock) ON a.JournalID=b.JournalID and b.CID=c.CID
            //                              INNER JOIN dbo.AuthorInfo d with(nolock) ON a.JournalID=d.JournalID and c.AuthorID=d.AuthorID";
            string tableSql = "select Title,A.Year,A.ViewCount,A.ContentID,A.[Month],Authors,B.JournalID from   dbo.IssueContent as B right join (select ContentID,COUNT(ContentID) as ViewCount,Year,Month from dbo.IssueViewLog group by ContentID,Year,Month) as A  on A.ContentID=B.ContentID where JournalID={0}";
            tableSql = string.Format(tableSql, query.JournalID);
            query.Title = SecurityUtils.SafeSqlString(query.Title);
            if (!string.IsNullOrWhiteSpace(query.Title))
                // tableSql += string.Format(" and b.Title like '%{0}%'", query.Title);
                tableSql += string.Format(" and  Title like '%{0}%'", query.Title);
            query.RealName = SecurityUtils.SafeSqlString(query.RealName);
            if (!string.IsNullOrWhiteSpace(query.RealName))
                tableSql += string.Format(" and Authors like '%{0}%'", query.RealName);
            if (query.Year!=0)
                tableSql += string.Format(" and Year='{0}'", query.Year);

            if (query.Month != 0)
                tableSql += string.Format(" and Month='{0}'", query.Month);

            //tableSql += string.Format(" and d.RealName like '%{0}%'", query.RealName);
            string strSql = string.Format(SQL_Page_Select_ROWNumber, tableSql, query.StartIndex, query.EndIndex, " ViewCount desc "), sumStr = string.Empty;
            if (!query.IsReport)
                sumStr = string.Format("SELECT RecordCount=COUNT(1) FROM ({0}) t", tableSql);
            return db.GetPageList<IssueViewLogEntity>(strSql
                , sumStr
                , query.CurrentPage, query.PageSize
                , (dr, pager) =>
                {
                    pager.TotalRecords = TypeParse.ToLong(dr["RecordCount"]);
                }
                , (dr) =>
                {
                    List<IssueViewLogEntity> list = new List<IssueViewLogEntity>();
                    IssueViewLogEntity model = null;
                    while (dr.Read())
                    {
                        model = new IssueViewLogEntity();
                        model.JournalID = dr.GetDrValue<Int64>("JournalID");
                        model.ContentID = dr.GetDrValue<Int64>("ContentID");
                        model.Title = dr.GetDrValue<String>("Title");
                        model.RealName = dr.GetDrValue<String>("Authors");
                        model.ViewCount = TypeParse.ToLong(dr["ViewCount"]);
                        list.Add(model);
                    }
                    dr.Close();
                    return list;
                });
        }
Esempio n. 5
0
        /// <summary>
        /// 获取期刊浏览明细
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public Pager<IssueViewLogEntity> GetIssueViewLogDetailPageList(IssueViewLogQuery query)
        {
            string tableSql = @"SELECT a.JournalID,a.ContentID,a.ViewLogID,a.Year,a.Month,a.Daytime,b.Title,a.AuthorID,(case when d.RealName is null then '游客' else d.RealName end) as RealName,(case when d.LoginName is null then '无' else d.LoginName end) as LoginName,(case when d.Mobile is null then '无' else d.Mobile end) as Mobile,a.IP,a.AddDate
                              FROM dbo.IssueViewLog a with(nolock)
                              INNER JOIN dbo.IssueContent b with(nolock) ON a.JournalID=b.JournalID and a.ContentID=b.ContentID
                              LEFT JOIN dbo.AuthorInfo d with(nolock) ON a.JournalID=d.JournalID and a.AuthorID=d.AuthorID
                              WHERE a.JournalID=" + query.JournalID;
            if (query.ContentID != null)
                tableSql += " and a.ContentID=" + query.ContentID.Value;
            query.Title = SecurityUtils.SafeSqlString(query.Title);
            if (!string.IsNullOrWhiteSpace(query.Title))
                tableSql += string.Format(" and b.Title like '%{0}%'", query.Title);
            query.RealName = SecurityUtils.SafeSqlString(query.RealName);

            if (query.Year != 0)
                tableSql += string.Format(" and a.Year='{0}'", query.Year);
            if (query.Month != 0)
                tableSql += string.Format(" and a.Month='{0}'", query.Month);

            if (!string.IsNullOrWhiteSpace(query.RealName))
                tableSql += string.Format(" and d.RealName like '%{0}%'", query.RealName);
            string strSql = string.Format(SQL_Page_Select_ROWNumber, tableSql, query.StartIndex, query.EndIndex, " AddDate desc"), sumStr = string.Empty;
            if (!query.IsReport)
                sumStr = string.Format("SELECT RecordCount=COUNT(1) FROM ({0}) t", tableSql);
            return db.GetPageList<IssueViewLogEntity>(strSql
                , sumStr
                , query.CurrentPage, query.PageSize
                , (dr, pager) =>
                {
                    pager.TotalRecords = TypeParse.ToLong(dr["RecordCount"]);
                }
                , (dr) =>
                {
                    List<IssueViewLogEntity> list = new List<IssueViewLogEntity>();
                    IssueViewLogEntity model = null;
                    while (dr.Read())
                    {
                        model = new IssueViewLogEntity();
                        model.ViewLogID = dr.GetDrValue<Int64>("ViewLogID");
                        model.Year = dr.GetDrValue<Int32>("Year");
                        model.Month = dr.GetDrValue<Int32>("Month");
                        model.JournalID = dr.GetDrValue<Int64>("JournalID");
                        model.ContentID = dr.GetDrValue<Int64>("ContentID");
                        model.Title = dr.GetDrValue<String>("Title");
                        model.AuthorID = dr.GetDrValue<Int64>("AuthorID");
                        model.RealName = dr.GetDrValue<String>("RealName");
                        model.LoginName = dr.GetDrValue<String>("LoginName");
                        model.Mobile = dr.GetDrValue<String>("Mobile");
                        model.IP = dr.GetDrValue<String>("IP");
                        model.AddDate = dr.GetDrValue<DateTime>("AddDate");
                        list.Add(model);
                    }
                    dr.Close();
                    return list;
                });
        }
 /// <summary>
 /// 保存访问日志
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public ExecResult SaveViewLog(IssueViewLogEntity model)
 {
     HttpClientHelper clientHelper = new HttpClientHelper();
     ExecResult execResult = clientHelper.Post<ExecResult, IssueViewLogEntity>(GetAPIUrl(APIConstant.ISSUE_SAVEVIEWLOG), model);
     return execResult;
 }
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="issueViewLog">IssueViewLogEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddIssueViewLog(IssueViewLogEntity issueViewLog)
 {
     return IssueViewLogDataAccess.Instance.AddIssueViewLog(issueViewLog);
 }
 public List<IssueViewLogEntity> MakeIssueViewLogList(IDataReader dr)
 {
     List<IssueViewLogEntity> list = new List<IssueViewLogEntity>();
     while (dr.Read())
     {
         IssueViewLogEntity issueViewLogEntity = new IssueViewLogEntity();
         issueViewLogEntity.ViewLogID = (Int64)dr["ViewLogID"];
         issueViewLogEntity.JournalID = (Int64)dr["JournalID"];
         issueViewLogEntity.ContentID = (Int64)dr["ContentID"];
         issueViewLogEntity.AuthorID = (Int64)dr["AuthorID"];
         issueViewLogEntity.Daytime = (Int32)dr["Daytime"];
         issueViewLogEntity.Year = (Int32)dr["Year"];
         issueViewLogEntity.Month = (Int32)dr["Month"];
         issueViewLogEntity.IP = (String)dr["IP"];
         issueViewLogEntity.AddDate = Convert.IsDBNull(dr["AddDate"]) ? null : (DateTime?)dr["AddDate"];
         list.Add(issueViewLogEntity);
     }
     dr.Close();
     return list;
 }
 public IssueViewLogEntity MakeIssueViewLog(DataRow dr)
 {
     IssueViewLogEntity issueViewLogEntity = null;
     if (dr != null)
     {
         issueViewLogEntity = new IssueViewLogEntity();
         issueViewLogEntity.ViewLogID = (Int64)dr["ViewLogID"];
         issueViewLogEntity.JournalID = (Int64)dr["JournalID"];
         issueViewLogEntity.ContentID = (Int64)dr["ContentID"];
         issueViewLogEntity.AuthorID = (Int64)dr["AuthorID"];
         issueViewLogEntity.Daytime = (Int32)dr["Daytime"];
         issueViewLogEntity.Year = (Int32)dr["Year"];
         issueViewLogEntity.Month = (Int32)dr["Month"];
         issueViewLogEntity.IP = (String)dr["IP"];
         issueViewLogEntity.AddDate = Convert.IsDBNull(dr["AddDate"]) ? null : (DateTime?)dr["AddDate"];
     }
     return issueViewLogEntity;
 }
Esempio n. 10
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="issueViewLog">IssueViewLogEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddIssueViewLog(IssueViewLogEntity issueViewLog)
 {
     return IssueViewLogBusProvider.AddIssueViewLog(issueViewLog);
 }