示例#1
0
        private void RptGroup_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var pair = (KeyValuePair <int, string>)e.Item.DataItem;

                var hfGroupId                   = (HiddenField)e.Item.FindControl("hfGroupID");
                var ltlGroupName                = (Literal)e.Item.FindControl("ltlGroupName");
                var ddlIsGroupWritingEnabled    = (DropDownList)e.Item.FindControl("ddlIsGroupWritingEnabled");
                var phIsGroupWritingEnabled     = (PlaceHolder)e.Item.FindControl("phIsGroupWritingEnabled");
                var tbGroupWritingAdminUserName = (TextBox)e.Item.FindControl("tbGroupWritingAdminUserName");

                hfGroupId.Value   = pair.Key.ToString();
                ltlGroupName.Text = pair.Value;

                var groupInfo            = UserGroupManager.GetGroupInfo(pair.Key);
                var isWritingEnabled     = groupInfo.Additional.IsWritingEnabled;
                var writingAdminUserName = groupInfo.Additional.WritingAdminUserName;

                EBooleanUtils.AddListItems(ddlIsGroupWritingEnabled, "开启", "关闭");
                ControlUtils.SelectListItemsIgnoreCase(ddlIsGroupWritingEnabled, isWritingEnabled.ToString());
                phIsGroupWritingEnabled.Visible  = isWritingEnabled;
                tbGroupWritingAdminUserName.Text = writingAdminUserName;
            }
        }
示例#2
0
        public IHttpActionResult Main()
        {
            try
            {
                var body     = new RequestBody();
                var account  = body.GetPostString("account");
                var password = body.GetPostString("password");

                string userName;
                string errorMessage;
                if (!BaiRongDataProvider.UserDao.ValidateAccount(account, password, out userName, out errorMessage))
                {
                    LogUtils.AddUserLog(userName, EUserActionType.LoginFailed, "用户登录失败");
                    BaiRongDataProvider.UserDao.UpdateLastActivityDateAndCountOfFailedLogin(userName);
                    return(BadRequest(errorMessage));
                }

                BaiRongDataProvider.UserDao.UpdateLastActivityDateAndCountOfLogin(userName);
                var userInfo  = BaiRongDataProvider.UserDao.GetUserInfoByUserName(userName);
                var user      = new User(userInfo);
                var groupInfo = UserGroupManager.GetGroupInfo(user.GroupId);

                body.UserLogin(userName);

                return(Ok(new
                {
                    User = user,
                    Group = groupInfo.Additional
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#3
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            _groupId = Body.GetQueryInt("GroupID");
            _isAdd   = Body.GetQueryBool("IsAdd");

            if (!IsPostBack)
            {
                if (!_isAdd)
                {
                    var groupInfo = UserGroupManager.GetGroupInfo(_groupId);
                    if (groupInfo != null)
                    {
                        GroupName.Text   = groupInfo.GroupName;
                        Description.Text = groupInfo.Description;
                    }
                }
                else
                {
                    if (_groupId > 0)
                    {
                        var groupInfo = UserGroupManager.GetGroupInfo(_groupId);
                        if (groupInfo != null)
                        {
                            GroupName.Text   = groupInfo.GroupName;
                            Description.Text = groupInfo.Description;
                        }
                    }
                }
            }
        }
示例#4
0
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var publishmentSystemId = body.GetPostInt("publishmentSystemId");

                var groupInfo     = UserGroupManager.GetGroupInfo(body.UserInfo.GroupId);
                var adminUserName = groupInfo.Additional.WritingAdminUserName;

                var nodeInfoList = PublishmentSystemManager.GetWritingNodeInfoList(adminUserName, publishmentSystemId);
                var nodes        = new List <object>();
                foreach (var nodeInfo in nodeInfoList)
                {
                    nodes.Add(new
                    {
                        nodeInfo.NodeId,
                        nodeInfo.NodeName
                    });
                }

                return(Ok(nodes));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#5
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                if (!_isAdd)
                {
                    try
                    {
                        var groupInfo = UserGroupManager.GetGroupInfo(_groupId);
                        if (groupInfo.GroupName != GroupName.Text && BaiRongDataProvider.UserGroupDao.IsExists(GroupName.Text))
                        {
                            FailMessage("用户组修改失败,用户组名称已存在!");
                            return;
                        }

                        groupInfo.GroupName   = GroupName.Text;
                        groupInfo.Description = Description.Text;

                        Body.AddAdminLog("修改用户组",
                                         $"用户组:{GroupName.Text}");

                        PageUtils.CloseModalPage(Page);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "用户组修改失败!");
                    }
                }
                else
                {
                    if (BaiRongDataProvider.UserGroupDao.IsExists(GroupName.Text))
                    {
                        FailMessage("用户组添加失败,用户组名称已存在!");
                        return;
                    }
                    else
                    {
                        var groupInfo = new UserGroupInfo(0, GroupName.Text, false, Description.Text, string.Empty);

                        try
                        {
                            BaiRongDataProvider.UserGroupDao.Insert(groupInfo);

                            Body.AddAdminLog("添加用户组",
                                             $"用户组:{GroupName.Text}");

                            PageUtils.CloseModalPage(Page);
                        }
                        catch (Exception ex)
                        {
                            FailMessage(ex, "用户组添加失败!" + ex.ToString());
                        }
                    }
                }
            }
        }
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var publishmentSystemId = body.GetPostInt("publishmentSystemId");
                var nodeId = body.GetPostInt("nodeId");

                var user          = new User(body.UserInfo);
                var groupInfo     = UserGroupManager.GetGroupInfo(user.GroupId);
                var adminUserName = groupInfo.Additional.WritingAdminUserName;

                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var nodeInfo          = NodeManager.GetNodeInfo(publishmentSystemId, nodeId);
                var tableName         = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
                var tableStyle        = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
                var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemId, nodeId);

                var contentInfo = ContentUtility.GetContentInfo(tableStyle);

                var postCollection = body.GetPostCollection();

                InputTypeParser.AddValuesToAttributes(tableStyle, tableName, publishmentSystemInfo, relatedIdentities, postCollection, contentInfo.Attributes, ContentAttribute.HiddenAttributes);

                contentInfo.IsChecked           = false;
                contentInfo.PublishmentSystemId = publishmentSystemId;
                contentInfo.NodeId           = nodeId;
                contentInfo.AddUserName      = adminUserName;
                contentInfo.WritingUserName  = user.UserName;
                contentInfo.LastEditUserName = adminUserName;
                contentInfo.AddDate          = DateTime.Now;
                contentInfo.LastEditDate     = DateTime.Now;

                var contentId = DataProvider.ContentDao.Insert(tableName, publishmentSystemInfo, contentInfo);

                LogUtils.AddUserLog(body.UserName, EUserActionType.WritingAdd, contentInfo.Title);

                return(Ok(new
                {
                    ID = contentId
                }));
            }
            catch (Exception ex)
            {
                //return InternalServerError(ex);
                return(InternalServerError(new Exception("程序错误")));
            }
        }
