protected virtual void OnTreeObjectEvent(TreeObjectEventArgs e) { if (TreeObjectEvent != null) { TreeObjectEvent(this, e); } }
public void Init() { mRootItem.Children.Clear(); if (SessionInfo == null) { return; } if (SessionInfo.UserInfo == null) { return; } mWorder = new BackgroundWorker(); mWorder.DoWork += (s, de) => InitControlOrgs(mRootItem, "-1"); mWorder.RunWorkerCompleted += (s, re) => { mRootItem.IsChecked = false; if (mRootItem.Children.Count > 0) { mRootItem.Children[0].IsExpanded = true; } TreeObjectEventArgs args = new TreeObjectEventArgs(); args.Code = 100; args.Data = mListObjects; OnTreeObjectEvent(args); }; mWorder.RunWorkerAsync(); }
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); } }