コード例 #1
0
ファイル: PageMenuAdd.cs プロジェクト: skotbenben/cms
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemId");
            _menuId   = Body.GetQueryInt("menuID");
            _parentId = Body.GetQueryInt("parentID");

            if (!IsPostBack)
            {
                EMenuTypeUtils.AddListItems(DdlMenuType);

                var menuInfo = DataProviderWx.MenuDao.GetMenuInfo(_menuId);
                if (menuInfo == null)
                {
                    _menuId = 0;
                }

                if (_menuId == 0)
                {
                    LtlPageTitle.Text = $"添加{(_parentId == 0 ? "主" : "子")}菜单";
                }
                else
                {
                    LtlPageTitle.Text = $"修改{(_parentId == 0 ? "主" : "子")}菜单({menuInfo.MenuName})";

                    TbMenuName.Text = menuInfo.MenuName;
                    ControlUtils.SelectListItems(DdlMenuType, EMenuTypeUtils.GetValue(menuInfo.MenuType));
                    TbKeyword.Text = menuInfo.Keyword;
                    TbUrl.Text     = menuInfo.Url;
                    LtlScript.Text =
                        $"<script>{MPUtils.GetChannelOrContentSelectScript(PublishmentSystemInfo, menuInfo.ChannelId, menuInfo.ContentId)}</script>";
                }

                DdlMenuType_OnSelectedIndexChanged(null, EventArgs.Empty);

                BtnKeywordSelect.Attributes.Add("onclick", "parent." + ModalKeywordSelect.GetOpenWindowString(PublishmentSystemId, "selectKeyword"));

                BtnContentSelect.Attributes.Add("onclick", "parent." + ModalContentSelect.GetOpenWindowString(PublishmentSystemId, false, "contentSelect"));
                BtnChannelSelect.Attributes.Add("onclick", "parent." + ModalChannelSelect.GetOpenWindowString(PublishmentSystemId));
            }
        }
コード例 #2
0
ファイル: BackgroundMenuAdd.cs プロジェクト: yankaics/cms-1
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");
            menuID   = TranslateUtils.ToInt(GetQueryString("menuID"));
            parentID = TranslateUtils.ToInt(GetQueryString("parentID"));

            if (!IsPostBack)
            {
                EMenuTypeUtils.AddListItems(ddlMenuType);

                var menuInfo = DataProviderWX.MenuDAO.GetMenuInfo(menuID);
                if (menuInfo == null)
                {
                    menuID = 0;
                }

                if (menuID == 0)
                {
                    ltlPageTitle.Text = $"添加{(parentID == 0 ? "主" : "子")}菜单";
                }
                else
                {
                    ltlPageTitle.Text = $"修改{(parentID == 0 ? "主" : "子")}菜单({menuInfo.MenuName})";

                    tbMenuName.Text = menuInfo.MenuName;
                    ControlUtils.SelectListItems(ddlMenuType, EMenuTypeUtils.GetValue(menuInfo.MenuType));
                    tbKeyword.Text = menuInfo.Keyword;
                    tbUrl.Text     = menuInfo.Url;
                    ltlScript.Text =
                        $"<script>{MPUtils.GetChannelOrContentSelectScript(PublishmentSystemInfo, menuInfo.ChannelID, menuInfo.ContentID)}</script>";
                }

                ddlMenuType_OnSelectedIndexChanged(null, EventArgs.Empty);

                btnKeywordSelect.Attributes.Add("onclick", "parent." + Modal.KeywordSelect.GetOpenWindowString(PublishmentSystemID, "selectKeyword"));

                btnContentSelect.Attributes.Add("onclick", "parent." + Modal.ContentSelect.GetOpenWindowString(PublishmentSystemID, false, "contentSelect"));
                btnChannelSelect.Attributes.Add("onclick", "parent." + CMS.BackgroundPages.Modal.ChannelSelect.GetOpenWindowString(PublishmentSystemID));
            }
        }
コード例 #3
0
ファイル: MenuDAO.cs プロジェクト: yuxi214/siteservercms
        public void Update(MenuInfo menuInfo)
        {
            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, menuInfo.PublishmentSystemID),
                GetParameter(PARM_MENU_NAME, EDataType.NVarChar, 50, menuInfo.MenuName),
                GetParameter(PARM_MENU_TYPE, EDataType.VarChar, 50, EMenuTypeUtils.GetValue(menuInfo.MenuType)),
                GetParameter(PARM_KEYWORD, EDataType.NVarChar, 50, menuInfo.Keyword),
                GetParameter(PARM_URL, EDataType.VarChar, 200, menuInfo.Url),
                GetParameter(PARM_CHANNEL_ID, EDataType.Integer, menuInfo.ChannelID),
                GetParameter(PARM_CONTENT_ID, EDataType.Integer, menuInfo.ContentID),
                GetParameter(PARM_PARENT_ID, EDataType.Integer, menuInfo.ParentID),
                GetParameter(PARM_TAXIS, EDataType.Integer, menuInfo.Taxis),
                GetParameter(PARM_MENU_ID, EDataType.Integer, menuInfo.MenuID)
            };

            ExecuteNonQuery(SQL_UPDATE, parms);
        }
