public JsonResult getTreeViewSource() { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); DBTreeDataProfile treedata = treeProfile.GetTreeViewItems(); return(Json(treedata, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> getDepartDetail() { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); var departItems = treeProfile.GetDepartDetail(); var res = await Task.Factory.StartNew <JsonResult>(() => Json(departItems, JsonRequestBehavior.AllowGet)); return(res);// Json(departItems,JsonRequestBehavior.AllowGet); }
public async Task <JsonResult> getUserAccItems(int MasterID, int DepartID) { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); List <SelectListItem> data = new List <SelectListItem>(); if (MasterID > 0 && DepartID > 0) { data = await Task.Run(() => treeProfile.GetUserAccItems(MasterID, DepartID)); } //System.Threading.Thread.Sleep(3000); return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); }
public async Task <JsonResult> getUserAccDetail(int UserID) { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); SQLQueryBuilder queryBuilder = new SQLQueryBuilder(); if (UserID > 0) { queryBuilder.QueryParameters.Add(new SQLQueryParameter("UserID", UserID)); } var data = treeProfile.GetUserAccDetail(queryBuilder); return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); }
private async Task <List <SelectListItem> > getDepartItemsOnLoad() { DBTreeDataProfile treeProfile = new DBTreeDataProfile(); var departItems = treeProfile.GetDepartItems(); List <SelectListItem> list = (from a in departItems select new SelectListItem() { Text = a.Text, Value = a.Value.ToString() }).ToList(); return(list); }
protected async Task <JsonResult> getAsyncDepartProfileData(int departID, CancellationToken ct) { int DepartID = departID; DBTreeDataProfile treeProfile = new DBTreeDataProfile(); SQLQueryBuilder queryBuilder = new SQLQueryBuilder(); if (DepartID > 0) { queryBuilder.QueryParameters.Add(new SQLQueryParameter("DepartID", DepartID)); } var data = treeProfile.getDepartList(queryBuilder); if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); } return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); }
protected async Task <JsonResult> getAsyncUserProfileData(int userID, CancellationToken ct) { int UserID = userID; await Task.Delay(3500); DBTreeDataProfile treeProfile = new DBTreeDataProfile(); SQLQueryBuilder queryBuilder = new SQLQueryBuilder(); if (UserID > 0) { queryBuilder.QueryParameters.Add(new SQLQueryParameter("UserID", UserID)); } var data = treeProfile.getUserList(queryBuilder); if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); } return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); }
public async Task <ActionResult> tvonDemand(int?nodeID, int?Level, int?rootID, CancellationToken ct) { List <DBTreeDataProfile> root = new List <DBTreeDataProfile>(); DBTreeDataProfile treeProfile = new DBTreeDataProfile(); var taskID = TaskID; await Task.Delay(3000); //cts = new CancellationTokenSource(); var rootItem = await Task.Run(() => treeProfile.getAccDepView()); if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); throw new OperationCanceledException(cts.Token); } int pid = 0; int rootid = 0; if (nodeID == null && Level == null) { var items = rootItem.Select(x => new { nodeID = x.MasterID, text = x.OrgSN, Level = 0, hasChildren = true, ParentName = "Company" }).OrderBy(q => q.text).Distinct().Select(x => new { ID = Guid.NewGuid().ToString().Replace("-", ""), x.nodeID, x.text, x.Level, x.hasChildren, x.ParentName, TaskID = taskID } ).ToList(); var data = new { items = items }; if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); throw new OperationCanceledException(cts.Token); } return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); } else { if (nodeID.HasValue) { if (Level.Value.Equals(0)) { pid = nodeID.Value; var subItems = rootItem.Where(x => x.MasterID.Equals(pid)).Select(x => new { nodeID = x.DepartID, text = x.DepartName, Level = 1, hasChildren = true, ParentName = "Department", rootID = pid }).Distinct() .OrderBy(a => a.text).Select(x => new { ID = Guid.NewGuid().ToString().Replace("-", ""), x.nodeID, x.Level, x.text, x.hasChildren, x.rootID, x.ParentName, TaskID = taskID }).ToList(); var data = new { items = subItems }; if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); throw new OperationCanceledException(cts.Token); } return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); } if (Level.Value.Equals(1)) { pid = nodeID.Value; rootid = rootID.Value; var subItems = rootItem.Where(x => x.DepartID.Equals(pid) && x.MasterID.Equals(rootid)).Select(x => new { nodeID = x.UserID, text = x.FirstName + " " + x.LastName, Level = 2, hasChildren = false, ParentName = "User" }).Distinct() .OrderBy(a => a.text).Select(x => new { ID = Guid.NewGuid().ToString().Replace("-", ""), x.nodeID, x.Level, x.text, x.hasChildren, x.ParentName, TaskID = taskID }).ToList(); var data = new { items = subItems }; if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); throw new OperationCanceledException(cts.Token); } return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet))); } else { return(null); } } return(null); } }
public async Task <JsonResult> TreeViewNode(int?node, int?Level, int?rootID) { List <DBTreeDataProfile> root = new List <DBTreeDataProfile>(); DBTreeDataProfile treeProfile = new DBTreeDataProfile(); var rootItem = await Task.Run(() => treeProfile.getAccDepView()).ConfigureAwait(false); int pid = 0, rootid = 0; if (node == null && Level == null) { var items = rootItem.Select(x => new { nodeID = x.MasterID, text = x.OrgSN, Level = 0, hasChildren = true, ParentName = "Company" }).OrderBy(q => q.text).Distinct().Select(x => new { ID = Guid.NewGuid().ToString().Replace("-", ""), x.nodeID, x.text, x.Level, x.hasChildren, x.ParentName }).ToList(); var data = new { item = items }; return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet)).ConfigureAwait(false)); } else { if (node.HasValue) { if (Level.Value.Equals(0)) { pid = node.Value; var subItems = rootItem.Where(x => x.MasterID.Equals(pid)).Select(x => new { nodeID = x.DepartID, text = x.DepartName, Level = 1, hasChildren = true, ParentName = "Department", rootID = pid }).Distinct().OrderBy(x => x.text).Select(x => new { ID = Guid.NewGuid().ToString().Replace("-", ""), x.nodeID, x.Level, x.text, x.ParentName, x.hasChildren, x.rootID }).ToList(); var data = new { item = subItems }; return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet)).ConfigureAwait(false)); } if (Level.Value.Equals(1)) { pid = node.Value; rootid = rootID.Value; var subItems = rootItem.Where(x => x.DepartID.Equals(pid) && x.MasterID.Equals(rootid)).Select(x => new { nodeID = x.UserID, text = x.FirstName + " " + x.LastName, Level = 2, hasChildren = false, ParentName = "User" }).Distinct().OrderBy(q => q.text).Select(x => new { ID = Guid.NewGuid().ToString().Replace("-", ""), x.nodeID, x.Level, x.text, x.hasChildren, x.ParentName }).ToList(); var data = new { items = subItems }; return(await Task.Run(() => Json(data, JsonRequestBehavior.AllowGet)).ConfigureAwait(false)); } else { return(null); } } return(null); } }