/// <summary> /// 更新菜单实例信息 /// </summary> /// <param name="instanceId">菜单实例地址 </param> /// <param name="instanceKey">该实例菜单关键字 </param> /// <param name="lst">所有菜单实例信息的集合,必须包含一个节点信息为 fatherId=0的根节点</param> public void UpdateMenuInstanceRelation(int instanceId, string instanceKey, IEnumerable <Wlst.Sr.Menu.Models.MenuInstancesRelation> lst) { if (DicInstanceRelation.ContainsKey(instanceId)) { DicInstanceRelation[instanceId].Clear(); } else { DicInstanceRelation.Add(instanceId, new Dictionary <Tuple <int, int>, Wlst.Sr.Menu.Models.MenuInstancesRelation>()); } foreach (var t in lst) { this.AddMenuInstanceRelation(t.FatherId, t.Id, t.SortIndex, t.Name, t.InstancesId); } var args = new PublishEventArgs() { EventType = PublishEventType.Core, EventId = EventIdAssign.MenuInstanceRelationUpdate }; args.AddParams(instanceId); args.AddParams(instanceKey); EventPublish.PublishEvent(args); WriteUpdateDbByPrivate(instanceId); }
/// <summary> /// 更新实例菜单 无则增加 /// </summary> /// <param name="sortIndex"> </param> /// <param name="name">实例菜单名称</param> /// <param name="fahterId">父节点为0标示为根节点 </param> /// <param name="id"> </param> /// <param name="instancesId">菜单实例标示值 </param> private void UpdateMenuInstanceRelation(int fahterId, int id, int sortIndex, string name, int instancesId) { if (!DicInstanceRelation.ContainsKey(instancesId)) { DicInstanceRelation.Add(instancesId, new Dictionary <Tuple <int, int>, Wlst.Sr.Menu.Models.MenuInstancesRelation>()); } var keyKey = new Tuple <int, int>(fahterId, id); if (!DicInstanceRelation[instancesId].ContainsKey(keyKey)) { DicInstanceRelation[instancesId].Add(keyKey, new Wlst.Sr.Menu.Models.MenuInstancesRelation() { FatherId = fahterId, Id = id, SortIndex = sortIndex, Name = name, InstancesId = instancesId } ); } else { DicInstanceRelation[instancesId][keyKey].FatherId = fahterId; DicInstanceRelation[instancesId][keyKey].Id = id; DicInstanceRelation[instancesId][keyKey].SortIndex = sortIndex; DicInstanceRelation[instancesId][keyKey].Name = name; DicInstanceRelation[instancesId][keyKey].InstancesId = instancesId; } }