Пример #1
0
        public List <ContentDetailInfo> GetList()
        {
            string cmdText = @"select Id,ContentTypeId,Title,ContentText,Sort,LastUpdatedDate 
			                from ContentDetail
							order by LastUpdatedDate "                            ;

            List <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ContentTypeId   = reader.GetGuid(1);
                        model.Title           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Sort            = reader.GetInt32(4);
                        model.LastUpdatedDate = reader.GetDateTime(5);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(ContentDetailInfo model)
        {
            if (IsExist(model.Title, model.ContentTypeId, model.Id))
            {
                return(110);
            }

            //定义查询命令
            string cmdText = @"update [Sys_ContentDetail] set ContentTypeId = @ContentTypeId,Title = @Title,ContentText = @ContentText,Sort = @Sort,LastUpdatedDate = @LastUpdatedDate,UserId = @UserId where Id = @Id";

            //创建查询命令参数集
            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@ContentTypeId",   SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",           SqlDbType.NVarChar,256),
                new SqlParameter("@ContentText",     SqlDbType.NText),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = Guid.Parse(model.Id.ToString());
            parms[1].Value = Guid.Parse(model.ContentTypeId.ToString());
            parms[2].Value = model.Title;
            parms[3].Value = model.ContentText;
            parms[4].Value = model.Sort;
            parms[5].Value = model.LastUpdatedDate;
            parms[6].Value = Guid.Parse(model.UserId.ToString());


            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Пример #3
0
        public int Insert(ContentDetailInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"insert into ContentDetail (ContentTypeId,Title,PictureId,Descr,ContentText,VirtualViewCount,ViewCount,Sort,IsDisable,LastUpdatedDate)
			            values
						(@ContentTypeId,@Title,@PictureId,@Descr,@ContentText,@VirtualViewCount,@ViewCount,@Sort,@IsDisable,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@ContentTypeId",    SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",            SqlDbType.NVarChar,                 100),
                new SqlParameter("@PictureId",        SqlDbType.UniqueIdentifier),
                new SqlParameter("@Descr",            SqlDbType.NVarChar,                 300),
                new SqlParameter("@ContentText",      SqlDbType.NText,             1073741823),
                new SqlParameter("@VirtualViewCount", SqlDbType.Int),
                new SqlParameter("@ViewCount",        SqlDbType.Int),
                new SqlParameter("@Sort",             SqlDbType.Int),
                new SqlParameter("@IsDisable",        SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate",  SqlDbType.DateTime)
            };
            parms[0].Value = model.ContentTypeId;
            parms[1].Value = model.Title;
            parms[2].Value = model.PictureId;
            parms[3].Value = model.Descr;
            parms[4].Value = model.ContentText;
            parms[5].Value = model.VirtualViewCount;
            parms[6].Value = model.ViewCount;
            parms[7].Value = model.Sort;
            parms[8].Value = model.IsDisable;
            parms[9].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Пример #4
0
        public List <ContentDetailInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select Id,ContentTypeId,Title,ContentText,Sort,LastUpdatedDate
                              from ContentDetail";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }

            List <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ContentTypeId   = reader.GetGuid(1);
                        model.Title           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Sort            = reader.GetInt32(4);
                        model.LastUpdatedDate = reader.GetDateTime(5);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #5
0
        /// <summary>
        /// 获取当前内容类型对应数据
        /// </summary>
        /// <param name="contentType"></param>
        /// <returns></returns>
        public static ContentDetailInfo GetModel(string contentType)
        {
            ContentDetail bll  = new ContentDetail();
            SqlParameter  parm = new SqlParameter("@TypeCode", SqlDbType.NVarChar, 50);

            parm.Value = contentType;

            if (!enableCaching)
            {
                return(bll.GetList("and ct.TypeCode = @TypeCode ", parm).FirstOrDefault());
            }

            string            key  = "contentDetail_single_" + contentType + "";
            ContentDetailInfo data = (ContentDetailInfo)HttpRuntime.Cache[key];

            if (data == null)
            {
                data = bll.GetList("and ct.TypeCode = @TypeCode ", parm).FirstOrDefault();

                AggregateCacheDependency cd = DependencyFacade.GetContentDetailDependency();
                HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(contentDetailTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            }

            return(data);
        }
Пример #6
0
        public ContentDetailInfo GetModel(object Id)
        {
            ContentDetailInfo model = null;

            string       cmdText = @"select top 1 Id,ContentTypeId,Title,ContentText,Sort,LastUpdatedDate 
			                   from ContentDetail
							   where Id = @Id "                            ;
            SqlParameter parm    = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                 = new ContentDetailInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ContentTypeId   = reader.GetGuid(1);
                        model.Title           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Sort            = reader.GetInt32(4);
                        model.LastUpdatedDate = reader.GetDateTime(5);
                    }
                }
            }

            return(model);
        }
        /// <summary>
        /// 添加数据到数据库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Insert(ContentDetailInfo model)
        {
            if (model == null)
            {
                return(-1);
            }

            //判断当前记录是否存在,如果存在则返回;
            if (IsExist(model.Title, model.ContentTypeId, ""))
            {
                return(110);
            }

            string cmdText = "insert into [Sys_ContentDetail] (ContentTypeId,Title,ContentText,Sort,LastUpdatedDate,UserId) values (@ContentTypeId,@Title,@ContentText,@Sort,@LastUpdatedDate,@UserId)";

            //创建查询命令参数集
            SqlParameter[] parms =
            {
                new SqlParameter("@ContentTypeId",   SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",           SqlDbType.NVarChar,256),
                new SqlParameter("@ContentText",     SqlDbType.NText),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = Guid.Parse(model.ContentTypeId.ToString());
            parms[1].Value = model.Title;
            parms[2].Value = model.ContentText;
            parms[3].Value = model.Sort;
            parms[4].Value = model.LastUpdatedDate;
            parms[5].Value = Guid.Parse(model.UserId.ToString());

            //执行数据库操作
            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Пример #8
0
        public IList <ContentDetailInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(500);

            sb.Append(@"select count(*) from ContentDetail ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.TygaSoftDbConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <ContentDetailInfo>());
            }

            sb.Clear();
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by Sort) as RowNumber,
			          AppCode,Id,UserId,ContentTypeId,Title,Keyword,Descr,ContentText,Openness,Sort,RecordDate,LastUpdatedDate
					  from ContentDetail "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.TygaSoftDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.AppCode         = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
                        model.Id              = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2);
                        model.UserId          = reader.IsDBNull(3) ? Guid.Empty : reader.GetGuid(3);
                        model.ContentTypeId   = reader.IsDBNull(4) ? Guid.Empty : reader.GetGuid(4);
                        model.Title           = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                        model.Keyword         = reader.IsDBNull(6) ? string.Empty : reader.GetString(6);
                        model.Descr           = reader.IsDBNull(7) ? string.Empty : reader.GetString(7);
                        model.ContentText     = reader.IsDBNull(8) ? string.Empty : reader.GetString(8);
                        model.Openness        = reader.IsDBNull(9) ? byte.MinValue : reader.GetByte(9);
                        model.Sort            = reader.IsDBNull(10) ? 0 : reader.GetInt32(10);
                        model.RecordDate      = reader.IsDBNull(11) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(11);
                        model.LastUpdatedDate = reader.IsDBNull(12) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(12);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #9
0
        public IList <ContentDetailInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select count(*) from ContentDetail ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <ContentDetailInfo>());
            }

            sb.Clear();
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by Title, LastUpdatedDate desc) as RowNumber,
			          Id,ContentTypeId,Title,PictureId,Descr,ContentText,VirtualViewCount,ViewCount,Sort,IsDisable,LastUpdatedDate
					  from ContentDetail "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id               = reader.GetGuid(1);
                        model.ContentTypeId    = reader.GetGuid(2);
                        model.Title            = reader.GetString(3);
                        model.PictureId        = reader.GetGuid(4);
                        model.Descr            = reader.GetString(5);
                        model.ContentText      = reader.GetString(6);
                        model.VirtualViewCount = reader.GetInt32(7);
                        model.ViewCount        = reader.GetInt32(8);
                        model.Sort             = reader.GetInt32(9);
                        model.IsDisable        = reader.GetBoolean(10);
                        model.LastUpdatedDate  = reader.GetDateTime(11);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
        private void OnSave()
        {
            string sTitle = txtTitle.Value.Trim();

            if (string.IsNullOrEmpty(sTitle))
            {
                MessageBox.Messager(this.Page, this.Page.Controls[0], MessageContent.Submit_Params_InvalidError, "错误提示", "error");
                return;
            }
            string sParent       = txtParent.Value.Trim();
            Guid   contentTypeId = Guid.Empty;

            if (!string.IsNullOrEmpty(sParent))
            {
                Guid.TryParse(sParent, out contentTypeId);
            }
            string sContent = HttpUtility.UrlDecode(hEditor1.Value).Trim();

            hEditor1.Value = sContent;

            ContentDetail     bll   = new ContentDetail();
            ContentDetailInfo model = new ContentDetailInfo();

            model.Title           = sTitle;
            model.ContentTypeId   = contentTypeId;
            model.ContentText     = sContent;
            model.Sort            = 0;
            model.LastUpdatedDate = DateTime.Now;
            model.UserId          = Common.GetUserId(Context);

            int effectCount = -1;

            if (!gId.Equals(Guid.Empty))
            {
                model.Id    = gId;
                effectCount = bll.Update(model);
            }
            else
            {
                effectCount = bll.Insert(model);
            }

            if (effectCount == 110)
            {
                MessageBox.Messager(this.Page, this.Page.Controls[0], MessageContent.Submit_Exist, "系统提示", "error");
                return;
            }
            if (effectCount > 0)
            {
                MessageBox.MessagerShow(this.Page, this.Page.Controls[0], MessageContent.Submit_Success);
            }
            else
            {
                MessageBox.Messager(this.Page, this.Page.Controls[0], MessageContent.Submit_Error);
            }
        }
 private void Bind()
 {
     if (!gId.Equals(Guid.Empty))
     {
         ContentDetail     bll   = new ContentDetail();
         ContentDetailInfo model = bll.GetModel(gId);
         if (model != null)
         {
             txtTitle.Value  = model.Title;
             txtParent.Value = model.ContentTypeId.ToString();
             hEditor1.Value  = model.ContentText;
         }
     }
 }
