public static bool AssertWFOutputCreatedByPlayer() { try { //STEP.Player #868 write local endpoint of Player var endPointPlayerFolder = FileEndPointManager.Project2EndPointFolder; var fileResult = Path.Combine(endPointPlayerFolder, EnumFiles.MyResult); //if there is result from player if (File.Exists(fileResult)) { return(true); } else { return(false); } } catch (Exception err) { BotHttpClient.Log(err.Message, true); return(false); } }
public async static Task <bool> AssertPlayerTimedOut(DateTime startRun) { // Timeout ConfigManager config = new ConfigManager(); var timeOut = Convert.ToInt32(config.GetValue("MaxTimeOutMinutes")); //create result file //STEP.Player #803 timeout var span = DateTime.Now - startRun; //TIP if ((int)span.TotalMinutes % 30 == 0) if ((int)span.Seconds % 30 == 0) { var msg = $"Task is Running :{span.TotalMinutes.ToString()} minutes already."; Console.WriteLine(msg); await BotHttpClient.Log(msg); } if (span.TotalMinutes >= timeOut) { return(true); } else { return(false); } }
public static void Retry() { ConfigManager config = new ConfigManager(); var screenshotOnFail = config.GetValue("ScreenshotOnFail"); if (File.Exists(screenshotOnFail)) { if (RetryCount < 3) { RetryCount += 1; File.Delete(screenshotOnFail); BotHttpClient.Log("RETRY FAILED RUN... Retry count is " + RetryCount.ToString(), true); GlobalDef.CurrentDesigner.HandleCmd(MyCmd); return; } } //show result to azure event... BotHttpClient.Log("Done WF Run... Retry count is " + RetryCount.ToString(), false); RetryCount = 0; MyCmd = null; //xTODO.. create azure event here... }
//STEP.Azure #41 Handle(DevNoteIntegrationEvent @event) public async Task Handle(DevNoteIntegrationEvent @event) { //convert to command param RunWFCmdParam cmd = new RunWFCmdParam { // XamlFullPath="QRLogin", //username = @event.//"*****@*****.**", //default //password =// "Pass@word1", EventName = @event.EventName, EventParameters = @event.EventParameters, GuidId = @event.GuidId }; //_HACK safe to delete #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 DEBUG System.Diagnostics.Debug.WriteLine("HACK-TEST -DevNoteIntegrationEvent"); if (GlobalDef.DEBUG_MODE == EnumDEBUG_MODE.TEST) { var stringContent = JsonConvert.SerializeObject(@event); Console.WriteLine("Azure recievedt: " + stringContent); return; } #endif #endregion //////////////END TEST if (!string.IsNullOrEmpty(@event.OuputResponse)) { //do not trigger wf await BotHttpClient.Log("Confirmed to AZURE: " + @event.OuputResponse); } else { //STEP_.EVENT CreateEventInput FileEnpoint here await FileEndPointManager.CreateEventInput(cmd); } return; //xTODO call this in UIMain by filewatcher #region //package to cmd RunWFCmdParam cmdCarrier = new RunWFCmdParam(); if (cmd.EventParameters == null) { cmd.EventParameters = new Dictionary <string, string>(); } //TIP: _ = await BotHttpClient.PostToDevNote(cmdCarrier); cmdCarrier.Payload = cmd; _ = await BotHttpClient.PostToDevNote(cmdCarrier); #endregion }
//must be 1 reference only public static async Task <DevNoteIntegrationEvent> CreateErrorOutputWF(string errorMessage) { //STEP_.RESULT #99 CreateOutputWF var stringContent = File.ReadAllText(FileEndPointManager.InputWFFilePath); var cmd = ReadInputWFCmdJsonFile(); var payload = cmd; //(RunWFCmdParam)cmd.Payload; var result = $"ERROR:{errorMessage}"; //FileEndPointManager.ReadMyGrabValueFile(); //TIP# Configure AutoMapper var config = new MapperConfiguration(cfg => cfg.CreateMap <RunWFCmdParam, DevNoteIntegrationEvent>()); var mapper = config.CreateMapper(); // Perform mapping var @event = mapper.Map <RunWFCmdParam, DevNoteIntegrationEvent>(cmd); @event.GuidId = cmd.GuidId; @event.EventParameters = cmd.EventParameters; @event.EventName = cmd.EventName; @event.OuputResponse = result; @event.RetryCount = cmd.RetryCount; @event.ErrorCode = "101";//ErrorCodes cmd.ErrorCode; @event.ReferenceId = cmd.ReferenceId; @event.MessageId = cmd.GuidId; @event.IsResponse = true; stringContent = JsonConvert.SerializeObject(@event); // var stringContent = JsonConvert.SerializeObject(cmd); //new StringContent(JsonConvert.SerializeObject(cmd), Encoding.UTF8, "application/json"); var file = Path.Combine(FileEndPointManager.MyWaitOneDirectory, EnumFiles.WFOutput); await BotHttpClient.Log("OuputValue:" + result); File.WriteAllText(file, stringContent); if (!string.IsNullOrEmpty(cmd.EventFilePath)) { try { if (File.Exists(cmd.EventFilePath)) { File.Delete(cmd.EventFilePath); } } catch (Exception err) { await BotHttpClient.Log(err.Message, true); } } //STEP_.RESULT #6 save to OUTCOME var fName = Path.GetFileName(cmd.EventFilePath); fName = fName.Replace(EnumFiles.WFInput, EnumFiles.WFOutput); file = Path.Combine(FileEndPointManager.MyOutcomeFolder, fName); File.WriteAllText(file, stringContent); await BotHttpClient.Log("EventOutputStatus: " + Environment.NewLine + stringContent); //var fileIn = Path.Combine(FileEndPointManager.MyWaitOneDirectory, EnumFiles.WFInput); //if (File.Exists(fileIn)) // File.Delete(fileIn); ClearInputWF(); //delete Eventfile if (!string.IsNullOrEmpty(cmd.EventFilePath)) { try { if (File.Exists(cmd.EventFilePath)) { File.Delete(cmd.EventFilePath); } } catch (Exception err) { await BotHttpClient.Log(err.Message, true); } } return(@event); }
//must be 1 reference only //only used by OutputManager!! public static async Task <DevNoteIntegrationEvent> CreateOutputWF() { //STEP_.RESULT #99 CreateOutputWF var stringContent = File.ReadAllText(FileEndPointManager.InputWFFilePath); var cmd = ReadInputWFCmdJsonFile(); var payload = cmd; //(RunWFCmdParam)cmd.Payload; var result = FileEndPointManager.ReadMyResultValueFile(); //TIP# Configure AutoMapper var config = new MapperConfiguration(cfg => cfg.CreateMap <RunWFCmdParam, DevNoteIntegrationEvent>()); var mapper = config.CreateMapper(); // Perform mapping var @event = mapper.Map <RunWFCmdParam, DevNoteIntegrationEvent>(cmd); @event.GuidId = cmd.GuidId; @event.EventParameters = cmd.EventParameters; @event.EventName = cmd.EventName; @event.OuputResponse = result; @event.RetryCount = cmd.RetryCount; @event.ErrorCode = cmd.ErrorCode; @event.ReferenceId = cmd.ReferenceId; @event.MessageId = cmd.GuidId; @event.IsResponse = true; stringContent = JsonConvert.SerializeObject(@event); // var stringContent = JsonConvert.SerializeObject(cmd); //new StringContent(JsonConvert.SerializeObject(cmd), Encoding.UTF8, "application/json"); var file = Path.Combine(FileEndPointManager.MyWaitOneDirectory, EnumFiles.WFOutput); //_HACK safe to delete #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 || DEBUG //System.Diagnostics.Debug.WriteLine("HACK-TEST -"); //await BotHttpClient.Log("FileEndPointManager.MyWaitOneDirectory:" + FileEndPointManager.MyWaitOneDirectory); //await BotHttpClient.Log("OuputResponse:" + result); #endif #endregion //////////////END TEST await BotHttpClient.Log("OuputValue:" + result); File.WriteAllText(file, stringContent); if (!string.IsNullOrEmpty(cmd.EventFilePath)) { try { if (File.Exists(cmd.EventFilePath)) { File.Delete(cmd.EventFilePath); } } catch (Exception err) { await BotHttpClient.Log(err.Message, true); } } //STEP_.RESULT #6 save to OUTCOME var fName = Path.GetFileName(cmd.EventFilePath); fName = fName.Replace(EnumFiles.WFInput, EnumFiles.WFOutput); file = Path.Combine(FileEndPointManager.MyOutcomeFolder, fName); File.WriteAllText(file, stringContent); await BotHttpClient.Log("EventOutputStatus: " + Environment.NewLine + stringContent); //var fileIn = Path.Combine(FileEndPointManager.MyWaitOneDirectory, EnumFiles.WFInput); //if (File.Exists(fileIn)) // File.Delete(fileIn); ClearInputWF(); //delete Eventfile if (!string.IsNullOrEmpty(cmd.EventFilePath)) { try { if (File.Exists(cmd.EventFilePath)) { File.Delete(cmd.EventFilePath); } } catch (Exception err) { await BotHttpClient.Log(err.Message, true); } } return(@event); }