public void SetUp() { _sut = new GetVersionParts(); _taskLogger = _taskLogger.Fake(); _sut.Logger = _taskLogger; }
protected AwsTaskBase(IAwsClientFactory awsClientFactory, ITaskLogger logger) : this(awsClientFactory) { if (logger == null) throw new ArgumentNullException("logger"); Logger = logger; }
public void Cancel(ITaskLogger taskLogger, CancellationToken cancellationToken) { taskLogger.Log("ExecutionHandler.Cancel"); // create timelinerecord if not provided // initialize logger // cancel }
public void SetUp() { _sut = new DecryptForLocalMachineScope(); _taskLogger = A.Fake<ITaskLogger>(); _sut.Logger = _taskLogger; }
internal PublishFiles(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, bool publicRead = true, ITaskLogger logger = null) : base(s3ClientFactory, timeoutMilliseconds, publicRead, logger) { }
internal EnumerateBuckets(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, int bufferSizeKilobytes = DefaultBufferSizeKilobytes, ITaskLogger logger = null) : base(s3ClientFactory, timeoutMilliseconds, bufferSizeKilobytes, logger) { }
public void SetUp() { _sut = new EncryptForLocalMachineScope(); _taskLogger = A.Fake <ITaskLogger>(); _sut.Logger = _taskLogger; }
internal PublishBase(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds, bool publicRead = true, ITaskLogger logger = null) : base(s3ClientFactory, timeoutMilliseconds, logger) { PublicRead = publicRead; }
public const int DefaultRequestTimeout = 300000; // 5 min default timeout protected S3Base(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, ITaskLogger logger = null) { _s3ClientFactory = s3ClientFactory; _logger = logger; TimeoutMilliseconds = timeoutMilliseconds; }
internal PublishFilesWithHeaders(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, int bufferSizeKilobytes = DefaultBufferSizeKilobytes, bool publicRead = true, ITaskLogger logger = null) : base(s3ClientFactory, timeoutMilliseconds, bufferSizeKilobytes, publicRead, logger) { }
/// <summary> /// Attempts to check if the repository has uncommitted changes. /// </summary> /// <param name="gitRunner"></param> /// <param name="logger"></param> /// <returns></returns> public static GitInfo GetGitStatus(IGitRunner gitRunner, ITaskLogger logger) { GitInfo status = new GitInfo(); try { string statusText = gitRunner.GetTextFromProcess(GitArgument.Status); Match match = StatusBranchSearch.Match(statusText); if (match.Success && match.Groups.Count > 1) { string branch = match.Groups[1].Value; status.Branch = branch; } else { Match detatchedMatch = DetatchedBranchSearch.Match(statusText); if (detatchedMatch.Success && detatchedMatch.Groups.Count > 1) { string branch = detatchedMatch.Groups[1].Value; status.Branch = branch; if (branch.StartsWith("pull/")) { status.IsPullRequest = true; } } } if (string.IsNullOrWhiteSpace(status.Branch)) { logger.LogMessage(MessageImportance.High, $"Unable to retrieve branch name from status text: \n{statusText}"); } statusText = statusText.ToUpper(); if (statusText.Contains(UnmodifiedText) || statusText.Contains(UntrackedOnlyText)) { status.Modified = "Unmodified"; } else { status.Modified = "Modified"; } } catch (GitRunnerException ex) { logger?.LogWarning($"Error getting 'git status': {ex.Message}"); } try { status.OriginUrl = gitRunner.GetTextFromProcess(GitArgument.OriginUrl); if (status.OriginUrl != null && status.OriginUrl.Length > 0) { status.GitUser = GetGitHubUser(status.OriginUrl); } } catch (GitRunnerException ex) { logger?.LogWarning($"Error getting git origin URL: {ex.Message}"); } return(status); }
public void SetUp() { _sut = new DecryptForLocalMachineScope(); _taskLogger = _taskLogger.Fake(); _sut.Logger = _taskLogger; _decryptForLocalMachineScopeQueryHandler = _decryptForLocalMachineScopeQueryHandler.Fake(); _sut.DecryptForLocalMachineScopeQueryHandler = _decryptForLocalMachineScopeQueryHandler; }
public void SetUp() { _sut = new EncryptForLocalMachineScope(); _taskLogger = _taskLogger.Fake(); _sut.Logger = _taskLogger; _encryptForLocalMachineScopeQueryHandler = _encryptForLocalMachineScopeQueryHandler.Fake(); _sut.EncryptForLocalMachineScopeQueryHandler = _encryptForLocalMachineScopeQueryHandler; }
protected S3Base(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, int bufferSizeKilobytes = DefaultBufferSizeKilobytes, ITaskLogger logger = null) { _s3ClientFactory = s3ClientFactory; _logger = logger; TimeoutMilliseconds = timeoutMilliseconds; BufferSizeKilobytes = bufferSizeKilobytes; }
protected AwsTaskBase(IAwsClientFactory awsClientFactory, ITaskLogger logger) : this(awsClientFactory) { if (logger == null) { throw new ArgumentNullException("logger"); } Logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="GitHubTagger"/> class. /// </summary> /// <param name="createCommand"> /// The command for creating a tag. /// </param> /// <param name="logger"> /// The task logger. /// </param> public GitHubTagger(ICreateTagCommand createCommand, ITaskLogger logger) { if (createCommand == null) throw new ArgumentNullException("createCommand"); if (logger == null) throw new ArgumentNullException("logger"); this.createCommand = createCommand; this.logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="NugetPackageDeleter"/> class. /// </summary> /// <param name="deleteCommand"> /// The command for deleting a nuget package. /// </param> /// <param name="logger"> /// The task logger. /// </param> public NugetPackageDeleter(IDeletePackageCommand deleteCommand, ITaskLogger logger) { if (deleteCommand == null) throw new ArgumentNullException("deleteCommand"); if (logger == null) throw new ArgumentNullException("logger"); this.deleteCommand = deleteCommand; this.logger = logger; }
public CopyToAzureStorage(IAzureBlobClientFactory blobClientWrapper, ITaskLogger taskLogger, IFileManager fileManager) { if (taskLogger == null) taskLogger = new LoggingHelperWrapper(this); this.logger = taskLogger; this.fileManager = fileManager; this.blobClientWrapper = blobClientWrapper; this.StorageClientTimeoutInMinutes = 30; this.ParallelOptionsThreadCount = 1; }
public ArchiverForm(ITaskLogger taskLogger) { _taskLogger = taskLogger; InitializeComponent(); var allTasks = _taskLogger.LoadAllTasks(); var taskGridItems = GetTaskGridItems(allTasks); ActiveTaskGridControl.DataSource = taskGridItems; var archivedTasks = _taskLogger.LoadArchivedTasks(); var archiveTaskGridItems = GetTaskGridItems(archivedTasks); ArchivedGridControl.DataSource = archiveTaskGridItems; }
public TaskTimer([NotNull] ITaskLogger taskLogger, [NotNull] MenuManager menuManager) { _taskLogger = taskLogger; _menuManager = menuManager; _menuManager.InitializeNewTrayIcon(this); _menuManager.PropertyChanged += MenuManagerOnPropertyChanged; _taskItems = _taskLogger.LoadTaskList(); _menuManager.AddMenuItems(_taskItems); _currentDayOfMonth = GetCurrentDayOfMonth(); Application.ApplicationExit += OnApplicationExit; }
/// <summary> /// Initializes a new instance of the <see cref="GitHubTagger"/> class. /// </summary> /// <param name="createCommand"> /// The command for creating a tag. /// </param> /// <param name="logger"> /// The task logger. /// </param> public GitHubTagger(ICreateTagCommand createCommand, ITaskLogger logger) { if (createCommand == null) { throw new ArgumentNullException("createCommand"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.createCommand = createCommand; this.logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="NugetPackageDeleter"/> class. /// </summary> /// <param name="deleteCommand"> /// The command for deleting a nuget package. /// </param> /// <param name="logger"> /// The task logger. /// </param> public NugetPackageDeleter(IDeletePackageCommand deleteCommand, ITaskLogger logger) { if (deleteCommand == null) { throw new ArgumentNullException("deleteCommand"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.deleteCommand = deleteCommand; this.logger = logger; }
/// <summary> /// Executes the task. /// </summary> /// <returns>true if successful</returns> public override bool Execute() { if (this.BuildEngine != null) { Logger = new LogWrapper(Log); } else { Logger = new MockTaskLogger(); } string errorCode = null; try { if (string.IsNullOrEmpty(ProcessName)) { errorCode = MessageCodes.IsProcessRunning.EmptyProcessName; throw new ArgumentNullException(nameof(ProcessName), $"{nameof(ProcessName)} cannot be empty."); } foreach (Process proc in Process.GetProcesses()) { if (proc.ProcessName.Contains(ProcessName)) { IsRunning = true; break; } } return(true); } catch (Exception ex) { if (string.IsNullOrEmpty(errorCode)) { errorCode = MessageCodes.IsProcessRunning.GeneralFailure; } if (BuildEngine != null) { int line = BuildEngine.LineNumberOfTaskNode; int column = BuildEngine.ColumnNumberOfTaskNode; Logger.LogError(null, errorCode, null, BuildEngine.ProjectFileOfTaskNode, line, column, line, column, $"Error in {GetType().Name}: {ex.Message}"); } else { Logger.LogError(null, errorCode, null, null, 0, 0, 0, 0, $"Error in {GetType().Name}: {ex.Message}"); } return(false); } }
/// <summary> /// Attempts to retrieve the git commit hash using the 'git' program. /// </summary> /// <param name="gitRunner"></param> /// <param name="logger"></param> /// <param name="commitHash"></param> /// <returns></returns> public static bool TryGetGitCommit(IGitRunner gitRunner, ITaskLogger logger, out string commitHash) { commitHash = null; try { string outText = gitRunner.GetTextFromProcess(GitArgument.CommitHash); if (outText.Length > 0) { commitHash = outText; return(true); } } catch (GitRunnerException ex) { logger?.LogWarning($"Error getting commit hash from 'git' command: {ex.Message}"); } return(false); }
/// <summary> /// Attempts to check if the repository has uncommitted changes. /// </summary> /// <param name="gitRunner"></param> /// <param name="logger"></param> /// <returns></returns> public static GitInfo GetGitStatus(IGitRunner gitRunner, ITaskLogger logger) { GitInfo status = new GitInfo(); try { string statusText = gitRunner.GetTextFromProcess(GitArgument.Status); Match match = StatusBranchSearch.Match(statusText); if (match.Success && match.Groups.Count > 1) { string branch = match.Groups[1].Value; status.Branch = branch; } statusText = statusText.ToUpper(); if (statusText.Contains(UnmodifiedText) || statusText.Contains(UntrackedOnlyText)) { status.Modified = "Unmodified"; } else { status.Modified = "Modified"; } } catch (GitRunnerException ex) { logger?.LogWarning($"Error getting 'git status': {ex.Message}"); } try { status.OriginUrl = gitRunner.GetTextFromProcess(GitArgument.OriginUrl); if (status.OriginUrl != null && status.OriginUrl.Length > 0) { status.GitUser = GetGitHubUser(status.OriginUrl); } } catch (GitRunnerException ex) { logger?.LogWarning($"Error getting git origin URL: {ex.Message}"); } return(status); }
/// <summary> /// Executes the task. /// </summary> /// <returns></returns> public override bool Execute() { if (this.BuildEngine != null) { Logger = new LogWrapper(Log, GetType().Name); } else { Logger ??= new MockTaskLogger(GetType().Name); } try { var manifest = MakeManifest(); manifest.Validate(RequiresBsipa); WriteManifest(manifest, TargetPath); BasePluginVersion = Util.StripVersionLabel(manifest.Version); PluginVersion = manifest.Version; return(true); } catch (ManifestValidationException ex) { // Generated manifest not valid. Logger.LogErrorFromException(ex); } catch (ArgumentException ex) { // Base manifest specified but doesn't exist. Logger.LogErrorFromException(ex); } catch (IOException ex) { // Base JSON read failed or write failed. Logger.LogErrorFromException(ex); } catch (Exception ex) { Logger.LogErrorFromException(ex); } return(false); }
/// <summary> /// Logs an error from the <see cref="ParsingException"/> using the given <see cref="ITaskLogger"/>. /// </summary> /// <param name="ex"></param> /// <param name="file"></param> /// <param name="position"></param> /// <param name="Log"></param> public static void LogErrorFromException(this ParsingException ex, ITaskLogger Log, string file, FilePosition position) { Log.LogError(null, ex.MessageCode, "", file, position, ex.Message, ex.MessageArgs); }
/// <summary> /// Logs an error from the <see cref="ParsingException"/> using the given <see cref="ITaskLogger"/>. /// </summary> /// <param name="ex"></param> /// <param name="Log"></param> public static void LogErrorFromException(this ParsingException ex, ITaskLogger Log) { Log.LogError(null, ex.MessageCode, "", ex.File, ex.LineNumber, ex.ColumnNumber, ex.EndLineNumber, ex.EndColumnNumber, ex.Message, ex.MessageArgs); }
internal PublishFilesWithHeaders(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, bool publicRead = true, ITaskLogger logger = null) : base(s3ClientFactory, timeoutMilliseconds, publicRead, logger) { }
internal EnumerateBuckets(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds = DefaultRequestTimeout, ITaskLogger logger = null) : base(s3ClientFactory, timeoutMilliseconds, logger) { }
protected TaskAbstract(ITaskLogger logger) { Logger = logger; }
public SendSQSMessageTask(IAwsClientFactory awsClientFactory, ITaskLogger logger) : base(awsClientFactory, logger) { }
public ModuleApiRequestCountSyncTask(ITaskLogger logger, IModuleService moduleService) : base(logger) { _moduleService = moduleService; }
public CreateSQSQueueTask(IAwsClientFactory awsClientFactory, ITaskLogger logger) : base(awsClientFactory, logger) { }
internal DeleteChildren(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds, ITaskLogger logger) : base(s3ClientFactory, timeoutMilliseconds, logger) { }
public void CancelAsync(ITaskLogger taskLogger, CancellationToken cancellationToken) { throw new NotImplementedException(); }
/// <summary> /// Executes the task. /// </summary> /// <returns>true if successful</returns> public override bool Execute() { if (this.BuildEngine != null) { Logger = new LogWrapper(Log, GetType().Name, MessagePrefix); } else { Logger = new MockTaskLogger(GetType().Name); } string errorCode = null; try { FileInfo zipFile = new FileInfo(DestinationFile); DirectoryInfo zipDir = zipFile.Directory; zipDir.Create(); zipDir.Refresh(); if (zipFile.Exists) { zipFile.Delete(); } if (string.IsNullOrEmpty(SourceDirectory)) { errorCode = MessageCodes.ZipDir.ZipEmptySource; throw new ArgumentNullException($"{nameof(SourceDirectory)} cannot be null or empty."); } if (string.IsNullOrEmpty(DestinationFile)) { errorCode = MessageCodes.ZipDir.ZipEmptyDestination; throw new ArgumentNullException($"{nameof(DestinationFile)} cannot be null or empty."); } if (!Directory.Exists(SourceDirectory)) { errorCode = MessageCodes.ZipDir.ZipMissingSource; throw new DirectoryNotFoundException($"{nameof(SourceDirectory)} '{SourceDirectory}' not found."); } Logger.LogMessage(MessageImportance.High, "Zipping Directory \"{0}\" to \"{1}\"", SourceDirectory, DestinationFile); ZipFile.CreateFromDirectory(SourceDirectory, DestinationFile); ZipPath = zipFile.FullName; return(true); } catch (Exception ex) { if (string.IsNullOrEmpty(errorCode)) { errorCode = MessageCodes.ZipDir.ZipFailed; } if (BuildEngine != null) { int line = BuildEngine.LineNumberOfTaskNode; int column = BuildEngine.ColumnNumberOfTaskNode; Logger.LogError(null, errorCode, null, BuildEngine.ProjectFileOfTaskNode, line, column, line, column, $"$Error in {GetType().Name}: {ex.Message}"); } else { Logger.LogError(null, errorCode, null, null, 0, 0, 0, 0, $"Error in {GetType().Name}: {ex.Message}"); } return(false); } }
internal DeleteBucket(IS3ClientFactory s3ClientFactory, int timeoutMilliseconds, int bufferSizeKilobytes, ITaskLogger logger) : base(s3ClientFactory, timeoutMilliseconds, bufferSizeKilobytes, logger) { }
/// <summary> /// Executes the task. /// </summary> /// <returns>true if successful</returns> public override bool Execute() { if (this.BuildEngine != null) { Logger = new LogWrapper(Log); } else { Logger = new MockTaskLogger(); } string errorCode = ""; try { if (string.IsNullOrEmpty(File)) { errorCode = MessageCodes.ReplaceInFile.EmptyFile; throw new ArgumentNullException(null, $"'{nameof(File)}' is null or empty."); } FileInfo sourceFile = new FileInfo(File); if (!sourceFile.Exists) { errorCode = MessageCodes.ReplaceInFile.MissingSource; throw new FileNotFoundException($"File '{sourceFile.FullName}' does not exist."); } if (string.IsNullOrEmpty(Pattern)) { errorCode = MessageCodes.ReplaceInFile.EmptyPattern; throw new ArgumentNullException(null, $"{nameof(Pattern)} cannot be null or empty."); } if (Substitute == null) { Substitute = ""; } string fileText = System.IO.File.ReadAllText(sourceFile.FullName); if (EscapeBackslash) { Substitute = Substitute.Replace(@"\", @"\\"); } Logger.LogMessage(MessageImportance.High, $"Replacing '{Pattern}' with '{Substitute}' in {sourceFile.FullName}"); fileText = ReplaceText(fileText); System.IO.File.WriteAllText(sourceFile.FullName, fileText); return(true); } catch (Exception ex) { if (string.IsNullOrEmpty(errorCode)) { errorCode = MessageCodes.ReplaceInFile.ReplaceFailed; } if (BuildEngine != null) { int line = BuildEngine.LineNumberOfTaskNode; int column = BuildEngine.ColumnNumberOfTaskNode; Logger.LogError(null, errorCode, null, BuildEngine.ProjectFileOfTaskNode, line, column, line, column, $"{GetType().Name} failed - {ex.Message}"); } else { Logger.LogError(null, errorCode, null, null, 0, 0, 0, 0, $"Error in {GetType().Name}: {ex.Message}"); } return(false); } }
public CreateUserTask(IAwsClientFactory awsClientFactory, ITaskLogger logger) : base(awsClientFactory, logger) { }
public HttpTask(ITaskLogger logger, IJobRepository repository, IJobHttpRepository httpRepository, IHttpClientFactory clientFactory) : base(logger) { _repository = repository; _httpRepository = httpRepository; _clientFactory = clientFactory; }
/// <summary> /// Executes the task. /// </summary> /// <returns>true if successful</returns> public override bool Execute() { if (this.BuildEngine != null) { Logger = new LogWrapper(Log, GetType().Name); } else { Logger = new MockTaskLogger(GetType().Name); } PlatformID platform = Environment.OSVersion.Platform; if (platform != PlatformID.Win32NT) { Logger.LogMessage(MessageImportance.High, $"This task isn't supported on platform: '{platform}'"); IsRunning = Fallback; return(true); } string errorCode = null; try { if (ProcessName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { ProcessName = Path.GetFileNameWithoutExtension(ProcessName); } if (string.IsNullOrEmpty(ProcessName)) { errorCode = MessageCodes.IsProcessRunning.EmptyProcessName; throw new ArgumentNullException(nameof(ProcessName), $"{nameof(ProcessName)} cannot be empty."); } foreach (Process proc in Process.GetProcesses()) { if (proc.ProcessName.Contains(ProcessName)) { IsRunning = true; break; } } return(true); } catch (Exception ex) { if (string.IsNullOrEmpty(errorCode)) { errorCode = MessageCodes.IsProcessRunning.GeneralFailure; } int line = 0; int column = 0; string projectFile = null; if (BuildEngine != null) { line = BuildEngine.LineNumberOfTaskNode; column = BuildEngine.ColumnNumberOfTaskNode; projectFile = BuildEngine.ProjectFileOfTaskNode; } Logger.LogError(null, errorCode, null, projectFile, line, column, line, column, $"Error in {GetType().Name}: {ex.Message}"); IsRunning = Fallback; return(true); } }