Exemplo n.º 1
0
 public DLLResults(string filename, RunResults res1, RunResults res2, DBResults resDb)
 {
     this.filename = filename;
     this.res1     = res1;
     this.res2     = res2;
     this.resDb    = resDb;
 }
        public async Task <RunResults> RunSimulation(RunSettings runSettings)
        {
            var runId            = runSettings.RunId;
            var gatlingStartInfo = new ProcessStartInfo(runSettings.GatlingPath)
            {
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
                Arguments =
                    $"-sf /tmp/{runId}/simulations -rsf /tmp/{runId}/resources -rf /tmp/{runId}/results -rd {runId} -s {runSettings.SimulationClassName}"
            };

            using (var process = new Process {
                StartInfo = gatlingStartInfo
            })
            {
                process.Start();
                process.WaitForExit();

                var results = new RunResults
                {
                    RunId         = runSettings.RunId,
                    ConsoleOutput = (await process.StandardOutput.ReadToEndAsync())
                                    .Split("\n")
                                    .ToList()
                };

                return(results);
            }
        }
Exemplo n.º 3
0
        public bool RunStep(RunResults results)
        {
            bool ran = false;

            if (tryCurrentVariant)
            {
                var result = TryCurrentVariant();

                CheckScore(result);

                tryCurrentVariant = false;
                ran = true;
            }

            if (variantsToTry > 0 && !ran)
            {
                var result = TryVariant();

                CheckScore(result);

                --variantsToTry;
            }

            if (!tryCurrentVariant && variantsToTry <= 0)
            {
                // Store the best result
                OnBestResultFound(results, currentBest);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
 private static void ContainsStandardUsageText(RunResults results)
 {
     Assert.Contains("Usage:", results.StandardOutput);
     Assert.Contains("PublishCoverity --help", results.StandardOutput);
     Assert.Contains("Options:", results.StandardOutput);
     Assert.Contains("What its for:", results.StandardOutput);
 }
Exemplo n.º 5
0
        private ExecuteResult GetExecutionResult(RunResults runResults, int exitCode, ILogger logger)
        {
            if (exitCode != 0)
            {
                return(new ExecuteResult(true, exitCode, new string[0], new string[0]));
            }

            var lines = new List <string>();

            foreach (var measurement in runResults.GetMeasurements())
            {
                lines.Add(measurement.ToOutputLine());
            }
            var ops = (long)typeof(RunResults)
                      .GetField("totalOperationsCount", BindingFlags.Instance | BindingFlags.NonPublic)
                      .GetValue(runResults);

            var s = runResults.GCStats.WithTotalOperations(ops);
            var totalOpsOutput = string.Format(
                "{0} {1} {2} {3} {4} {5}", (object)"GC: ",
                s.Gen0Collections, s.Gen1Collections, s.Gen2Collections,
                s.AllocatedBytes, s.TotalOperations);

            lines.Add(totalOpsOutput);

            return(new ExecuteResult(true, 0, lines.ToArray(), new string[0]));
        }
        /// <summary>
        ///   Run an executable.
        /// </summary>
        /// <param name = "executablePath">Path to the executable.</param>
        /// <param name = "arguments">The arguments to pass along.</param>
        /// <param name = "workingDirectory">The directory to use as working directory when running the executable.</param>
        /// <returns>A RunResults object which contains the output of the executable, plus runtime information.</returns>
        public static RunResults RunExecutable( string executablePath, string arguments, string workingDirectory )
        {
            RunResults runResults = new RunResults();

            if ( File.Exists( executablePath ) )
            {
                using ( Process proc = new Process() )
                {
                    proc.StartInfo.FileName = executablePath;
                    proc.StartInfo.Arguments = arguments;
                    proc.StartInfo.WorkingDirectory = workingDirectory;
                    proc.StartInfo.UseShellExecute = false;
                    proc.StartInfo.RedirectStandardOutput = true;
                    proc.StartInfo.RedirectStandardError = true;
                    proc.OutputDataReceived +=
                        ( o, e ) => runResults.Output.Append( e.Data ).Append( Environment.NewLine );
                    proc.ErrorDataReceived +=
                        ( o, e ) => runResults.ErrorOutput.Append( e.Data ).Append( Environment.NewLine );

                    proc.Start();
                    proc.BeginOutputReadLine();
                    proc.BeginErrorReadLine();

                    proc.WaitForExit();
                    runResults.ExitCode = proc.ExitCode;
                }
            }
            else
            {
                throw new ArgumentException( "Invalid executable path.", "executablePath" );
            }

            return runResults;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Call lifePRO
        /// </summary>
        /// <returns></returns>
        private static RunResults CallLifepro(string command, string args, string goodFile)
        {
            RunResults result  = RunResults.Success;
            Process    process = new Process();

            process.StartInfo.FileName        = command;
            process.StartInfo.Arguments       = GetCycleCoder() + args;
            process.StartInfo.CreateNoWindow  = false;
            process.StartInfo.UseShellExecute = false;
            process.Start();
            process.WaitForExit();
            waitSeconds(10);  //give external program time to finish

            if (File.Exists(goodFile))
            {
                using (TextReader reader = File.OpenText(goodFile))
                {
                    string line = reader.ReadLine();
                    line = line.Substring(4, 2) + "/" + line.Substring(6, 2) + "/" + line.Substring(0, 4);
                    DateTime dateTimeOfSandPGood = DateTime.ParseExact(line, "MM/dd/yyyy", null);
                    reader.Close();
                    DateTime today = DateTime.Today;
                    if (dateTimeOfSandPGood.Year != today.Year || dateTimeOfSandPGood.Month != today.Month || dateTimeOfSandPGood.Day != today.Day)
                    {
                        result = RunResults.BadDate;
                    }
                }
            }
            else
            {
                result = RunResults.NoFile;
            }
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>Submits run results to the host.</summary>
        /// <param name="runResults">The run results.</param>
        public void Print(RunResults runResults)
        {
            RunResults = runResults;

            if (_logger != null)
            {
                using (var w = new StringWriter())
                {
                    foreach (Measurement measurement in runResults.GetMeasurements())
                    {
                        _logger.WriteLine(measurement.ToOutputLine());
                    }

                    var ops = (long)typeof(RunResults)
                              .GetField("totalOperationsCount", BindingFlags.Instance | BindingFlags.NonPublic)
                              .GetValue(runResults);

                    var s = runResults.GCStats.WithTotalOperations(ops);
                    var totalOpsOutput = string.Format(
                        "{0} {1} {2} {3} {4} {5}", (object)"GC: ",
                        s.Gen0Collections, s.Gen1Collections, s.Gen2Collections,
                        s.AllocatedBytes, s.TotalOperations);
                    _logger.WriteLine(totalOpsOutput);
                    _logger.WriteLine();

                    _logger.Write(w.GetStringBuilder().ToString());
                }
            }
        }
Exemplo n.º 9
0
 private void LogResults(IController controller, Scene scene)
 {
     var elapsed = scene.Elapsed;
     var fps = scene.FrameCount / elapsed.TotalSeconds;
     var results = new RunResults(
         controller.Library + " " + controller.Description,
         elapsed, fps, scene.CpuUsageSelf.Cpu, scene.CpuUsageDwm.Cpu);
     _runResults.Add(results);
 }
Exemplo n.º 10
0
        /// <summary>Submits run results to the host.</summary>
        /// <param name="runResults">The run results.</param>
        public void ReportResults(RunResults runResults)
        {
            RunResults = runResults;

            using (var w = new StringWriter())
            {
                runResults.Print(w);
                logger.Write(w.GetStringBuilder().ToString());
            }
        }
Exemplo n.º 11
0
            internal static RunResults FromOutLines(IEnumerable <string> outLines)
            {
                var res = new RunResults();

                foreach (var line in outLines)
                {
                    res.MatchLine(line);
                }
                return(res);
            }
        private ExecuteResult GetExecutionResult(RunResults runResults, int exitCode, ILogger logger, Encoding encoding)
        {
            if (exitCode != 0)
            {
                return(new ExecuteResult(true, exitCode, Array.Empty <string>(), Array.Empty <string>()));
            }

            var lines = runResults.GetMeasurements().Select(measurement => measurement.ToOutputLine()).ToList();

            lines.Add(runResults.GCStats.ToOutputLine());

            return(new ExecuteResult(true, 0, lines.ToArray(), Array.Empty <string>()));
        }
Exemplo n.º 13
0
 private static RunResults AppropriateErrorResult(CompilerResults cr)
 {
     foreach (CompilerError error in cr.Errors)
     {
         if (error.ToString().Contains("is defined in an assembly that is not referenced"))
         {
             //Console.WriteLine("@@@" + error.ToString());
             //Console.WriteLine("@@@" + this.ToString());
             return(RunResults.CompilationFailed(RunResults.CompilFailure.MissingReference, cr.Errors));
         }
     }
     return(RunResults.CompilationFailed(RunResults.CompilFailure.Other, cr.Errors));
 }
Exemplo n.º 14
0
        public void Handle(RunResults message)
        {
            var template = new HtmlTemplate
            {
                Results = message,
                Notifications = _notifications.ToLookup(x => x.Source)
            };

            var html = template.TransformText();

            Console.WriteLine(html);

            // Write to a file
        }
Exemplo n.º 15
0
        /// <summary>
        /// Execute the run context.
        /// </summary>
        /// <param name="error">The error message if the run fails.</param>
        /// <param name="stackTrace">The stack trace at the point of the error if the run fails.</param>
        /// <returns>True if the run succeeds, false otherwise with an error message and a stack trace.</returns>
        public RunError?StartRun()
        {
            string?error = null, moduleName = null, stackTrace = string.Empty;

            if (!ValidateModelSystem(ref error) || !GetStart(Start.ParseStartString(StartToExecute), out var startingMss, ref error) ||
                startingMss == null)
            {
                return(new RunError(RunErrorType.Validation, error, moduleName, stackTrace));
            }
            var originalDir = Directory.GetCurrentDirectory();

            try
            {
                Directory.SetCurrentDirectory(_currentWorkingDirectory);
                if (!RuntimeValidation(ref moduleName, ref error))
                {
                    RunResults.WriteValidationError(_currentWorkingDirectory, moduleName, error);
                    return(new RunError(RunErrorType.Runtime, error, moduleName, stackTrace));
                }
                if (startingMss.Module is IAction modelStart)
                {
                    modelStart.Invoke();
                }
                else
                {
                    return(new RunError(RunErrorType.Runtime, "Unable to invoking the starting module!", startingMss.Module?.Name ?? "Unknown module", string.Empty));
                }
                RunResults.WriteRunCompleted(_currentWorkingDirectory);
            }
            catch (Exception e)
            {
                while (e.InnerException is Exception current)
                {
                    e = current;
                }
                error      = e.Message;
                stackTrace = e.StackTrace;
                RunResults.WriteError(_currentWorkingDirectory, e);
                return(new RunError(RunErrorType.Runtime, error,
                                    e is XTMFRuntimeException xtmfError ? xtmfError.FailingModule?.Name ?? "Unknown module" : null, stackTrace));
            }
            finally
            {
                Directory.SetCurrentDirectory(originalDir);
            }
            // success for now
            return(null);
        }
Exemplo n.º 16
0
        public bool RunStep(RunResults results)
        {
            // ReSharper disable RedundantArgumentDefaultValue
            var config = new SimulationConfiguration(map, 1)
            {
                Results = results
            };

            // ReSharper restore RedundantArgumentDefaultValue

            // Directly feed the population results to the main results object

            PopulationSimulation.Simulate(config);

            return(true);
        }
Exemplo n.º 17
0
        public RunResults RunExternal()
        {
            // Set up compiler parameters.
            CompilerParameters cp = new CompilerParameters();

            AddReferenceLibraries(cp);
            cp.GenerateExecutable    = true;
            cp.OutputAssembly        = "Temp.exe";
            cp.GenerateInMemory      = false;
            cp.TreatWarningsAsErrors = false;

            // Compile sources.
            CodeDomProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
            CompilerResults cr       = provider.CompileAssemblyFromSource(cp, this.ToString());

            if (cr.Errors.Count > 0)
            {
                return(AppropriateErrorResult(cr));
            }

            // Run test in separate process.
            Process p = new Process();

            p.StartInfo.FileName = Common.Enviroment.MiniDHandler;
            p.StartInfo.RedirectStandardOutput = true;
            StringBuilder arguments = new StringBuilder();

            arguments.Append("/O:\"C:\\foobar.txt\"");
            arguments.Append(" /I:" + "\"" + Common.Enviroment.DefaultDhi + "\"");
            arguments.Append(" /App:\"Temp\"");
            p.StartInfo.Arguments       = arguments.ToString();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.ErrorDialog     = true;
            p.StartInfo.CreateNoWindow  = false;

            p.Start();
            string output = p.StandardOutput.ReadToEnd();

            p.WaitForExit(10000);

            // Exit code 100 means behavior was reproduced.
            if (p.ExitCode != 100)
            {
                return(RunResults.CompiledOKBehaviorNotReproduced());
            }
            return(RunResults.CompiledOKBehaviorWasReproduced());
        }
Exemplo n.º 18
0
        private ExecuteResult GetExecutionResult(RunResults runResults, int exitCode, ILogger logger, Encoding encoding)
        {
            if (exitCode != 0)
            {
                return(new ExecuteResult(true, exitCode, Array.Empty <string>(), Array.Empty <string>()));
            }

            var lines = new List <string>();

            foreach (var measurement in runResults.GetMeasurements())
            {
                lines.Add(measurement.ToOutputLine());
            }
            lines.Add(runResults.GCStats.ToOutputLine());

            return(new ExecuteResult(true, 0, lines.ToArray(), Array.Empty <string>()));
        }
Exemplo n.º 19
0
        private ExecuteResult GetExecutionResult(RunResults runResults, int exitCode, ILogger logger)
        {
            if (exitCode != 0)
            {
                return(new ExecuteResult(true, exitCode, new string[0], new string[0]));
            }

            var lines = new List <string>();

            foreach (var measurement in runResults.GetMeasurements())
            {
                lines.Add(measurement.ToOutputLine());
            }
            lines.Add(runResults.GCStats.WithTotalOperations(runResults.TotalOperationsCount).ToOutputLine());

            return(new ExecuteResult(true, 0, lines.ToArray(), new string[0]));
        }
Exemplo n.º 20
0
        public void Handle(RunResults message)
        {
            var results = message;

            if (results == null)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("No results were produced.");
                Console.ResetColor();
                return;
            }

            if (results.Total <= 0)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("No verifications found!");
                Console.ResetColor();
                return;
            }

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("** Results **");

            if (results.PassCount > 0)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Passed: {0}", results.PassCount);
                Console.ResetColor();
                Console.WriteLine(String.Join(Environment.NewLine, results.Passed.Select(y => y.Name)));
                Console.WriteLine();
            }

            if (results.FailCount > 0)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Failed: {0}", results.FailCount);
                Console.ResetColor();
                Console.WriteLine(String.Join(Environment.NewLine, results.Failed.Select(y => y.Name)));
                Console.WriteLine();
            }

            Console.ForegroundColor = results.FailCount > 0 ? ConsoleColor.Red : ConsoleColor.Green;
            Console.WriteLine("Pass rate: {0} out of {1} which is {2:#0.#}%", results.PassCount, results.Total, results.PassRate);
            Console.ResetColor();
        }