コード例 #4
0
ファイル: MenuDAO.cs プロジェクト: skotbenben/cms
        public void Update(MenuInfo menuInfo)
        {
            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, menuInfo.PublishmentSystemId),
                GetParameter(ParmMenuName, EDataType.NVarChar, 50, menuInfo.MenuName),
                GetParameter(ParmMenuType, EDataType.VarChar, 50, EMenuTypeUtils.GetValue(menuInfo.MenuType)),
                GetParameter(ParmKeyword, EDataType.NVarChar, 50, menuInfo.Keyword),
                GetParameter(ParmUrl, EDataType.VarChar, 200, menuInfo.Url),
                GetParameter(ParmChannelId, EDataType.Integer, menuInfo.ChannelId),
                GetParameter(ParmContentId, EDataType.Integer, menuInfo.ContentId),
                GetParameter(ParmParentId, EDataType.Integer, menuInfo.ParentId),
                GetParameter(ParmTaxis, EDataType.Integer, menuInfo.Taxis),
                GetParameter(ParmMenuId, EDataType.Integer, menuInfo.MenuId)
            };

            ExecuteNonQuery(SqlUpdate, parms);
        }
コード例 #5
0
        public object GetValue(string attributeName)
        {
            foreach (var name in AllAttributes)
            {
                if (StringUtils.EqualsIgnoreCase(name, attributeName))
                {
                    var nameVlaue = GetType().GetProperty(name).GetValue(this, null);

                    if (attributeName == "MenuType")
                    {
                        return(EMenuTypeUtils.GetEnumType(nameVlaue.ToString()));
                    }

                    return(nameVlaue);
                }
            }
            return(null);
        }
コード例 #6
0
ファイル: MenuDAO.cs プロジェクト: yuxi214/siteservercms
        public int Insert(MenuInfo menuInfo)
        {
            var menuID = 0;

            var sqlString = "INSERT INTO wx_Menu (PublishmentSystemID, MenuName, MenuType, Keyword, Url, ChannelID, ContentID, ParentID, Taxis) VALUES (@PublishmentSystemID, @MenuName, @MenuType, @Keyword, @Url, @ChannelID, @ContentID, @ParentID, @Taxis)";

            var taxis = GetMaxTaxis(menuInfo.ParentID) + 1;
            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, menuInfo.PublishmentSystemID),
                GetParameter(PARM_MENU_NAME, EDataType.NVarChar, 50, menuInfo.MenuName),
                GetParameter(PARM_MENU_TYPE, EDataType.VarChar, 50, EMenuTypeUtils.GetValue(menuInfo.MenuType)),
                GetParameter(PARM_KEYWORD, EDataType.NVarChar, 50, menuInfo.Keyword),
                GetParameter(PARM_URL, EDataType.VarChar, 200, menuInfo.Url),
                GetParameter(PARM_CHANNEL_ID, EDataType.Integer, menuInfo.ChannelID),
                GetParameter(PARM_CONTENT_ID, EDataType.Integer, menuInfo.ContentID),
                GetParameter(PARM_PARENT_ID, EDataType.Integer, menuInfo.ParentID),
                GetParameter(PARM_TAXIS, EDataType.Integer, taxis)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, sqlString, parms);
                        menuID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, "wx_Menu");
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(menuID);
        }
コード例 #7
0
ファイル: MenuDAO.cs プロジェクト: skotbenben/cms
        public int Insert(MenuInfo menuInfo)
        {
            var menuId = 0;

            var sqlString = "INSERT INTO wx_Menu (PublishmentSystemID, MenuName, MenuType, Keyword, Url, ChannelID, ContentID, ParentID, Taxis) VALUES (@PublishmentSystemID, @MenuName, @MenuType, @Keyword, @Url, @ChannelID, @ContentID, @ParentID, @Taxis)";

            var taxis = GetMaxTaxis(menuInfo.ParentId) + 1;
            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, menuInfo.PublishmentSystemId),
                GetParameter(ParmMenuName, EDataType.NVarChar, 50, menuInfo.MenuName),
                GetParameter(ParmMenuType, EDataType.VarChar, 50, EMenuTypeUtils.GetValue(menuInfo.MenuType)),
                GetParameter(ParmKeyword, EDataType.NVarChar, 50, menuInfo.Keyword),
                GetParameter(ParmUrl, EDataType.VarChar, 200, menuInfo.Url),
                GetParameter(ParmChannelId, EDataType.Integer, menuInfo.ChannelId),
                GetParameter(ParmContentId, EDataType.Integer, menuInfo.ContentId),
                GetParameter(ParmParentId, EDataType.Integer, menuInfo.ParentId),
                GetParameter(ParmTaxis, EDataType.Integer, taxis)
            };

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        menuId = ExecuteNonQueryAndReturnId(trans, sqlString, parms);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(menuId);
        }
