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);
        }
Beispiel #2
0
        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" }));
                    }
                }
        public List <IssueDownLogEntity> MakeIssueDownLogList(DataTable dt)
        {
            List <IssueDownLogEntity> list = new List <IssueDownLogEntity>();

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    IssueDownLogEntity issueDownLogEntity = MakeIssueDownLog(dt.Rows[i]);
                    list.Add(issueDownLogEntity);
                }
            }
            return(list);
        }
        public IssueDownLogEntity GetIssueDownLog(Int64 downLogID)
        {
            IssueDownLogEntity issueDownLogEntity = null;
            StringBuilder      sqlCommandText     = new StringBuilder();

            sqlCommandText.Append("SELECT TOP 1  DownLogID,JournalID,ContentID,AuthorID,Daytime,Year,Month,IP,AddDate FROM dbo.IssueDownLog WITH(NOLOCK)");
            sqlCommandText.Append(" WHERE  DownLogID=@DownLogID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd, "@DownLogID", DbType.Int64, downLogID);

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                issueDownLogEntity = MakeIssueDownLog(dr);
            }
            return(issueDownLogEntity);
        }
        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);
        }
        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);
        }
Beispiel #7
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="issueDownLog">IssueDownLogEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddIssueDownLog(IssueDownLogEntity issueDownLog)
 {
     return(IssueDownLogBusProvider.AddIssueDownLog(issueDownLog));
 }