BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
/// <summary> /// Gets the reportees. /// </summary> /// <param name="bossID">The boss ID.</param> /// <returns></returns> public async Task<IEnumerable<EmployeeInfo>> GetReportees(int bossID) { List<EmployeeInfo> list = new List<EmployeeInfo>(); int loc = FindID(bossID); if (loc > -1) { await Task.Delay(1); while (loc < this.EmployeeDetails.Count && this.EmployeeDetails[loc].ReportsTo == bossID) list.Add(this.EmployeeDetails[loc++]); } return list; }
async void AssociatedObject_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args)
System.Threading.AutoResetEvent autoreset = new System.Threading.AutoResetEvent(false); async void AssociatedObject_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args) { if (args.ParentItem == null) { //get the root list - get all employees who have no boss args.ChildItems = viewModel.EmployeeDetails.Where(x => x.ReportsTo == -1); //get all employees whose boss's id is -1 (no boss) } else //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem. { //get the children of the parent object EmployeeInfo emp = args.ParentItem as EmployeeInfo; if (emp != null) { Task t = Task.Run(() => { GetChildItem(args); }); autoreset.WaitOne(); } } } private async void GetChildItem(TreeGridRequestTreeItemsEventArgs args) { EmployeeInfo emp = args.ParentItem as EmployeeInfo; args.ChildItems = await viewModel.GetReportees(emp.ID); autoreset.Set(); } |