public ExamplesMenu() { Selector = "examples"; PromptCharacter = "examples>"; Add(new MI_Add()); Add(new MI_Echo()); Add(new MI_If()); Add(new MI_Pause()); var frs = new FileRecordStore(); Add(new MI_Record(frs)); Add(new MI_Replay(this, frs)); var procmgr = new ProcManager(); Add(new MI_Proc(procmgr)); Add(new MI_Call(this, procmgr)); Add(new MI_Return(this, procmgr)); Add(new MI_Goto(procmgr)); OnRun += m => { Console.Write("Example menu - "); m.CQ.ImmediateInput("help"); }; }
public bool Open(XRegistry ZDef) { IsLoading = true; try { XParameter Param = ZDef.Parameter("Procedures"); PM = new ProcManager(Param); NotifyChanged("ProcList"); SetBanner(); return(true); } catch (InvalidFIleException) { ProcManager.PanelMessage(ID, Res.RSTR("InvalidXML"), LogType.ERROR); } catch (Exception ex) { Logger.Log(ID, ex.Message, LogType.ERROR); } finally { IsLoading = false; } return(false); }
private void MessageBus_OnDelivery(Message Mesg) { ProcConvoy Convoy = Mesg.Payload as ProcConvoy; if (Mesg.Content == "RUN_RESULT" && Convoy != null && Convoy.Dispatcher == EditTarget) { TempInst = Convoy.Payload as BookInstruction; ProcConvoy ProcCon = ProcManager.TracePackage(Convoy, (P, C) => P is ProcParameter); if (ProcCon != null) { ProcParameter PPClone = new ProcParameter(); PPClone.ReadParam(ProcCon.Dispatcher.ToXParam()); ProcCon = new ProcConvoy(PPClone, null); } TempInst.PackVolumes(ProcCon); Preview.Navigate( typeof(TableOfContents) , new Tuple <Volume[], SelectionChangedEventHandler>(TempInst.GetVolInsts().Remap(x => x.ToVolume(TempInst.Entry)), PreviewContent) ); Preview.BackStack.Clear(); TestRunning.IsActive = false; } }
public async Task Given_Api_Is_Down_Expected_Response_Occurs() { // Arrange - kill the API ProcManager.KillByPort(_fixture.WebApiWrapper.HttpsPort); // get discovery document var disco = await _fixture.IdentityServerHttpClient.GetDiscoveryDocumentAsync(_fixture.IdentityServerWrapper.UriString); var tokenEndpoint = disco.TokenEndpoint; // request token var tokenResponse = await _fixture.IdentityServerHttpClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { Address = tokenEndpoint, ClientId = "client", ClientSecret = "secret", Scope = "api1" }); // set bearer token on API client _fixture.WebApiHttpClient.SetBearerToken(tokenResponse.AccessToken); // Act await Assert.ThrowsAsync <HttpRequestException>(() => _fixture.WebApiHttpClient.GetAsync($"{_fixture.WebApiWrapper.UriString}/identity")); // reset _fixture.RestartWebApi(); }
private int SearchIndexDofusWindowByPort(ushort port) { int dw = -1; dw = dofusWindow.FindIndex(x => x._Port == port); if (dw == -1) { List <PRC> lprc = ProcManager.GetAllProcesses(); PRC prc = lprc.Find(x => x.Port == port); dw = dofusWindow.FindIndex(x => x._Process.Id == prc.PID); if (dw == -1) { dw = dofusWindow.Count; var b = (Button)Controls["character" + dw]; b.BackColor = System.Drawing.Color.SandyBrown; dofusWindow.Add(new DofusWindow { _Process = Process.GetProcessById(prc.PID), _Port = port, _IdCharacter = -1, _Button = b }); } else { dofusWindow[dw]._Port = port; } lprc.Clear(); lprc = null; } return(dw); }
private async void PreviewContent(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0 || TestRunning.IsActive) { return; } TestRunning.IsActive = true; TOCItem Item = ( TOCItem )e.AddedItems[0]; Chapter Ch = Item.Ch; if (Ch == null) { ProcManager.PanelMessage(ID, "Chapter is not available", LogType.INFO); return; } string VId = Ch.Volume.Meta[AppKeys.GLOBAL_VID]; string CId = Ch.Meta[AppKeys.GLOBAL_CID]; EpInstruction EpInst = TempInst.GetVolInsts().First(x => x.VId == VId).EpInsts.Cast <EpInstruction>().First(x => x.CId == CId); IEnumerable <ProcConvoy> Convoys = await EpInst.Process(); StorageFile TempFile = await AppStorage.MkTemp(); StringResources stx = StringResources.Load("LoadingMessage"); foreach (ProcConvoy Konvoi in Convoys) { ProcConvoy Convoy = ProcManager.TracePackage( Konvoi , (d, c) => c.Payload is IEnumerable <IStorageFile> || c.Payload is IStorageFile ); if (Convoy == null) { continue; } if (Convoy.Payload is IStorageFile) { await TempFile.WriteFile(( IStorageFile )Convoy.Payload, true, new byte[] { ( byte )'\n' }); } else if (Convoy.Payload is IEnumerable <IStorageFile> ) { foreach (IStorageFile ISF in ((IEnumerable <IStorageFile>)Convoy.Payload)) { ProcManager.PanelMessage(ID, string.Format(stx.Str("MergingContents"), ISF.Name), LogType.INFO); await TempFile.WriteFile(ISF, true, new byte[] { ( byte )'\n' }); } } } ShowSource(TempFile); TestRunning.IsActive = false; }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { Console.WriteLine("Port number you want to clear"); var input = Console.ReadLine(); //var port = int.Parse(input); var prc = new ProcManager(); prc.KillByPort(7972); }
private ProcessWrapper PublishAndRun(WebAppWrapper parms) { // publish the web app to better control processes ProcManager.PublishWebApp(parms.ProjectPath, parms.OutputPath); // start process to ensure its port is actually listening var processWrapper = ProcManager.RunWebApp(parms.ProjectPath, parms.OutputPath, parms.UriString); return(processWrapper); }
public void Setup(WebAppWrapper webAppWrapper) { // ensure nothing is running on the port ProcManager.KillByPort(webAppWrapper.HttpsPort); // ensure the output directory to which we'll publish is empty DirManager.DeleteAndRecreate(webAppWrapper.OutputPath); // publish and run the specified webApp webAppWrapper.ProcWrapper = PublishAndRun(webAppWrapper); }
public void Teardown(WebAppWrapper webAppWrapper) { // (we don't delete the output here in case the tester wants to look at the logs) // dump the log var logFilename = $"{webAppWrapper.OutputPath}\\{GetNewLogfileName()}"; File.WriteAllText(logFilename, webAppWrapper.ProcWrapper.LoggingOutput.ToString()); // ensure nothing is running on the port ProcManager.KillByPort(webAppWrapper.HttpsPort); }
public MainMenu(Settings s) { this.s = s; portManager = new ProcManager(); InitializeComponent(); LoadSettings(); button1.Enabled = false; console = new ControlWriter(ConsoleOutput, this); Console.SetOut(console); if (!File.Exists(s.data["Flash Player"])) { playgamebtn.Text = "Download Projector and Start Client"; } }
public async Task Given_IdentityServer_Is_Down_Expected_Response_Occurs() { // Arrange - kill IdentityServer ProcManager.KillByPort(_fixture.IdentityServerWrapper.HttpsPort); // Act var disco = await _fixture.IdentityServerHttpClient.GetDiscoveryDocumentAsync(_fixture.IdentityServerWrapper.UriString); // Assert disco.IsError.Should().BeTrue(); disco.Error.StartsWith("Error connecting").Should().BeTrue(); // restart IdentityServer _fixture.RestartIdentityServer(); }
private async void TestDef(object sender, RoutedEventArgs e) { if (TestRunning.IsActive) { return; } string Url = UrlInput.Text.Trim(); TestRunning.IsActive = true; if (string.IsNullOrEmpty(Url)) { MessageBus.SendUI(typeof(ProceduresPanel), "RUN", EditTarget); return; } try { if (PreviewFile == null) { PreviewFile = await MCrawler.DownloadSource(Url); } // The resulting convoy may not be the book instruction originally created ProcConvoy Convoy = await new ProceduralSpider(new Procedure[] { EditTarget }) .Crawl(new ProcConvoy(new ProcDummy(), PreviewFile)); // So we trackback the Book Convoy Convoy = ProcManager.TracePackage(Convoy, (D, C) => C.Payload is BookInstruction); if (Convoy == null) { throw new Exception("Unable to find the generated book convoy"); } await ViewTestResult(( BookInstruction )Convoy.Payload); } catch (Exception ex) { ProcManager.PanelMessage(ID, ex.Message, LogType.INFO); } TestRunning.IsActive = false; }
private async void ImportBookSpider(object sender, RoutedEventArgs e) { IStorageFile ISF = await AppStorage.OpenFileAsync(".xml"); if (ISF == null) { return; } try { EditTarget.ImportSpider(new XRegistry(await ISF.ReadString(), null, false).Parameter("Procedures")); } catch (Exception ex) { ProcManager.PanelMessage(EditTarget, Res.SSTR("InvalidXML", ex.Message), LogType.ERROR); } }
/// <summary> /// 适用场境,在测试库时,更新完数据后,验证数据是否有异常 /// /// 常用方法: ///var update = new SqlUpdateCollection(new ///{ /// id = id, /// agentno = agentno ///}) ///.PrimaryKeyFields("id"); ///PFSqlUpdateValidateHelper.TestUpdate("t_hyzl_orders", update, sqlExec); /// /// </summary> /// <param name="tableName"></param> /// <param name="update"></param> /// <param name="sql"></param> public static void TestUpdate(string tableName, SqlUpdateCollection update, ProcManager sql) { string updateSqlString = string.Format(@" select * from {0} {1} ", tableName, update.ToWhereSql()); string totalSqlString = string.Format(@" select count(*) from {0} ", tableName); //用set条件的字段做where来查总数,如果行数等于全表行数,那说明把整个表的值都更新了(where没有生效) var updateSet = new SqlWhereCollection(); foreach (var i in update) { updateSet.Add(i.Key, i.Value.Value); } string updateSetTotalSqlString = string.Format(@" select count(*) from {0} {1} ", tableName, updateSet.ToSql()); var updated = sql.GetQueryTable(updateSqlString); var total = PFDataHelper.ObjectToInt(sql.QuerySingleValue(totalSqlString)); var setTotal = PFDataHelper.ObjectToInt(sql.QuerySingleValue(updateSetTotalSqlString)); if (updated == null) { throw new Exception("更新后的数据全部丢失.异常"); } if (total < 2) { throw new Exception("测试数据少于2条,这样不保险"); } if (total == updated.Rows.Count) { throw new Exception("更新了整个表的数据,请确认是否缺少where条件.异常"); } if (total == setTotal) { throw new Exception("更新了整个表的数据,请确认是否缺少where条件.异常"); } AssertIsTrue(updated != null && updated.Rows.Count == 1); AssertIsTrue(total > 1); AssertIsTrue(IsDataRowMatchUpdate(updated.Rows[0], update)); AssertIsTrue(setTotal >= updated.Rows.Count && setTotal < total); }
private async void LoadChapterInst(Chapter C) { BookInstruction BkInst = ( BookInstruction )CurrentBook ?? new BookInstruction(C.Book); XRegistry Settings = SpiderBook.GetSettings(BkInst.ZoneId, BkInst.ZItemId); EpInstruction Inst = new EpInstruction(C, Settings); IEnumerable <ProcConvoy> Convoys = await Inst.Process(); string ChapterText = ""; foreach (ProcConvoy Konvoi in Convoys) { ProcConvoy Convoy = ProcManager.TracePackage( Konvoi , (d, c) => c.Payload is IEnumerable <IStorageFile> || c.Payload is IStorageFile ); if (Convoy == null) { continue; } if (Convoy.Payload is IStorageFile) { ChapterText += await(( IStorageFile )Convoy.Payload).ReadString(); } else if (Convoy.Payload is IEnumerable <IStorageFile> ) { foreach (IStorageFile ISF in ((IEnumerable <IStorageFile>)Convoy.Payload)) { Shared.LoadMessage("MergingContents", ISF.Name); ChapterText += (await ISF.ReadString()) + "\n"; } } } await new ContentParser().ParseAsync(ChapterText, C); OnComplete(C); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseKestrel(options => { var prc = new ProcManager(); prc.KillByPort(5000); prc.KillByPort(5001); prc.KillByPort(8080); options.Listen(IPAddress.Loopback, 5000); options.Listen(IPAddress.Loopback, 5001); //options.Listen(IPAddress.Loopback, 5001, listenOptions => //{ // listenOptions.UseHttps("localhost.pfx", "Tuk6puPb5pZ87JCX"); //}); }); webBuilder.UseStartup <Startup>(); //.UseUrls("https://localhost:5001"); });
private void MessageBus_OnDelivery(Message Mesg) { ProcConvoy Convoy = Mesg.Payload as ProcConvoy; if (Mesg.Content == "RUN_RESULT" && Convoy != null && Convoy.Dispatcher == EditTarget) { TestRunning.IsActive = false; Convoy = ProcManager.TracePackage(Convoy, (P, C) => Convoy.Payload is IEnumerable <BookInstruction>); if (Convoy == null) { throw new Exception("Unable to find the generated book convoy"); } else { var j = ViewTestResult((IEnumerable <BookInstruction>)Convoy.Payload); } } }
public void RestartWebApi() { // restart IdentityServer - creates a new process after it's been killed by child tests WebApiWrapper.ProcWrapper = ProcManager.RunWebApp(WebApiWrapper.ProjectPath, WebApiWrapper.OutputPath, WebApiWrapper.UriString); }
public async Task <IList <T> > NextPage(uint ExpectedCount = 30) { TaskCompletionSource <T[]> Ts = new TaskCompletionSource <T[]>(); try { ProcPassThru RunMode; if (FirstLoad) { FirstLoad = false; RunMode = new ProcPassThru(); } else { RunMode = new ProcPassThru(ProcType.FEED_RUN); } ProcConvoy Convoy = await Spider.Crawl(new ProcConvoy( RunMode, FeedParams )); string FeedParam = ""; if (Convoy.Payload is IEnumerable <IStorageFile> ) { FeedParam = await((IEnumerable <IStorageFile>)Convoy.Payload).FirstOrDefault()?.ReadString(); } else if (Convoy.Payload is IEnumerable <string> ) { FeedParam = ((IEnumerable <string>)Convoy.Payload).FirstOrDefault(); } else if (Convoy.Payload is IStorageFile) { FeedParam = await(( IStorageFile )Convoy.Payload).ReadString(); } else if (Convoy.Payload is string) { FeedParam = ( string )Convoy.Payload; } FeedParams = FeedParam.Split('\n'); Convoy = ProcManager.TracePackage(Convoy, (P, C) => C.Payload is IEnumerable <T>); if (Convoy != null) { IEnumerable <T> Items = (IEnumerable <T>)Convoy.Payload; Ts.SetResult(Items.ToArray()); } else { Ts.TrySetResult(new T[0]); } } catch (Exception ex) { Ts.TrySetResult(new T[0]); Logger.Log(ID, ex.Message, LogType.WARNING); } T[] Cs = await Ts.Task; PageEnded = (Cs.Length == 0); return(Cs); }
private void EventRunExplorer(object sender, EventArgs e) { var tag = ((Button)sender).Tag; ProcManager.RunExplorer(((TextBox)this.Controls["txt" + tag]).Text); }