示例#7
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            try
            {
                var groupInfoList = new List <UserGroupInfo>();
                foreach (RepeaterItem item in RptGroup.Items)
                {
                    if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                    {
                        var hfGroupId = (HiddenField)item.FindControl("hfGroupID");
                        var ddlIsGroupWritingEnabled    = (DropDownList)item.FindControl("ddlIsGroupWritingEnabled");
                        var tbGroupWritingAdminUserName = (TextBox)item.FindControl("tbGroupWritingAdminUserName");

                        var isWritingEnabled     = TranslateUtils.ToBool(ddlIsGroupWritingEnabled.SelectedValue);
                        var writingAdminUserName = tbGroupWritingAdminUserName.Text;

                        if (!string.IsNullOrEmpty(writingAdminUserName))
                        {
                            if (!BaiRongDataProvider.AdministratorDao.IsUserNameExists(writingAdminUserName))
                            {
                                FailMessage($"保存失败,管理员不存在:{writingAdminUserName}");
                                return;
                            }
                        }

                        var groupId = TranslateUtils.ToInt(hfGroupId.Value);

                        var groupInfo = UserGroupManager.GetGroupInfo(groupId);
                        groupInfo.Additional.IsWritingEnabled     = isWritingEnabled;
                        groupInfo.Additional.WritingAdminUserName = writingAdminUserName;

                        groupInfoList.Add(groupInfo);
                    }
                }

                foreach (var groupInfo in groupInfoList)
                {
                    BaiRongDataProvider.UserGroupDao.Update(groupInfo);
                }

                ConfigManager.UserConfigInfo.IsWritingEnabled = TranslateUtils.ToBool(DdlIsWritingEnabled.SelectedValue);
                BaiRongDataProvider.ConfigDao.Update(ConfigManager.Instance);

                Body.AddAdminLog("投稿基本设置");
                SuccessMessage("投稿基本设置成功");
            }
            catch (Exception ex)
            {
                FailMessage(ex, ex.Message);
            }
        }