Exemplo n.º 21
0
        private static RunResults ProcessRun(string fullname)
        {
            var ferr = new FileInfo(fullname + ".err");

            if (ferr.Exists && ferr.Length > 0)
            {
                return(RunResults.Err);
            }

            var fout = new FileInfo(fullname + ".out");

            if (!fout.Exists || fout.Length == 0)
            {
                return(RunResults.Err);
            }

            return(RunResults.FromOutLines(File.ReadLines(fout.FullName)));
        }
Exemplo n.º 22
0
        public static RunResults RunExecutable(string executablePath, string arguments, string workingDirectory)
        {
            RunResults runResults = new RunResults
            {
                Output       = new StringBuilder(),
                Error        = new StringBuilder(),
                RunException = null
            };

            try
            {
                if (File.Exists(executablePath))
                {
                    using (Process proc = new Process())
                    {
                        proc.StartInfo.FileName               = executablePath;
                        proc.StartInfo.Arguments              = arguments;
                        proc.StartInfo.WorkingDirectory       = workingDirectory;
                        proc.StartInfo.UseShellExecute        = false;
                        proc.StartInfo.RedirectStandardOutput = true;
                        proc.StartInfo.RedirectStandardError  = true;
                        proc.OutputDataReceived              +=
                            (o, e) => runResults.Output.Append(e.Data).Append(Environment.NewLine);
                        proc.ErrorDataReceived +=
                            (o, e) => runResults.Error.Append(e.Data).Append(Environment.NewLine);
                        proc.Start();
                        proc.BeginOutputReadLine();
                        proc.BeginErrorReadLine();
                        proc.WaitForExit();
                        runResults.ExitCode = proc.ExitCode;
                    }
                }
                else
                {
                    throw new ArgumentException("Invalid executable path.", "exePath");
                }
            }
            catch (Exception e)
            {
                runResults.RunException = e;
            }
            return(runResults);
        }