Пример #12
0
        public ResResultModel SaveContentDetail(ContentDetailFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                if (string.IsNullOrWhiteSpace(model.AppCode) || string.IsNullOrWhiteSpace(model.Title))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                Guid contentTypeId = Guid.Empty;
                if (model.ContentTypeId != null)
                {
                    Guid.TryParse(model.ContentTypeId.ToString(), out contentTypeId);
                }
                var userId    = WebCommon.GetUserId();
                var currTime  = DateTime.Now;
                var modelInfo = new ContentDetailInfo(model.AppCode, Id, userId, contentTypeId, model.Title, model.Keyword, model.Descr, model.ContentText, model.Openness, model.Sort, currTime, currTime);

                var bll    = new ContentDetail();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    modelInfo.Id = Guid.NewGuid();
                    effect       = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
        /// <summary>
        /// 获取数据分页列表,并返回所有记录数
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <param name="sqlWhere"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        public List <ContentDetailInfo> GetList(int pageIndex, int pageSize, out int totalCount, string sqlWhere, params SqlParameter[] cmdParms)
        {
            //获取数据集总数
            string cmdText = "select count(*) from [Sys_ContentDetail] cd left join Sys_ContentType ct on ct.Id = cd.ContentTypeId ";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            totalCount = (int)SqlHelper.ExecuteScalar(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms);
            //返回分页数据
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            cmdText = @"select * from(select row_number() over(order by cd.LastUpdatedDate desc) as RowNumber,cd.Id,cd.ContentTypeId,cd.Title,cd.ContentText,cd.Sort,cd.LastUpdatedDate,cd.UserId from [Sys_ContentDetail] cd
                      left join Sys_ContentType ct on ct.Id = cd.ContentTypeId ";
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " ";

            List <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id              = reader.GetGuid(1);
                        model.ContentTypeId   = reader.GetGuid(2);
                        model.Title           = reader.GetString(3);
                        model.ContentText     = reader.GetString(4);
                        model.Sort            = reader.GetInt32(5);
                        model.LastUpdatedDate = reader.GetDateTime(6);
                        model.UserId          = reader.GetGuid(7);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #14
0
        public ContentDetailInfo GetModelByTitle(string title)
        {
            ContentDetailInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 cd.Id,cd.ContentTypeId,cd.Title,cd.PictureId,cd.Descr,cd.ContentText,cd.VirtualViewCount,cd.ViewCount,cd.Sort,cd.IsDisable,cd.LastUpdatedDate 
			            ,pc.FileExtension,pc.FileDirectory,pc.RandomFolder
                        from ContentDetail cd
                        left join ContentType ct on ct.Id = cd.ContentTypeId
                        left join Picture_Content pc on pc.Id = cd.PictureId
						where ct.TypeValue = @TypeValue "                        );
            SqlParameter parm = new SqlParameter("@TypeValue", SqlDbType.NVarChar, 50);

            parm.Value = title;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                  = new ContentDetailInfo();
                        model.Id               = reader.GetGuid(0);
                        model.ContentTypeId    = reader.GetGuid(1);
                        model.Title            = reader.GetString(2);
                        model.PictureId        = reader.GetGuid(3);
                        model.Descr            = reader.GetString(4);
                        model.ContentText      = reader.GetString(5);
                        model.VirtualViewCount = reader.GetInt32(6);
                        model.ViewCount        = reader.GetInt32(7);
                        model.Sort             = reader.GetInt32(8);
                        model.IsDisable        = reader.GetBoolean(9);
                        model.LastUpdatedDate  = reader.GetDateTime(10);
                        model.FileExtension    = reader.IsDBNull(11) ? string.Empty : reader.GetString(11);
                        model.FileDirectory    = reader.IsDBNull(12) ? string.Empty : reader.GetString(12);
                        model.RandomFolder     = reader.IsDBNull(13) ? string.Empty : reader.GetString(13);
                    }
                }
            }

            return(model);
        }