示例#8
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var groupID = TranslateUtils.ToInt(UserGroupIDDropDownList.SelectedValue);

            var groupInfo = UserGroupManager.GetGroupInfo(groupID);

            foreach (var userID in _userIdList)
            {
                var userInfo = BaiRongDataProvider.UserDao.GetUserInfo(userID);

                userInfo.GroupId = groupID;

                BaiRongDataProvider.UserDao.Update(userInfo);
            }

            Body.AddAdminLog("设置用户类别", string.Empty);

            PageUtils.CloseModalPage(Page);
        }
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var groupInfo     = UserGroupManager.GetGroupInfo(body.UserInfo.GroupId);
                var adminUserName = groupInfo.Additional.WritingAdminUserName;

                var publishmentSystemInfoList = PublishmentSystemManager.GetWritingPublishmentSystemInfoList(adminUserName);

                return(Ok(publishmentSystemInfoList));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
示例#10
0
        public IHttpActionResult Main()
        {
            try
            {
                var body = new RequestBody();
                if (!body.IsUserLoggin)
                {
                    return(Unauthorized());
                }

                var publishmentSystemId = body.GetPostInt("publishmentSystemId");
                var nodeId = body.GetPostInt("nodeId");

                var searchType = PageUtils.FilterSqlAndXss(body.GetPostString("searchType"));
                var keyword    = PageUtils.FilterSqlAndXss(body.GetPostString("keyword"));
                var dateFrom   = PageUtils.FilterSqlAndXss(body.GetPostString("dateFrom"));
                var dateTo     = PageUtils.FilterSqlAndXss(body.GetPostString("dateTo"));
                var page       = body.GetPostInt("page");

                var user          = new User(body.UserInfo);
                var groupInfo     = UserGroupManager.GetGroupInfo(user.GroupId);
                var adminUserName = groupInfo.Additional.WritingAdminUserName;

                var nodeIdList = new List <int> {
                    nodeId
                };

                var writingNodeInfoList = PublishmentSystemManager.GetWritingNodeInfoList(adminUserName, publishmentSystemId);
                foreach (var writingNodeInfo in writingNodeInfoList)
                {
                    if (StringUtils.In(writingNodeInfo.ParentsPath, nodeId.ToString()))
                    {
                        nodeIdList.Add(writingNodeInfo.NodeId);
                    }
                }

                var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
                var nodeInfo          = NodeManager.GetNodeInfo(publishmentSystemId, nodeId);
                var tableName         = NodeManager.GetTableName(publishmentSystemInfo, nodeInfo);
                var tableStyle        = NodeManager.GetTableStyle(publishmentSystemInfo, nodeInfo);
                var relatedIdentities = RelatedIdentities.GetChannelRelatedIdentities(publishmentSystemId, nodeId);

                var sqlString = DataProvider.ContentDao.GetWritingSelectCommend(user.UserName, tableName, publishmentSystemId, nodeIdList, searchType, keyword, dateFrom, dateTo);

                var results  = new List <Dictionary <string, object> >();
                var sqlPager = new SqlPager
                {
                    ItemsPerPage  = 20,
                    SelectCommand = sqlString,
                    OrderByString = ETaxisTypeUtils.GetOrderByString(tableStyle, ETaxisType.OrderByAddDateDesc)
                };

                sqlPager.DataBind(page);

                if (sqlPager.TotalCount > 0)
                {
                    foreach (System.Data.DataRowView row in sqlPager.PagedDataSource.DataSource)
                    {
                        var contentInfo = new ContentInfo(row);
                        results.Add(ContentUtility.ContentToDictionary(contentInfo, tableStyle, tableName, relatedIdentities));
                    }
                }

                return(Ok(new
                {
                    Results = results,
                    TotalPage = sqlPager.TotalPages
                }));
            }
            catch (Exception ex)
            {
                //return InternalServerError(ex);
                return(InternalServerError(new Exception("程序错误")));
            }
        }