Exemplo n.º 23
0
        public bool RunStep(RunResults results)
        {
            bool ran = false;

            if (tryCurrentVariant)
            {
                var result = TryCurrentVariant();

                if (currentBest == null || result.Score > currentBest.Score)
                {
                    currentBest = result;
                }

                tryCurrentVariant = false;
                ran = true;
            }

            if (variantsToTry > 0 && !ran)
            {
                var result = TryVariant();

                if (currentBest == null || result.Score > currentBest.Score)
                {
                    currentBest = result;
                }

                --variantsToTry;
                ran = true;
            }

            if (!tryCurrentVariant && variantsToTry <= 0)
            {
                // Store the best result
                OnBestResultFound(results, currentBest);
                return(true);
            }
            else
            {
                return(false);
            }
        }
			public RunResults RunAwaitResult()
			{
				var runResults = new RunResults();

				_process.StartInfo.RedirectStandardOutput = true;
				_process.StartInfo.RedirectStandardError = true;
				_process.OutputDataReceived +=
					( o, e ) => runResults.Output.Append( e.Data ).Append( Environment.NewLine );
				_process.ErrorDataReceived +=
					( o, e ) => runResults.ErrorOutput.Append( e.Data ).Append( Environment.NewLine );

				_process.Start();
				_process.BeginOutputReadLine();
				_process.BeginErrorReadLine();

				_process.WaitForExit();
				runResults.ExitCode = _process.ExitCode;

				_process.Dispose();
				return runResults;
			}