コード例 #8
0
ファイル: PageMenuAdd.cs プロジェクト: skotbenben/cms
        public void DdlMenuType_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            var isHideAll = false;

            if (_parentId == 0 && _menuId > 0)
            {
                var childrenCount = DataProviderWx.MenuDao.GetCount(_menuId);
                if (childrenCount > 0)
                {
                    isHideAll = true;
                }
            }

            if (isHideAll)
            {
                PhMenuType.Visible = PhUrl.Visible = PhKeyword.Visible = PhSite.Visible = false;
            }
            else
            {
                var menuType = EMenuTypeUtils.GetEnumType(DdlMenuType.SelectedValue);

                PhUrl.Visible = PhKeyword.Visible = PhSite.Visible = false;

                if (menuType == EMenuType.Url)
                {
                    PhUrl.Visible = true;
                }
                else if (menuType == EMenuType.Keyword)
                {
                    PhKeyword.Visible = true;
                }
                else if (menuType == EMenuType.Site)
                {
                    PhSite.Visible = true;
                }
            }
        }
コード例 #9
0
ファイル: BackgroundMenuAdd.cs プロジェクト: yankaics/cms-1
        public void ddlMenuType_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            var isHideAll = false;

            if (parentID == 0 && menuID > 0)
            {
                var childrenCount = DataProviderWX.MenuDAO.GetCount(menuID);
                if (childrenCount > 0)
                {
                    isHideAll = true;
                }
            }

            if (isHideAll)
            {
                phMenuType.Visible = phUrl.Visible = phKeyword.Visible = phSite.Visible = false;
            }
            else
            {
                var menuType = EMenuTypeUtils.GetEnumType(ddlMenuType.SelectedValue);

                phUrl.Visible = phKeyword.Visible = phSite.Visible = false;

                if (menuType == EMenuType.Url)
                {
                    phUrl.Visible = true;
                }
                else if (menuType == EMenuType.Keyword)
                {
                    phKeyword.Visible = true;
                }
                else if (menuType == EMenuType.Site)
                {
                    phSite.Visible = true;
                }
            }
        }
コード例 #10
0
ファイル: MenuDAO.cs プロジェクト: yuxi214/siteservercms
        public List <MenuInfo> GetMenuInfoList(int publishmentSystemID)
        {
            var list = new List <MenuInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(PARM_PUBLISHMENT_SYSTEM_ID, EDataType.Integer, publishmentSystemID),
                GetParameter(PARM_PARENT_ID, EDataType.Integer, 0)
            };

            using (var rdr = ExecuteReader(SQL_SELECT_ALLBY, parms))
            {
                while (rdr.Read())
                {
                    var menuInfo = new MenuInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetValue(2).ToString(), EMenuTypeUtils.GetEnumType(rdr.GetValue(3).ToString()), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetInt32(6), rdr.GetInt32(7), rdr.GetInt32(8), rdr.GetInt32(9));
                    list.Add(menuInfo);
                }
                rdr.Close();
            }

            return(list);
        }
コード例 #11
0
ファイル: MenuDAO.cs プロジェクト: yuxi214/siteservercms
        public MenuInfo GetMenuInfo(int menuID)
        {
            MenuInfo menuInfo = null;

            var parms = new IDataParameter[]
            {
                GetParameter(PARM_MENU_ID, EDataType.Integer, menuID)
            };

            using (var rdr = ExecuteReader(SQL_SELECT, parms))
            {
                if (rdr.Read())
                {
                    menuInfo = new MenuInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetValue(2).ToString(), EMenuTypeUtils.GetEnumType(rdr.GetValue(3).ToString()), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetInt32(6), rdr.GetInt32(7), rdr.GetInt32(8), rdr.GetInt32(9));
                }
                rdr.Close();
            }

            return(menuInfo);
        }
