public void AddRun(string key, IRunnable runner, LoggerList loggers) { CancellationTokenSource tokenSource = new CancellationTokenSource(); _runs.Add(key, runner); _tokens.Add(key, tokenSource); Task task = Task.Run(() => { try { runner.Run(tokenSource.Token, loggers); } catch (OperationCanceledException e) { _tokens.Remove(key); _runs.Remove(key); } finally { tokenSource.Dispose(); } _runs.Remove(key); _tokens.Remove(key); }, tokenSource.Token); }
public void Dispose() { _catalog.Dispose(); _catalog = null; LoggerList.Clear(); LoggerList = null; }
public DebugOutputUserControl() { InitializeComponent(); viewModel = new DebugOutputViewModel(); viewModel.SearchFinished = () => LoggerList.ScrollIntoView(viewModel.DisplayLoggerMessages.LastOrDefault()); DataContext = viewModel; }
/// <summary> /// Returns a Logger object that corresponds to the given path. Creates a new one if none exists. /// </summary> /// <param name="message">The message to be writen to the Logger</param> /// <param name="forceFlush">If true will post to the Logger file no matter the PostRealTime value.</param> /// <returns>A Logger object to the given path.</returns> static public Logger GetInstance(string path) { if (LoggerList.Exists(i => i.Path == path)) { return(LoggerList.Find(i => i.Path == path)); } else { var result = new Logger(path); LoggerList.Add(result); return(LoggerList.Last()); } }
public void Run(CancellationToken taskCancelToken, LoggerList loggers) { //Create Build Object Build build = CreateBuild(); //Create Job Build logger JobBuildLogger buildLogger = new JobBuildLogger(Name, build.Number); loggers.AddLogger(buildLogger); //Start Execution buildLogger.Log(new Log("Start at " + DateTime.Now + "\n")); FailedBuildTokenSource failedTokenSource = new FailedBuildTokenSource(); try { //Create the build Environment Class.Environment env = new Class.Environment(); foreach (Property prop in Properties) { prop.Definition.Apply(env, prop.Parameters.ToArray(), failedTokenSource, loggers); CheckIfBuildCanceled(taskCancelToken, build, buildLogger); failedTokenSource.Token.ThrowIfFailed(); } env.Properties.Add("buildNumber", build.Number.ToString()); PreBuild(build, env, taskCancelToken, failedTokenSource, loggers); Build(build, env, taskCancelToken, failedTokenSource, loggers); AfterBuild(build, env, taskCancelToken, failedTokenSource, loggers); buildLogger.Log(new Log("\nBUILD SUCCESS")); buildLogger.Log(new Log("\nEnd at " + DateTime.Now)); build.Status = "SUCCESS"; } catch (OperationCanceledException e) { throw e; } catch (FailedBuildException e) { build.Status = "FAILED"; buildLogger.Log(new Log("BUILD FAILED")); buildLogger.Log(new Log("\nEnd at " + DateTime.Now)); } }
private void FindClick(object sender, System.Windows.RoutedEventArgs e) { if (!findWindowOpened) { Action <LoggerMessageViewModel> action = new Action <LoggerMessageViewModel>((loggerMessage) => { LoggerList.ScrollIntoView(loggerMessage); viewModel.SelectedLoggerMessage = loggerMessage; }); findWindow = new FindWindow(viewModel.DisplayLoggerMessages, action); findWindow.Closed += FindWindow_Closed; findWindow.Show(); findWindowOpened = true; } }
public void RunJob(JobRunModel model) { //Instanciate plugins depending on class name Job job = PluginStorage.CreateObject <Job>( //Go Fetch class name from config file JObject.Parse(File.ReadAllText("jobs\\" + model.Name + "\\config.json")).Value <string>("_class") ); //Load job from folder configuration job.LoadFromFolder("jobs", model.Name); //Create Logger list for the run LoggerList loggers = new LoggerList(); //Add Standard logger in the logger list loggers.AddLogger(new StandardLogger()); //Add job build in the process with his name as key and provide log _threadApplication.AddRun(model.Name, job, loggers); }
/// <summary> /// Initializes a new instance of the <see cref="ChainedLogger"/> class /// by using the specified logger. /// </summary> /// <param name="logger">The first logger of the chain.</param> /// <remarks> /// The first logger of the chain will dictate the behavior of the methods /// used to check if a particular level is enabled or not. Note that the /// first logger dictates onle the level of the <see cref="ChainedLogger"/> /// class, each logger uses it own level to perform logging /// operations. /// </remarks> public ChainedLogger(ILogger logger) { logger_chain_ = new LoggerList(logger); main_logger_ = logger; }
public abstract void Build(Build build, Class.Environment env, CancellationToken taskCancelToken, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers);
public virtual void AfterBuild(Build build, Class.Environment env, CancellationToken taskCancelToken, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers) { }
public abstract void Apply(Environment env, Parameter[] parameters, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers);
public sealed override void Apply(Environment env, Parameter[] parameters, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers) { foreach (Parameter parameter in parameters) { env.Properties.Add(parameter.Name, parameter.Value); } }
public sealed override void Build(Build build, Environment env, CancellationToken taskCancelToken, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers) { foreach (BuildStep step in BuildSteps) { step.Apply(env, failedBuildTokenSource, loggers); CheckIfBuildCanceled(taskCancelToken, build, loggers.GetLogger <JobBuildLogger.JobBuildLogger>()); failedBuildTokenSource.Token.ThrowIfFailed(); } }
public sealed override void AfterBuild(Build build, Environment env, CancellationToken taskCancelToken, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers) { }
public sealed override void Apply(Environment env, Parameter[] parameters, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers) { env.Properties.Add("node", parameters.Single(o => o.Name == "label").Value); }
//複数のLoggerを返して、一気に書き込める。 public static ILogger g(string[] filenames) { LoggerList loggers = new LoggerList(); foreach (var filename in filenames) { loggers.Add(g(filename.Trim())); } return loggers; }
public sealed override void Apply(Environment env, Parameter[] parameters, FailedBuildTokenSource failedBuildTokenSource, LoggerList loggers) { string command = parameters.Single(o => o.Name == "command").Value; ProcessStartInfo processInfo = new ProcessStartInfo("cmd.exe", "/c " + command); string directory = Path.Combine(System.Environment.CurrentDirectory, "jobs", env.Properties["jobName"]); JobBuildLogger.JobBuildLogger buildLogger = loggers.GetLogger <JobBuildLogger.JobBuildLogger>(); buildLogger.Log(new Log("[windows-batch] : " + command)); Process process = new Process(); process.StartInfo.WorkingDirectory = directory; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.OutputDataReceived += (sender, args) => buildLogger.Log(new Log(args.Data)); process.ErrorDataReceived += (sender, args) => buildLogger.Log(new Log(args.Data)); foreach (KeyValuePair <string, string> prop in env.Properties) { process.StartInfo.Environment.Add(prop.Key.ToUpper(), prop.Value); } Node node = new Node() { WorkSpace = "C:", IpAddress = "machine" }; node.Execute(process, command); process.BeginErrorReadLine(); process.BeginOutputReadLine(); process.WaitForExit(); if (process.ExitCode != 0) { failedBuildTokenSource.Failed(); } }
private static LoggerList all() { LoggerList logs = new LoggerList(); foreach (var key in logDict.Keys) { if ( ! key.Contains(',') ) { logs.Add(logDict[key]); } } MakeUndeclaredName = false; return logs; }