Exemplo n.º 25
0
            public RunResults RunAwaitResult()
            {
                var runResults = new RunResults();

                _process.StartInfo.RedirectStandardOutput = true;
                _process.StartInfo.RedirectStandardError  = true;
                _process.OutputDataReceived +=
                    (o, e) => runResults.Output.Append(e.Data).Append(Environment.NewLine);
                _process.ErrorDataReceived +=
                    (o, e) => runResults.ErrorOutput.Append(e.Data).Append(Environment.NewLine);

                _process.Start();
                _process.BeginOutputReadLine();
                _process.BeginErrorReadLine();

                _process.WaitForExit();
                runResults.ExitCode = _process.ExitCode;

                _process.Dispose();
                return(runResults);
            }
Exemplo n.º 26
0
        /// <summary>
        /// Validate the model system contained within this run context.
        /// </summary>
        /// <param name="error">An error message if the model system is invalid.</param>
        /// <returns>True if the model system is valid, false otherwise with an error message.</returns>
        private bool ValidateModelSystem(ref string?error)
        {
            string?moduleName = null;

            // Make sure that we are able to actually construct the directory
            try
            {
                Directory.CreateDirectory(_currentWorkingDirectory);
            }
            catch (IOException e)
            {
                error = e.Message;
                return(false);
            }
            // Construct the model system
            if (!Convert(_modelSystemAsData, out var modelSystemAsString))
            {
                error = "Unable to convert model system data into a string!";
                return(false);
            }
            if (!ModelSystem.Load(modelSystemAsString, _runtime, out var ms, ref error) ||
                !ms !.Construct(_runtime, ref error) ||
                !ms !.Validate(ref moduleName, ref error))
            {
                RunResults.WriteValidationError(_currentWorkingDirectory, moduleName, error);
                return(false);
            }
            _modelSystem = ms;
            // Ensure that the starting point exists
            if (!GetStart(Start.ParseStartString(StartToExecute),
                          out var _, ref error))
            {
                _modelSystem = null;
                return(false);
            }
            return(true);
        }
