Ejemplo n.º 1
0
        public ActionResult List()
        {
            if (Request.HttpMethod.ToUpper() == "POST")
            {
                if (CECRequest.GetFormString("action").ToLower() == "del")
                {
                    //删除
                    int id = CECRequest.GetFormInt("id", 0);
                    JobService.Delete(id);
                }
                if (CECRequest.GetFormString("action").ToLower() == "pub")
                {
                    //发布
                    int id = CECRequest.GetFormInt("id", 0);
                    JobService.SetPublish(id, true);
                }
            }

            var list = JobService.List(new JobSearchSetting()
            {
                PageSize            = 15,
                PageIndex           = CECRequest.GetQueryInt("page", 1),
                IsOnlyShowPublished = false //false 全部显示
            });

            ViewBag.List = list;
            return(View());
        }
Ejemplo n.º 2
0
        //
        // GET: /PagesAdmin/Attach/

        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            if (Request.HttpMethod.ToUpper() == "POST")
            {
                if (CECRequest.GetFormString("action").ToLower() == "del")
                {
                    //删除
                    int id = CECRequest.GetFormInt("id", 0);
                    AttachmentService.Delete(id);
                }
            }

            int catId = CECRequest.GetQueryInt("catId", 0);

            if (catId == 0)
            {
                catId = Elco.Config.GeneralConfig.DownloadRootId_DE;
            }

            var list = AttachmentService.List(new AttachmentSearchSetting()
            {
                PageIndex  = CECRequest.GetQueryInt("page", 1),
                PageSize   = 15,
                CategoryId = catId
            });

            ViewBag.List = list;



            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Ajax()
        {
            string m = Controleng.Common.CECRequest.GetFormString("m");

            if (m == "treelist")
            {
                var lang = Utils.StrToInt(CECRequest.GetFormString("lang"), 0);
                if (lang < 0)
                {
                    return(Content(CategoryService.RenderTreeViewForAdminWithEdit((WebLanguage)Enum.Parse(typeof(WebLanguage), lang.ToString()))));
                }
            }
            return(Content(string.Empty));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 管理员列表
        /// </summary>
        /// <returns></returns>
        public ActionResult AdminList()
        {
            if (Request.HttpMethod.ToUpper() == "POST")
            {
                string _action = CECRequest.GetFormString("_action").ToLower();
                if (_action == "search")
                {
                    //查询
                    string _userName = CECRequest.GetFormString("txtUserName");
                    if (!string.IsNullOrEmpty(_userName))
                    {
                        ViewBag.SearchList = MemberService.SearchAdmin(_userName);
                    }
                }

                if (_action == "add")
                {
                    int  _userId   = CECRequest.GetFormInt("_userId", 0);
                    bool isSuccess = MemberService.AddAdmin(_userId);
                    if (isSuccess)
                    {
                        ViewBag.Status = "AddSuccess";
                    }
                    else
                    {
                        ViewBag.Status = "AddError";
                    }
                }

                //判断是否为删除
                if (_action == "delete")
                {
                    int _userId = CECRequest.GetFormInt("_userId", 0);
                    MemberService.DeleteAdmin(_userId);
                    ViewBag.Status = "DeleteSuccess";
                }
            }
            var list = MemberService.AdminList();

            ViewBag.List = list;

            return(View());
        }
Ejemplo n.º 5
0
        public ActionResult ResumeList()
        {
            if (Request.HttpMethod.ToUpper() == "POST")
            {
                if (CECRequest.GetFormString("_action").ToLower() == "del")
                {
                    int id = CECRequest.GetFormInt("_id", 0);
                    ResumeService.Delete(id);
                }
            }

            var list = ResumeService.List(new SearchSetting()
            {
                PageIndex = CECRequest.GetQueryInt("page", 1)
            });

            ViewBag.List = list;

            return(View());
        }
Ejemplo n.º 6
0
        public ActionResult ReplyThread(FormCollection fc)
        {
            int forumId = CECRequest.GetFormInt("catalogId", 0);
            int topicId = CECRequest.GetFormInt("threadId", 0);

            var forumInfo = ForumService.Get(forumId);
            //检查用户是否查看的权限
            //获取通过审核的用户,只有审核通过的用户才能查看论坛
            var userInfo = UserService.Get(User.Identity.Name);

            if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId))
            {
                return(new TipView()
                {
                    Msg = ErrorMsg.APPLYNOTPASS
                });
            }

            //判断主题是否存在
            var topicInfo = ForumTopicService.Get(topicId);

            string threadUrlFormat = "/thread/{0}.html{1}";

            if (topicInfo.Id == 0 || topicInfo.ForumId != forumId || topicInfo.IsDeleted)
            {
                return(new TipView()
                {
                    Msg = ErrorMsg.THREADNOTEXISTS
                });
            }

            #region == 发表回帖 ==
            //判断提交类型
            if (CECRequest.GetFormString("event_submit_do_publish") == "anything")
            {
                string replyContent = fc["txtReplyContent"];

                //判断回复内容是否为空
                if (string.IsNullOrEmpty(replyContent))
                {
                    return(new TipView()
                    {
                        Msg = "请输入回复内容", Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty)
                    });
                }


                //回复
                ForumReplyInfo replyInfo = new ForumReplyInfo();
                replyInfo.Content  = replyContent;
                replyInfo.ForumId  = topicInfo.ForumId;
                replyInfo.TopicId  = topicInfo.Id;
                replyInfo.Poster   = userInfo.UserName;
                replyInfo.PosterId = userInfo.Id;

                replyInfo = ForumTopicService.PostReply(topicInfo, replyInfo);

                return(new TipView()
                {
                    Msg = ErrorMsg.POSTREPLYSUCCESS, Url = String.Format(threadUrlFormat, topicInfo.Id, String.Format("#reply{0}", replyInfo.Id)), Success = true
                });
            }
            #endregion

            #region == 删除回帖 ==
            if (CECRequest.GetFormString("event_submit_do_delete") == "anything")
            {
                int replyId = CECRequest.GetFormInt("replyId", 0);

                var replyInfo = ForumTopicService.GetReplyInfo(replyId);
                if (replyInfo.Id == 0 || replyInfo.IsDeleted || topicInfo.Id != replyInfo.TopicId || replyInfo.ForumId != forumId)
                {
                    return(new TipView()
                    {
                        Msg = ErrorMsg.NOTNORMALOPERATE, Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty)
                    });
                }

                ForumTopicService.DeleteReply(replyInfo);
                return(new TipView()
                {
                    Msg = ErrorMsg.DELETEREPLYSUCCESS, Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty), Success = true
                });
            }
            #endregion

            return(new TipView()
            {
                Msg = ErrorMsg.NOTNORMALOPERATE, Url = String.Format(threadUrlFormat, topicInfo.Id, string.Empty)
            });
        }