コード例 #12
0
ファイル: PageMenuAdd.cs プロジェクト: skotbenben/cms
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                try
                {
                    var menuInfo = new MenuInfo();
                    if (_menuId > 0)
                    {
                        menuInfo = DataProviderWx.MenuDao.GetMenuInfo(_menuId);
                    }

                    menuInfo.MenuName            = TbMenuName.Text;
                    menuInfo.ParentId            = _parentId;
                    menuInfo.PublishmentSystemId = PublishmentSystemId;
                    menuInfo.MenuType            = EMenuTypeUtils.GetEnumType(DdlMenuType.SelectedValue);

                    if (PhMenuType.Visible)
                    {
                        if (menuInfo.MenuType == EMenuType.Keyword)
                        {
                            if (!DataProviderWx.KeywordMatchDao.IsExists(PublishmentSystemId, TbKeyword.Text))
                            {
                                FailMessage("菜单保存失败,所填关键词不存在,请先在关键词回复中添加");
                                return;
                            }
                        }
                        else if (menuInfo.MenuType == EMenuType.Site)
                        {
                            var idsCollection = Request.Form["idsCollection"];
                            if (!string.IsNullOrEmpty(idsCollection))
                            {
                                menuInfo.ChannelId = TranslateUtils.ToInt(idsCollection.Split('_')[0]);
                                menuInfo.ContentId = TranslateUtils.ToInt(idsCollection.Split('_')[1]);
                            }

                            if (menuInfo.ChannelId == 0 && menuInfo.ContentId == 0)
                            {
                                FailMessage("菜单保存失败,必须选择微网站页面,请点击下方按钮进行选择");
                                return;
                            }
                        }
                    }

                    if (_parentId > 0)
                    {
                        if (StringUtils.GetByteCount(TbMenuName.Text) > 26)
                        {
                            FailMessage("菜单保存失败,子菜单菜名称不能超过26个字节(13个汉字)");
                            return;
                        }
                    }
                    else
                    {
                        if (StringUtils.GetByteCount(TbMenuName.Text) > 16)
                        {
                            FailMessage("菜单保存失败,子菜单菜名称不能超过16个字节(8个汉字)");
                            return;
                        }
                    }
                    if (menuInfo.MenuType == EMenuType.Url)
                    {
                        if (StringUtils.GetByteCount(TbUrl.Text) > 256)
                        {
                            FailMessage("菜单保存失败,菜单网址不能超过256个字节");
                            return;
                        }
                    }

                    if (menuInfo.MenuType == EMenuType.Url)
                    {
                        menuInfo.Url = TbUrl.Text;
                    }
                    else if (menuInfo.MenuType == EMenuType.Keyword)
                    {
                        menuInfo.Keyword = TbKeyword.Text;
                    }
                    else if (menuInfo.MenuType == EMenuType.Site)
                    {
                        var idsCollection = Request.Form["idsCollection"];
                        if (!string.IsNullOrEmpty(idsCollection))
                        {
                            menuInfo.ChannelId = TranslateUtils.ToInt(idsCollection.Split('_')[0]);
                            menuInfo.ContentId = TranslateUtils.ToInt(idsCollection.Split('_')[1]);
                        }
                    }

                    if (_menuId > 0)
                    {
                        DataProviderWx.MenuDao.Update(menuInfo);

                        Body.AddSiteLog(PublishmentSystemId, "修改自定义菜单");
                        SuccessMessage("自定义菜单修改成功!");
                    }
                    else
                    {
                        _menuId = DataProviderWx.MenuDao.Insert(menuInfo);

                        Body.AddSiteLog(PublishmentSystemId, "新增自定义菜单");
                        SuccessMessage("自定义菜单新增成功!");
                    }

                    var redirectUrl = PageMenu.GetRedirectUrl(PublishmentSystemId, _parentId, _menuId);
                    LtlPageTitle.Text += $@"<script>parent.redirect('{redirectUrl}');</script>";
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "自定义菜单配置失败!");
                }
            }
        }
コード例 #13
0
ファイル: MenuDAO.cs プロジェクト: skotbenben/cms
        public List <MenuInfo> GetMenuInfoList(int publishmentSystemId)
        {
            var list = new List <MenuInfo>();

            var parms = new IDataParameter[]
            {
                GetParameter(ParmPublishmentSystemId, EDataType.Integer, publishmentSystemId),
                GetParameter(ParmParentId, EDataType.Integer, 0)
            };

            using (var rdr = ExecuteReader(SqlSelectAllby, parms))
            {
                while (rdr.Read())
                {
                    var menuInfo = new MenuInfo(rdr.GetInt32(0), rdr.GetInt32(1), rdr.GetValue(2).ToString(), EMenuTypeUtils.GetEnumType(rdr.GetValue(3).ToString()), rdr.GetValue(4).ToString(), rdr.GetValue(5).ToString(), rdr.GetInt32(6), rdr.GetInt32(7), rdr.GetInt32(8), rdr.GetInt32(9));
                    list.Add(menuInfo);
                }
                rdr.Close();
            }

            return(list);
        }