/// <summary>
        /// 组装数据
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private SiteContentEntity MakeSiteContentModel(IDataReader dr)
        {
            SiteContentEntity model = new SiteContentEntity();

            model.ContentID  = (Int64)dr["ContentID"];
            model.JournalID  = (Int64)dr["JournalID"];
            model.ChannelID  = (Int64)dr["ChannelID"];
            model.Title      = (String)dr["Title"];
            model.Linkurl    = (String)dr["Linkurl"];
            model.TitleColor = (String)dr["TitleColor"];
            model.IsBold     = (Boolean)dr["IsBold"];
            model.IsItalic   = (Boolean)dr["IsItalic"];
            model.Source     = (String)dr["Source"];
            model.Author     = (String)dr["Author"];
            model.Tags       = (String)dr["Tags"];
            model.Abstruct   = (String)dr["Abstruct"];
            model.TitlePhoto = (String)dr["TitlePhoto"];
            model.FJPath     = dr["FJPath"] == System.DBNull.Value?"": (String)dr["FJPath"];
            model.SortID     = dr["SortID"] == System.DBNull.Value ? 0 : (Int32)dr["SortID"];
            model.InAuthor   = (Int64)dr["InAuthor"];
            model.EditAuthor = (Int64)dr["EditAuthor"];
            model.EditDate   = (DateTime)dr["EditDate"];
            model.AddDate    = (DateTime)dr["AddDate"];
            return(model);
        }
        private SiteContentEntity GetModel(Int64 ContentID)
        {
            SiteContentEntity model = null;

            if (ContentID > 0)
            {
                SiteContentQuery query = new SiteContentQuery();
                query.JournalID = CurAuthor.JournalID;
                query.ContentID = ContentID;
                ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();
                model = service.GetSiteContentModel(query);
            }
            if (model == null)
            {
                model = new SiteContentEntity();
            }
            return(model);
        }
Exemple #3
0
        /// <summary>
        /// 保存资讯
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ExecResult Save(SiteContentEntity model)
        {
            ExecResult execResult = new ExecResult();
            bool       result     = false;

            model.Title      = model.Title.TextFilter();
            model.Linkurl    = model.Linkurl.TextFilter();
            model.TitleColor = model.TitleColor.TextFilter();
            model.Source     = model.Source.TextFilter();
            model.Author     = model.Author.TextFilter();
            model.Tags       = model.Tags.TextFilter();
            model.Abstruct   = model.Abstruct.TextFilter();
            model.Content    = model.Content.HtmlFilter();
            if (model.ContentID == 0)
            {
                result = AddSiteContent(model);
                if (result)
                {
                    execResult.result = EnumJsonResult.success.ToString();
                    execResult.msg    = "新增新闻资讯成功!";
                }
                else
                {
                    execResult.result = EnumJsonResult.failure.ToString();
                    execResult.msg    = "新增新闻资讯失败!";
                }
            }
            else
            {
                result = UpdateSiteContent(model);
                if (result)
                {
                    execResult.result = EnumJsonResult.success.ToString();
                    execResult.msg    = "修改新闻资讯成功!";
                }
                else
                {
                    execResult.result = EnumJsonResult.failure.ToString();
                    execResult.msg    = "修改新闻资讯失败!";
                }
            }
            return(execResult);
        }
        /// <summary>
        /// 获取资讯实体
        /// </summary>
        /// <param name="ContentID"></param>
        /// <returns></returns>
        public SiteContentEntity GetSiteContentModel(Int64 ContentID)
        {
            string            strSql = string.Format(@"SELECT TOP 1 a.*,b.Content FROM dbo.SiteContent a with(nolock) 
                                            INNER JOIN dbo.SiteContentAtt b with(nolock) ON a.ContentID=b.ContentID 
                                            WHERE a.ContentID={0}", ContentID);
            SiteContentEntity model  = null;
            DbCommand         cmd    = db.GetSqlStringCommand(strSql);

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                if (dr.Read())
                {
                    model         = MakeSiteContentModel(dr);
                    model.Content = (String)dr["Content"];
                }
                dr.Close();
            }
            return(model);
        }
        public ActionResult Save(SiteContentEntity model)
        {
            ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();

            model.JournalID = CurAuthor.JournalID;
            if (model.ContentID == 0)
            {
                model.InAuthor = CurAuthor.AuthorID;
            }
            else
            {
                model.EditAuthor = CurAuthor.AuthorID;
            }
            if (!string.IsNullOrWhiteSpace(model.Content))
            {
                model.Content = Server.UrlDecode(model.Content);
            }
            ExecResult result = service.SaveSiteContent(model);

            return(Json(new { result = result.result, msg = result.msg }));
        }