Exemplo n.º 27
0
 private ExecuteResult GetExecutionResult(RunResults runResults, int exitCode)
 {
     if (exitCode != 0)
     {
         return(new ExecuteResult(true, exitCode, default, Array.Empty <string>(), Array.Empty <string>()));
Exemplo n.º 28
0
        public static async Task Run(IMediator mediator, WrappingWriter writer, string projectName)
        {
            await writer.WriteLineAsync("===============");

            await writer.WriteLineAsync(projectName);

            await writer.WriteLineAsync("===============");

            await writer.WriteLineAsync();

            await writer.WriteLineAsync("Publishing Message...");

            ISignal signal = new Message()
            {
                Text = "I'm a signal message body"
            };
            await mediator.Publish(signal);

            await writer.WriteLineAsync();

            await writer.WriteLineAsync("Publishing Pinged...");

            await mediator.Publish(new Pinged());

            await writer.WriteLineAsync();

            await writer.WriteLineAsync("Publishing Ponged...");

            var failedPong = false;

            try
            {
                await mediator.Publish(new Ponged());
            }
            catch (Exception e)
            {
                failedPong = true;
                await writer.WriteLineAsync(e.ToString());
            }
            await writer.WriteLineAsync();

            await writer.WriteLineAsync("---------------");

            var contents = writer.Contents;
            var order    = new[] {
                contents.IndexOf("- Starting Up", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("-- Handling Request", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("--- Handled Ping", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("-- Finished Request", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("- All Done", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("- All Done with Ping", StringComparison.OrdinalIgnoreCase),
            };

            var results = new RunResults
            {
                RequestHandlers                       = contents.Contains("--- Handled Ping:"),
                PipelineBehaviors                     = contents.Contains("-- Handling Request"),
                RequestPreProcessors                  = contents.Contains("- Starting Up"),
                RequestPostProcessors                 = contents.Contains("- All Done"),
                OrderedPipelineBehaviors              = order.SequenceEqual(order.OrderBy(i => i)),
                NotificationHandler                   = contents.Contains("Got pinged async"),
                MultipleNotificationHandlers          = contents.Contains("Got pinged async") && contents.Contains("Got pinged also async"),
                ConstrainedGenericNotificationHandler = contents.Contains("Got pinged constrained async") && !failedPong,
                CovariantNotificationHandler          = contents.Contains("Got notified")
            };

            await writer.WriteLineAsync($"Request Handler....................................................{(results.RequestHandlers ? "Y" : "N")}");

            await writer.WriteLineAsync($"Void Request Handler...............................................{(results.VoidRequestsHandlers ? "Y" : "N")}");

            await writer.WriteLineAsync($"Pipeline Behavior..................................................{(results.PipelineBehaviors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Pre-Processor......................................................{(results.RequestPreProcessors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Post-Processor.....................................................{(results.RequestPostProcessors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Constrained Post-Processor.........................................{(results.ConstrainedGenericBehaviors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Ordered Behaviors..................................................{(results.OrderedPipelineBehaviors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Notification Handler...............................................{(results.NotificationHandler ? "Y" : "N")}");

            await writer.WriteLineAsync($"Notification Handlers..............................................{(results.MultipleNotificationHandlers ? "Y" : "N")}");

            await writer.WriteLineAsync($"Constrained Notification Handler...................................{(results.ConstrainedGenericNotificationHandler ? "Y" : "N")}");

            await writer.WriteLineAsync($"Covariant Notification Handler.....................................{(results.CovariantNotificationHandler ? "Y" : "N")}");

            await writer.WriteLineAsync($"Handler for inherited request with same exception used.............{(results.HandlerForSameException ? "Y" : "N")}");

            await writer.WriteLineAsync($"Handler for inherited request with base exception used.............{(results.HandlerForBaseException ? "Y" : "N")}");

            await writer.WriteLineAsync($"Handler for request with less specific exception used by priority..{(results.HandlerForLessSpecificException ? "Y" : "N")}");

            await writer.WriteLineAsync($"Preferred handler for inherited request with base exception used...{(results.PreferredHandlerForBaseException ? "Y" : "N")}");

            await writer.WriteLineAsync($"Overridden handler for inherited request with same exception used..{(results.OverriddenHandlerForBaseException ? "Y" : "N")}");

            await writer.WriteLineAsync();
        }
Exemplo n.º 29
0
        public static void ProcessRates()
        {
            holidays = ConfigurationManager.GetSection("Holidays") as NameValueCollection;
            string url          = ConfigurationManager.AppSettings["url"] as string;
            string workArea     = ConfigurationManager.AppSettings["lifePROWorkarea"] as string;
            string emailAddress = ConfigurationManager.AppSettings["emailNotifcations"] as string;
            string retrivalTime = ConfigurationManager.AppSettings["retrivalTime"] as string;
            string outputFile   = ConfigurationManager.AppSettings["outputFile"] as string;
            string goodFile     = ConfigurationManager.AppSettings["goodFile"] as string;
            string cmdPath      = ConfigurationManager.AppSettings["cmdPath"] as string;
            string cmd          = ConfigurationManager.AppSettings["cmd"] as string;
            string args         = ConfigurationManager.AppSettings["args"] as string;

            string retVal;
            string retTime;

            DateTime startTime = Convert.ToDateTime(retrivalTime);

            double millisecondsToWait = (startTime - DateTime.Now).TotalMilliseconds;

            try
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                while (stopwatch.Elapsed < TimeSpan.FromMilliseconds(millisecondsToWait))
                {
                    // Do nothing until stopwatch stops...
                    //log.Debug("Waiting..");
                }
                stopwatch.Stop();
            }
            catch (Exception e)
            {
                log.Error(e);
                SendMail(emailAddress, "*****@*****.**", "Error getting Standard and Poors closing index",
                         "Error while wiating for closing time of " + retrivalTime);
                return;
            }


            if (!IsHoliday())
            {
                if (File.Exists(Path.Combine(workArea, goodFile)))
                {
                    File.Delete(Path.Combine(workArea, goodFile));
                }
                if (ScreenScraper.GetRate(url, out retVal, out retTime))
                {
                    WriteOutputFile(Path.Combine(workArea, outputFile), retVal);
                    RunResults result = CallLifepro(Path.Combine(cmdPath, cmd), args, Path.Combine(workArea, goodFile));
                    switch (result)
                    {
                    case RunResults.Success:
                        SendMail(emailAddress, "*****@*****.**", "Successful call to get Standard and Poors closing index",
                                 "Standard and Poors Closing index value sucessfully retrieved and LifePRO program called at: " + DateTime.Now.ToShortDateString() + "  " + DateTime.Now.ToShortTimeString());
                        break;

                    case RunResults.BadDate:
                        log.Error("SANDP.GOOD was present but had the wrong date present. This indicates that the LifePRO program  did not run. Rates will need to be entered manually.");
                        SendMail(emailAddress, "*****@*****.**", "Error getting Standard and Poors closing index",
                                 "SANDP.GOOD was present but had the wrong date present. This indicates that the LifePRO program  did not run. Rates will need to be entered manually.");
                        break;

                    case RunResults.NoFile:
                        log.Error("No SANDP.GOOD FILE Found. The LifePRO program must not have run. Rates need to be entered manually.");
                        SendMail(emailAddress, "*****@*****.**", "Error getting Standard and Poors closing index",
                                 "No SANDP.GOOD FILE Found. The LifePRO program must not have run. Rates need to be entered manually.");
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    log.Error(retVal);
                    SendMail(emailAddress, "*****@*****.**", "Error getting Standard and Poors closing index",
                             "There was an error scraping the screen for S & P index rates. The error is " + retVal);
                }
            }
        }
Exemplo n.º 30
0
 internal static ExecuteResult FromRunResults(RunResults runResults, int exitCode)
 => exitCode != 0
         ? CreateFailed(exitCode)
         : new ExecuteResult(runResults.GetMeasurements().ToList(), runResults.GCStats, runResults.ThreadingStats);
Exemplo n.º 31
0
        public static async Task Run(IResolver resolver, WrappingWriter writer, string projectName)
        {
            await writer.WriteLineAsync("===============");

            await writer.WriteLineAsync(projectName);

            await writer.WriteLineAsync("===============");

            var ct = new CancellationToken();

            await writer.WriteLineAsync("Sending Ping...");

            var pingPong = resolver.Resolve <IMessageHandler <Ping, Pong> >();
            var pong     = await pingPong.Handle(new Ping { Message = "Ping" }, ct);

            await writer.WriteLineAsync("Received: " + pong.Message);

            await writer.WriteLineAsync("Publishing Pinged...");

            var pinged = resolver.Resolve <BroadcastMessageHandler <Pinged> >();
            await pinged.Handle(new Pinged(), ct);

            await writer.WriteLineAsync("Publishing Ponged...");

            var failedPong = false;

            try
            {
                var ponged = resolver.Resolve <BroadcastMessageHandler <Ponged> >();
                await ponged.Handle(new Ponged(), ct);
            }
            catch (Exception e)
            {
                failedPong = true;
                await writer.WriteLineAsync(e.ToString());
            }

            bool failedJing = false;
            await writer.WriteLineAsync("Sending Jing...");

            try
            {
                var jing = resolver.Resolve <IMessageHandler <Jing, EmptyResponse> >();
                await jing.Handle(new Jing { Message = "Jing" }, ct);
            }
            catch (Exception e)
            {
                failedJing = true;
                await writer.WriteLineAsync(e.ToString());
            }

            await writer.WriteLineAsync("---------------");

            var contents = writer.Contents;
            var order    = new[] {
                contents.IndexOf("- Starting Up", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("-- Handling Request", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("--- Handled Ping", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("-- Finished Request", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("- All Done", StringComparison.OrdinalIgnoreCase),
                contents.IndexOf("- All Done with Ping", StringComparison.OrdinalIgnoreCase),
            };

            var results = new RunResults
            {
                RequestHandlers                       = contents.Contains("--- Handled Ping:"),
                VoidRequestsHandlers                  = contents.Contains("--- Handled Jing:"),
                PipelineBehaviors                     = contents.Contains("-- Handling Request"),
                RequestPreProcessors                  = contents.Contains("- Starting Up"),
                RequestPostProcessors                 = contents.Contains("- All Done"),
                ConstrainedGenericBehaviors           = contents.Contains("- All Done with Ping") && !failedJing,
                OrderedPipelineBehaviors              = order.SequenceEqual(order.OrderBy(i => i)),
                NotificationHandler                   = contents.Contains("Got pinged async"),
                MultipleNotificationHandlers          = contents.Contains("Got pinged async") && contents.Contains("Got pinged also async"),
                ConstrainedGenericNotificationHandler = contents.Contains("Got pinged constrained async") && !failedPong,
                CovariantNotificationHandler          = contents.Contains("Got notified")
            };

            await writer.WriteLineAsync($"Request Handler...................{(results.RequestHandlers ? "Y" : "N")}");

            await writer.WriteLineAsync($"Void Request Handler..............{(results.VoidRequestsHandlers ? "Y" : "N")}");

            await writer.WriteLineAsync($"Pipeline Behavior.................{(results.PipelineBehaviors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Pre-Processor.....................{(results.RequestPreProcessors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Post-Processor....................{(results.RequestPostProcessors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Constrained Post-Processor........{(results.ConstrainedGenericBehaviors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Ordered Behaviors.................{(results.OrderedPipelineBehaviors ? "Y" : "N")}");

            await writer.WriteLineAsync($"Notification Handler..............{(results.NotificationHandler ? "Y" : "N")}");

            await writer.WriteLineAsync($"Notification Handlers.............{(results.MultipleNotificationHandlers ? "Y" : "N")}");

            await writer.WriteLineAsync($"Constrained Notification Handler..{(results.ConstrainedGenericNotificationHandler ? "Y" : "N")}");

            await writer.WriteLineAsync($"Covariant Notification Handler....{(results.CovariantNotificationHandler ? "Y" : "N")}");
        }
Exemplo n.º 32
0
 protected override void OnBestResultFound(RunResults results, IAttemptResult bestVariant)
 {
     results.AddMutationResultForSpecies(species, ((AttemptResult)bestVariant).Mutation);
 }
Exemplo n.º 33
0
 /// <summary>
 ///   Called after the best attempted variant is determined
 /// </summary>
 /// <param name="results">Results to apply the found solution to.</param>
 /// <param name="bestVariant">Best variant found.</param>
 protected abstract void OnBestResultFound(RunResults results, IAttemptResult bestVariant);
Exemplo n.º 34
0
 internal static RunResults FromOutLines(IEnumerable<string> outLines)
 {
   var res = new RunResults();
   foreach (var line in outLines)
     res.MatchLine(line);
   return res;
 }
Exemplo n.º 35
0
 public DLLResults(string filename, RunResults res1, RunResults res2, DBResults resDb)
 {
   this.filename = filename;
   this.res1 = res1;
   this.res2 = res2;
   this.resDb = resDb;
 }