Пример #15
0
        public IList <ContentDetailInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(500);

            sb.Append(@"select AppCode,Id,UserId,ContentTypeId,Title,Keyword,Descr,ContentText,Openness,Sort,RecordDate,LastUpdatedDate
                        from ContentDetail ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.Append("order by Sort ");

            IList <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.TygaSoftDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.AppCode         = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
                        model.Id              = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1);
                        model.UserId          = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2);
                        model.ContentTypeId   = reader.IsDBNull(3) ? Guid.Empty : reader.GetGuid(3);
                        model.Title           = reader.IsDBNull(4) ? string.Empty : reader.GetString(4);
                        model.Keyword         = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                        model.Descr           = reader.IsDBNull(6) ? string.Empty : reader.GetString(6);
                        model.ContentText     = reader.IsDBNull(7) ? string.Empty : reader.GetString(7);
                        model.Openness        = reader.IsDBNull(8) ? byte.MinValue : reader.GetByte(8);
                        model.Sort            = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        model.RecordDate      = reader.IsDBNull(10) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(10);
                        model.LastUpdatedDate = reader.IsDBNull(11) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(11);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #16
0
        public ContentDetailInfo GetModel(Guid id)
        {
            ContentDetailInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 AppCode,Id,UserId,ContentTypeId,Title,Keyword,Descr,ContentText,Openness,Sort,RecordDate,LastUpdatedDate 
			            from ContentDetail
						where Id = @Id "                        );
            SqlParameter[] parms =
            {
                new SqlParameter("@Id", SqlDbType.UniqueIdentifier)
            };
            parms[0].Value = id;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.TygaSoftDbConnString, CommandType.Text, sb.ToString(), parms))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        model                 = new ContentDetailInfo();
                        model.AppCode         = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
                        model.Id              = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1);
                        model.UserId          = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2);
                        model.ContentTypeId   = reader.IsDBNull(3) ? Guid.Empty : reader.GetGuid(3);
                        model.Title           = reader.IsDBNull(4) ? string.Empty : reader.GetString(4);
                        model.Keyword         = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                        model.Descr           = reader.IsDBNull(6) ? string.Empty : reader.GetString(6);
                        model.ContentText     = reader.IsDBNull(7) ? string.Empty : reader.GetString(7);
                        model.Openness        = reader.IsDBNull(8) ? byte.MinValue : reader.GetByte(8);
                        model.Sort            = reader.IsDBNull(9) ? 0 : reader.GetInt32(9);
                        model.RecordDate      = reader.IsDBNull(10) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(10);
                        model.LastUpdatedDate = reader.IsDBNull(11) ? DateTime.Parse("1754-01-01") : reader.GetDateTime(11);
                    }
                }
            }

            return(model);
        }