Ejemplo n.º 7
0
        public ActionResult PulishThread(ForumTopicInfo oldModel)
        {
            #region == 发表主题 ==
            if (CECRequest.GetFormString("event_submit_do_publish") == "anything")
            {
                //发布或编辑
                var forumInfo = ForumService.Get(oldModel.ForumId);
                //检查用户是否查看的权限
                //获取通过审核的用户,只有审核通过的用户才能查看论坛
                var userInfo = UserService.Get(User.Identity.Name);
                if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId))
                {
                    return(new TipView()
                    {
                        Msg = ErrorMsg.APPLYNOTPASS
                    });
                }

                ViewBag.ForumInfo = forumInfo;

                //在这里多设一个
                //下面更新问oldModel就会自动变成新的实体
                int requestTopicId = oldModel.Id;

                oldModel.PosterId = userInfo.Id;
                oldModel.Poster   = userInfo.UserName;
                if (string.IsNullOrEmpty(oldModel.Title))
                {
                    ModelState.AddModelError("Title", "帖子标题不能为空!");
                }
                if (string.IsNullOrEmpty(oldModel.Content))
                {
                    ModelState.AddModelError("Content", "帖子内容不能为空!");
                }
                if (ModelState.IsValid)
                {
                    oldModel = ForumTopicService.PostTopic(oldModel);
                    string url = String.Format("/thread/{0}.html", oldModel.Id);
                    return(new TipView()
                    {
                        Msg = string.Format("{0}成功!", requestTopicId > 0 ? "编辑" : "发表"), Url = url, Success = true
                    });
                }
            }
            #endregion

            #region == 删除主题 ==
            if (CECRequest.GetFormString("event_submit_do_delete") == "anything")
            {
                //删除主题
                int    forumId   = CECRequest.GetFormInt("catalogId", 0);
                int    topicId   = CECRequest.GetFormInt("threadId", 0);
                string returnUrl = string.Format("/catalog/{0}.html", forumId);

                var forumInfo = ForumService.Get(forumId);
                //检查用户是否查看的权限
                //获取通过审核的用户,只有审核通过的用户才能查看论坛
                var userInfo = UserService.Get(User.Identity.Name);
                if (!CheckApplyUserAuth(userInfo.Id, forumInfo.GroupId))
                {
                    return(new TipView()
                    {
                        Msg = ErrorMsg.APPLYNOTPASS
                    });
                }

                var topicInfo = ForumTopicService.Get(topicId);
                if (topicInfo.Id > 0 && topicInfo.ForumId == forumId && !topicInfo.IsDeleted)
                {
                    //执行删除操作
                    ForumTopicService.DeleteTopic(topicInfo);
                    return(new TipView()
                    {
                        Msg = ErrorMsg.DELETETHREADSUCCESS, Success = true, Url = returnUrl
                    });
                }
                return(new TipView()
                {
                    Msg = ErrorMsg.NOTNORMALOPERATE, Url = returnUrl
                });
            }
            #endregion

            return(View(oldModel));
        }
