public static IWXMenu GetFactory() { if (factory == null) { Type type = Type.GetType("Common." + SystemDefaultConfig.DatabaseProvider + "Repository.WeiXin.WXMenuDAL,Common." + SystemDefaultConfig.DatabaseProvider + "Repository", true); factory = (IWXMenu)Activator.CreateInstance(type); } return(factory); }
public static bool Update(WX_Menu model) { IWXMenu factory = WXMenuFactory.GetFactory(); bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <WX_Menu>(model, OperateType.Update); } return(result); }
public static bool UpdateMenuKeyId(int menuId, int?keyId) { if (menuId < 1) { throw new ArgumentNullException("menuId"); } IWXMenu factory = WXMenuFactory.GetFactory(); bool result = factory.UpdateMenuKeyId(menuId, keyId); if (result) { OperateLogServices.AddOperateLog(string.Format("编号:{0},关键字为:{1}", menuId, keyId.HasValue ? keyId.Value.ToString() : string.Empty), OperateType.Update); } return(result); }
public static bool UpdateMenuName(int menuId, string menuName, int seq) { if (menuId < 1) { throw new ArgumentNullException("menuId"); } if (menuName.IsEmpty()) { throw new ArgumentNullException("menuName"); } IWXMenu factory = WXMenuFactory.GetFactory(); bool result = factory.UpdateMenuName(menuId, menuName, seq); if (result) { OperateLogServices.AddOperateLog(string.Format("编号:{0},修改菜单名称为:{1},序号为:{2}", menuId, menuName, seq), OperateType.Update); } return(result); }
public static bool Delete(string companyId, int id) { if (id < 1) { throw new ArgumentNullException("Id"); } IWXKeyword factory = WXKeywordFactory.GetFactory(); IWXMenu menufactory = WXMenuFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); List <WX_Menu> menus = menufactory.GetMenuByKeyId(companyId, MenuType.GKeyValue, id); if (menus.Count > 0) { throw new MyException("微信菜单上已绑定该关键字,请解除绑定后再删除"); } bool result = factory.Delete(id, dbOperator); if (!result) { throw new MyException("删除失败"); } dbOperator.CommitTransaction(); if (result) { OperateLogServices.AddOperateLog(string.Format("删除编号:{0}", id), OperateType.Delete); } return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }
public static bool Delete(string companyId, int menuId) { if (menuId < 1) { throw new ArgumentNullException("menuId"); } IWXMenu factory = WXMenuFactory.GetFactory(); List <WX_Menu> models = factory.GetMenus(companyId); WX_Menu model = models.FirstOrDefault(p => p.ID == menuId); if (model != null && models.Count(p => p.MasterID == menuId) > 0) { throw new MyException("请先删除该菜单下的二级菜单"); } bool result = factory.Delete(menuId); if (result) { OperateLogServices.AddOperateLog(string.Format("删除菜单编号为:{0}菜单", menuId), OperateType.Update); } return(result); }
public static List <WX_Menu> GetMenuByKeyId(string companyId, MenuType type, int keyId) { IWXMenu factory = WXMenuFactory.GetFactory(); return(factory.GetMenuByKeyId(companyId, type, keyId)); }
public static List <WX_Menu> GetMenus(string companyId) { IWXMenu factory = WXMenuFactory.GetFactory(); return(factory.GetMenus(companyId)); }