private static void _run(List <SysCatalog> SysCatalogList, string updateString) { TaskExecute <SysCatalog> tasks = new TaskExecute <SysCatalog>(o => { Console.WriteLine($"获取分类:{o.Url}"); new CasperJs(s => { DataReceived(s, o, new SysCatalogRepository(), updateString); }).Exec(ScriptPath, o.Url); }, 4); SysCatalogList.ForEach(l => { tasks.AddQueue(l); //Console.WriteLine($"获取分类:{l.Url}"); //new CasperJs(o => //{ // DataReceived(o, l, SysCatalogDal, updateString); //}).Exec(ScriptPath, l.Url); }); tasks.Run(); }
public void LoginGameTest() { try { Login target = new Login(); // TODO: 初始化为适当的值 target.Uname = "用户名"; target.Passwd = "密码"; // ExcuteState expected = null; // TODO: 初始化为适当的值 ExcuteState actual; actual = target.LoginGame(); if (actual.State == IdentityCode.Fail) { return; } bool bSuccess = target.getUserkeyFromCookie(); bSuccess = target.getPkeyFromCookie(); RoleSel role = new RoleSel(target.Client); role.TasktxtPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "自动任务列表.txt"; role.StrServerName = target.StrServerName; actual = role.getPlayerList(); if (actual.State == IdentityCode.Fail) { return; } if (role.Rolelist.Count > 0) { webRole roler = role.Rolelist[0]; actual = role.getPlayerInfo(roler); if (actual.State == IdentityCode.Fail) { return; } } bool bret = role.getServerIP(); if (!bret) { return; } Dictionary <string, string> lst = new Dictionary <string, string>(); // TODO: 初始化为适当的值 lst.Add("userkey", target.Userkey); Command cmd = new Command("login_user", lst); byte[] sendarr = cmd.outputarr; RoleInfoStoreClient client = new RoleInfoStoreClient(role.ServerAddr, role.ServerPort); client.Send(sendarr); client.SendDone.WaitOne(); client.Receive(); client.ReceiveDone.WaitOne(); // int i = 0; while (i++ < 5) { Thread.Sleep(1000); } // 开启线程 发送心跳报文 CommandList cmdlst = new CommandList(role.Roledetail.pkey2, client); Thread heatThread = new Thread(cmdlst.HeatBeatThread); heatThread.IsBackground = true; heatThread.Start(); // CommandList.SendGetBuildingInfo(client, 1); // 获取主城信息 CommandList.GetMainCityInfo(client); // Thread.Sleep(100); Command cmd4 = new Command(CommandList.GENERAL_GET_GENERALSIMPLEINFO2, lst); client.Send(cmd4.outputarr); client.SendDone.WaitOne(); i = 0; while (i++ < 5) { Thread.Sleep(1000); } // 获取主城信息 client.SetJson2AreaLst(); i = 0; // 获取当前任务,执行 PacketSend.Task curTask = role.CurTask; TaskExecute tasker = new TaskExecute(client); while (i++ < 60) { Thread.Sleep(1000); bret = tasker.ExecuteTask(ref role); if (!bret) { Thread.Sleep(1000 * 5); break; } } client.PrintInfo(); } catch (Exception ex) { Console.WriteLine(ex.Message + ";" + ex.StackTrace); } }