Beispiel #1
0
        public int Site_Content_Insert(Site_Content obj)
        {
            DbCommand dbCmd = db.GetStoredProcCommand("Proc_Site_Content_Insert");

            db.AddOutParameter(dbCmd, "@c_id", DbType.Int32, 4);
            db.AddInParameter(dbCmd, "@c_gid", DbType.String, obj.c_gid);
            db.AddInParameter(dbCmd, "@c_c_gid", DbType.String, obj.c_c_gid);
            db.AddInParameter(dbCmd, "@c_title", DbType.String, obj.c_title);
            db.AddInParameter(dbCmd, "@c_keywords", DbType.String, obj.c_keywords);
            db.AddInParameter(dbCmd, "@c_sub_title", DbType.String, obj.c_sub_title);
            db.AddInParameter(dbCmd, "@c_intro", DbType.String, obj.c_intro);
            db.AddInParameter(dbCmd, "@c_content", DbType.String, obj.c_content);
            db.AddInParameter(dbCmd, "@c_img_src", DbType.String, obj.c_img_src);
            db.AddInParameter(dbCmd, "@c_createUserId", DbType.String, obj.c_createUserId);
            db.AddInParameter(dbCmd, "@c_createUserName", DbType.String, obj.c_createUserName);
            db.AddInParameter(dbCmd, "@c_createUserNickName", DbType.String, obj.c_createUserNickName);
            db.AddInParameter(dbCmd, "@c_createTime", DbType.DateTime, obj.c_createTime);
            db.AddInParameter(dbCmd, "@c_status", DbType.Int32, obj.c_status);
            db.AddInParameter(dbCmd, "@c_state", DbType.Boolean, obj.c_state);
            db.AddInParameter(dbCmd, "@c_updateTime", DbType.DateTime, obj.c_updateTime);

            try
            {
                int returnValue = db.ExecuteNonQuery(dbCmd);
                int c_id        = (int)dbCmd.Parameters["@c_id"].Value;
                return(returnValue);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #2
0
        public List <Site_Content> Site_Content_SelectPageByc_id(int cateId, int pageIndex, int pageSize, out int rowCount)
        {
            DbCommand dbCmd = db.GetStoredProcCommand("Proc_Site_Content_SelectPageByc_id");

            db.AddInParameter(dbCmd, "@cateId", DbType.Int32, cateId);
            db.AddInParameter(dbCmd, "@pageIndex", DbType.Int32, pageIndex);
            db.AddInParameter(dbCmd, "@pageSize", DbType.Int32, pageSize);
            db.AddOutParameter(dbCmd, "@rowCount", DbType.Int32, 4);

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

            try
            {
                using (IDataReader reader = db.ExecuteReader(dbCmd))
                {
                    while (reader.Read())
                    {
                        //属性赋值
                        Site_Content obj = this.Obj2Model <Site_Content>(reader);

                        list.Add(obj);
                    }
                    reader.NextResult();
                }
                rowCount = (int)dbCmd.Parameters["@rowCount"].Value;

                return(list);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #3
0
        public List <Site_Content> Site_Content_SelectPage(string cloumns, int pageIndex, int pageSize, string orderBy, string where, out int rowCount)
        {
            DbCommand dbCmd = db.GetStoredProcCommand("Proc_Site_Content_SelectPage");

            db.AddOutParameter(dbCmd, "@rowCount", DbType.Int32, 4);
            db.AddInParameter(dbCmd, "@cloumns", DbType.String, cloumns);
            db.AddInParameter(dbCmd, "@pageIndex", DbType.Int32, pageIndex);
            db.AddInParameter(dbCmd, "@pageSize", DbType.Int32, pageSize);
            db.AddInParameter(dbCmd, "@orderBy", DbType.String, orderBy);
            db.AddInParameter(dbCmd, "@where", DbType.String, where);
            List <Site_Content> list = new List <Site_Content>();

            try
            {
                using (IDataReader reader = db.ExecuteReader(dbCmd))
                {
                    while (reader.Read())
                    {
                        Site_Content obj = this.Obj2Model <Site_Content>(reader);
                        //属性赋值

                        list.Add(obj);
                    }
                    reader.NextResult();
                }
                rowCount = (int)dbCmd.Parameters["@rowCount"].Value;
                return(list);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #4
0
 public int Site_Content_UpdateByc_id(Site_Content obj)
 {
     using (SiteContentAccesss access = new SiteContentAccesss())
     {
         return(access.Site_Content_UpdateByc_id(obj));
     }
 }
Beispiel #5
0
        public ActionResult SiteContentCheck()
        {
            string c_gid  = Request["c_gid"] ?? string.Empty;
            int    status = Request["status"].ToInt32(1);

            int          successCount = 0;
            int          failCount    = 0;
            int          result       = 0;
            Site_Content info         = null;

            string[] c_gidArr = c_gid.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < c_gidArr.Length; i++)
            {
                info          = SiteServiceClass.Site_Content_SelectByc_gid(c_gidArr[i]);
                info.c_status = status;
                result        = SiteServiceClass.Site_Content_UpdateByc_id(info);
                if (result > 0)
                {
                    successCount++;
                }
                else
                {
                    failCount++;
                }
            }
            if (c_gidArr.Length == 1)
            {
                return(Json(new { success = true, errors = new { text = "审核成功" } }));
            }
            else
            {
                return(Json(new { success = true, errors = new { text = string.Format("审核成功{0}条,失败{1}条", successCount, failCount) } }));
            }
        }
Beispiel #6
0
 public int Site_Content_Insert(Site_Content obj)
 {
     using (SiteContentAccesss access = new SiteContentAccesss())
     {
         return(access.Site_Content_Insert(obj));
     }
 }
        public static int Site_Content_UpdateByc_id(Site_Content obj)
        {
            ISiteService channel = Entity.CreateChannel <ISiteService>(SiteEnum.SiteService.SiteService);
            var          result  = channel.Site_Content_UpdateByc_id(obj);

            (channel as IDisposable).Dispose();
            return(result);
        }
Beispiel #8
0
        // GET: Detail
        public ActionResult Index(string gid)
        {
            Site_Content info = SiteServiceClass.Site_Content_SelectByc_gid(gid);

            if (info != null)
            {
                if (info.c_status == (int)SiteEnum.SiteItemStatus.待审核 || info.c_status == (int)SiteEnum.SiteItemStatus.关闭)
                {
                    return(RedirectToAction("NotFound", "Error"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Error"));
            }

            ViewBag.info = info;
            return(View());
        }
Beispiel #9
0
        public ActionResult ContentEditView()
        {
            string cate_gid = Request["cate_gid"] ?? string.Empty;
            string c_gid    = Request["c_gid"] ?? string.Empty;

            Site_Content info = null;

            if (string.IsNullOrEmpty(c_gid))
            {
                info = new Site_Content();
            }
            else
            {
                info = SiteServiceClass.Site_Content_SelectByc_gid(c_gid);
            }
            ViewData["window"] = Request["window"] ?? string.Empty;
            ViewData["info"]   = info;
            ViewBag.c_gid      = c_gid;
            ViewBag.cate_gid   = cate_gid;

            return(View());
        }
Beispiel #10
0
        public Site_Content Site_Content_SelectByc_gid(string c_gid)
        {
            DbCommand dbCmd = db.GetStoredProcCommand("Proc_Site_Content_SelectByc_gid");

            db.AddInParameter(dbCmd, "@c_gid", DbType.String, c_gid);
            Site_Content obj = null;

            try
            {
                using (IDataReader reader = db.ExecuteReader(dbCmd))
                {
                    while (reader.Read())
                    {
                        //属性赋值
                        obj = this.Obj2Model <Site_Content>(reader);
                    }
                }
                return(obj);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Beispiel #11
0
        public ActionResult SiteContentRecommendEdit()
        {
            //内容ID
            string c_gid = Request["c_gid"] ?? string.Empty;
            //推荐区块ID
            string b_gid = Request["b_gid"] ?? string.Empty;
            //区块页面ID
            string p_gid = Request["p_gid"] ?? string.Empty;

            Site_Content content      = null;
            Site_CMSItem item         = null;
            int          existCount   = 0;
            int          successCount = 0;
            int          failCount    = 0;
            int          result       = 0;

            Site_CMSBlock b_info = SiteServiceClass.Site_CMSBlock_SelectByb_gid(b_gid);

            string[] c_gidArr = c_gid.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < c_gidArr.Length; i++)
            {
                content = SiteServiceClass.Site_Content_SelectByc_gid(c_gidArr[i]);
                item    = SiteServiceClass.Site_CMSItem_SelectByc_gidAndb_gid(c_gidArr[i], b_gid);
                if (item != null)
                {
                    existCount++;
                    continue;
                }

                item              = new Site_CMSItem();
                item.i_b_gid      = b_gid;
                item.i_intro      = content.c_intro;
                item.i_createTime = DateTime.Now;
                item.i_createUser = SiteHelp.CurrentUserName;
                item.i_c_gid      = content.c_gid;
                item.i_c_type     = string.Empty;
                item.i_gid        = Guid.NewGuid().ToString().Substring(0, 8);
                item.i_p_gid      = p_gid;
                item.i_status     = (int)SiteEnum.SiteItemStatus.待审核;
                item.i_subTitle   = content.c_sub_title;
                item.i_title      = content.c_sub_title;
                item.i_c_img_src  = string.Empty;

                //图片需要根据该区块设置的图片尺寸,缩放该图片,使用原图来进行缩放
                if (!string.IsNullOrEmpty(b_info.b_img_size.Trim()))
                {
                    if (!string.IsNullOrEmpty(content.c_img_src))
                    {
                        int    index     = content.c_img_src.LastIndexOf('_');
                        string sourceSrc = content.c_img_src.Substring(0, index) + ".jpg";

                        string error;
                        byte[] imgData = SiteUntility.GetRemoteImage(sourceSrc, out error);
                        if (imgData != null)
                        {
                            List <string> srcResult = UploadServiceClass.UploadImg(
                                imgData,
                                SiteEnum.SiteUploadConfigName.baseUpload.ToString(),
                                new List <string>()
                            {
                                b_info.b_img_size
                            },
                                ".jpg", "s"
                                );
                            item.i_c_img_src = srcResult[1];
                        }
                    }
                }

                result = SiteServiceClass.Site_CMSItem_Insert(item);
                if (result > 0)
                {
                    successCount++;
                }
                else
                {
                    failCount++;
                }
            }

            if (c_gidArr.Length == 1)
            {
                return(Json(new { success = true, errors = new { text = "推荐成功" } }));
            }
            else
            {
                return(Json(new { success = true, errors = new { text = string.Format("推荐成功{0}条,失败{1}条,重复{2}条", successCount, failCount, existCount) } }));
            }
        }
Beispiel #12
0
        public ActionResult SiteContentEdit()
        {
            string c_title    = Request["c_title"] ?? string.Empty;
            string c_keywords = Request["c_keywords"] ?? string.Empty;
            string c_subTitle = Request["c_subTitle"] ?? string.Empty;
            string c_content  = Request["c_content"] ?? string.Empty;
            string c_intro    = Request["c_intro"] ?? string.Empty;
            string c_gid      = Request["c_gid"] ?? string.Empty;
            string c_c_gid    = Request["cate_gid"] ?? string.Empty;

            Site_Content info = null;

            if (string.IsNullOrEmpty(c_gid))
            {
                info = new Site_Content();
                //新增
                info.c_gid                = Entity.GenerateGUID();
                info.c_createUserName     = SiteHelp.CurrentUserName;
                info.c_createUserNickName = SiteHelp.CurrentUserNickName;
                info.c_createUserId       = string.Empty;
                info.c_createTime         = DateTime.Now;
            }
            else
            {
                info = SiteServiceClass.Site_Content_SelectByc_gid(c_gid);
            }

            info.c_status     = (int)SiteEnum.SiteItemStatus.待审核;
            info.c_updateTime = DateTime.Now;
            info.c_sub_title  = c_subTitle;
            info.c_title      = c_title;
            info.c_keywords   = c_keywords;
            info.c_c_gid      = c_c_gid;
            info.c_content    = c_content;
            info.c_intro      = c_intro;
            info.c_img_src    = string.Empty;

            //默认第一张图片为封面
            MatchCollection list = Regex.Matches(c_content, @"<img src=""(?<img>[\S]*)""[^/]*/>");

            if (list.Count > 0)
            {
                string img_src = list[0].Groups["img"].Value;
                info.c_img_src = img_src;
            }

            if (string.IsNullOrEmpty(c_gid))
            {
                int result = SiteServiceClass.Site_Content_Insert(info);
                if (result > 0)
                {
                    return(Json(new { success = true, errors = new { text = "新增成功" } }));
                }
                else
                {
                    return(Json(new { success = false, errors = new { text = "新增失败" } }));
                }
            }
            else
            {
                int result = SiteServiceClass.Site_Content_UpdateByc_id(info);
                if (result > 0)
                {
                    return(Json(new { success = true, errors = new { text = "修改成功" } }));
                }
                else
                {
                    return(Json(new { success = false, errors = new { text = "修改失败" } }));
                }
            }
        }