/// <summary>
        ///  生成菜单Json
        /// </summary>
        /// <param name="CompanyID">公司ID</param>
        /// <returns></returns>
        public static string GetMenuJsonStr(Guid CompanyID)
        {
            StringBuilder         sb    = new StringBuilder();
            List <button>         btns  = new List <button>();
            IEnumerable <WX_Menu> menus = WX_MenuService.instance().GetEnumByCompanyID(CompanyID);

            foreach (WX_Menu m in menus)
            {
                button btn = new button();
                btn.name = m.Name;
                btn.type = m.TypeStr;
                btn.url  = m.URL;
                btn.key  = m.KeyWord == null ? "" : m.KeyWord.KeyWords;
                if (m.Ishaschild)
                {
                    btn.sub_button = new List <sub_button>();
                    foreach (var item in m.Childs)
                    {
                        WX_KeyWord key = WX_KeyWordService.instance().GetEnumerableByID(item.KeyWordID).FirstOrDefault();
                        sub_button b   = new sub_button();
                        b.name = item.Name;
                        b.key  = key == null ? "" : key.KeyWords;
                        b.url  = item.URL;
                        b.type = item.TypeStr;
                        btn.sub_button.Add(b);
                    }
                }
                btns.Add(btn);
            }
            sb.Append("{\"button\":");
            sb.Append(JsonHelper.SerializeObject(btns));
            sb.Append("}");
            return(sb.ToString());
        }
Exemple #2
0
 public static WX_KeyWordService instance()
 {
     if (_instance == null)
     {
         _instance = new WX_KeyWordService();
     }
     return(_instance);
 }
        public IEnumerable <WX_Menu> GetEnumByCompanyID(Guid Companyid)
        {
            IEnumerable <WX_Menu> result = new List <WX_Menu>();

            _db.Execute(() =>
            {
                result = _db.GetList <WX_Menu>(m => m.CompanyID == Companyid && m.ParentID == Guid.Empty && m.DR == false);
            });
            foreach (var item in result)
            {
                item.Childs  = GetChilds(item.ID);
                item.KeyWord = WX_KeyWordService.instance().GetEnumerableByID(item.KeyWordID).FirstOrDefault();
            }
            return(result);
        }