//获取所有拥有权限的任务类型 public List<MODEL.T_TaskType> GetAccessRightTaskTypeList() { List<MODEL.T_TaskType> listTaskType = new List<MODEL.T_TaskType>(); MODEL.T_MemberInformation user = new OperateContext().Usr; string stuNum = user.StuNum; if (iBLLSession.IProjectInformationBLL.GetListBy(proj => proj.ProjLeader == stuNum).Count > 0) { //添加项目任务 listTaskType.Add(iBLLSession.ITaskTypeBLL.GetListBy(tp => tp.TaskTypeId == 10003)[0]); } List<MODEL.T_RoleAct> listRoleAct = iBLLSession.IRoleActBLL.GetListBy(ra => ra.RoleActor == stuNum); foreach(MODEL.T_RoleAct role in listRoleAct) { if (role.RoleId == 10001)//总裁 { listTaskType.Add(iBLLSession.ITaskTypeBLL.GetListBy(tp => tp.TaskTypeId == 10004)[0]);//学生讲座 } if (role.RoleId == 10002)//部长 { listTaskType.Add(iBLLSession.ITaskTypeBLL.GetListBy(tp => tp.TaskTypeId == 10002)[0]);//开发任务 } if (role.RoleId == 10003)//团长 { listTaskType.Add(iBLLSession.ITaskTypeBLL.GetListBy(tp => tp.TaskTypeId == 10001)[0]);//学习任务 } } return listTaskType; }
/// <summary> /// Returns the content of required uris. /// Method has to use the asynchronous way and can be used to compare the performace /// of sync \ async approaches. /// maxConcurrentStreams parameter should control the maximum of concurrent streams /// that are running at the same time (throttling). /// </summary> /// <param name="uris">Sequence of required uri</param> /// <param name="maxConcurrentStreams">Max count of concurrent request streams</param> /// <returns>The sequence of downloaded url content</returns> public static IEnumerable<string> GetUrlContentAsync(this IEnumerable<Uri> uris, int maxConcurrentStreams) { List<string> result = new List<string>(); int length = uris.Count(); Func<Uri, string>[] arrOfDownloads = new Func<Uri, string>[Math.Min(maxConcurrentStreams, length)]; for (int i = 0; i < arrOfDownloads.Length; i++) arrOfDownloads[i] = new WebClient().DownloadString; int k; IAsyncResult[] results = new IAsyncResult[arrOfDownloads.Length]; for (int i = 0; i < length; i++) { if (i < maxConcurrentStreams) results[i] = arrOfDownloads[i].BeginInvoke(uris.ElementAt(i), null, null); else { k = i%maxConcurrentStreams; if (results[k].IsCompleted) { result.Add(arrOfDownloads[k].EndInvoke(results[k])); results[k] = arrOfDownloads[k].BeginInvoke(uris.ElementAt(i), null, null); } else i--; } } return result; }