コード例 #1
0
        public bool AddIssueDownLog(IssueDownLogEntity issueDownLogEntity)
        {
            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.IssueDownLog ({0}) VALUES ({1})", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString()));

            db.AddInParameter(cmd, "@JournalID", DbType.Int64, issueDownLogEntity.JournalID);
            db.AddInParameter(cmd, "@ContentID", DbType.Int64, issueDownLogEntity.ContentID);
            db.AddInParameter(cmd, "@AuthorID", DbType.Int64, issueDownLogEntity.AuthorID);
            db.AddInParameter(cmd, "@Daytime", DbType.Int32, issueDownLogEntity.Daytime);
            db.AddInParameter(cmd, "@Year", DbType.Int32, issueDownLogEntity.Year);
            db.AddInParameter(cmd, "@Month", DbType.Int32, issueDownLogEntity.Month);
            db.AddInParameter(cmd, "@IP", DbType.AnsiString, issueDownLogEntity.IP);
            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch (SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
コード例 #2
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="issueDownLog">IssueDownLogEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddIssueDownLog(IssueDownLogEntity issueDownLog)
 {
     return IssueDownLogDataAccess.Instance.AddIssueDownLog(issueDownLog);
 }
コード例 #3
0
 public ExecResult SaveDownloadLog(IssueDownLogEntity model)
 {
     ExecResult exeResult = new ExecResult();
     IIssueDownLogService service = ServiceContainer.Instance.Container.Resolve<IIssueDownLogService>();
     try
     {
         bool flag = service.AddIssueDownLog(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;
 }
コード例 #4
0
        /// <summary>
        /// 获取期刊下载次数
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public Pager<IssueDownLogEntity> GetIssueDownLogPageList(IssueDownLogQuery 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.DownLoadCount,Authors,A.ContentID,A.[Month],B.JournalID from   dbo.IssueContent as B right join (select ContentID,COUNT(ContentID) as DownLoadCount,Year,Month from dbo.IssueDownLog 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);

            string strSql = string.Format(SQL_Page_Select_ROWNumber, tableSql, query.StartIndex, query.EndIndex, " DownLoadCount desc "), sumStr = string.Empty;
            if (!query.IsReport)
                sumStr = string.Format("SELECT RecordCount=COUNT(1) FROM ({0}) t", tableSql);
            return db.GetPageList<IssueDownLogEntity>(strSql
                , sumStr
                , query.CurrentPage, query.PageSize
                , (dr, pager) =>
                {
                    pager.TotalRecords = TypeParse.ToLong(dr["RecordCount"]);
                }
                , (dr) =>
                {
                    List<IssueDownLogEntity> list = new List<IssueDownLogEntity>();
                    IssueDownLogEntity model = null;
                    while (dr.Read())
                    {
                        model = new IssueDownLogEntity();
                        model.JournalID = dr.GetDrValue<Int64>("JournalID");
                        model.ContentID = dr.GetDrValue<Int64>("ContentID");
                        //  model.CNumber = dr.GetDrValue<String>("CNumber");
                        model.Title = dr.GetDrValue<String>("Title");
                        // model.AuthorID = dr.GetDrValue<Int64>("AuthorID");
                        model.RealName = dr.GetDrValue<String>("Authors");
                        // model.LoginName = dr.GetDrValue<String>("LoginName");
                        // model.Mobile = dr.GetDrValue<String>("Mobile");
                        model.DownLoadCount = TypeParse.ToLong(dr["DownLoadCount"]);
                        list.Add(model);
                    }
                    dr.Close();
                    return list;
                });
        }
コード例 #5
0
        /// <summary>
        /// 获取期刊下载明细
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public Pager<IssueDownLogEntity> GetIssueDownLogDetailPageList(IssueDownLogQuery query)
        {
            string tableSql = @"SELECT a.JournalID,a.ContentID,a.DownLogID,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.IssueDownLog 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);
            if (!string.IsNullOrWhiteSpace(query.IP))
                tableSql += string.Format(" and a.IP = '{0}'", query.IP);
            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<IssueDownLogEntity>(strSql
                , sumStr
                , query.CurrentPage, query.PageSize
                , (dr, pager) =>
                {
                    pager.TotalRecords = TypeParse.ToLong(dr["RecordCount"]);
                }
                , (dr) =>
                {
                    List<IssueDownLogEntity> list = new List<IssueDownLogEntity>();
                    IssueDownLogEntity model = null;
                    while (dr.Read())
                    {
                        model = new IssueDownLogEntity();
                        model.DownLogID = dr.GetDrValue<Int64>("DownLogID");
                        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;
                });
        }
コード例 #6
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="issueDownLog">IssueDownLogEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddIssueDownLog(IssueDownLogEntity issueDownLog)
 {
     return IssueDownLogBusProvider.AddIssueDownLog(issueDownLog);
 }
コード例 #7
0
 /// <summary>
 /// 保存下载日志
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 public ExecResult SaveDownloadLog(IssueDownLogEntity model)
 {
     HttpClientHelper clientHelper = new HttpClientHelper();
     ExecResult execResult = clientHelper.Post<ExecResult, IssueDownLogEntity>(GetAPIUrl(APIConstant.ISSUE_SAVEDOWNLOADLOG), model);
     return execResult;
 }
コード例 #8
0
 public List<IssueDownLogEntity> MakeIssueDownLogList(IDataReader dr)
 {
     List<IssueDownLogEntity> list = new List<IssueDownLogEntity>();
     while (dr.Read())
     {
         IssueDownLogEntity issueDownLogEntity = new IssueDownLogEntity();
         issueDownLogEntity.DownLogID = (Int64)dr["DownLogID"];
         issueDownLogEntity.JournalID = (Int64)dr["JournalID"];
         issueDownLogEntity.ContentID = (Int64)dr["ContentID"];
         issueDownLogEntity.AuthorID = (Int64)dr["AuthorID"];
         issueDownLogEntity.Daytime = (Int32)dr["Daytime"];
         issueDownLogEntity.Year = (Int32)dr["Year"];
         issueDownLogEntity.Month = (Int32)dr["Month"];
         issueDownLogEntity.IP = (String)dr["IP"];
         issueDownLogEntity.AddDate = (DateTime)dr["AddDate"];
         list.Add(issueDownLogEntity);
     }
     dr.Close();
     return list;
 }
コード例 #9
0
 public IssueDownLogEntity MakeIssueDownLog(DataRow dr)
 {
     IssueDownLogEntity issueDownLogEntity = null;
     if (dr != null)
     {
         issueDownLogEntity = new IssueDownLogEntity();
         issueDownLogEntity.DownLogID = (Int64)dr["DownLogID"];
         issueDownLogEntity.JournalID = (Int64)dr["JournalID"];
         issueDownLogEntity.ContentID = (Int64)dr["ContentID"];
         issueDownLogEntity.AuthorID = (Int64)dr["AuthorID"];
         issueDownLogEntity.Daytime = (Int32)dr["Daytime"];
         issueDownLogEntity.Year = (Int32)dr["Year"];
         issueDownLogEntity.Month = (Int32)dr["Month"];
         issueDownLogEntity.IP = (String)dr["IP"];
         issueDownLogEntity.AddDate = (DateTime)dr["AddDate"];
     }
     return issueDownLogEntity;
 }
コード例 #10
0
ファイル: StatController.cs プロジェクト: zhanglc8801/WKT2015
        public JsonResult DownStat(long CID)
        {
            try
            {
                IssueContentQuery issueCQuery = new IssueContentQuery();
                issueCQuery.contentID = CID;
                issueCQuery.JournalID = JournalID;
                IIssueFacadeService service = ServiceContainer.Instance.Container.Resolve<IIssueFacadeService>();
                IssueContentEntity issueEntity = service.GetIssueContentModel(issueCQuery);
                if (issueEntity == null)
                {
                    return Json(new { flag = "NOfile" });
                }
                else
                {
                    if (!string.IsNullOrEmpty(issueEntity.FilePath))
                    {
                        string downPath = GetUploadPath(issueEntity.FilePath);
                        if (!System.IO.File.Exists(downPath))
                            return Json(new { flag = "NOfile" });
                        //更新下载次数
                        service.UpdateIssueContentDownloads(issueCQuery);
                        # region 记录下载日志

                        try
                        {
                            IssueDownLogEntity issueLogEntity = new IssueDownLogEntity();
                            issueLogEntity.ContentID = CID;
                            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.SaveDownloadLog(issueLogEntity);
                        }
                        catch
                        {
                        }

                        # endregion

                        return Json(new { flag = "success", URL = "http://" + Request.Url.Host + issueEntity.FilePath });
                    }
                    else
                    {
                        return Json(new { flag = "NOfile" });
                    }
                }
            }
            catch (Exception ex)
            {
                WKT.Log.LogProvider.Instance.Error("记录下载日志出现异常:" + ex.Message);

                return Json(new { flag = "记录下载日志出现异常:" + ex.Message });
            }
        }
コード例 #11
0
ファイル: StatController.cs プロジェクト: zhanglc8801/WKT2015
        public ActionResult FileDownload(long ContentID, string fileName)
        {
            #region 登录验证(未使用)
            //HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["WKT_SSO.CN"];
            //if (cookie != null)
            //{

            //}
            #endregion
            if (Utils.GetRealIP() == "60.220.197.252" || Utils.GetRealIP() == "218.26.232.181")
                return Content("检查到您的IP异常,已禁止下载。");

            long AuthorID = 0;
            if (Request.Cookies["WKT_PRELOGINUSERID"] != null)
                AuthorID = Convert.ToInt64(Request.Cookies["WKT_PRELOGINUSERID"].Value);
            IssueContentQuery issueCQuery = new IssueContentQuery();
            issueCQuery.contentID = ContentID;
            issueCQuery.JournalID = JournalID;
            IIssueFacadeService service = ServiceContainer.Instance.Container.Resolve<IIssueFacadeService>();
            IssueContentEntity issueEntity = service.GetIssueContentModel(issueCQuery);
            string downPath = GetUploadPath(issueEntity.FilePath);
            if (!System.IO.File.Exists(downPath))
                return Content("文件不存在!");
            fileName += Path.GetExtension(issueEntity.FilePath);
            HttpResponseBase response = this.HttpContext.Response;
            HttpServerUtilityBase server = this.HttpContext.Server;
            response.Clear();
            response.Buffer = true;
            response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
            response.ContentType = "application/octet-stream";
            response.TransmitFile(downPath);

            Response.Flush();
            response.End();
            //Response.Close();

            //根据客户端IP、期刊ID获取下载记录数
            IIssueFacadeService issueService = ServiceContainer.Instance.Container.Resolve<IIssueFacadeService>();
            IssueDownLogQuery issueQuery = new IssueDownLogQuery();
            issueQuery.JournalID = JournalID;
            issueQuery.ContentID = ContentID;
            issueQuery.IP = Utils.GetRealIP();
            issueQuery.IsReport = false;
            issueQuery.CurrentPage = 1;
            issueQuery.PageSize = 25;

            if (issueService.GetIssueDownLogDetailPageList(issueQuery).TotalRecords == 0)
            {
                //更新下载次数
                service.UpdateIssueContentDownloads(issueCQuery);
                # region 记录下载日志

                try
                {
                    IssueDownLogEntity issueLogEntity = new IssueDownLogEntity();
                    issueLogEntity.ContentID = ContentID;
                    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 = AuthorID;
                    service.SaveDownloadLog(issueLogEntity);
                }
                catch
                {
                }

                # endregion
            }
            return Content("文件下载成功");
        }