Пример #17
0
        /// <summary>
        /// 获取当前ID对应数据
        /// </summary>
        /// <param name="nId"></param>
        /// <returns></returns>
        public static ContentDetailInfo GetModel(object nId)
        {
            ContentDetail bll = new ContentDetail();

            if (!enableCaching)
            {
                return(bll.GetModel(nId));
            }

            string            key  = "contentDetail_" + nId.ToString() + "";
            ContentDetailInfo data = (ContentDetailInfo)HttpRuntime.Cache[key];

            if (data == null)
            {
                data = bll.GetModel(nId);

                AggregateCacheDependency cd = DependencyFacade.GetContentDetailDependency();
                HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(contentDetailTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            }

            return(data);
        }
Пример #18
0
        public IList <ContentDetailInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ContentTypeId,Title,PictureId,Descr,ContentText,VirtualViewCount,ViewCount,Sort,IsDisable,LastUpdatedDate
                        from ContentDetail ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

            IList <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id               = reader.GetGuid(0);
                        model.ContentTypeId    = reader.GetGuid(1);
                        model.Title            = reader.GetString(2);
                        model.PictureId        = reader.GetGuid(3);
                        model.Descr            = reader.GetString(4);
                        model.ContentText      = reader.GetString(5);
                        model.VirtualViewCount = reader.GetInt32(6);
                        model.ViewCount        = reader.GetInt32(7);
                        model.Sort             = reader.GetInt32(8);
                        model.IsDisable        = reader.GetBoolean(9);
                        model.LastUpdatedDate  = reader.GetDateTime(10);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #19
0
        public int InsertByOutput(ContentDetailInfo model)
        {
            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"insert into ContentDetail (Id,AppCode,UserId,ContentTypeId,Title,Keyword,Descr,ContentText,Openness,Sort,RecordDate,LastUpdatedDate)
			            values
						(@Id,@AppCode,@UserId,@ContentTypeId,@Title,@Keyword,@Descr,@ContentText,@Openness,@Sort,@RecordDate,@LastUpdatedDate)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@AppCode",         SqlDbType.Char,                      10),
                new SqlParameter("@UserId",          SqlDbType.UniqueIdentifier),
                new SqlParameter("@ContentTypeId",   SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",           SqlDbType.NVarChar,                 256),
                new SqlParameter("@Keyword",         SqlDbType.NVarChar,                 256),
                new SqlParameter("@Descr",           SqlDbType.NVarChar,                 300),
                new SqlParameter("@ContentText",     SqlDbType.NText,             1073741823),
                new SqlParameter("@Openness",        SqlDbType.TinyInt),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@RecordDate",      SqlDbType.DateTime),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value  = model.Id;
            parms[1].Value  = model.AppCode;
            parms[2].Value  = model.UserId;
            parms[3].Value  = model.ContentTypeId;
            parms[4].Value  = model.Title;
            parms[5].Value  = model.Keyword;
            parms[6].Value  = model.Descr;
            parms[7].Value  = model.ContentText;
            parms[8].Value  = model.Openness;
            parms[9].Value  = model.Sort;
            parms[10].Value = model.RecordDate;
            parms[11].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.TygaSoftDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Пример #20
0
        public List <ContentDetailInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms)
        {
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            string cmdText = @"select * from(select row_number() over(order by LastUpdatedDate) as RowNumber,
			                 Id,ContentTypeId,Title,ContentText,Sort,LastUpdatedDate
							 from ContentDetail"                            ;

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            cmdText += ")as objTable where RowNumber between " + startIndex + " and " + endIndex + " ";

            List <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id              = reader.GetGuid(1);
                        model.ContentTypeId   = reader.GetGuid(2);
                        model.Title           = reader.GetString(3);
                        model.ContentText     = reader.GetString(4);
                        model.Sort            = reader.GetInt32(5);
                        model.LastUpdatedDate = reader.GetDateTime(6);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #21
0
        public int Update(ContentDetailInfo model)
        {
            string cmdText = @"update ContentDetail set ContentTypeId = @ContentTypeId,Title = @Title,ContentText = @ContentText,Sort = @Sort,LastUpdatedDate = @LastUpdatedDate 
			                 where Id = @Id"            ;

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@ContentTypeId",   SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",           SqlDbType.NVarChar,                 256),
                new SqlParameter("@ContentText",     SqlDbType.NText,             1073741823),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.ContentTypeId;
            parms[2].Value = model.Title;
            parms[3].Value = model.ContentText;
            parms[4].Value = model.Sort;
            parms[5].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parms));
        }
