public void DoesNotTakeTooLongWhenManyTasks() { int taskCount = 1000000; var tasks = new List <Time_planner_api.Models.Task>(); var rnd = new Random(); while (taskCount-- > 0) { // todo: to be changed when there would be proper latitude/longitude to set tasks.Add(new Time_planner_api.Models.Task() { Id = rnd.Next(), Title = rnd.Next().ToString(), Longitude = rnd.Next(), Latitude = rnd.Next() }); } int timeout = 5; var task = System.Threading.Tasks.Task.Run(() => SalesmanHelper.FindShortestRoute(tasks)); var completed = System.Threading.Tasks.Task.WaitAll(new[] { task }, TimeSpan.FromSeconds(timeout)); if (task.Exception != null) { if (task.Exception.InnerExceptions.Count == 1) { throw task.Exception.InnerExceptions[0]; } throw task.Exception; } if (!completed) { throw new TimeoutException(); } }
/// <summary> /// 经销商 /// </summary> /// <returns></returns> public ActionResult Distributor(string code) { url.urltype = "Distributor"; try { if (!string.IsNullOrEmpty(code)) { if (!string.IsNullOrEmpty(CodeJjudgeByOpenid(code))) { var user = wuser.GetUserInfo(this.openid); if (user.UserInfo == null) { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } else { if (partner.GetPartnerInfo(this.openid) == null) { ViewBag.user = user; ViewBag.parnter = partner.GetPartnerInfo(openid); ViewBag.Salesman = SalesmanHelper.GetAllSalesman(); //获取所有销售 ViewBag.AllDistrict = partner.GetAllDistrict(); //获取所有地区 } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Partner", "")); } } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Register", "")); } } else { Response.Redirect(WechatHelper.BackForCode("PhoneWeb", "Supplier", "")); } } catch (Exception) { throw; } ViewBag.openid = this.openid; return(View()); }