public static Menu[] GetAllMenus() {//先去掉state树状态,just for test List <Menu> retValue = new List <Menu>(); using (MySqlConnection conn = DBUtility.OpenConnection()) { Menu[] menus = MenuDal.GetMenusByParentID(0, conn); foreach (Menu menu in menus) { //child Menu[] children = MenuDal.GetMenusByParentID(menu.id, conn); if (children != null && children.Length > 0) { menu.children = new Menu[children.Length]; for (int i = 0; i < children.Length; i++) { menu.children[i] = children[i]; //menu.children[i].state = ""; } } retValue.Add(menu); } } if (retValue.Count > 0) { //retValue[0].state = ""; } return(retValue.ToArray()); }
public static List <DishDto> Menu(int statusMeal) { List <Dish> menus = MenuDal.Menu(statusMeal); List <Dto.DishDto> m = menus.Select(menu => new Dto.DishDto(menu)).ToList(); return(m); }
/// <summary> /// Descripción: Obtiene informacion de los menus activos filtrado por Nombre /// Author: Terceros. /// Fecha Creacion: 01/01/2017 /// Fecha Modificación: 02/02/2017. /// Modificación: Se agregaron comentarios. /// </summary> /// <param name="nombre"></param> /// <returns></returns> public List <Menu> GetMenues(string nombre) { using (var menuDal = new MenuDal()) { return(menuDal.GetMenues(nombre)); } }
/// <summary> /// Descripción: Obtiene informacion de los menu/rol activos filtrado por IdRol /// Author: Terceros. /// Fecha Creacion: 01/01/2017 /// Fecha Modificación: 02/02/2017. /// Modificación: Se agregaron comentarios. /// </summary> /// <param name="idRol"></param> /// <returns></returns> public List <Menu> GetMenuByRol(int idRol) { using (var menuDal = new MenuDal()) { return(menuDal.GetMenuByRol(idRol)); } }
public List <Menu> startAlgo(User user) { List <Menu> menuPopulation = MenuDal.getInstance().GetMenues(); fitness(menuPopulation, user); List <Menu> bestFivePopulation = menuPopulation.OrderByDescending(x => x.MenuFitness).Take(5).ToList(); List <Menu> bestFivePopulation1 = geneticAlgo(bestFivePopulation, user, 1); return(bestFivePopulation1); }
/// <summary> /// 取得菜单 /// </summary> /// <returns></returns> public IList <Bill_SysMenu> GetMenu() { MenuDal menu = new MenuDal(); IList <Bill_SysMenu> userList = menu.GetMenuByUser(users.UserCode); IList <Bill_SysMenu> roleList = menu.GetMenuByRole(users.UserGroup); foreach (Bill_SysMenu roleMenu in roleList) { var temp = from linqtemp in userList where linqtemp.MenuId == roleMenu.MenuId select linqtemp; if (temp.Count() < 1) { userList.Add(roleMenu); } } return(userList); }
public override void getCurrentDal() { GetCurrentDal = new MenuDal(); }
public MenuService() { Dal = new MenuDal(); }
private MenuActions() { dal = MenuDal.getInstance(); }
public static JArray GetAllMenus() { JArray retValue = new JArray(); using (MySqlConnection conn = DBUtility.OpenConnection()) { try { Menu[] dbMenus = MenuDal.GetAllMenus(conn); if (dbMenus != null && dbMenus.Length > 0) { //dbMenus为单级权限菜单,需要组装成二级菜单 Dictionary <int, List <Menu> > menuDict = new Dictionary <int, List <Menu> >(); foreach (Menu dbmenu in dbMenus) { List <Menu> menuGroup = null; if (menuDict.ContainsKey(dbmenu.parent_id)) { menuGroup = menuDict[dbmenu.parent_id]; //选择合适位置插入 int insertIndex = 0; for (; insertIndex < menuGroup.Count; insertIndex++) { if (string.Compare(menuGroup[insertIndex].menu_no, dbmenu.menu_no, StringComparison.OrdinalIgnoreCase) > 0) { break; } } menuGroup.Insert(insertIndex, dbmenu); } else { Menu parent = MenuDal.GetMenu(dbmenu.parent_id, conn); if (parent != null) { menuGroup = new List <Menu>() { parent, dbmenu }; menuDict.Add(dbmenu.parent_id, menuGroup); } } } //生成json数组 int[] keys = menuDict.Keys.ToArray(); for (int i = 0; i < keys.Length; i++) { Menu parent = menuDict[keys[i]][0]; JArray jChildren = new JArray(); for (int j = 1; j < menuDict[keys[i]].Count; j++) { Menu child = menuDict[keys[i]][j]; jChildren.Add(new JObject(new JProperty("id", child.menu_no), new JProperty("name", child.name), new JProperty("icon", child.icon_class), new JProperty("url", child.action_url))); } JObject jMenuGroup = new JObject(new JProperty("id", parent.menu_no), new JProperty("icon", parent.icon_class), new JProperty("name", parent.name), new JProperty("children", jChildren)); //父级菜单还需一次排序 int insertIndex = 0; for (; insertIndex < retValue.Count; insertIndex++) { JObject item = (JObject)retValue[insertIndex]; if (string.Compare(item["id"].ToString(), jMenuGroup["id"].ToString(), StringComparison.OrdinalIgnoreCase) > 0) { break; } } retValue.Insert(insertIndex, jMenuGroup); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(retValue); }
public string GetMenusKey() { UserInfo user = AdminUtil.GetLoginUser(this); return(MenuDal.GetMenusLevel3(user)); }
public string GetMenus(string selectId) { UserInfo user = AdminUtil.GetLoginUser(this); return(MenuDal.GetMenusLevel2(user, selectId)); }
public CompanyController() { companyDal = new CompanyDal(); menuDal = new MenuDal(); companyMenuListDal = new CompanyMenuListDal(); }
static void Main(string[] args) { FoodDal food_dal = FoodDal.getInstance(); GoalDal goal_dal = GoalDal.getInstance(); MealsInMenuDal mim_dal = MealsInMenuDal.getInstance(); MealTypeDal mt_dal = MealTypeDal.getInstance(); MeasurementDal msrmnt_dal = MeasurementDal.getInstance(); MenuDal menu_dal = MenuDal.getInstance(); UserDal user_dal = UserDal.getInstance(); //Menu menu = menu_dal.GetMenu(1); //User user = user_dal.GetUser(4); //List<Menu> lstMenues = new List<Menu>(); //Menu menutest; //for (int i = 1; i < 6; i++) //{ // menutest = menu_dal.GetMenu(i); // lstMenues.Add(menutest); //} //GeneticAlgo.getInstance().startAlgo(user); #region Food //food_dal.InsertOrUpdateFood(new Food() //{ // Name = "orez", // Calories = 3400, // Carbohydrates = 2.22, // Fat = 44.2, // Protein = 5.55, // Category = 1 //}); //Food getFoodById = food_dal.GetFoodById(1); //List<Food> getAllFoods = food_dal.GetFoods(); //bool deleteFood = food_dal.DeleteFood(2); #endregion //User us = new User() //{ // Birthday = DateTime.Now, // Email = "*****@*****.**", // FirstName = "aba", // Gender = 1, // Height = 1.95, // LastName = "bo", // Password = "******", // Measurement = new Measurement() // { // BodyFat = 15, // Weight = 100 // }, // Goal = new Goal() // { // BodyFat = 12, // StartingWeight = 100, // GoalWeight = 80 // }, // MeasurementID = 0, // GoalID = 0 //}; //Menu menu = new Menu(0); //menu.Breakfast.Add(food_dal.GetFoodById(1)); //menu.Breakfast.Add(food_dal.GetFoodById(2)); //menu.Breakfast.Add(food_dal.GetFoodById(13)); //menu.Lunch.Add(food_dal.GetFoodById(7)); //menu.Lunch.Add(food_dal.GetFoodById(8)); //menu.Lunch.Add(food_dal.GetFoodById(9)); //menu.Dinner.Add(food_dal.GetFoodById(6)); //menu.Dinner.Add(food_dal.GetFoodById(12)); //menu.Dinner.Add(food_dal.GetFoodById(13)); //menu_dal.InsertMenu(menu); //Menu menucheck = menu_dal.GetMenuById(1); // WORKS //Menu menucheck2 = menu_dal.GetMenu(8); // WORKS //List<Menu> menucheck3 = menu_dal.GetMenues(); // WORKS //menu_dal.InsertMenu(menu); //Menu menucheck2 = menu_dal.GetMenu(10); //menucheck2 = menu_dal.IncreasePickRate(menucheck2); //bool isLoginOK = UserActions.getInstance().checkLogin("*****@*****.**", "ppa123"); //List<User> lstusers = user_dal.GetUsers(); //int userId = user_dal.InsertOrUpdateUser(us); //User userFromGetUser = user_dal.GetUser(1); //userFromGetUser.Goal.GoalWeight = 88.8; //int userIdAfterUpdate = user_dal.InsertOrUpdateUser(userFromGetUser); //bool s1 = user_dal.IsUserExists("*****@*****.**"); //bool s2 = user_dal.IsUserExists("*****@*****.**"); Console.WriteLine("stam"); }
/// <summary> /// 创建菜单 /// </summary> public static string CreateMenu(string access_token, string orgID) { string menuJsonStr = MenuDal.GetMenuJsonStr(orgID); return(CreateMenu2(access_token, menuJsonStr)); }
protected void Page_Load(object sender, EventArgs e) { string action = Request["action"]; string json = string.Empty; try { switch (action) { case "Load": int pageSize = Convert.ToInt32(Request["rows"]); int pageNum = Convert.ToInt32(Request["page"]); string userName = Session["WebUser"].ToString(); DataTable dt = MenuDal.GetMenuList(userName); int count = dt.Rows.Count; Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("total", count); dic.Add("rows", dt); json = JsonConvert.SerializeObject(dic); break; case "edit": string id = Request["id"]; DataTable menudt = MenuDal.GetMenuByID(int.Parse(id)); string codelen = menudt.Rows[0]["Code"].ToString(); if (codelen.Length == 2) { menudt.Rows[0]["Code"] = "0"; } else { menudt.Rows[0]["Code"] = codelen.Substring(0, 2); } json = JsonConvert.SerializeObject(menudt); break; case "add": string codes = Request["code"]; string mname = Request["name"]; string mtype = Request["type"]; string mkey = Request["key"]; string murl = Request["url"]; string username = Session["WebUser"].ToString(); string mcode = ""; if (codes == "0") { mcode = MenuDal.GetOneCode(); } else { mcode = MenuDal.GetTwoCode(codes); } int addrow = MenuDal.AddMenu(mcode, mname, mtype, mkey, murl, username); if (addrow == 1) { json = "1"; } break; case "update": string menuId = Request["id"]; //string code = Request["code"]; string name = Request["name"]; string type = Request["type"]; string key = Request["key"]; string url = Request["url"]; int uprow = MenuDal.UpdateMenu(menuId, name, type, key, url); if (uprow == 1) { json = "1"; } break; case "deleteMenu": var ids = Request["id"]; if (ids != null) { int row = MenuDal.DeleteMenu(ids); if (row == 1) { json = "1"; } else { json = "0"; } } else { json = "0"; } break; case "deleteOneMenu": var oneCode = Request["code"]; if (oneCode != null) { int row = MenuDal.DeleteOneMenu(oneCode, AdminUtil.GetLoginUser(this)); if (row > 0) { json = "1"; } } break; case "updateWX": //同步到微信 UserInfo user = AdminUtil.GetLoginUser(this); string result = WXApi.CreateMenu(AdminUtil.GetAccessToken(this), user.OrgID); if (Tools.GetJsonValue(result, "errcode") == "0") { json = "{\"code\":1,\"msg\":\"\"}"; } else { json = "{\"code\":0,\"msg\":\"errcode:" + Tools.GetJsonValue(result, "errcode") + ", errmsg:" + Tools.GetJsonValue(result, "errmsg") + "\"}"; } break; case "tree": DataTable menudts = MenuDal.GetOneMenuList(AdminUtil.GetLoginUser(this)); List <MenuModel> flowList = new List <MenuModel>(); MenuModel flow; foreach (DataRow drFlowType in menudts.Rows) { flow = new MenuModel(); flow.id = drFlowType["Code"].ToString(); flow.level = 0; flow.parent = "-1"; flow.isLeaf = false; flow.expanded = true; flow.Id = int.Parse(drFlowType["Id"].ToString()); flow.Code = drFlowType["Code"].ToString(); flow.Name = drFlowType["Name"].ToString(); flow.Type = drFlowType["Type"].ToString(); flow.MenuKey = drFlowType["MenuKey"].ToString(); flow.Url = drFlowType["Url"].ToString(); flow.OrgID = drFlowType["OrgID"].ToString(); flowList.Add(flow); DataTable menudts2 = MenuDal.GetTwoMenuList(flow.Code); foreach (DataRow twoRow in menudts2.Rows) { MenuModel flow2 = new MenuModel(); flow2.id = twoRow["Code"].ToString(); flow2.level = 1; flow2.parent = twoRow["Code"].ToString().Substring(0, 2); flow2.isLeaf = true; flow2.expanded = true; flow2.Id = int.Parse(twoRow["Id"].ToString()); flow2.Code = twoRow["Code"].ToString(); flow2.Name = twoRow["Name"].ToString(); flow2.Type = twoRow["Type"].ToString(); flow2.MenuKey = twoRow["MenuKey"].ToString(); flow2.Url = twoRow["Url"].ToString(); flow2.OrgID = twoRow["OrgID"].ToString(); flowList.Add(flow2); } } json = JsonConvert.SerializeObject(flowList); break; case "menulist": DataTable onedt = MenuDal.GetOneMenuList(AdminUtil.GetLoginUser(this)); DataRow onerow = onedt.NewRow(); onerow["Code"] = 0; onerow["Name"] = "无"; onedt.Rows.InsertAt(onerow, 0); json = JsonConvert.SerializeObject(onedt); break; default: break; } } catch (Exception) { throw; } if (!string.IsNullOrEmpty(json)) { Response.Write(json); Response.End(); } }