Пример #22
0
        public ContentDetailInfo GetModel(object Id)
        {
            ContentDetailInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,ContentTypeId,Title,PictureId,Descr,ContentText,VirtualViewCount,ViewCount,Sort,IsDisable,LastUpdatedDate 
			                   from ContentDetail
							   where Id = @Id "                            );
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                  = new ContentDetailInfo();
                        model.Id               = reader.GetGuid(0);
                        model.ContentTypeId    = reader.GetGuid(1);
                        model.Title            = reader.GetString(2);
                        model.PictureId        = reader.GetGuid(3);
                        model.Descr            = reader.GetString(4);
                        model.ContentText      = reader.GetString(5);
                        model.VirtualViewCount = reader.GetInt32(6);
                        model.ViewCount        = reader.GetInt32(7);
                        model.Sort             = reader.GetInt32(8);
                        model.IsDisable        = reader.GetBoolean(9);
                        model.LastUpdatedDate  = reader.GetDateTime(10);
                    }
                }
            }

            return(model);
        }
        /// <summary>
        /// 获取满足当前条件的数据列表
        /// </summary>
        /// <param name="sqlWhere"></param>
        /// <param name="cmdParms"></param>
        /// <returns></returns>
        public List <ContentDetailInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            string cmdText = @"select cd.Id,cd.ContentTypeId,cd.Title,cd.ContentText,cd.Sort,cd.LastUpdatedDate,cd.UserId from [Sys_ContentDetail] cd 
                             left join Sys_ContentType ct on ct.Id = cd.ContentTypeId ";

            if (!string.IsNullOrEmpty(sqlWhere))
            {
                cmdText += "where 1=1 " + sqlWhere;
            }
            cmdText += " order by cd.LastUpdatedDate desc ";

            List <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    list = new List <ContentDetailInfo>();

                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ContentTypeId   = reader.GetGuid(1);
                        model.Title           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Sort            = reader.GetInt32(4);
                        model.LastUpdatedDate = reader.GetDateTime(5);
                        model.UserId          = reader.GetGuid(6);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #24