Ejemplo n.º 8
0
        public ActionResult Rest(FormCollection fc)
        {
            string method = CECRequest.GetQueryString("method").ToLower();

            #region == 登录 ==
            if (method == "login")
            {
                string userName  = CECRequest.GetFormString("username");
                string password  = CECRequest.GetFormString("password");
                string returnUrl = CECRequest.GetQueryString("url");

                var userInfo = MemberService.Get(userName);
                if (userInfo.Id > 0 && userInfo.Password == password)
                {
                    //写登录Cookie
                    ILoginAdapter la = new LoginAdapter();
                    la.WriteLoginCookie(new LoginUserInfo()
                    {
                        Email    = userInfo.Email,
                        UserId   = userInfo.Id,
                        RoleId   = (int)userInfo.Type,
                        UserName = userInfo.UserName,
                        Password = userInfo.Password
                    });
                }
                else
                {
                    return(Content("<script type=\"text/javascript\">alert(\"用户名或密码错误,请重新输入!\");location.href = location.href;</script>"));
                }
                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
            }
            #endregion

            #region == 登出 ==
            if (method == "logout")
            {
                string        returnUrl = CECRequest.GetQueryString("url");
                ILoginAdapter la        = new LoginAdapter();
                if (la.IsClientLogin())
                {
                    la.LoginOut();
                }
                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
            }
            #endregion

            #region == 是否在线 ==
            if (method == "isolineuser")
            {
                var userName   = CECRequest.GetFormString("UserName");
                var userPwd    = CECRequest.GetFormString("PassWord");
                var memberInfo = MemberService.Get(userName);

                if (memberInfo.Id > 0 && memberInfo.Password == userPwd)
                {
                    return(Content("true"));
                }
                return(Content("false"));
            }
            #endregion

            #region == 获取用户信息 ==
            if (method == "getuserinfo")
            {
                StringBuilder sb         = new StringBuilder();
                var           userName   = CECRequest.GetFormString("UserName");
                var           memberInfo = MemberService.Get(userName);
                if (memberInfo.Id > 0)
                {
                    sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    sb.Append("<root>");
                    sb.AppendFormat("<Email>{0}</Email>", memberInfo.Email);
                    sb.AppendFormat("<MobilePhone>{0}</MobilePhone>", memberInfo.Mobile);
                    sb.AppendFormat("<Realname>{0}</Realname>", memberInfo.RealName);
                    sb.Append("</root>");
                }
                return(Content(sb.ToString()));
            }
            #endregion

            return(Content(string.Empty));
        }
Ejemplo n.º 9
0
        public ActionResult List()
        {
            if (Request.HttpMethod.ToUpper() == "POST")
            {
                //POST
                var action = CECRequest.GetFormString("action").ToLower();
                if (action == "addparent")
                {
                    //添加父节点
                    string name = CECRequest.GetFormString("txtParentName");
                    if (string.IsNullOrEmpty(name))
                    {
                        ModelState.AddModelError("PNAMEEMPTY", "根栏目名称不能为空");
                    }
                    if (ModelState.IsValid)
                    {
                        //Insert
                        ColumnService.Create(new ColumnInfo()
                        {
                            Name      = name,
                            Alias     = string.Empty,
                            ParentId  = 0,
                            RootId    = 0,
                            IsDeleted = false,
                            ParentIds = "0",
                            Sort      = 999999
                        });
                        ViewBag.Msg = "根栏目添加成功";
                    }
                }
                if (action == "addchild")
                {
                    //添加子节点
                    string name = CECRequest.GetFormString("txtChildName");
                    if (string.IsNullOrEmpty(name))
                    {
                        ModelState.AddModelError("CNAMEEMPTY", "子栏目名称不能为空");
                    }
                    if (ModelState.IsValid)
                    {
                        //保存
                        int parentId         = Utils.StrToInt(CECRequest.GetFormString("select_column"), 0);
                        var parentColumnInfo = ColumnService.GetById(parentId);
                        if (parentColumnInfo.Id > 0)
                        {
                            //RootId
                            int rootId = parentColumnInfo.RootId;
                            if (parentColumnInfo.ParentId == 0)
                            {
                                //说明是根分类
                                rootId = parentColumnInfo.Id;
                            }
                            //ParentIds
                            string parentIds = string.Format("{0},{1}", parentColumnInfo.ParentIds, parentColumnInfo.Id);

                            ColumnService.Create(new ColumnInfo()
                            {
                                Alias     = string.Empty,
                                IsDeleted = false,
                                Name      = name,
                                ParentId  = parentId,
                                ParentIds = parentIds,
                                RootId    = rootId,
                                Sort      = 999999
                            });
                            ViewBag.Msg = "子栏目添加成功";
                        }
                    }
                }
            }

            //创建下拉列表
            var allColumn    = ColumnService.List().ToList();
            var dropdownList = new List <ColumnInfo>();

            ColumnService.BuildListForTree(dropdownList, allColumn, 0);
            ViewBag.DropDownList = dropdownList;

            ViewBag.ColumnListHtml = _BuildColumnList(allColumn, 0);


            return(View());
        }
