private static UserEntity TranslateUserEntity(UserInfo userInfo, bool alldata = true) { UserEntity userEntity = new UserEntity(); if (userInfo != null) { userEntity.UserID = userInfo.UserID; userEntity.UserName = userInfo.UserName; userEntity.NickName = userInfo.NickName; userEntity.Status = userInfo.Status; userEntity.CustomerID = userInfo.CustomerID; userEntity.StorageIDs = userInfo.StorageIDs; if (alldata) { List <MenuEntity> allMenus = new List <MenuEntity>(); MenuCompare compare = new MenuCompare(); if (!string.IsNullOrEmpty(userInfo.RoleIDs)) { userEntity.Roles = RoleService.GetRoleByKeys(userInfo.RoleIDs); if (userEntity.Roles.Count > 0) { foreach (RoleEntity r in userEntity.Roles) { allMenus = allMenus.Merge(r.Menus, compare); } } } if (!string.IsNullOrEmpty(userInfo.GroupIDs)) { userEntity.Groups = GroupService.GetGroupByKeys(userInfo.GroupIDs); if (userEntity.Groups.Count > 0) { foreach (GroupEntity r in userEntity.Groups) { allMenus = allMenus.Merge(r.Menus, compare); } } } userEntity.Menus = allMenus; } } return(userEntity); }
private ToolStripMenuItem[] MakeMenuGroup(int language) { ToolStripMenuItem newitem = null; //english = null, japanese = null, deutsch = null, french = null ToolStripMenuItem[] target_category = null; // categories_en = null, categories_jp = null, FFXIATPhrase[] atp = this.ATPhraseLoader.ATPhrases; int category_cnt = 0; // en_cat_cnt = 0, jp_cat_cnt = 0, string GroupName = "Unknown Group"; string ItemName = String.Empty; MenuCompare mcompare = new MenuCompare(); if (atp != null) { for (int i = 0; i < atp.Length; i++) { if ((atp[i] == null) || (atp[i].MessageID == 0x00)) continue; else if (atp[i].Language != language) continue; else if (atp[i].value.Trim() == String.Empty) continue; byte b1 = atp[i].StringResource, b2 = atp[i].Language, b3 = atp[i].GroupID, b4 = atp[i].MessageID; ItemName = atp[i].value; if (ItemName == " ") continue; FFXIATPhrase grp = this.ATPhraseLoader.GetPhraseByID(b1, b2, b3); if (grp != null) GroupName = grp.value; else GroupName = "Unknown Group"; if (target_category == null) { target_category = new ToolStripMenuItem[1]; if ((b2 <= FFXIATPhraseLoader.ffxiLanguages.NUM_LANG_MAX) && (b2 >= FFXIATPhraseLoader.ffxiLanguages.NUM_LANG_MIN)) target_category[0] = new ToolStripMenuItem(GroupName, Icons.GeneralIcon[b2]); //else target_category[0] = new ToolStripMenuItem(GroupName); category_cnt = 0; } else { for (category_cnt = 0; category_cnt < target_category.Length; category_cnt++) { if (target_category[category_cnt].Text == GroupName) break; } if (category_cnt == target_category.Length) { Array.Resize(ref target_category, target_category.Length + 1); if ((b2 <= FFXIATPhraseLoader.ffxiLanguages.NUM_LANG_MAX) && (b2 >= FFXIATPhraseLoader.ffxiLanguages.NUM_LANG_MIN)) target_category[target_category.Length - 1] = new ToolStripMenuItem(GroupName, Icons.GeneralIcon[b2]); } } newitem = new ToolStripMenuItem(ItemName, null, ContextAT_Click); if ((b2 <= FFXIATPhraseLoader.ffxiLanguages.NUM_LANG_MAX) && (b2 >= FFXIATPhraseLoader.ffxiLanguages.NUM_LANG_MIN)) newitem.Image = Icons.GeneralIcon[b2]; newitem.Name = atp[i].ToString(); // FFXIEncoding.atp_String(atp[i]); target_category[category_cnt].DropDownItems.Add(newitem); } } if (target_category != null) { // Sorting for (int _cnt = 0; _cnt < target_category.Length; _cnt++) { if (target_category[_cnt].DropDownItems.Count < 19) continue; ToolStripItem[] ts = new ToolStripItem[target_category[_cnt].DropDownItems.Count]; target_category[_cnt].DropDownItems.CopyTo(ts, 0); Array.Sort(ts, mcompare); target_category[_cnt].DropDownItems.Clear(); target_category[_cnt].DropDownItems.AddRange(ts); } return target_category; } return (null); }