示例#1
0
        public ActionResult AddMenu(WXMenu menu)
        {
            if (menu.ParentID == 0)
            {
                if (WXMenu.GetMenuCount(menu.ParentID) >= 3)
                {
                    return(Content("fail|一级菜单最多只能有三个,不能再加了"));
                }
            }
            if (menu.ParentID > 0)
            {
                if (WXMenu.GetMenuCount(menu.ParentID) >= 5)
                {
                    return(Content("fail|二级菜单最多只能有五个,不能再加了"));
                }
            }

            menu.Menukey = DAL.Generate_Second.NextBillNumber();
            do
            {
                WXMenu oldmenu = WXMenu.GetMenuByMenukey(menu.Menukey);
                if (oldmenu == null)
                {
                    break;
                }
            }while (true);


            int menuid = menu.InsertAndReturnIdentity();

            return(Content("ok|" + menuid.ToString()));
        }
示例#2
0
        public ActionResult GetMenuByMenuID(int id)
        {
            WXMenu menu = WXMenu.GetEntityByID(id);

            if (menu == null)
            {
            }

            return(Json(menu, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult ToPublish()
        {
            string rtn = WXMenu.ToPublish();

            if (rtn == "ok")
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("发布失败,请检查是否填写完整。详情:" + rtn));
            }
        }
示例#4
0
        public ActionResult Index()
        {
            //List<WXMenu> menus = WXMenu.GetEntitysAll();
            //if (menus == null || menus.Count <= 0)
            //{
            //    WxMenuConvert.GetPublishMenuToDB();
            //}

            //拉取微信菜单保存到本地数据库
            WxMenuConvert.GetPublishMenuToDB();
            List <WXMenu> menus = WXMenu.GetEntitysAll();

            return(View(menus));
        }
示例#5
0
        public InvokeResult CreateWXButtons()
        {
            InvokeResult          result       = new InvokeResult();
            WXButtonsCreateResult createResult = new WXButtonsCreateResult {
            };

            var all_buttons = BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).List <WXButton>(new WXButton {
                Status = 1
            }).ToList();

            createResult.button = all_buttons.Where(item => item.Levels == 1).OrderBy(item => item.OrderNo).ToList().Select(item =>
            {
                WXMenu x = new WXMenu {
                    name = item.ButtonName
                };
                x.sub_button = all_buttons.Where(subitem => subitem.ParentId == item.ButtonId).OrderBy(subitem => subitem.OrderNo).Select(subitem =>
                {
                    dynamic y = new ExpandoObject();
                    y.name    = subitem.ButtonName;
                    y.type    = subitem.Type;

                    if (subitem.Type == "click")
                    {
                        y.key = subitem.KeyOrUrl;
                    }
                    else if (subitem.Type == "view")
                    {
                        y.url = subitem.KeyOrUrl;
                    }
                    return(y);
                }).ToList();
                return(x);
            }).ToList();

            string jsonStr = JsonConvert.SerializeObject(createResult);

            _CreateWXButtonsToWeiXin(jsonStr, () =>
            {
                result.Success = true;
            }, (errCode, errMsg) =>
            {
                result.ErrorCode    = errCode;
                result.ErrorMessage = errMsg;
            });

            return(result);
        }
示例#6
0
        public static string createMenuStrAsXml()
        {
            GetForCreateRet result = new GetForCreateRet {
            };

            var all_buttons = BuilderFactory.DefaultBulder().List <WXButton>().ToList();


            result.button = all_buttons.Where(item => item.Levels == 1).OrderBy(item => item.OrderNo).ToList().Select(item =>
            {
                WXMenu x = new WXMenu {
                    name = item.ButtonName
                };
                x.sub_button = all_buttons.Where(subitem => subitem.ParentId == item.ButtonId).OrderBy(subitem => subitem.OrderNo).Select(subitem =>
                {
                    dynamic y = new ExpandoObject();
                    y.name    = subitem.ButtonName;
                    y.type    = subitem.Type;

                    if (subitem.Type == "click")
                    {
                        y.key = subitem.KeyOrUrl;
                    }
                    else if (subitem.Type == "view")
                    {
                        y.url = subitem.KeyOrUrl;
                    }
                    return(y);
                }).ToList();
                return(x);
            }).ToList();

            string jsonStr = JsonConvert.SerializeObject(result);

            return(jsonStr);
        }
示例#7
0
        public ActionResult DelMenuByID(int id)
        {
            int rtn = WXMenu.DeleteAllByID(id);

            return(Content(rtn > 0 ? "ok" : "删除失败"));
        }
示例#8
0
        public ActionResult EditMedia(int menuid, string Media_id, string MediaType)
        {
            int rtn = WXMenu.EditMedia(menuid, Media_id, MediaType);

            return(rtn > 0 ? Content("ok") : Content("修改失败"));
        }
示例#9
0
        public ActionResult Edit(int id, string name, string value)
        {
            int rtn = WXMenu.Edit(id, name, value);

            return(rtn > 0 ? Content("ok") : Content("修改失败"));
        }