Ejemplo n.º 10
0
        public ActionResult Add(ArticleInfo oldModel, FormCollection fc)
        {
            bool isAdd = true;

            if (oldModel.Id > 0)
            {
                isAdd = false;
            }
            if (ModelState.IsValid)
            {
                //TODO
                //在这,最好检查一下标题是否重复,目前没做
                oldModel.AddUserName        = User.Identity.Name;
                oldModel.LastModifyUserName = User.Identity.Name;
                oldModel.CategoryId         = Utils.StrToInt(fc["select_column"], 0);

                //改变URL
                oldModel.Url = oldModel.QuickLinkUrl;
                if (string.IsNullOrEmpty(oldModel.Url))
                {
                    oldModel.Url = string.Format("/article/show/{0}.html", oldModel.TimeSpan);
                }

                oldModel = ArticleService.Create(oldModel);

                //插入到Article2Category表中
                //1,技术分类
                var        requestTechListArray = CECRequest.GetFormString("cbtechlist").Split(',');
                List <int> techList             = new List <int>();
                foreach (string item in requestTechListArray)
                {
                    int id = Utils.StrToInt(item, 0);
                    if (id > 0)
                    {
                        techList.Add(id);
                    }
                }
                ArticleService.InsertArticle2Category(oldModel.Id, CatType.Tech, techList);
                //2,行业分类
                var        requestIndustryList = CECRequest.GetFormString("cbindustrylist").Split(',');
                List <int> industryList        = new List <int>();
                foreach (string item in requestIndustryList)
                {
                    int id = Utils.StrToInt(item, 0);
                    if (id > 0)
                    {
                        industryList.Add(id);
                    }
                }
                ArticleService.InsertArticle2Category(oldModel.Id, CatType.Industry, industryList);


                //完成,提示信息
                if (isAdd)
                {
                    ViewBag.Msg = "添加成功!<a href=\"add\">继续?</a><span class=\"ml10\">或</span><a href=\"list\" class=\"ml10\">返回</a>";
                }
                else
                {
                    ViewBag.Msg = "修改成功!<a href=\"add\">添加新文章?</a><span class=\"ml10\">或</span><a href=\"list\" class=\"ml10\">返回</a>";
                }
            }

            //初始化栏目类别
            //初始化栏目类别
            var allColumnList = ColumnService.List().ToList();
            var dropdownList  = new List <ColumnInfo>();

            ColumnService.BuildListForTree(dropdownList, allColumnList, 0);
            ViewBag.ColumnDropDownList = dropdownList;

            //输出技术分类
            ViewBag.TechList = TechService.List().Where(m => m.IsDeleted == false);
            //输出行业分类
            ViewBag.IndustryList = IndustryService.List().Where(m => m.IsDeleted == false);

            //已选择的技术分类和行业分类
            ViewBag.SelectTechList     = ArticleService.Article2CategoryListByArticleIdAndType(oldModel.Id, CatType.Tech);
            ViewBag.SelectIndustryList = ArticleService.Article2CategoryListByArticleIdAndType(oldModel.Id, CatType.Industry);

            string companyName = string.Empty;

            if (oldModel.CompanyId > 0)
            {
                //对CompanyName进行赋值
                //数据库中只保存CompanyId,没有保存CompanyName,只能在这里处理一下
                companyName = MemberService.GetBaseCompanyInfo(oldModel.CompanyId).CompanyName;
            }
            ViewBag.CompanyName = companyName;

            return(View(oldModel));
        }