private void BtnViewLog_Click(object sender, EventArgs e) { Button button = sender as Button; if (button == null) { return; } string logfileName = string.Empty; switch (button.Name) { case "btnViewBuildLog": logfileName = string.Concat(solutionFolderName, Constants.MSBuildLogIdentifier, Constants.LogExtension); break; case "btnViewTFLog": logfileName = string.Concat(solutionFolderName, Constants.TFSLogIdentifier, Constants.LogExtension); break; case "btnViewDeployLog": logfileName = string.Concat(solutionFolderName, Constants.AzureLogIdentifier, Constants.LogExtension); break; } if (string.IsNullOrEmpty(logfileName)) { // This case doesnot exist return; } try { string logFilePath = Path.Combine(this.logFolderPath, logfileName); using (File.OpenRead(logFilePath)) { } // This is to test the file access using (LogViewer viewer = new LogViewer(logFilePath)) { viewer.ShowDialog(this); } } catch (DirectoryNotFoundException ex) { ex.WriteToLog(); GenericMessageForLogFiles.ShowUIInformation(); } catch (FileNotFoundException ex) { ex.WriteToLog(); GenericMessageForLogFiles.ShowUIInformation(); } catch (UnauthorizedAccessException ex) { ex.WriteToLog(); GenericMessageForLogFiles.ShowUIInformation(); } catch (Exception ex) { ex.WriteToLog(); ex.ShowGenericException(); } }
/// <summary> /// Handles the Click event of the btnViewTFLog, btnViewDeployLog and btnViewBuildLog control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void BtnViewLog_Click(object sender, EventArgs e) { Button button = sender as Button; if (button == null) { return; } string path = string.Empty; switch (button.Name) { case "btnViewBuildLog": path = this.msbuildLogPath; break; case "btnViewTFLog": path = this.teamfoundationExeLogPath; break; case "btnViewDeployLog": path = this.cloudDeploymentLogPath; break; } if (string.IsNullOrEmpty(path)) { // This case doesnot exist return; } using (LogViewer viewer = new LogViewer(path)) { viewer.ShowDialog(this); } }