0
        public IList <ContentDetailInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ContentTypeId,Title,PictureId,Descr,ContentText,VirtualViewCount,ViewCount,Sort,IsDisable,LastUpdatedDate 
			            from ContentDetail
					    order by LastUpdatedDate desc "                    );

            IList <ContentDetailInfo> list = new List <ContentDetailInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ContentDetailInfo model = new ContentDetailInfo();
                        model.Id               = reader.GetGuid(0);
                        model.ContentTypeId    = reader.GetGuid(1);
                        model.Title            = reader.GetString(2);
                        model.PictureId        = reader.GetGuid(3);
                        model.Descr            = reader.GetString(4);
                        model.ContentText      = reader.GetString(5);
                        model.VirtualViewCount = reader.GetInt32(6);
                        model.ViewCount        = reader.GetInt32(7);
                        model.Sort             = reader.GetInt32(8);
                        model.IsDisable        = reader.GetBoolean(9);
                        model.LastUpdatedDate  = reader.GetDateTime(10);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Пример #25
0
        public int Update(ContentDetailInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update ContentDetail set ContentTypeId = @ContentTypeId,Title = @Title,PictureId = @PictureId,Descr = @Descr,ContentText = @ContentText,VirtualViewCount = @VirtualViewCount,ViewCount = @ViewCount,Sort = @Sort,IsDisable = @IsDisable,LastUpdatedDate = @LastUpdatedDate 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",               SqlDbType.UniqueIdentifier),
                new SqlParameter("@ContentTypeId",    SqlDbType.UniqueIdentifier),
                new SqlParameter("@Title",            SqlDbType.NVarChar,                 100),
                new SqlParameter("@PictureId",        SqlDbType.UniqueIdentifier),
                new SqlParameter("@Descr",            SqlDbType.NVarChar,                 300),
                new SqlParameter("@ContentText",      SqlDbType.NText,             1073741823),
                new SqlParameter("@VirtualViewCount", SqlDbType.Int),
                new SqlParameter("@ViewCount",        SqlDbType.Int),
                new SqlParameter("@Sort",             SqlDbType.Int),
                new SqlParameter("@IsDisable",        SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate",  SqlDbType.DateTime)
            };
            parms[0].Value  = model.Id;
            parms[1].Value  = model.ContentTypeId;
            parms[2].Value  = model.Title;
            parms[3].Value  = model.PictureId;
            parms[4].Value  = model.Descr;
            parms[5].Value  = model.ContentText;
            parms[6].Value  = model.VirtualViewCount;
            parms[7].Value  = model.ViewCount;
            parms[8].Value  = model.Sort;
            parms[9].Value  = model.IsDisable;
            parms[10].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), parms));
        }
        /// <summary>
        /// 获取对应的数据
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ContentDetailInfo GetModel(object Id)
        {
            Guid gId = Guid.Empty;

            Guid.TryParse(Id.ToString(), out gId);
            if (gId == Guid.Empty)
            {
                return(null);
            }

            ContentDetailInfo model = new ContentDetailInfo();

            string       cmdText = @"select top 1 Id,ContentTypeId,Title,ContentText,Sort,LastUpdatedDate,UserId from [Sys_ContentDetail] where Id = @Id order by LastUpdatedDate desc ";
            SqlParameter parm    = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = gId;

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model.Id              = reader.GetGuid(0);
                        model.ContentTypeId   = reader.GetGuid(1);
                        model.Title           = reader.GetString(2);
                        model.ContentText     = reader.GetString(3);
                        model.Sort            = reader.GetInt32(4);
                        model.LastUpdatedDate = reader.GetDateTime(5);
                        model.UserId          = reader.GetGuid(6);
                    }
                }
            }

            return(model);
        }
