//无限接循环子节点添加到根节点下面 private void ForeachPropertyNode(RegulationsTreeInfo node, string pid, List <RegulationsTreeInfo> nodes) { foreach (RegulationsTreeInfo tempNode in nodes) { if (tempNode.Parent_guid == pid) { ForeachPropertyNode(tempNode, tempNode.Guid, nodes); node.Children.Add(tempNode); } } }
public OfficeManage() { InitializeComponent(); activity = CO_IA.Client.RiasPortal.ModuleContainer.Activity; //新建还是读取 if (activity == null || string.IsNullOrEmpty(activity.Guid) == true) { //创建默认的组织结构组 CreateAndSaveDefaultTreeInfos(); } else { List <RegulationsTreeInfo> nodes = new List <RegulationsTreeInfo>(); PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.RuleAndFileManage.I_CO_IA_RuleAndFile>(channel => { //更新当前节点 nodes = channel.GetTree(activity.Guid); }); if (nodes.Count() == 0) { CreateAndSaveDefaultTreeInfos(); } else { treePlace.ItemsSource = null; RegulationsTreeInfo tempTreeInfo = new RegulationsTreeInfo(); foreach (RegulationsTreeInfo node in nodes) { if (string.IsNullOrEmpty(node.Parent_guid)) { tempTreeInfo = node; break; } } ForeachPropertyNode(tempTreeInfo, tempTreeInfo.Guid, nodes); itemList.Add(tempTreeInfo); this.treePlace.ItemsSource = null; this.treePlace.ItemsSource = itemList; } } //InitData(); }
private void CreateAndSaveDefaultTreeInfos() { string rootGUID = CO_IA.Client.Utility.NewGuid(); RegulationsTreeInfo nodes = new RegulationsTreeInfo { Guid = rootGUID, Activity_guid = CurrentActivity.Guid, Name = "文件管理" }; bool isSuccesful = false; //保存相关数据信息 PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.RuleAndFileManage.I_CO_IA_RuleAndFile>(channel => { //更新当前节点 isSuccesful = channel.AddTree(nodes); }); if (isSuccesful == false) { MessageBox.Show("系统默认创建和保存活动组织结构失败。"); } itemList.Add(nodes); this.treePlace.ItemsSource = null; this.treePlace.ItemsSource = itemList; }