private static void FillMenuItem(DTObject item, XmlNode node, string language) { string url = GetNodeValue(node, "url"), target = GetNodeValue(node, "target"); var codeDTO = DTObject.Create(); if (!string.IsNullOrEmpty(url)) { codeDTO.SetValue("url", url); if (!string.IsNullOrEmpty(target)) { codeDTO.SetValue("target", target); } } string name = GetNodeValue(node, "name"); name = ParseName(name, language); string icon = GetNodeValue(node, "icon"); string iconFontSize = GetNodeValue(node, "iconFontSize"); string tags = GetNodeValue(node, "tags"); string roles = GetNodeValue(node, "roles"); if (!string.IsNullOrEmpty(icon)) { item.SetValue("icon", icon); } if (!string.IsNullOrEmpty(iconFontSize)) { item.SetValue("iconFontSize", iconFontSize); } if (!string.IsNullOrEmpty(tags)) { var temp = tags.Split(','); item.Push("tags", temp, (t, tag) => { t.SetValue(tag); }); } if (!string.IsNullOrEmpty(roles)) { var temp = roles.Split(','); item.Push("roles", temp, (t, role) => { t.SetValue(role); }); } item.SetValue("name", name); item.SetObject("code", codeDTO); foreach (XmlNode childNode in node.ChildNodes) { if (childNode.NodeType != XmlNodeType.Element) { continue; } var child = item.CreateAndPush("childs"); FillMenuItem(child, childNode, language); } }
public override void Write(DTObject data) { foreach (UploadFile file in _filesContainer.Children) { var info = file.GetInfo(); if (info?.Storage != null) { data.Push(this.MemberName, info.Storage); } } }
/// <summary> /// 根据登录人拥有的角色过滤菜单项 /// </summary> /// <param name="rawMenu"></param> /// <param name="principalRoles"></param> /// <returns></returns> private static DTObject FilterMenu(DTObject rawMenu, Principal.Role[] principalRoles) { var menuRoles = rawMenu.GetList("roles", false); if (menuRoles != null) { var roleCodes = menuRoles.ToArray <string>(); var result = principalRoles.FirstOrDefault((role) => { return(roleCodes.Contains(role.MarkedCode, StringComparer.OrdinalIgnoreCase)); }); if (result == null) { return(null); //当前登录人没有菜单需要的角色,不能显示 } } DTObject menu = DTObject.CreateReusable(); foreach (var member in _outputMembers) { if (rawMenu.Exist(member)) { menu[member] = rawMenu[member]; } } rawMenu.Each("childs", (child) => { var target = FilterMenu(child, principalRoles); if (target != null) { menu.Push("childs", target); } }); return(menu); }
//internal bool ContainsItem(TextItem data) //{ // if (_list == null || data == null) return false; // var datas = _list.ItemsSource as IEnumerable<TextItem>; // if (datas == null) return false; // return datas.FirstOrDefault((t) => // { // return t.Value.Equals(data.Value); // }) != null; //} #endregion public override void Write(DTObject data) { var result = this.Get(); if (this.IsRadio) { var item = result.FirstOrDefault(); if (item != null) { DTObject d = DTObject.Create(); d["text"] = item.Text; d["value"] = item.Value; data.SetObject(this.MemberName, d); } } else { data.Push(this.MemberName, result, (d, item) => { d["text"] = item.Text; d["value"] = item.Value; }); } }