Пример #27
0
 public int Update(ContentDetailInfo model)
 {
     return(dal.Update(model));
 }
Пример #28
0
 public int InsertByOutput(ContentDetailInfo model)
 {
     return(dal.InsertByOutput(model));
 }
Пример #29
0
        /// <summary>
        /// 站点内容
        /// </summary>
        /// <param name="context"></param>
        private void SaveContentDetail(HttpContext context)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$txtTitle"]))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }
                if (string.IsNullOrWhiteSpace(context.Request.Form["contentTypeId"]))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }

                Guid gId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$hId"].Trim()))
                {
                    Guid.TryParse(context.Request.Form["ctl00$cphMain$hId"].Trim(), out gId);
                }

                Guid contentTypeId = Guid.Empty;
                Guid.TryParse(context.Request.Form["contentTypeId"], out contentTypeId);
                Guid pictureId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$hPictureId"]))
                {
                    Guid.TryParse(context.Request.Form["ctl00$cphMain$hPictureId"], out pictureId);
                }
                int virtualViewCount = 0;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$txtVirtualViewCount"]))
                {
                    int.TryParse(context.Request.Form["ctl00$cphMain$txtVirtualViewCount"], out virtualViewCount);
                }
                int sort = 0;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["ctl00$cphMain$txtSort"]))
                {
                    int.TryParse(context.Request.Form["ctl00$cphMain$txtSort"], out sort);
                }
                bool isDisable = false;
                if (!string.IsNullOrWhiteSpace(context.Request.Form["isDisable"]))
                {
                    bool.TryParse(context.Request.Form["isDisable"], out isDisable);
                }

                ContentDetailInfo model = new ContentDetailInfo();
                model.Id = gId;
                model.LastUpdatedDate  = DateTime.Now;
                model.Title            = context.Request.Form["ctl00$cphMain$txtTitle"].Trim();
                model.PictureId        = pictureId;
                model.Descr            = context.Request.Form["ctl00$cphMain$txtaDescr"] == null ? "" : context.Request.Form["ctl00$cphMain$txtaDescr"].Trim();
                model.ContentText      = context.Request.Form["txtContent"] == null ? "" : HttpUtility.HtmlDecode(context.Request.Form["txtContent"].Trim());
                model.ContentTypeId    = contentTypeId;
                model.VirtualViewCount = virtualViewCount;
                model.Sort             = sort;
                model.IsDisable        = isDisable;

                ContentDetail bll    = new ContentDetail();
                int           effect = -1;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (TransactionScope scope2 = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        if (bll.IsExist(model.ContentTypeId, model.Id))
                        {
                            scope2.Complete();
                            scope.Complete();
                            context.Response.Write("{\"success\": false,\"message\": \"已存在该类别的内容,请勿重复操作\"}");
                            return;
                        }
                    }
                    if (!gId.Equals(Guid.Empty))
                    {
                        effect = bll.Update(model);
                    }
                    else
                    {
                        effect = bll.Insert(model);
                    }

                    scope.Complete();
                }
                if (effect == 110)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Exist + "\"}");
                    return;
                }
                if (effect != 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"操作失败,请正确输入\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"操作成功\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"异常:" + ex.Message + "\"}");
            }
        }