//public Task<bool> Play(bool isRecording = false) //{ // throw new NotImplementedException(); // //int RevisionNumber = (int)(DateTime.UtcNow.Date - DateTime.UtcNow.AddHours(-12)).TotalSeconds; //} public async Task <bool> Play(bool isRecording = false) { // this.InvokeOnUiThreadIfRequired(() => ShowHelper()); CloseCodeCeptJsWindow(); // ConfigManager config = new ConfigManager(); var defaultXML = FileEndPointManager.DefaultPlayXMLFile; // config.GetValue("DefaultXMLFile"); if (isRecording) { var endPointFolder = FileEndPointManager.Project2Folder; //TODO check for error in UI //ActivateGroupBox(groupBoxRec); defaultXML = Path.Combine(endPointFolder, "latest.xml"); } OpenedFile = "New Unsaved Recording"; UpdateStatus(false); //groupBoxRec.Visible = true; //_HACK BtnPlay_Click #region ---TEST ONLY: Compiler will automatically erase this in RELEASE mode and it will not run if Global.GlobalTestMode is not set to TestMode.Simulation #if OVERRIDE || OFFLINE Console.WriteLine("HACK-TEST -"); //defaultXML = @"D:\_MY_PROJECTS\_DEVNOTE\_DevNote3\DevNote.Main\bin\Debug\KatalonRaw\ExternalRecordings\commonTestOrig.xml"; //defaultXML = @"D:\_MY_PROJECTS\_DEVNOTE\_DevNote3\DevNote.Main\bin\Debug\KatalonRaw\ExternalRecordings\Tour.xml"; // defaultXML = @"D:\_MY_PROJECTS\_DEVNOTE\_DevNote3\DevNote.Main\bin\Debug\KatalonRaw\ExternalRecordings\Inquiry.xml"; // defaultXML = @"D:\_MY_PROJECTS\_DEVNOTE\_DevNote3\DevNote.Main\bin\Debug\KatalonRaw\ExternalRecordings\Inquiry.xml"; // defaultXML = @"D:\_MY_PROJECTS\_DEVNOTE\WFH_Xamun_RawKatalon.xml"; //defaultXML = @"D:\_KATALON\ERROR\latest.xml"; #endif #endregion //////////////END TEST //step# 5 load defaultXML Open_File(defaultXML); //dgActions.DataSource = actionSource; //dgActions.Refresh(); // Make sure this comes first //dgActions.Parent.Refresh(); // Make sure this comes second //flowMain.Refresh(); RunCondeceptjsDefault(); //Application.DoEvents(); //int limit = MyRetry ; TaskWaiter.Conditions cond = new TaskWaiter.Conditions("Wait_CondceptJS_Console"); await cond.WaitUntil(() => CmdExeForCodecept != null) .ContinueWith(x => { //Task.Delay(1); // WindowsHelper.FollowConsole(CmdExeForCodecept); //this.Activate(); }); return(true); }
public async Task Run(string filepath) { //STEP.Player #850 reset results.txt GlobalPlayer.ResetResult(); var selectedJSXML = openFileDialog2.FileName = filepath; CloseCodeCeptJsWindow(); //todo: make this LIstbox not gridview error on ui when using grid // ActivateGroupBox(groupBoxRec); // groupBoxRec.Visible = true; //STEP_.Player #802 load defaultXML Open_File(selectedJSXML); string ext = Path.GetExtension(selectedJSXML); if (ext.ToLower() == ".js") { //update latest_test.js //STEP_.Player #803 get extension variables var runCmd = FileEndPointManager.ReadInputWFCmdJsonFile(); var externalParam = runCmd.EventParameters; var internalResult = BotHttpClient.DevNoteGetParameters(runCmd.EventName).Content;//.ReadAsStringAsync(); var internalParam = JsonConvert.DeserializeObject <Dictionary <string, string> >(internalResult); var script = File.ReadAllText(openFileDialog1.FileName); if (internalParam != null && externalParam != null) { //STEP_.Player #804 CrossBreed the parameters Dictionary <string, string> crossBreed = new Dictionary <string, string>(); foreach (var external in externalParam) { //internalParam-(arg.MappedTo_Input_X, arg.PropertyName.lower()); //ExternalParam---------------------------(PropertyName.tolower(), value); this is the external dictionary crossed //results to ---(arg.MappedTo_Input_X,value) if (internalParam.ContainsValue(external.Key.ToLower())) { var internalP = internalParam.First(p => p.Value == external.Key.ToLower()); crossBreed.Add(internalP.Key, external.Value); } } //STEP_.Player #803 insert variables Interpreter it = new Interpreter(); //STEP.Player #804 Insert Variables var selectedContent = it.InsertVariables(openFileDialog1.FileName, crossBreed).ToString(); script = selectedContent; BotHttpClient.UpdateMainUI("InsertVariables " + Environment.NewLine + crossBreed.ToArray().ToString()); } // var selectedContent = File.ReadAllText(selectedJSXML); var dir = LogApplication.Agent.GetCurrentDir(); dir = dir.Replace("file:\\", string.Empty); string drive = Path.GetPathRoot(dir); string driveLetter = drive.First().ToString(); var codeceptjsFolder = string.Format("{0}\\CodeceptJs\\Project2", dir); //@"D:\_ROBOtFRAMeWORK\CodeceptsJs\Project1\"; var codeceptTestPath = Path.Combine(codeceptjsFolder, "latest_test.js"); if (File.Exists(codeceptTestPath)) { File.Delete(codeceptTestPath); } File.WriteAllText(codeceptTestPath, script); //play // dgActions.DataSource = actionSource; // dgActions.Refresh(); // Make sure this comes first // dgActions.Parent.Refresh(); // Make sure this comes second // flowMain.Refresh(); } //STEP.Player #803 run _test.js using bat file RunCondeceptjsDefault(); var started = DateTime.Now; //Application.DoEvents(); TaskWaiter.Conditions cond = new TaskWaiter.Conditions("Wait_CondceptJS_Console"); await cond.WaitUntil(() => (DateTime.Now - started).TotalSeconds > 5) .ContinueWith(x => { WindowsHelper.FollowConsole(CmdExeForCodecept); }); //STEP.Player #855 //check result //wait for output //todo HERE... //var cond1 = new TaskWaiter.Conditions("wait_for_result.txt"); //await cond1.WaitUntil(() => AutoPlayPolicy.AssertPlayerResultExist(started) == true, 1000).ContinueWith(x => //{ // //setStatus(string.Format("Retried {0} times", MyRetry), EnumPlayStatus.Success); // //Task.Delay(1000); // //IsAutoPlaying = false; // //Stop(); // //var result = await AutoPlay(); // BotHttpClient.Log("Done.. Play codecept."); // //step# 12 done EnumTaskStatus.DoneCodeCept // //IsAutoplayDone = EnumTaskStatus.DoneCodeCept; // //MyPayload.IsSuccess = true; // //MyPayload.IsRespond = true; // //step# 12.4 finished status // //IsAutoplayDone = EnumTaskStatus.Finished; // //not here.. yet it will retry // // GlobalPlayer.CreateWFOutput("none"); //}); //check result //STEP_.Player screenshot ERROR //if (GlobalPlayer.IsFailedResult) //{ // return false;// continue to retry //} //else // return true; //no need to retry }