Exemplo n.º 1
0
 public JsonResult Delrecord(FormCollection fc)
 {
     BBSSite.MyPublic.LoginStatus IStatus = new BBSSite.MyPublic.LoginStatus();
     if (IStatus.IsLogin)
     {
         int FMID;
         if (int.TryParse(fc["FMID"], out FMID))
         {
             using (DB_BBSEntities db = new DB_BBSEntities())
             {
                 tb_ForumMain fm = new tb_ForumMain()
                 {
                     ID = FMID
                 };
                 tb_ForumMain updateForumMain = db.tb_ForumMain.Attach(fm);
                 updateForumMain.Isdelete = true;
                 db.Entry(updateForumMain).Property(P => P.Isdelete).IsModified = true;
                 db.Configuration.ValidateOnSaveEnabled = false;
                 bool IsUpdate = db.SaveChanges() > 0;
                 db.Configuration.ValidateOnSaveEnabled = false;
                 if (IsUpdate)
                 {
                     return(Json(new { ResultStatus = 1, ResultMsg = "操作成功!" }, JsonRequestBehavior.AllowGet));
                 }
             }
             return(Json(new { ResultStatus = 0, ResultMsg = "操作失败!" }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { ResultStatus = -1, ResultMsg = "参数验证失败!" }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { ResultStatus = -2, ResultMsg = "未登录!" }, JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 2
0
        /// <summary>
        /// SecondContent action,用于读取贴子详细数据
        /// </summary>
        /// <param name="id">主贴ID</param>
        /// <param name="CurrentPageindex">分页页码</param>
        /// <returns>根据传入的强类型ForumMainJoinForumSecondEntity实例模型,返回SecondContent视图</returns>
        public ActionResult SecondContent(int id = 0, int CurrentPageindex = 1)
        {
            if (id == 0)
            {
                return(Goto("Index", "Home"));
            }                                                                          //执行跳转到上一次访问的动作,或跳转到指定的动作
            PublicFunctions.SetUrls(ViewBag, Url);                                     //构造资源路径(js、css、image等)
            const int    PageSize = 10, PageCount = 5;                                 //定义每页显示数据总数及最多显示的页码
            ConfigPaging cp = new ConfigPaging(CurrentPageindex, PageSize, PageCount); //构造分页对象配置类
            ForumMainJoinForumSecondEntity Model = null;                               //要返回的数据模型

            using (DB_BBSEntities db = new DB_BBSEntities())                           //构造数据库上下文类
            {
                //根据条件,查询主贴表数据
                Model = db.tb_ForumMain.Where(W => W.ID == id && W.Isdelete == false).Select(S => new ForumMainJoinForumSecondEntity
                {
                    ForumMain        = S,                                                //主贴信息
                    ForumClassify    = S.tb_ForumClassify,                               //所属子专区信息
                    UsersByCustomer  = S.tb_UsersByCustomer,                             //发帖人信息
                    ZY_Sex           = S.tb_UsersByCustomer.tb_ZY_Sex,                   //发帖人性别(读取资源表)
                    ForumSecondCount = S.tb_ForumSecond.Count(C => C.IsDelete == false), //总回复数
                    //查询该贴的跟帖数据集合,并使用分页进行查询
                    ForumSecond = S.tb_ForumSecond.Where(W1 => W1.IsDelete == false && W1.CurSequence > 0).OrderBy(O => O.CurSequence).Skip(cp.StartRow).Take(PageSize).Select(S1 =>
                                                                                                                                                                               new ChildForumSecondByUsersByCustomer
                    {
                        ForumSecond     = S1,                             //跟帖数据
                        UsersByCustomer = S1.tb_UsersByCustomer,          //回复人
                        ZY_Sex          = S1.tb_UsersByCustomer.tb_ZY_Sex //回复人性别(读取资源表)
                    }).ToList()
                }).FirstOrDefault();
            }
            cp.GetPaging(ViewBag, Model.ForumSecondCount); //绑定分页数据
            ViewBag.curid = id;                            //此id为传入的所属专区ID,将在下次分页时传回
            return(View(Model));                           //返回视图
        }
Exemplo n.º 3
0
        /// <summary>
        /// 登录或注册成功时,保存的用户信息
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Session">请求的Session状态对象</param>
        public void LoginSuccess(string UserName, HttpSessionStateBase Session)
        {
            tb_UsersByCustomer MyUsersByCustomer = null;
            tb_ZY_Sex          MyZY_Sex          = null;

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                MyUsersByCustomer = db.tb_UsersByCustomer.Where(W => W.UserName == UserName).First();
                MyZY_Sex          = db.tb_ZY_Sex.Where(W => W.ID == MyUsersByCustomer.SexID).First();
            }
            if (MyUsersByCustomer != null)
            {
                LoginStatusEntity LSE = new LoginStatusEntity
                {
                    ID        = MyUsersByCustomer.ID,
                    UserName  = MyUsersByCustomer.UserName,
                    NickName  = MyUsersByCustomer.NickName,
                    SexID     = MyUsersByCustomer.SexID,
                    Sex       = MyZY_Sex.Content,
                    Age       = MyUsersByCustomer.Age,
                    PhotoUrl  = MyUsersByCustomer.PhotoUrl,
                    Email     = MyUsersByCustomer.Email,
                    Fatieshu  = MyUsersByCustomer.Fatieshu ?? 0,
                    Huitieshu = MyUsersByCustomer.Huitieshu ?? 0
                };
                Session.Add("LoginSuccess", LSE);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 读取栏目表tb_Column数据
 /// </summary>
 /// <returns>返回栏目表所有数据</returns>
 public static void GetColumn(dynamic ViewBag)
 {
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         ViewBag.Columns = db.tb_Column.ToList();
     }
 }
Exemplo n.º 5
0
 public static tb_Column GetCurrentColumnCode(int ColumnGrade, string ChooseParentColumn)
 {
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         if (ColumnGrade == 1)
         {
             Expression <Func <tb_Column, bool> > Exp = where => where.ColumnCode.Length == 1;
             var list = db.tb_Column.Where(Exp.Compile()).OrderByDescending(O => O.ColumnCode).Take(1).ToList();
             if (list != null && list.Count > 0)
             {
                 return(list.First());
             }
         }
         else
         {
             Expression <Func <tb_Column, bool> > Exp1 = where => where.ColumnCode.Length > 1 && where.ColumnCode.Substring(0, 1) == ChooseParentColumn;
             var list = db.tb_Column.Where(Exp1.Compile()).OrderByDescending(O => O.ColumnCode).ToList();
             if (list != null && list.Count > 0)
             {
                 return(list.First());
             }
         }
     }
     return(null);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 通过递归获取对话评论内容
        /// </summary>
        /// <returns>返回是否结束递归</returns>
        public bool While()
        {
            List <ChildReplyEntity> Es = EachArray[Index];
            List <ChildReplyEntity> TempChildReplyEntity = new List <ChildReplyEntity>();

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                foreach (ChildReplyEntity CE in Es)
                {
                    IQueryable <tb_ForumSecond> WhereForumSecond = db.tb_ForumSecond.Where(W => W.ReplySequenceID == CE.ForumSecond.ID && W.IsDelete == false && W.CurSequence == 0);
                    var list = db.tb_ForumSecond.Where(W => W.ReplySequenceID == CE.ForumSecond.ID && W.IsDelete == false && W.CurSequence == 0)
                               .Select(S => new ChildReplyEntity
                    {
                        ForumSecond     = S,
                        UsersByCustomer = S.tb_UsersByCustomer
                    }).ToList().Select(S => new ChildReplyEntity {
                        ForumSecond = S.ForumSecond, UsersByCustomer = S.UsersByCustomer, ByUsersByCustomer = CE.UsersByCustomer
                    }).ToList();
                    TempChildReplyEntity.AddRange(list);
                }
            }
            if (TempChildReplyEntity == null || TempChildReplyEntity.Count == 0)
            {
                return(true);
            }
            EachArray.Add(TempChildReplyEntity);
            Index++;
            return(While());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Recommend action,用于读取精华贴数据
        /// </summary>
        /// <param name="CurrentPageindex">分页页码</param>
        /// <returns>根据传入的强类型ForumMainByRecommendEntity实例模型,返回Recommend视图</returns>
        public ActionResult Recommend(int CurrentPageindex = 1)
        {
            PublicFunctions.SetUrls(ViewBag, Url);  //构造资源路径(js、css、image等)
            const int PageSize = 20, PageCount = 5; //定义每页显示数据总数及最多显示的页码
            //构造分页对象配置类
            ConfigPaging cp = new ConfigPaging(CurrentPageindex, PageSize, PageCount);
            //要返回的数据模型
            ForumMainByRecommendEntity Model = new ForumMainByRecommendEntity();

            using (DB_BBSEntities db = new DB_BBSEntities())//构造数据库上下文
            {
                //查询标记为精华帖的列表内容
                Model.ForumMain = db.tb_ForumMain.Where(W => W.IsRecommend == true && W.Isdelete == false)
                                  .OrderByDescending(O => O.ID).Skip(cp.StartRow).Take(PageSize).ToList();
                //查询发帖人
                Model.UsersByCustomer = Model.ForumMain.Select(S => S.tb_UsersByCustomer).ToList();
                //查询回复次数列表内容
                Model.ReplyNumber = Model.ForumMain.Select(S => S.tb_ForumInfoStatus.Where(W => W.ForumMainID == S.ID).First().ReplyNumber).ToList();
                //查询查看次数列表内容
                Model.SeeNumber = Model.ForumMain.Select(S => S.tb_ForumInfoStatus.Where(W => W.ForumMainID == S.ID).First().SeeNumber).ToList();
                //查询最后回复人列表内容
                Model.LastReplyUser = Model.ForumMain.Select(S => S.tb_ForumInfoStatus.Where(W => W.ForumMainID == S.ID).First().tb_UsersByCustomer.UserName).ToList();
                //统计精华帖总数
                Model.ForumMainCount = db.tb_ForumMain.Count(C => C.IsRecommend == true && C.Isdelete == false);
            }
            cp.GetPaging(ViewBag, Model.ForumMainCount); //绑定分页数据
            return(View(Model));                         //返回视图
        }
Exemplo n.º 8
0
        public ActionResult Index()
        {
            PublicFunctions.SetUrls(ViewBag, Url);                     //构造资源路径(js、css、image等)
            IList <ForumAreaJoinForumClassifyEntity> ModelList = null; //要返回的数据模型

            using (DB_BBSEntities db = new DB_BBSEntities())           //构造数据库上下文
            {
                //查询tb_ForumArea表数据并绑定到ForumAreaJoinForumClassifyEntity自定义实体类
                ModelList = db.tb_ForumArea.Select(S => new ForumAreaJoinForumClassifyEntity
                {
                    ID       = S.ID,       //赋值ID
                    AreaName = S.AreaName, //赋值大板块区域名称
                    //查询该大板块区域下的所有子板块并绑定到ChildForumClassify自定义实体类,赋值给ChildForumClassify集合
                    ChildForumClassify = S.tb_ForumClassify.Select(S1 => new ChildForumClassify
                    {
                        Classifys = S1,             //赋值子版块
                        ForumMain = S1.tb_ForumMain //查询该子版块推荐帖子并且是未删除状态的帖子数据,获取方式按照ID将排序
                                    .Where(W2 => W2.IsRecommend == true && W2.Isdelete == false)
                                    .OrderByDescending(O => O.ID).Take(3).ToList()
                    }).ToList()
                }).ToList();
            }
            //返回视图,传入包含大板块区域、子版块区域、推荐帖子的集合模型对象
            return(View(ModelList));
        }
Exemplo n.º 9
0
 public static IList <SP_Get_UsersByCustomer_NotTargetForumClassify_Result> GetUsersByCustomer_NotTargetForumClassify()
 {
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         ObjectResult <SP_Get_UsersByCustomer_NotTargetForumClassify_Result> O = db.SP_Get_UsersByCustomer_NotTargetForumClassify();
         return(O.ToList());
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 读取栏目表tb_Column数据
        /// </summary>
        /// <returns>返回栏目表一级栏目数据</returns>
        internal static void GetColumnOneGrade(dynamic ViewBag)
        {
            Expression <Func <tb_Column, bool> > Exp = where => where.ColumnCode.Length == 1;

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                ViewBag.Columns = db.tb_Column.Where(Exp.Compile()).ToList();
            }
        }
Exemplo n.º 11
0
 public static void GetUsersByCustomer(dynamic ViewBag, int UserID)
 {
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         ViewBag.Users = db.tb_UsersByCustomer.Where(W => W.IsModerator).Select(S => new SelectListItem()
         {
             Text = S.UserName, Value = S.ID.ToString(), Selected = (S.ID == UserID ? true : false)
         }).ToList();
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// 获取举报类型资源表tb_ZY_ReportType数据
        /// </summary>
        /// <returns>返回多种条件类型集合属性数据</returns>
        public ReportTypeEntity GetReportType()
        {
            ReportTypeEntity RTE = new ReportTypeEntity();

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                RTE.PersonalReportType = db.tb_ZY_ReportType.Where(W => W.ReportType == 1).ToList();
                RTE.GarbageReportType  = db.tb_ZY_ReportType.Where(W => W.ReportType == 2).ToList();
            }
            return(RTE);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 读取角色表tb_UserByRole数据,并赋值给页面RoleID变量
        /// </summary>
        /// <param name="ViewBag"></param>
        public static void GetRole(dynamic ViewBag, int SelectID)
        {
            IList <SelectListItem> RoleChoose = null;

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                RoleChoose = db.tb_UserByRole.Select(S => new SelectListItem {
                    Text = S.RoleName, Value = S.ID.ToString(), Selected = (S.ID == SelectID ? true : false)
                }).ToList();
            }
            ViewBag.DropDownListRoleID = RoleChoose;
        }
Exemplo n.º 14
0
        /// <summary>
        /// 读取性别资源表tb_ZY_Sex数据,并赋值给页面SexID变量
        /// </summary>
        public static void RegistSexIDBind(dynamic ViewBag)
        {
            IEnumerable <SelectListItem> SexChoose = null;

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                SexChoose = db.tb_ZY_Sex.Select(S => new SelectListItem {
                    Text = S.Content, Value = S.ID.ToString()
                }).ToList();
            }
            ViewBag.SexID = SexChoose;
        }
Exemplo n.º 15
0
        /// <summary>
        /// 回复帖子时接受处理方法
        /// </summary>
        /// <param name="FC">提交的Form表单</param>
        /// <returns>返回原页面(如果存在)或返回首页</returns>
        public ActionResult ReplyContent(FormCollection FC)
        {
            int    ForumMainID = 0; //定义主贴id变量
            string Content;         //定义回复内容变量

            //接受并验证Form表单提交过来的字段值
            if (int.TryParse(FC["curid"], out ForumMainID) && ForumMainID > 0 && (Content = FC["content"]) != null && Content != "")
            {
                int CurSequence = 0, ReplySequenceID;                     //定义楼层变量和回复楼层的id
                int.TryParse(FC["ReplySequenceID"], out ReplySequenceID); //被回复人的帖子ID
                if (ReplySequenceID == 0)                                 //如果该值为0则代表当前回复的是主贴
                {
                    CurSequence = 1;                                      //回复主贴时,查找最大的楼层数并且加1就为该贴的楼层,否则为1
                    using (DB_BBSEntities db = new DB_BBSEntities())      //实例化数据库上下文类
                    {
                        //查找该贴的所有回复
                        IQueryable <tb_ForumSecond> Where = db.tb_ForumSecond.Where(W => W.ForumMainID == ForumMainID && W.IsDelete == false);
                        if (Where.Any())                                 //如果能够找到回复信息
                        {
                            CurSequence = Where.Max(S => S.CurSequence); //取出最大楼层数
                            CurSequence++;                               //最大楼层数加1,则为当前回复贴的楼层
                        }
                    }
                    ReplySequenceID = ForumMainID;//在回复主贴时,回复楼层id值应为主贴ID
                }
                //取出当前用户ID
                int CurrentUserID = new LoginStatus().LoginStatusEntity.ID;
                //创建回复数据实体并赋值
                tb_ForumSecond ForumSecond = new Models.tb_ForumSecond();
                ForumSecond.ForumMainID     = ForumMainID;
                ForumSecond.Content         = Encoding.UTF8.GetString(Convert.FromBase64String(Content));
                ForumSecond.CreateUserID    = CurrentUserID;
                ForumSecond.CreateTime      = DateTime.Now;
                ForumSecond.CurSequence     = CurSequence;
                ForumSecond.ReplySequenceID = ReplySequenceID;
                ForumSecond.IsDelete        = false;
                //保存数据
                using (DB_BBSEntities db = new DB_BBSEntities())
                {
                    db.tb_ForumSecond.Add(ForumSecond);
                    if (db.SaveChanges() > 0)
                    {
                        //如果保存成功返回原页面
                        return(Redirect(Request.UrlReferrer.AbsolutePath));
                    }
                }
            }
            //在保存失败或者参数验证未通过时,返回原页面(如果存在)或返回首页,并发送失败消息
            return(PublicFunctions.ToRedirect(this, "ReplyContentError", "未能成功回复帖子,请检查输入信息!",
                                              (Url) => { return Redirect(Url); },
                                              (Url) => { return RedirectToAction("Index", "Home"); }));
        }
Exemplo n.º 16
0
 public bool CheckUnique(string value, int MyType, int KeyID)
 {
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         bool IsExists = false;
         switch (MyType)
         {
         case 1:
             IsExists = db.tb_ForumClassify.Count(C => C.ClassifyName == value) == 0;
             break;
         }
         return(IsExists);
     }
 }
Exemplo n.º 17
0
        public bool CheckUnique(string value, int MyType, int KeyID)
        {
            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                bool IsExists = false;
                switch (MyType)
                {
                case 1:
                    IsExists = db.tb_UsersBySystem.Count(C => C.UserName == value) == 0;
                    break;

                case 2:
                    IsExists = db.tb_UsersBySystem.Count(C => C.Email == value) == 0;
                    break;
                }
                return(IsExists);
            }
        }
Exemplo n.º 18
0
        //public static IList<RoleJoinColumnEntity> GettingColumn()
        //{
        //    int UserRoleID = new AdminLoginStatus().LoginStatusEntity.RoleID;
        //    using (DB_BBSEntities db = new DB_BBSEntities())
        //    {
        //        var ColumnRecord = from UserByRoleJoinColumn in db.tb_UserByRoleJoinColumn.DefaultIfEmpty()
        //                           join Column in db.tb_Column on UserByRoleJoinColumn.ColumnID equals Column.ID
        //                           where UserByRoleJoinColumn.RoleID == UserRoleID
        //                           select new RoleJoinColumnEntity { ColumnID = UserByRoleJoinColumn.ColumnID, ColumnCode = Column.ColumnCode, ColumnName = Column.ColumnName, Url = Column.Url };
        //        IList<RoleJoinColumnEntity> RoleJoinColumnEntitys = ColumnRecord.ToList();
        //        return RoleJoinColumnEntitys;
        //    }
        //}
        public static IList <RoleJoinColumnEntity> GettingColumn(string AbsoluteUri)
        {
            IList <RoleJoinColumnEntity>         RJCE = null;
            Expression <Func <tb_Column, bool> > Exp  = where => where.Url != null && where.Url.ToLower() == AbsoluteUri.ToLower();

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                tb_Column Column = db.tb_Column.SingleOrDefault(Exp.Compile());
                if (Column == null)
                {
                    if (MyCache.Current.Contains("SingleOrDefault"))
                    {
                        Column      = MyCache.Current.Get <tb_Column>("SingleOrDefault");
                        AbsoluteUri = Column.Url;
                    }
                }
                string ColumnCode = "";
                if (Column != null)
                {
                    ColumnCode = Column.ColumnCode.Substring(0, 1);
                    if (!MyCache.Current.Contains("SingleOrDefault"))
                    {
                        MyCache.Current.Add(Column, "SingleOrDefault");
                    }
                }
                else
                {
                    ColumnCode = "A";
                }
                RJCE = db.tb_Column.Select(S => new RoleJoinColumnEntity
                {
                    ColumnID      = S.ID,
                    ColumnCode    = S.ColumnCode,
                    ColumnName    = S.ColumnName,
                    Url           = S.Url,
                    LogoClassName = S.LogoClassName,
                    IsClassA      = S.ColumnCode.Length == 1,
                    IsSelectedA   = (S.ColumnCode == ColumnCode),
                    IsSelected    = S.Url.ToLower() == AbsoluteUri.ToLower(),
                    IsUrlNull     = (S.Url == null || S.Url == "")
                }).ToList();
                return(RJCE);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 读取主题回复的对话回复数据
        /// </summary>
        /// <param name="ForumSecondID">回复贴的ID</param>
        /// <param name="IsData">返回是否存在对话回复数据</param>
        /// <returns>返回对话回复数据列表</returns>
        public List <ChildReplyEntity> GetChildReply(int ForumSecondID, out bool IsData)
        {
            List <ChildReplyEntity> TempChildReplyEntity = new List <ChildReplyEntity>();

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                IQueryable <tb_ForumSecond> WhereForumSecond = db.tb_ForumSecond.Where(W => W.ReplySequenceID == ForumSecondID && W.IsDelete == false && W.CurSequence == 0);
                TempChildReplyEntity = WhereForumSecond.Select(S => new ChildReplyEntity {
                    ForumSecond = S, UsersByCustomer = S.tb_UsersByCustomer, ByUsersByCustomer = null
                }).ToList();
                IsData = TempChildReplyEntity.Count > 0;
                EachArray.Add(TempChildReplyEntity);
            }
            While();
            foreach (var InEachArray in EachArray)
            {
                ReturnList.AddRange(InEachArray);
            }
            return(ReturnList.OrderBy(O => O.ForumSecond.CreateTime).ToList());
        }
Exemplo n.º 20
0
 public MyAuthorizeAttribute(int ColumnID)            //传入栏目ID,构造验证类
 {
     using (DB_BBSEntities db = new DB_BBSEntities()) //创建数据库上下文类
     {
         IList <int> UserByRoleJoinColumns = null;    //定义用户角色与栏目关联表(权限表)的集合对象
         if (ColumnID > 0)                            //如果传入的栏目ID大于0
         {
             UserByRoleJoinColumns = db.tb_UserByRoleJoinColumn.Where(W => W.ColumnID == ColumnID)
                                     .Select(S => S.RoleID).ToList();//查询拥有该栏目权限的所有角色ID
         }
         else
         {
             UserByRoleJoinColumns = db.tb_UserByRole.Select(S => S.ID).ToList(); //查询所有角色ID
         }
         if (UserByRoleJoinColumns != null && UserByRoleJoinColumns.Count > 0)    //验证数据是否为空
         {
             this.Roles = string.Join(",", UserByRoleJoinColumns);                //赋值基类的角色字符串数据
         }
     }
 }
Exemplo n.º 21
0
 public bool CheckUnique(string value, int MyType, int KeyID)
 {
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         bool IsExists = false;
         switch (MyType)
         {
         case 1:
             if (KeyID == 0)
             {
                 IsExists = db.tb_ForumArea.Count(C => C.AreaName == value) == 0;
             }
             else
             {
                 IsExists = db.tb_ForumArea.Count(C => C.AreaName == value && C.ID != KeyID) == 0;
             }
             break;
         }
         return(IsExists);
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// 登录或注册成功时,保存的用户信息
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="Session">请求的Session状态对象</param>
        public void LoginSuccess(string UserName, HttpSessionStateBase Session)
        {
            tb_UsersBySystem MyUsersBySystem = null;

            using (DB_BBSEntities db = new DB_BBSEntities())
            {
                MyUsersBySystem = db.tb_UsersBySystem.Where(W => W.UserName == UserName).First();
            }
            if (MyUsersBySystem != null)
            {
                LoginStatusAdminEntity LSAE = new LoginStatusAdminEntity
                {
                    ID       = MyUsersBySystem.ID,
                    RoleID   = MyUsersBySystem.RoleID,
                    UserName = MyUsersBySystem.UserName,
                    NickName = MyUsersBySystem.NickName,
                    Email    = MyUsersBySystem.Email
                };
                Session.Add("LoginAdminSuccess", LSAE);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 举报帖子时接受处理方法
        /// </summary>
        /// <param name="FC">提交的Form表单</param>
        /// <returns>返回原页面(如果存在)或返回首页</returns>
        public string SubWarningInfo(FormCollection FC)
        {
            //接受并验证Form表单提交过来的字段值
            int    RdoWarningType, ForumID, ForumTypeID;
            string WarningInfoText = FC["WarningInfoText"];

            if (int.TryParse(FC["RdoWarningType"], out RdoWarningType) && RdoWarningType > 0 &&
                int.TryParse(FC["ForumID"], out ForumID) && ForumID > 0 &&
                int.TryParse(FC["ForumTypeID"], out ForumTypeID) && ForumTypeID > 0 &&
                WarningInfoText != null)
            {
                //取出当前用户ID
                int            CurrentUserID = new LoginStatus().LoginStatusEntity.ID;
                tb_ForumReport ForumReport   = new tb_ForumReport();
                ForumReport.ForumID             = ForumID;
                ForumReport.ReportForumTypeID   = ForumTypeID;
                ForumReport.ReportTypeID        = RdoWarningType;
                ForumReport.CreateUserID        = CurrentUserID;
                ForumReport.CreateTime          = DateTime.Now;
                ForumReport.ReportDetailContent = WarningInfoText;
                //保存数据到数据库,并返回Json数据,如果保存成功返回状态为1并提示成功消息,否则状态为0或1并提示失败消息
                using (DB_BBSEntities db = new DB_BBSEntities())
                {
                    db.tb_ForumReport.Add(ForumReport);
                    if (db.SaveChanges() > 0)
                    {
                        return(PublicFunctions.ToJson(new HomeSaveResultJson {
                            Status = 1, Content = "已提交举报信息,请等待审核!"
                        }));
                    }
                    return(PublicFunctions.ToJson(new HomeSaveResultJson {
                        Status = 0, Content = "未能提交举报信息,已失败!"
                    }));
                }
            }
            return(PublicFunctions.ToJson(new HomeSaveResultJson {
                Status = -1, Content = "提交举报信息不全,请核查!"
            }));
        }
Exemplo n.º 24
0
 public bool CheckUnique(string value, int MyType, int KeyID) //实现ICheckUnique接口中的CheckUnique方法
 {
     using (DB_BBSEntities db = new DB_BBSEntities())         //实例化操作数据库上下文类
     {
         bool IsExists = false;                               //定义数据验证是否成功变量
         switch (MyType)                                      //判断要查询的字段,此处指查询RoleName角色名称
         {
         case 1:
             if (KeyID == 0)
             {
                 //查询指定的角色名称是否存在于tb_UserByRole表中
                 IsExists = db.tb_UserByRole.Count(C => C.RoleName == value) == 0;
             }
             else
             {
                 //查询指定的ID值和角色名称是否存在于tb_UserByRole表中
                 IsExists = db.tb_UserByRole.Count(C => C.RoleName == value && C.ID != KeyID) == 0;
             }
             break;
         }
         return(IsExists);//返回验证结果
     }
 }
Exemplo n.º 25
0
 public ActionResult Search(string text)
 {
     //构造资源路径(js、css、image等)
     ViewBag.text = text;
     PublicFunctions.SetUrls(ViewBag, Url);
     using (DB_BBSEntities db = new DB_BBSEntities())
     {
         //tb_ForumArea
         //tb_ForumClassify
         //tb_ForumMain
         //tb_ForumSecond
         List <tb_ForumMain>   ForumMains    = db.tb_ForumMain.Where(W => W.Content.Contains(text)).ToList();
         List <tb_ForumSecond> ForumSeconds  = db.tb_ForumSecond.Where(W => W.Content.Contains(text)).ToList();
         List <SearchEntity>   SearchEntitys = new List <SearchEntity>();
         foreach (tb_ForumMain FM in ForumMains)
         {
             SearchEntitys.Add(new SearchEntity()
             {
                 ID      = FM.ID,
                 Title   = FM.Title.Replace(text, "<em>" + text + "</em>"),
                 Content = FM.Content.Replace(text, "<em>" + text + "</em>")
             });
         }
         foreach (tb_ForumSecond FS in ForumSeconds)
         {
             SearchEntitys.Add(new SearchEntity()
             {
                 ID      = FS.tb_ForumMain.ID,
                 Title   = FS.tb_ForumMain.Title.Replace(text, "<em>" + text + "</em>"),
                 Content = FS.Content.Replace(text, "<em>" + text + "</em>")
             });
         }
         return(View(SearchEntitys));
     }
     return(View());
 }
Exemplo n.º 26
0
        /// <summary>
        /// 发布新帖时接受处理方法
        /// </summary>
        /// <param name="FC">提交的Form表单</param>
        /// <returns>返回原页面(如果存在)或返回首页</returns>
        public ActionResult PulishNewContent(FormCollection FC)
        {
            //接受并验证Form表单提交过来的字段值
            int    ForumClassifyID, IntIsRecommend;
            bool   IsRecommend;
            string Title, Content;

            if (int.TryParse(FC["ForumClassifyID"], out ForumClassifyID) && ForumClassifyID > 0 &&
                (Title = FC["mainTitle"]) != null && (Content = FC["content"]) != null && Title != "" && Content != "")
            {
                int.TryParse(FC["IsRecommend"], out IntIsRecommend);
                IsRecommend = Convert.ToBoolean(IntIsRecommend);
                //Base64解码发布的内容
                Content = Encoding.UTF8.GetString(Convert.FromBase64String(Content));
                //查找出该贴所属的大专区板块
                int ForumAreaID = 0;
                using (DB_BBSEntities db = new DB_BBSEntities())
                {
                    ForumAreaID = db.tb_ForumClassify.Where(W => W.ID == ForumClassifyID).Select(S => S.ForumAreaID).First();
                }
                if (ForumAreaID > 0)
                {
                    //取出当前用户ID
                    int          CurrentUserID = new LoginStatus().LoginStatusEntity.ID;
                    tb_ForumMain ForumMain     = new tb_ForumMain();
                    ForumMain.Title           = Title;
                    ForumMain.ForumAreaID     = ForumAreaID;
                    ForumMain.ForumClassifyID = ForumClassifyID;
                    ForumMain.CreateUserID    = CurrentUserID;
                    ForumMain.CreateTime      = DateTime.Now;
                    ForumMain.Content         = Content;
                    ForumMain.IsRecommend     = IsRecommend;
                    ForumMain.IsExamine       = 0;
                    ForumMain.Isdelete        = false;
                    ForumMain.Zan             = 0;
                    //创建一条与该贴对应的帖子状态表数据
                    ForumMain.tb_ForumInfoStatus = new List <tb_ForumInfoStatus>
                    {
                        new tb_ForumInfoStatus
                        {
                            ForumMainID     = ForumMain.ID,
                            ReplyNumber     = 0,
                            SeeNumber       = 0,
                            LastReplyUserID = CurrentUserID,
                            LastReplytime   = DateTime.Now
                        }
                    };
                    //保存数据到数据库
                    using (DB_BBSEntities db = new DB_BBSEntities())
                    {
                        db.tb_ForumMain.Add(ForumMain);
                        if (db.SaveChanges() > 0)
                        {
                            //如果保存成功返回原页面
                            return(Redirect(Request.UrlReferrer.AbsolutePath));
                        }
                    }
                }
            }
            //在保存失败或者参数验证未通过时,返回原页面(如果存在)或返回首页,并发送失败消息
            return(PublicFunctions.ToRedirect(this, "PulishNewContentError", "未能成功发表帖子,请检查输入信息!", (Url) =>
            {
                return Redirect(Url);
            },
                                              (Url) =>
            {
                return RedirectToAction("Index", "Home");
            }));
        }
Exemplo n.º 27
0
        public ActionResult MainContent(int id = 0, int CurrentPageindex = 1)
        {
            if (id == 0)                       //判断子专区id值是否为0
            {
                return(Goto("Index", "Home")); //执行跳转到上一次访问的动作,或跳转到指定的动作
            }
            bool IsLimit = false;              //定义权限变量

            ViewBag.IsLimit = false;           //将权限值赋予动态类型,用于视图中的访问
            //实例化用户登录状态类
            BBSSite.MyPublic.LoginStatus IStatus = new BBSSite.MyPublic.LoginStatus();
            if (IStatus.IsLogin)                                 //判断用户是否登录
            {
                tb_ForumClassify ForumClassify = null;           //定义子专区数据类
                using (DB_BBSEntities db = new DB_BBSEntities()) //实例化数据库上下文类
                {
                    //按照子专区id值查询该专区的其他信息
                    ForumClassify = db.tb_ForumClassify.Where(W => W.ID == id).FirstOrDefault();
                    if (ForumClassify != null)//如果查询数据不为空
                    {
                        //获取该专区的所属用户id,改用户可对该专区的帖子列表有执行操作权限
                        int ForumClassifyUserID = ForumClassify.ForumUserID;
                        //取出该子专区所属大板块专区的信息数据
                        tb_ForumArea ForumArea = db.tb_ForumArea.Where(W => W.ID == ForumClassify.ForumAreaID).FirstOrDefault();
                        //取出大板块专区的所属用户id
                        int ForumAreaUserID = ForumArea.UserID;
                        //如果当前登录用户与拥有子专区或大板块专区权限的用户相同
                        if (IStatus.LoginStatusEntity.ID == ForumClassifyUserID || IStatus.LoginStatusEntity.ID == ForumAreaUserID)
                        {
                            ViewBag.IsLimit = true;//该用户有执行操作权限
                            IsLimit         = true;
                        }
                    }
                }
            }
            PublicFunctions.SetUrls(ViewBag, Url);  //构造资源路径(js、css、image等)
            const int PageSize = 20, PageCount = 5; //定义每页显示数据总数及最多显示的页码
            //构造分页对象配置类
            ConfigPaging cp = new ConfigPaging(CurrentPageindex, PageSize, PageCount);
            ForumClassifyJoinForumMainEntity Model = null;   //要返回的数据模型

            using (DB_BBSEntities db = new DB_BBSEntities()) //实例化数据库上下文类
            {
                //按条件查询子专区表以及所属主贴表数据
                Model = db.tb_ForumClassify.Where(W => W.ID == id).Select(S => new ForumClassifyJoinForumMainEntity
                {
                    ID                = S.ID,
                    ClassifyName      = S.ClassifyName,
                    ClassifyInnerLogo = S.ClassifyInnerLogo,
                    UsersByBanzhu     = S.tb_UsersByCustomer,
                    ForumMain         = (ICollection <tb_ForumMain>)S.tb_ForumMain.Where(Where => Where.Isdelete == false && ((!IsLimit && Where.IsExamine == 1) || IsLimit)).OrderByDescending(O => O.ID).Skip(cp.StartRow).Take(PageSize)
                }).FirstOrDefault();
                //以下为与ForumMain(帖子)表对应的外键表信息
                Model.ReplyNumber     = Model.ForumMain.Select(S => S.tb_ForumInfoStatus.Where(W => W.ForumMainID == S.ID).First().ReplyNumber).ToList();                                                                 //统计回复次数
                Model.SeeNumber       = Model.ForumMain.Select(S => S.tb_ForumInfoStatus.Where(W => W.ForumMainID == S.ID).First().SeeNumber).ToList();                                                                   //统计查看次数
                Model.LastReplyUser   = Model.ForumMain.Select(S => S.tb_ForumInfoStatus.Where(W => W.ForumMainID == S.ID).First().tb_UsersByCustomer.UserName).ToList();                                                 //最后回复人
                Model.UsersByCustomer = Model.ForumMain.Select(S => S.tb_UsersByCustomer).ToList();                                                                                                                       //发帖人
                Model.ImgUrl          = Model.ForumMain.Select(S => (S.IsRecommend ? "pin_1.gif" : "folder_new.gif")).ToList();                                                                                           //推荐帖与普通帖logo
                Model.FMType          = Model.ForumMain.Select(S => (S.IsRecommend ? "日月精华" : "最新帖子")).ToList();                                                                                                          //推荐贴与普通帖提示标题
                //以下为总的统计数据
                Model.TotalForumCount = db.tb_ForumMain.Count(W => W.Isdelete == false && W.ForumClassifyID == id);                                                                                                       //总帖子数
                Model.TotalReplyCount = db.tb_ForumMain.Where(W => W.Isdelete == false && W.ForumClassifyID == id).ToList().Aggregate(0, (count, current) => count + current.tb_ForumInfoStatus.Sum(S => S.ReplyNumber)); //总回复数
                Model.TotalSeeCount   = db.tb_ForumMain.Where(W => W.Isdelete == false && W.ForumClassifyID == id).ToList().Aggregate(0, (count, current) => count + current.tb_ForumInfoStatus.Sum(S => S.SeeNumber));   //只查看数
            }
            cp.GetPaging(ViewBag, Model.TotalForumCount);                                                                                                                                                                 //绑定分页数据
            ViewBag.curid = id;                                                                                                                                                                                           //此id为传入的所属专区ID,将在下次分页时带入
            return(View(Model));                                                                                                                                                                                          //返回视图
        }