private void InitControlAgents(TreeObjectItem parentItem, string parentID) { try { WebRequest webRequest = new WebRequest(); webRequest.Session = SessionInfo; webRequest.Code = (int)RequestCode.WSGetUserObjList; webRequest.ListData.Add(SessionInfo.UserID.ToString()); webRequest.ListData.Add("0"); webRequest.ListData.Add(ConstValue.RESOURCE_AGENT.ToString()); webRequest.ListData.Add(parentID); Service11012Client client = new Service11012Client( WebHelper.CreateBasicHttpBinding(SessionInfo), WebHelper.CreateEndpointAddress( SessionInfo.AppServerInfo, "Service11012")); WebReturn webReturn = client.DoOperation(webRequest); client.Close(); if (!webReturn.Result) { return; } if (webReturn.ListData == null) { return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string strInfo = webReturn.ListData[i]; string[] arrInfo = strInfo.Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.RemoveEmptyEntries); if (arrInfo.Length < 3) { continue; } string strID = arrInfo[0]; string strName = arrInfo[1]; string strFullName = arrInfo[2]; TreeObjectItem item = new TreeObjectItem(); item.ObjType = ConstValue.RESOURCE_AGENT; item.ObjID = Convert.ToInt64(strID); item.Name = strName; item.Description = strFullName; item.Data = strInfo; item.Icon = "Images/agent.ico"; Dispatcher.Invoke(new Action(() => parentItem.AddChild(item))); mListObjects.Add(item); } } catch (Exception ex) { TreeObjectEventArgs args = new TreeObjectEventArgs(); args.Code = 999; args.Message = ex.Message; OnTreeObjectEvent(args); } }
private void GetObjects(TreeObjectItem parentItem, ref List <TreeObjectItem> listObjects) { for (int i = 0; i < parentItem.Children.Count; i++) { TreeObjectItem item = parentItem.Children[i] as TreeObjectItem; if (item != null) { listObjects.Add(item); GetObjects(item, ref listObjects); } } }
private void GetCheckedObjects(TreeObjectItem parentItem, ref List <TreeObjectItem> listObjects) { for (int i = 0; i < parentItem.Children.Count; i++) { TreeObjectItem item = parentItem.Children[i] as TreeObjectItem; if (item != null) { if (item.IsChecked == true) { listObjects.Add(item); } if (item.IsChecked == false) { continue; } GetCheckedObjects(item, ref listObjects); } } }
public TreeObjectViewer() { mRootItem = new TreeObjectItem(); mListObjects = new List <TreeObjectItem>(); Loaded += TreeObjectViewer_Loaded; }