protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } string aiSetupJson = AiSetupJson.Get(context); AiLogger aiLogger = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService, localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory); string name = Name.Get(context); int value = MetricValue.Get(context); int? count = Count.Get(context); int? min = Min.Get(context); int? max = Max.Get(context); int stdDev = StdDev.Get(context); bool logSuccess = aiLogger.WriteMetric(name, value, count, min, max, stdDev); LogSuccess.Set(context, logSuccess); }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } string aiSetupJson = AiSetupJson.Get(context); AiLogger aiLogger = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService, localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory); string name = Name.Get(context); string method = Method.Get(context); string type = Type.Get(context); int duration = Duration.Get(context); int? resultCode = ResultCode.Get(context); bool success = Success.Get(context); string data = Data.Get(context); bool logSuccess = aiLogger.WriteDependency(name, method, type, duration, resultCode, success, data); LogSuccess.Set(context, logSuccess); }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } string aiSetupJson = AiSetupJson.Get(context); AiLogger aiLogger = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService, localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory); string message = Message.Get(context); string severity = Severity.Get(context); string severityValidationResult = AiTrace.ValidateSeverityValue(severity); if (!string.IsNullOrEmpty(severityValidationResult)) { localContext.TracingService.Trace(severityValidationResult); LogSuccess.Set(context, false); return; } Enum.TryParse(severity, out AiTraceSeverity traceSeverity); bool logSuccess = aiLogger.WriteTrace(message, traceSeverity); LogSuccess.Set(context, logSuccess); }
private static void TraceParameters(bool input, LocalPluginContext localContext) { ParameterCollection parameters = input ? localContext.PluginExecutionContext.InputParameters : localContext.PluginExecutionContext.OutputParameters; if (parameters == null || parameters.Count == 0) { return; } try { foreach (KeyValuePair <string, object> parameter in parameters) { StringBuilder sb = new StringBuilder(); var typeFullname = (object)parameter.Value?.GetType().FullName; string parameterType = input ? "Input" : "Output"; string typeFullnameString = typeFullname != null?typeFullname.ToString() : "NULL"; sb.Append($"{parameterType} Parameter({typeFullnameString}): {parameter.Key}: "); AiLogger.AppendValue(localContext.OrganizationService, typeFullname, sb, parameter.Value); localContext.TracingService.Trace(sb.ToString()); } } catch (Exception e) { localContext.TracingService.Trace($"Error tracing parameters: {e.Message}"); } }
public void DependencyTest() { AiSetup aiSetup = Configs.GetAiSetup(false, false, false, false, false, false, true); string secureConfig = SerializationHelper.SerializeObject <AiSetup>(aiSetup); XrmFakedTracingService fakedTracingService = new XrmFakedTracingService(); XrmFakedContext context = new XrmFakedContext(); IOrganizationService fakedService = context.GetOrganizationService(); XrmFakedPluginExecutionContext xrmFakedPluginExecution = new XrmFakedPluginExecutionContext(); Guid userId = Guid.Parse("9e7ec57b-3a08-4a41-a4d4-354d66f19b65"); xrmFakedPluginExecution.InitiatingUserId = userId; xrmFakedPluginExecution.UserId = userId; xrmFakedPluginExecution.CorrelationId = Guid.Parse("15cc775b-9ebc-48d1-93a6-b0ce9c920b66"); xrmFakedPluginExecution.PrimaryEntityName = "account"; xrmFakedPluginExecution.PrimaryEntityId = Guid.Parse("f14c4d40-96e9-40a5-95b7-4028af9605de"); xrmFakedPluginExecution.MessageName = "Update"; xrmFakedPluginExecution.Mode = 1; xrmFakedPluginExecution.Depth = 1; xrmFakedPluginExecution.OrganizationName = "test.crm.dynamics.com"; xrmFakedPluginExecution.Stage = 40; xrmFakedPluginExecution.OperationCreatedOn = DateTime.Now; AiLogger aiLogger = new AiLogger(secureConfig, fakedService, fakedTracingService, xrmFakedPluginExecution, xrmFakedPluginExecution.Stage, null); bool result = aiLogger.WriteDependency("https://www.test1.com/test/123", "GET", "HTTP", 2346, 200, true, "Hello from DependencyTest - 0"); Assert.IsTrue(result); }
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } try { AiLogger aiLogger = new AiLogger(_unsecureConfig, localContext.OrganizationService, localContext.TracingService, localContext.PluginExecutionContext, localContext.PluginExecutionContext.Stage, null); string message = ActionHelpers.GetInputValue <string>("message", localContext.PluginExecutionContext, localContext.TracingService); string severity = ActionHelpers.GetInputValue <string>("severity", localContext.PluginExecutionContext, localContext.TracingService); string severityValidationResult = AiTrace.ValidateSeverityValue(severity); if (!string.IsNullOrEmpty(severityValidationResult)) { localContext.TracingService.Trace(severityValidationResult); return; } bool isValid = Enum.TryParse(severity, out AiTraceSeverity traceSeverity); aiLogger.WriteTrace(message, isValid ? traceSeverity : AiTraceSeverity.Information); } catch (Exception e) { localContext.TracingService.Trace($"Unhandled Exception: {e.Message}"); } }
public void BeginScope_always_returns_same_instance() { var sut = new AiLogger("abc", new TelemetryClient(), (a, b) => false); var scope1 = sut.BeginScope(""); var scope2 = sut.BeginScope(""); Assert.Equal(scope1, scope2); }
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } try { AiLogger aiLogger = new AiLogger(_unsecureConfig, localContext.OrganizationService, localContext.TracingService, localContext.PluginExecutionContext, localContext.PluginExecutionContext.Stage, null); string name = ActionHelpers.GetInputValue <string>("name", localContext.PluginExecutionContext, localContext.TracingService); string method = ActionHelpers.GetInputValue <string>("method", localContext.PluginExecutionContext, localContext.TracingService); string typeInput = ActionHelpers.GetInputValue <string>("type", localContext.PluginExecutionContext, localContext.TracingService); int? duration = ActionHelpers.GetInputValue <int?>("duration", localContext.PluginExecutionContext, localContext.TracingService); int? resultcode = ActionHelpers.GetInputValue <int?>("resultcode", localContext.PluginExecutionContext, localContext.TracingService); bool? success = ActionHelpers.GetInputValue <bool?>("success", localContext.PluginExecutionContext, localContext.TracingService); string data = ActionHelpers.GetInputValue <string>("data", localContext.PluginExecutionContext, localContext.TracingService); if (string.IsNullOrEmpty(name) || duration == null || string.IsNullOrEmpty(typeInput) || success == null) { string errorMessage; if (string.IsNullOrEmpty(name)) { errorMessage = "Name must be populated"; } else if (duration == null) { errorMessage = "Duration must be populated"; } else if (string.IsNullOrEmpty(typeInput)) { errorMessage = "Type must be populated"; } else { errorMessage = "Success must be populated"; } localContext.TracingService.Trace(errorMessage); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, errorMessage); return; } bool result = aiLogger.WriteDependency(name, method, typeInput, (int)duration, resultcode, (bool)success, data); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, result, null); } catch (Exception e) { localContext.TracingService.Trace($"Unhandled Exception: {e.Message}"); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, e.Message); } }
//[Authorize(Policy = Policies.Controller)] public async Task <ActionResult <WorkflowInstance> > StartWorkflow(string id) { string contentReq = null; using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { contentReq = await reader.ReadToEndAsync(); } var logTrace = new LogTrace(); AiLogger.LogInfo(logTrace, "Workflow Start: " + contentReq); object workflowData = contentReq; string workflowId = null; if (id.Equals(CompressJobWorkflow.WorkflowId)) { workflowId = CompressJobWorkflow.WorkflowId; workflowData = NewtonJsonConvert.DeserializeObject <CompressJobData>(contentReq); } else if (id.Equals(WfFileInWorkflow.WorkflowId)) { workflowId = WfFileInWorkflow.WorkflowId; workflowData = NewtonJsonConvert.DeserializeObject <WfFileInData>(contentReq); } else if (id.Equals(Test01UserWorkflow.WorkflowId)) { var wfEvent = Newtonsoft.Json.JsonConvert.DeserializeObject <Pdf4meWorkflowEvent>(contentReq); workflowData = new Pdf4meWorkflowData() { WorkflowEvent = wfEvent }; workflowId = Test01UserWorkflow.WorkflowId; //workflowData = NewtonJsonConvert.DeserializeObject<WfFileInData>(contentReq); } else { var wfEvent = Newtonsoft.Json.JsonConvert.DeserializeObject <Pdf4meWorkflowEvent>(contentReq); workflowData = new Pdf4meWorkflowData() { WorkflowEvent = wfEvent }; workflowId = id; } var instanceId = await _workflowController.StartWorkflow(workflowId, workflowData); var result = await _persistenceProvider.GetWorkflowInstance(instanceId); return(Created(instanceId, _mapper.Map <WorkflowInstance>(result))); }
//[Authorize(Policy = Policies.Viewer)] public async Task <ActionResult <WorkflowInstance> > Get(string id) { var logTrace = new LogTrace(); AiLogger.LogInfo(logTrace, "Workflow Get: " + id); var result = await _persistenceProvider.GetWorkflowInstance(id); if (result == null) { return(NotFound()); } return(Ok(_mapper.Map <WorkflowInstance>(result))); }
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } try { AiLogger aiLogger = new AiLogger(_unsecureConfig, localContext.OrganizationService, localContext.TracingService, localContext.PluginExecutionContext, localContext.PluginExecutionContext.Stage, null); string name = ActionHelpers.GetInputValue <string>("name", localContext.PluginExecutionContext, localContext.TracingService); string measurementName = ActionHelpers.GetInputValue <string>("measurementname", localContext.PluginExecutionContext, localContext.TracingService); float? measurementValue = ActionHelpers.GetFloatInput("measurementvalue", localContext.PluginExecutionContext, localContext.TracingService); if (string.IsNullOrEmpty(name)) { localContext.TracingService.Trace("Name must be populated"); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, "Name must be populated"); return; } string measurementNameValidationResult = AiEvent.ValidateMeasurementName(measurementName); if (!string.IsNullOrEmpty(measurementNameValidationResult)) { localContext.TracingService.Trace(measurementNameValidationResult); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, measurementNameValidationResult); return; } Dictionary <string, double> measurements = new Dictionary <string, double> { { measurementName, Convert.ToDouble(measurementValue) } }; bool result = aiLogger.WriteEvent(name, measurements); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, result, null); } catch (Exception e) { localContext.TracingService.Trace($"Unhandled Exception: {e.Message}"); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, e.Message); } }
public void Visualize(AiProperty player1AiProperty, AiProperty player2AiProperty) { Activate(); _aiProperties = new[] { player1AiProperty, player2AiProperty }; GameLogger = new Logger { EnableWritingConsole = true }; AiLoggers[0] = new AiLogger(); AiLoggers[1] = new AiLogger(); Player1NameTextBlock.Text = "Player1"; Player2NameTextBlock.Text = "Player2"; StartGame(); }
public void TraceTest() { AiSetup aiSetup = Configs.GetAiSetup(false, false, false, false, false, false, true); string secureConfig = SerializationHelper.SerializeObject <AiSetup>(aiSetup); XrmFakedTracingService fakedTracingService = new XrmFakedTracingService(); XrmFakedContext context = new XrmFakedContext(); IOrganizationService fakedService = context.GetOrganizationService(); XrmFakedPluginExecutionContext xrmFakedPluginExecution = new XrmFakedPluginExecutionContext(); Guid userId = Guid.Parse("9e7ec57b-3a08-4a41-a4d4-354d66f19b65"); xrmFakedPluginExecution.InitiatingUserId = userId; xrmFakedPluginExecution.UserId = userId; xrmFakedPluginExecution.CorrelationId = Guid.Parse("15cc775b-9ebc-48d1-93a6-b0ce9c920b66"); xrmFakedPluginExecution.PrimaryEntityName = "account"; xrmFakedPluginExecution.PrimaryEntityId = Guid.Parse("f14c4d40-96e9-40a5-95b7-4028af9605de"); xrmFakedPluginExecution.MessageName = "Update"; xrmFakedPluginExecution.Mode = 1; xrmFakedPluginExecution.Depth = 1; xrmFakedPluginExecution.OrganizationName = "test.crm.dynamics.com"; xrmFakedPluginExecution.Stage = 40; xrmFakedPluginExecution.OperationCreatedOn = DateTime.Now; xrmFakedPluginExecution.InputParameters = new ParameterCollection { new System.Collections.Generic.KeyValuePair <string, object>("InputParam1", "test"), new System.Collections.Generic.KeyValuePair <string, object>("InputParam2", 34) }; xrmFakedPluginExecution.OutputParameters = new ParameterCollection { new System.Collections.Generic.KeyValuePair <string, object>("OutputParam1", "test"), new System.Collections.Generic.KeyValuePair <string, object>("OutputParam2", 34) }; AiLogger aiLogger = new AiLogger(secureConfig, fakedService, fakedTracingService, xrmFakedPluginExecution, xrmFakedPluginExecution.Stage, null); bool result = aiLogger.WriteTrace("Hello from TraceTest - 0", AiTraceSeverity.Information); Assert.IsTrue(result); }
public virtual void Visualize(string replayFileName) { Activate(); GameMain?.Dispose(); _playingReplayGameData = new ReplayGameData(); _playingReplayGameData.Load(replayFileName); var player1ReplayData = _playingReplayGameData.Matches[0].Player1ReplayData; var player1Name = player1ReplayData.OutputLines[0]; Player1NameTextBlock.Text = player1Name; var player2ReplayData = _playingReplayGameData.Matches[0].Player2ReplayData; var player2Name = player2ReplayData.OutputLines[0]; Player2NameTextBlock.Text = player2Name; GameConfig = _playingReplayGameData.Matches[0].GameConfig; var temp = new List <int>(); for (var i = 0; i < _playingReplayGameData.MatchesCount; ++i) { temp.Add(i); } _isUser = false; GameComboBox.ItemsSource = temp; _currentMatch = 0; BuildGame(0); GameLogger = new Logger { EnableWritingConsole = true }; AiLoggers[0] = new AiLogger(); AiLoggers[1] = new AiLogger(); StartGame(0); }
public async Task Pdf4meActionHandlerAsync(ProcessingMessage message, CancellationToken token) { var logTrace = new LogTrace(); try { AiLogger.LogInfo(logTrace, "WfMessage to execute: " + JsonConvert.SerializeObject(message)); var msgId = message.MessageId; var docPluginRes = JsonConvert.DeserializeObject <DocPluginRes>(message.MessageBody); await _wfHost.PublishEvent(docPluginRes.WfEventName, docPluginRes.WfEventKey, message.MessageBody); AiLogger.LogInfo(logTrace, "WfMessage executed!"); }catch (Exception e) { AiLogger.LogException(logTrace, e); } }
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { //if (localContext.PluginExecutionContext.MessageName != "Update") return; if (localContext.PluginExecutionContext.PrimaryEntityName == "plugintracelog" || localContext.PluginExecutionContext.PrimaryEntityName.Substring(0, 3) == "sdk") { return; // abort plugin if not needed. } try { if (localContext.PluginExecutionContext.MessageName.Equals("update", StringComparison.InvariantCultureIgnoreCase) && localContext.PluginExecutionContext.Stage == 10) { if (!localContext.PluginExecutionContext.InputParameters.ContainsKey("ConcurrencyBehavior")) { localContext.PluginExecutionContext.InputParameters["ConcurrencyBehavior"] = ConcurrencyBehavior.Default; } } AiLogger aiLogger = new AiLogger( _unsecureConfig, localContext.OrganizationService, localContext.TracingService, localContext.PluginExecutionContext, localContext.PluginExecutionContext.Stage, null); var measurements = new Dictionary <string, double> { { "Stage", localContext.PluginExecutionContext.Stage } }; aiLogger.WriteEvent("XRM Message", measurements); } catch (Exception e) { localContext.TracingService.Trace($"Unhandled Exception: {e.Message}"); //throw; //ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, e.Message); } }
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } try { AiLogger aiLogger = new AiLogger(_unsecureConfig, localContext.OrganizationService, localContext.TracingService, localContext.PluginExecutionContext, localContext.PluginExecutionContext.Stage, null); string name = ActionHelpers.GetInputValue <string>("name", localContext.PluginExecutionContext, localContext.TracingService); int? value = ActionHelpers.GetInputValue <int?>("value", localContext.PluginExecutionContext, localContext.TracingService); int? count = ActionHelpers.GetInputValue <int?>("count", localContext.PluginExecutionContext, localContext.TracingService); int? min = ActionHelpers.GetInputValue <int?>("min", localContext.PluginExecutionContext, localContext.TracingService); int? max = ActionHelpers.GetInputValue <int?>("max", localContext.PluginExecutionContext, localContext.TracingService); int? stdDev = ActionHelpers.GetInputValue <int?>("stddev", localContext.PluginExecutionContext, localContext.TracingService); if (string.IsNullOrEmpty(name) || value == null) { var errorMessage = string.IsNullOrEmpty(name) ? "Name must be populated" : "Value must be populated"; localContext.TracingService.Trace(errorMessage); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, errorMessage); return; } bool result = aiLogger.WriteMetric(name, (int)value, count, min, max, stdDev); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, result, null); } catch (Exception e) { localContext.TracingService.Trace($"Unhandled Exception: {e.Message}"); ActionHelpers.SetOutputParameters(localContext.PluginExecutionContext.OutputParameters, false, e.Message); } }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } string aiSetupJson = AiSetupJson.Get(context); AiLogger aiLogger = new AiLogger(aiSetupJson, localContext.OrganizationService, localContext.TracingService, localContext.WorkflowExecutionContext, null, localContext.WorkflowExecutionContext.WorkflowCategory); string name = Name.Get(context); string measurementName = MeasurementName.Get(context); double measurementValue = MeasurementValue.Get(context); string measurementNameValidationResult = AiEvent.ValidateMeasurementName(measurementName); if (!string.IsNullOrEmpty(measurementNameValidationResult)) { localContext.TracingService.Trace(measurementNameValidationResult); LogSuccess.Set(context, false); return; } Dictionary <string, double> measurements = new Dictionary <string, double> { { measurementName, Convert.ToDouble(measurementValue) } }; bool logSuccess = aiLogger.WriteEvent(name, measurements); LogSuccess.Set(context, logSuccess); }
public void IsEnabled_returns_false() { var sut = new AiLogger("abc", new TelemetryClient(), (name, logLevel) => logLevel < LogLevel.Information); Assert.False(sut.IsEnabled(LogLevel.Debug)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. //app.UseHsts(); } app.Use(async(context, next) => { Console.WriteLine($"method called with path {context.Request.Method}"); await next.Invoke(); Console.WriteLine($"method called with path {context.Request.Method}"); } ); app.UseAuthentication(); //app.UseHttpsRedirection(); app.UseMvc(cfg => { // cfg. }); app.UseRouting(); //app.UseMvcWithDefaultRoute(); app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); var host = app.ApplicationServices.GetService <IWorkflowHost>(); var defService = app.ApplicationServices.GetService <IDefinitionService>(); var backplane = app.ApplicationServices.GetService <IClusterBackplane>(); defService.LoadDefinitionsFromStorage(); // Register pdf4me Built-in Workflows //Pdf4meWorkflowRegistration.RegisterPdf4meServices(services); //Pdf4meWorkflowRegistration.RegisterPdf4meServices(services); host.RegisterWorkflow <CompressJobWorkflow, CompressJobData>(); host.RegisterWorkflow <CompressUserWorkflow, CompressData>(); host.RegisterWorkflow <WfFileInWorkflow, WfFileInData>(); host.RegisterWorkflow <Test01UserWorkflow, Pdf4meWorkflowData>(); host.RegisterWorkflow <WorkflowDocClassGenModel, MLWorkflowData>(); host.OnStepError += StepErrorEventHandler; backplane.Start(); host.Start(); applicationLifetime.ApplicationStopped.Register(() => { host.Stop(); backplane.Stop(); }); AiLogger.Instance.Init(Configuration.GetValue <string>("AppInsightKey"), "Pdf4meWorkflow"); AiLogger.LogInfo(new LogTrace(), "Init AiLogger for Pdf4meWorkflow : "); var msgHandler = new Pdf4meMessageHandler(host); Pdf4meBusFactory.Instance.SetServiceBusConnection(Configuration.GetValue <string>("ServiceBus")); Pdf4meBusFactory.Instance.RegisterQueueMessageHandler("wfexecution", msgHandler.Pdf4meActionHandlerAsync); }
public void IsEnabled_returns_false_when_category_name_starts_with_internal_namespace() { var sut = new AiLogger("ApplicationInsights.TelemetryReplication.Whatever", new TelemetryClient(), (a, b) => false); Assert.False(sut.IsEnabled(LogLevel.Information)); }
private void RunButton_OnClick(object sender, RoutedEventArgs e) { StopButton.IsEnabled = true; RunButton.IsEnabled = false; ColumnTextBox.IsEnabled = false; RowTextBox.IsEnabled = false; RandomTextBox.IsEnabled = false; MinChainTextBox.IsEnabled = false; ColorNumberTextBox.IsEnabled = false; MatchNumTextBox.IsEnabled = false; ReplayButton.IsEnabled = false; RunGameVsHuman(); return; var f1 = Player1FileName; var f2 = Player2FileName; if ((f1.Length == 0) || (f2.Length == 0)) { var message = "実行ファイル名が無効です."; var title = "Puchipro6 Visualizer"; MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); StopGame(); return; } var fileNames = new[] { f1, f2 }; _gameLogger = new Logger(); #if DEBUG _gameLogger.EnableWritingConsole = true; #endif _gameLogger.OnLogAdded += GameLoggerOnOnLogAdded; GameLogTextBox.Text = "初期化中...\n"; BattleProgressTextBox.Text = ""; _ai1AiLogger = new AiLogger(); _ai1AiLogger.InputLogger.OnLogAdded += Player1InputLoggerOnOnLogAdded; _ai1AiLogger.OutputLogger.OnLogAdded += Player1OutputLoggerOnOnLogAdded; _ai1AiLogger.ErrorOutputLogger.OnLogAdded += Player1ErrorOutputLoggerOnOnLogAdded; Player1InputTextBox.Text = ""; Player1OutputTextBox.Text = ""; Player1ErrorOutputTextBox.Text = ""; _ai2AiLogger = new AiLogger(); _ai2AiLogger.InputLogger.OnLogAdded += Player2InputLoggerOnOnLogAdded; _ai2AiLogger.OutputLogger.OnLogAdded += Player2OutputLoggerOnOnLogAdded; _ai2AiLogger.ErrorOutputLogger.OnLogAdded += Player2ErrorOutputLoggerOnOnLogAdded; Player2InputTextBox.Text = ""; Player2OutputTextBox.Text = ""; Player2ErrorOutputTextBox.Text = ""; _gameMain = GameMain.Run(GameConfig, fileNames, true, _gameLogger, new[] { _ai1AiLogger, _ai2AiLogger }, new SpecialRand((uint)GameConfig.RandomSeed)); _tokenSource = new CancellationTokenSource(); _token = _tokenSource.Token; _gameTask = _taskFactory.StartNew(RunGame, _token); }