Exemple #6
0
 /// <summary>
 /// 编辑资讯
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateSiteContent(SiteContentEntity model)
 {
     return(SiteContentBusProvider.UpdateSiteContent(model));
 }
Exemple #7
0
 /// <summary>
 /// 新增资讯
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddSiteContent(SiteContentEntity model)
 {
     return(SiteContentBusProvider.AddSiteContent(model));
 }
        /// <summary>
        /// 编辑资讯
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateSiteContent(SiteContentEntity model)
        {
            StringBuilder whereCommandText = new StringBuilder();

            whereCommandText.Append("  ContentID=@ContentID");
            StringBuilder sqlCommandText = new StringBuilder();

            sqlCommandText.Append(" Title=@Title");
            sqlCommandText.Append(", Linkurl=@Linkurl");
            sqlCommandText.Append(", TitleColor=@TitleColor");
            sqlCommandText.Append(", IsBold=@IsBold");
            sqlCommandText.Append(", IsItalic=@IsItalic");
            sqlCommandText.Append(", Source=@Source");
            sqlCommandText.Append(", Author=@Author");
            sqlCommandText.Append(", Tags=@Tags");
            sqlCommandText.Append(", Abstruct=@Abstruct");
            sqlCommandText.Append(", TitlePhoto=@TitlePhoto");
            sqlCommandText.Append(", FJPath=@FJPath");
            sqlCommandText.Append(", SortID=@SortID");
            sqlCommandText.Append(", EditAuthor=@EditAuthor");
            sqlCommandText.Append(", EditDate=getdate()");

            using (DbConnection conn = db.CreateConnection())
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                DbTransaction trans = conn.BeginTransaction();
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.SiteContent SET {0} WHERE  {1}", sqlCommandText.ToString(), whereCommandText.ToString()));

                    db.AddInParameter(cmd, "@ContentID", DbType.Int64, model.ContentID);
                    db.AddInParameter(cmd, "@Title", DbType.AnsiString, model.Title);
                    db.AddInParameter(cmd, "@Linkurl", DbType.AnsiString, model.Linkurl);
                    db.AddInParameter(cmd, "@TitleColor", DbType.AnsiString, model.TitleColor);
                    db.AddInParameter(cmd, "@IsBold", DbType.Boolean, model.IsBold);
                    db.AddInParameter(cmd, "@IsItalic", DbType.Boolean, model.IsItalic);
                    db.AddInParameter(cmd, "@Source", DbType.AnsiString, model.Source);
                    db.AddInParameter(cmd, "@Author", DbType.AnsiString, model.Author);
                    db.AddInParameter(cmd, "@Tags", DbType.AnsiString, model.Tags);
                    db.AddInParameter(cmd, "@Abstruct", DbType.AnsiString, model.Abstruct);
                    db.AddInParameter(cmd, "@TitlePhoto", DbType.AnsiString, model.TitlePhoto);
                    db.AddInParameter(cmd, "@FJPath", DbType.AnsiString, model.FJPath);
                    db.AddInParameter(cmd, "@SortID", DbType.Int32, model.SortID);
                    db.AddInParameter(cmd, "@EditAuthor", DbType.AnsiString, model.EditAuthor);

                    if (db.ExecuteNonQuery(cmd, trans) < 1)
                    {
                        trans.Rollback();
                        return(false);
                    }

                    cmd = db.GetSqlStringCommand("UPDATE dbo.SiteContentAtt set Content=@Content where ContentID=@ContentID");
                    db.AddInParameter(cmd, "@Content", DbType.String, model.Content);
                    db.AddInParameter(cmd, "@ContentID", DbType.Int64, model.ContentID);
                    if (db.ExecuteNonQuery(cmd, trans) < 1)
                    {
                        trans.Rollback();
                        return(false);
                    }

                    trans.Commit();
                    conn.Close();
                    return(true);
                }
                catch (SqlException sqlEx)
                {
                    trans.Rollback();
                    throw sqlEx;
                }
            }
        }
        /// <summary>
        /// 新增资讯
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddSiteContent(SiteContentEntity model)
        {
            StringBuilder sqlCommandText = new StringBuilder();

            sqlCommandText.Append(" @JournalID");
            sqlCommandText.Append(", @ChannelID");
            sqlCommandText.Append(", @Title");
            sqlCommandText.Append(", @Linkurl");
            sqlCommandText.Append(", @TitleColor");
            sqlCommandText.Append(", @IsBold");
            sqlCommandText.Append(", @IsItalic");
            sqlCommandText.Append(", @Source");
            sqlCommandText.Append(", @Author");
            sqlCommandText.Append(", @Tags");
            sqlCommandText.Append(", @Abstruct");
            sqlCommandText.Append(", @TitlePhoto");
            sqlCommandText.Append(", @FJPath");
            sqlCommandText.Append(", @SortID");
            sqlCommandText.Append(", @InAuthor");

            using (DbConnection conn = db.CreateConnection())
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                DbTransaction trans = conn.BeginTransaction();
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.SiteContent ({0},AddDate) VALUES ({1},getdate());select SCOPE_IDENTITY();", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString()));

                    db.AddInParameter(cmd, "@JournalID", DbType.Int64, model.JournalID);
                    db.AddInParameter(cmd, "@ChannelID", DbType.Int64, model.ChannelID);
                    db.AddInParameter(cmd, "@Title", DbType.AnsiString, model.Title);
                    db.AddInParameter(cmd, "@Linkurl", DbType.AnsiString, model.Linkurl);
                    db.AddInParameter(cmd, "@TitleColor", DbType.AnsiString, model.TitleColor);
                    db.AddInParameter(cmd, "@IsBold", DbType.Boolean, model.IsBold);
                    db.AddInParameter(cmd, "@IsItalic", DbType.Boolean, model.IsItalic);
                    db.AddInParameter(cmd, "@Source", DbType.AnsiString, model.Source);
                    db.AddInParameter(cmd, "@Author", DbType.AnsiString, model.Author);
                    db.AddInParameter(cmd, "@Tags", DbType.AnsiString, model.Tags);
                    db.AddInParameter(cmd, "@Abstruct", DbType.AnsiString, model.Abstruct);
                    db.AddInParameter(cmd, "@TitlePhoto", DbType.AnsiString, model.TitlePhoto);
                    db.AddInParameter(cmd, "@FJPath", DbType.AnsiString, model.FJPath);
                    db.AddInParameter(cmd, "@SortID", DbType.Int32, model.SortID);
                    db.AddInParameter(cmd, "@InAuthor", DbType.AnsiString, model.InAuthor);

                    Int64 ContentID = db.ExecuteScalar(cmd, trans).TryParse <Int64>();

                    if (ContentID == 0)
                    {
                        trans.Rollback();
                        return(false);
                    }

                    cmd = db.GetSqlStringCommand("INSERT INTO dbo.SiteContentAtt(ContentID,Content) VALUES(@ContentID,@Content)");
                    db.AddInParameter(cmd, "@ContentID", DbType.Int64, ContentID);
                    db.AddInParameter(cmd, "@Content", DbType.String, model.Content);
                    if (db.ExecuteNonQuery(cmd, trans) < 1)
                    {
                        trans.Rollback();
                        return(false);
                    }

                    trans.Commit();
                    conn.Close();
                    return(true);
                }
                catch (SqlException sqlEx)
                {
                    trans.Rollback();
                    throw sqlEx;
                }
            }
        }
Exemple #10
0
 /// <summary>
 /// 编辑资讯
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateSiteContent(SiteContentEntity model)
 {
     return(SiteContentDataAccess.Instance.UpdateSiteContent(model));
 }
Exemple #11
0
 /// <summary>
 /// 新增资讯
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddSiteContent(SiteContentEntity model)
 {
     return(SiteContentDataAccess.Instance.AddSiteContent(model));
 }