internal static void ProcessValidationReport(IOutputWindow outputWindow, ValidationReporter validationReporter, bool showWarnings) { // Enumerate all validation messages and write to the output window. foreach (ValidationItem item in validationReporter.ValidationItemsList) { if (item.Severity == Severity.Error) { outputWindow.ReportStatusError(OutputWindowErrorSeverity.Error, GetErrorId(item.ValidationCode), GetValidationReporterMessage(item), item.FilePath, item.Line, item.Offset); } else if (item.Severity == Severity.Warning) { outputWindow.ReportStatusError(OutputWindowErrorSeverity.Warning, GetErrorId(item.ValidationCode), GetValidationReporterMessage(item), item.FilePath, item.Line, item.Offset); } else { outputWindow.ReportStatusMessage(GetValidationReporterMessage(item)); } } if (validationReporter.HasErrors || (showWarnings && validationReporter.HasWarnings)) { // Display the modal form as well var form = new BimlValidationListForm(validationReporter, showWarnings); form.ShowDialog(); } }
public static void ValidateRequiredProperty(ValidationReporter reporter, string propertyName, string value) { if (Varigence.Utility.Extensions.StringChecker.IsNullOrWhiteSpace(value)) { reporter.Report(Severity.Error, "Required property '{0}' was not supplied", propertyName); } }
internal static void ProcessValidationReport(IOutputWindow outputWindow, ValidationReporter validationReporter, bool showWarnings) { // Enumerate all validation messages and write to the output window. foreach (ValidationItem item in validationReporter.ValidationItemsList) { if (item.Severity == Severity.Error) { outputWindow.ReportStatusError(OutputWindowErrorSeverity.Error, GetErrorId(item.ValidationCode), GetValidationReporterMessage(item), item.FilePath, item.Line, item.Offset); } else if (item.Severity == Severity.Warning) { outputWindow.ReportStatusError(OutputWindowErrorSeverity.Warning, GetErrorId(item.ValidationCode), GetValidationReporterMessage(item), item.FilePath, item.Line, item.Offset); } else { outputWindow.ReportStatusMessage(GetValidationReporterMessage(item)); } } if (validationReporter.HasErrors || (showWarnings && validationReporter.HasWarnings)) { // Display the modal form as well var form = new BimlValidationListForm(validationReporter, showWarnings); form.ShowDialog(); } }
public void Validate(ValidationReporter reporter) { ValidationHelper.ValidateRequiredProperty(reporter, "Path", Path); if (Schema == null) { reporter.Report(Severity.Error, "Schema descriptor must be supplied"); } }
public BimlValidationListForm(ValidationReporter validationReporter) { InitializeComponent(); foreach (var validationItem in validationReporter.Errors) { listViewValidationItems.Items.Add(new ListViewItem(new string[] { validationItem.Severity.ToString(), validationItem.Message, validationItem.Recommendation, validationItem.Line.ToString(), validationItem.Offset.ToString() })); } listViewValidationItems.Columns[1].Width = -1; listViewValidationItems.Columns[2].Width = -1; }
public ValidationReporter Validate() { var reporter = new ValidationReporter(); ValidationHelper.ValidateRequiredProperty(reporter, "Name", Name); foreach (var resource in Resources) { resource.Validate(reporter); } return(reporter); }
public void Validate(ValidationReporter reporter) { if (Fields == null || Fields.Count == 0) { reporter.Report(Severity.Error, "At least one field must be supplied"); } else { foreach (var field in Fields) { field.Validate(reporter); } } }
internal static ValidationReporter GetValidationReporter(List <string> bimlScriptPaths, Project project, string projectDirectory, string tempTargetDirectory) { // ArgumentNullException - Value cannot be null. Parameter: input - Caused when using the 1.6 BIML engine version but 1.7 code, BidsHelperPhaseWorkflows xml file name mismatched. Biml vs Hadron #if KATMAI SsisVersion ssisVersion = BimlUtility.GetSsisVersion2008Variant(); ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2008, ssisVersion, SsasVersion.Ssas2008, SsisDeploymentModel.Package); #elif DENALI ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2008, SsisVersion.Ssis2012, SsasVersion.Ssas2008, DeployPackagesPlugin.IsLegacyDeploymentMode(project) ? SsisDeploymentModel.Package : SsisDeploymentModel.Project); #elif SQL2014 SsisVersion version = (SSISHelpers.GetProjectTargetVersion(project) == SSISHelpers.ProjectTargetVersion.SQLServer2012 ? SsisVersion.Ssis2012 : SsisVersion.Ssis2014); ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2008, version, SsasVersion.Ssas2008, DeployPackagesPlugin.IsLegacyDeploymentMode(project) ? SsisDeploymentModel.Package : SsisDeploymentModel.Project); #else ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2005, SsisVersion.Ssis2005, SsasVersion.Ssas2005, SsisDeploymentModel.Package); #endif return(validationReporter); }
public static void ValidateRequiredProperty(ValidationReporter reporter, string propertyName, string value, IEnumerable <string> supportedValues, IEnumerable <string> unsupportedValues) { if (Varigence.Utility.Extensions.StringChecker.IsNullOrWhiteSpace(value)) { reporter.Report(Severity.Error, "Required property '{0}' was not supplied", propertyName); } else if (!supportedValues.Contains(value)) { if (unsupportedValues != null && unsupportedValues.Contains(value)) { reporter.Report(Severity.Error, "The value '{0}' is not supported for the required property '{1}'", value, propertyName); } else { reporter.Report(Severity.Error, "The value '{0}' is not a valid value for the required property '{1}'", value, propertyName); } } }
internal static ValidationReporter GetValidationReporter(List <string> bimlScriptPaths, Project project, string projectDirectory, string tempTargetDirectory) { // ArgumentNullException - Value cannot be null. Parameter: input - Caused when using the 1.6 BIML engine version but 1.7 code, BidsHelperPhaseWorkflows xml file name mismatched. Biml vs Hadron #if SQL2016 // This is a placeholder only, as BIML doesn't support 2016 yet // Assume default of 2014 for now. SsisVersion version = SsisVersion.Ssis2014; if (SSISHelpers.GetTargetServerVersion(project) == SsisTargetServerVersion.SQLServer2012) { // Downgrade Biml target version to match project target. version = SsisVersion.Ssis2012; } ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2008, version, SsasVersion.Ssas2008, DeployPackagesPlugin.IsLegacyDeploymentMode(project) ? SsisDeploymentModel.Package : SsisDeploymentModel.Project); #elif SQL2014 ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2008, SsisVersion.Ssis2014, SsasVersion.Ssas2008, DeployPackagesPlugin.IsLegacyDeploymentMode(project) ? SsisDeploymentModel.Package : SsisDeploymentModel.Project); #elif DENALI ValidationReporter validationReporter = BidsHelper.CompileBiml(typeof(AstNode).Assembly, "Varigence.Biml.BidsHelperPhaseWorkflows.xml", "Compile", bimlScriptPaths, new List <string>(), tempTargetDirectory, projectDirectory, SqlServerVersion.SqlServer2008, SsisVersion.Ssis2012, SsasVersion.Ssas2008, DeployPackagesPlugin.IsLegacyDeploymentMode(project) ? SsisDeploymentModel.Package : SsisDeploymentModel.Project); #endif return(validationReporter); }
public BimlValidationListForm(ValidationReporter validationReporter, bool showWarnings) { InitializeComponent(); this.Icon = Resources.Common.Biml; // TODO: Get better icons, as per VS Error List, flatter, smoother, no resize requried. // Load icons into imge list, with indexes matching the enum Varigence.Flow.FlowFramework.Severity this.imageList.Images.Add(Resources.Common.Stop); this.imageList.Images.Add(Resources.Common.Stop); this.imageList.Images.Add(ResizeIcon(SystemIcons.Warning)); this.imageList.Images.Add(ResizeIcon(SystemIcons.Information)); this.imageList.Images.Add(ResizeIcon(SystemIcons.Question)); // Set font that is readable, and appears to match VS Error List font, but probably just conincidence since VS fonts can be reset in VS itself, rather than using system defaults this.dataGridView.DefaultCellStyle.Font = SystemFonts.MenuFont; // Ensure that the Image column doesn't try and render a misisng image icon, we just want it to be empty if we pass in null ((DataGridViewImageColumn)this.dataGridView.Columns[0]).DefaultCellStyle.NullValue = null; // Enumerate validation items and add them to the foreach (var validationItem in validationReporter.Errors) { this.dataGridView.Rows.Add(this.imageList.Images[(int)validationItem.Severity], validationItem.Message, validationItem.Recommendation, validationItem.Line, validationItem.Offset, Path.GetFileName(validationItem.FileName), validationItem.FilePath); } // Enumerate validation items and add them to the if (showWarnings) { foreach (var validationItem in validationReporter.Warnings) { this.dataGridView.Rows.Add(this.imageList.Images[(int)validationItem.Severity], validationItem.Message, validationItem.Recommendation, validationItem.Line, validationItem.Offset, Path.GetFileName(validationItem.FileName), validationItem.FilePath); } } // Add a final row that tells people to go and look in the Output window, coz it is cool! this.dataGridView.Rows.Add(null, "Please see the Output window for more information."); }
public BimlValidationListForm(ValidationReporter validationReporter, bool showWarnings) { InitializeComponent(); this.Icon = Resources.Common.Biml; // TODO: Get better icons, as per VS Error List, flatter, smoother, no resize requried. // Load icons into imge list, with indexes matching the enum Varigence.Flow.FlowFramework.Severity this.imageList.Images.Add(Resources.Common.Stop); this.imageList.Images.Add(Resources.Common.Stop); this.imageList.Images.Add(ResizeIcon(SystemIcons.Warning)); this.imageList.Images.Add(ResizeIcon(SystemIcons.Information)); this.imageList.Images.Add(ResizeIcon(SystemIcons.Question)); // Set font that is readable, and appears to match VS Error List font, but probably just conincidence since VS fonts can be reset in VS itself, rather than using system defaults this.dataGridView.DefaultCellStyle.Font = SystemFonts.MenuFont; // Ensure that the Image column doesn't try and render a misisng image icon, we just want it to be empty if we pass in null ((DataGridViewImageColumn)this.dataGridView.Columns[0]).DefaultCellStyle.NullValue = null; // Enumerate validation items and add them to the foreach (var validationItem in validationReporter.Errors) { this.dataGridView.Rows.Add(this.imageList.Images[(int)validationItem.Severity], validationItem.Message, validationItem.Recommendation, validationItem.Line, validationItem.Offset, Path.GetFileName(validationItem.FileName), validationItem.FilePath); } // Enumerate validation items and add them to the if (showWarnings) { foreach (var validationItem in validationReporter.Warnings) { this.dataGridView.Rows.Add(this.imageList.Images[(int)validationItem.Severity], validationItem.Message, validationItem.Recommendation, validationItem.Line, validationItem.Offset, Path.GetFileName(validationItem.FileName), validationItem.FilePath); } } // Add a final row that tells people to go and look in the Output window, coz it is cool! this.dataGridView.Rows.Add(null, "Please see the Output window for more information."); }
private void ShowValidationItems(List <string> bimlScriptPaths, Project project, string projectDirectory) { var tempTargetDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { Directory.CreateDirectory(tempTargetDirectory); // Get the General output window, we use it to write out our BIML "compilation" messages this.ApplicationObject.ToolWindows.OutputWindow.Parent.SetFocus(); IOutputWindowFactory service = ((System.IServiceProvider)project).GetService(typeof(IOutputWindowFactory)) as IOutputWindowFactory; IOutputWindow outputWindow = service.GetStandardOutputWindow(StandardOutputWindow.Build); outputWindow.Clear(); outputWindow.ReportStatusMessage("Validating BIML"); ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(true, "Checking Biml for Errors", 1, 2); ValidationReporter validationReporter = BimlUtility.GetValidationReporter(bimlScriptPaths, project, projectDirectory, tempTargetDirectory); ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(false, "Checking Biml for Errors", 2, 2); // If we have no errors and no warnings, say so if (!validationReporter.HasErrors && !validationReporter.HasWarnings) { // Write a closing message to the output window outputWindow.ReportStatusMessage("No errors or warnings were found."); outputWindow.ReportStatusMessage("BIML validation completed."); // Show message to user MessageBox.Show("No errors or warnings were found.", DefaultMessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // We have errors and/or warnings. Show both. BimlUtility.ProcessValidationReport(outputWindow, validationReporter, true); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { // Clean up the temporary directory and files, but supress any errors encountered try { if (Directory.Exists(tempTargetDirectory)) { Directory.Delete(tempTargetDirectory); } } catch (Exception) { } try { ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(false, "Checking Biml for Errors", 2, 2); } catch { } } }
public void Validate(ValidationReporter reporter) { ValidationHelper.ValidateRequiredProperty(reporter, "Name", Name); ValidationHelper.ValidateRequiredProperty(reporter, "Type", Type, new[] { "string", "integer", "number", "boolean", "datetime", "date", "time" }, new[] { "null", "object", "array", "geopoint", "geojson", "any" }); }
private void Expand(List <string> bimlScriptPaths, Project project, string projectDirectory) { var tempTargetDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { Directory.CreateDirectory(tempTargetDirectory); // Get the General output window, and use that to write out our BIML "compilation" messages this.ApplicationObject.ToolWindows.OutputWindow.Parent.SetFocus(); IOutputWindowFactory service = ((System.IServiceProvider)project).GetService(typeof(IOutputWindowFactory)) as IOutputWindowFactory; IOutputWindow outputWindow = service.GetStandardOutputWindow(StandardOutputWindow.Build); outputWindow.Clear(); outputWindow.ReportStatusMessage("Expanding BIML"); // Set status here as well as calling method, as that wasn't showing - Check and cleanup later ApplicationObject.StatusBar.Animate(true, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(true, "Generating SSIS Packages", 1, 3); ValidationReporter validationReporter = BimlUtility.GetValidationReporter(bimlScriptPaths, project, projectDirectory, tempTargetDirectory); // If we have errors show them, and finish if (validationReporter.HasErrors) { ApplicationObject.StatusBar.Animate(false, vsStatusAnimation.vsStatusAnimationDeploy); ApplicationObject.StatusBar.Progress(false, "Generating SSIS Packages", 3, 3); BimlUtility.ProcessValidationReport(outputWindow, validationReporter, false); } else { // We can compile OK, but show warnings if we have them if (validationReporter.HasWarnings) { BimlUtility.ProcessValidationReport(outputWindow, validationReporter, true); } // Write a closing message to the output window, since we have completed OK outputWindow.ReportStatusMessage("BIML expansion completed."); ApplicationObject.StatusBar.Progress(true, "Generating SSIS Packages", 2, 3); List <string> newProjectFiles = new List <string>(); string[] newPackageFiles = Directory.GetFiles(tempTargetDirectory, "*.dtsx", SearchOption.AllDirectories); newProjectFiles.AddRange(newPackageFiles); #if (!YUKON && !KATMAI) //IF DENALI or later... // Read packages AND project connection managers string[] newConnFiles = Directory.GetFiles(tempTargetDirectory, "*.conmgr", SearchOption.AllDirectories); newProjectFiles.AddRange(newConnFiles); #endif var safePackageFilePaths = new List <string>(); var conflictingPackageFilePaths = new List <string>(); foreach (var tempFilePath in newProjectFiles) { string tempFileName = Path.GetFileName(tempFilePath); string projectItemFileName = Path.Combine(projectDirectory, tempFileName); if (File.Exists(projectItemFileName)) { conflictingPackageFilePaths.Add(tempFilePath); } else { safePackageFilePaths.Add(tempFilePath); } } if (conflictingPackageFilePaths.Count > 0) { var dialog = new MultipleSelectionConfirmationDialog(conflictingPackageFilePaths, projectDirectory, safePackageFilePaths.Count); if (dialog.ShowDialog() == DialogResult.OK) { foreach (var filePath in dialog.SelectedFilePaths) { safePackageFilePaths.Add(filePath); } } else { return; } } #if (DENALI || SQL2014) /* * Make sure that the package correctly references the Project connection manager, if used */ List <ProjectConnectionManagerInfo> prjConnInfoList = new List <ProjectConnectionManagerInfo>(); // STEP 1 - Store all existing Project Connection Managers foreach (ProjectItem item in project.ProjectItems) { if (item.Name.EndsWith(".conmgr")) { string fileFullPath = item.FileNames[0]; XmlReader r = new XmlTextReader(fileFullPath); XmlDocument doc = new XmlDocument(); doc.Load(r); //XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(doc.NameTable); //xmlnsManager.AddNamespace("DTS", "www.microsoft.com/SqlServer/Dts"); XmlElement node = doc.DocumentElement; string prefix = node.GetPrefixOfNamespace("www.microsoft.com/SqlServer/Dts"); XmlAttribute xaObjectName = node.Attributes[prefix + ":ObjectName"]; XmlAttribute xaDTSID = node.Attributes[prefix + ":DTSID"]; if (xaObjectName == null) { throw new ApplicationException("ObjectName attribute cannot found."); } if (xaDTSID == null) { throw new ApplicationException("DTSID attribute cannot found."); } prjConnInfoList.Add(new ProjectConnectionManagerInfo(fileFullPath, xaObjectName.Value, xaDTSID.Value)); r.Close(); } } // STEP 2 - For all the Connection Managers that have to be inserted in the solution, // if a connection manager with the same name alread exists, use the existing GUID // to avoid corrupting the package that will be inserted foreach (var tempFilePath in safePackageFilePaths) { if (tempFilePath.EndsWith(".conmgr")) { string fileFullPath = tempFilePath; XmlReader r = new XmlTextReader(fileFullPath); XmlDocument doc = new XmlDocument(); doc.Load(r); //XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(doc.NameTable); //xmlnsManager.AddNamespace("DTS", "www.microsoft.com/SqlServer/Dts"); XmlElement node = doc.DocumentElement; string prefix = node.GetPrefixOfNamespace("www.microsoft.com/SqlServer/Dts"); bool saveRequired = false; ProjectConnectionManagerInfo pcmi = prjConnInfoList.Find(x => System.IO.Path.GetFileName(x.FileFullPath) == System.IO.Path.GetFileName(fileFullPath)); if (pcmi != null) { XmlAttribute xaDTSID = node.Attributes[prefix + ":DTSID"]; if (xaDTSID == null) { throw new ApplicationException("DTSID attribute cannot found."); } xaDTSID.Value = pcmi.DTSID; saveRequired = true; } else { XmlAttribute xaObjectName = node.Attributes[prefix + ":ObjectName"]; XmlAttribute xaDTSID = node.Attributes[prefix + ":DTSID"]; if (xaObjectName == null) { throw new ApplicationException("ObjectName attribute cannot found."); } if (xaDTSID == null) { throw new ApplicationException("DTSID attribute cannot found."); } prjConnInfoList.Add(new ProjectConnectionManagerInfo(fileFullPath, xaObjectName.Value, xaDTSID.Value)); } r.Close(); if (saveRequired) { doc.Save(fileFullPath); } } } // STEP 3 - For Each NEW package make sure that the Project Connection Manager // points to the correct GUID foreach (var tempFilePath in safePackageFilePaths) { if (tempFilePath.EndsWith(".dtsx")) { string fileFullPath = tempFilePath; XmlReader r = new XmlTextReader(fileFullPath); XmlDocument doc = new XmlDocument(); doc.Load(r); XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(doc.NameTable); xmlnsManager.AddNamespace("DTS", "www.microsoft.com/SqlServer/Dts"); XmlElement root = doc.DocumentElement; XmlNodeList nodes = root.SelectNodes("//connection", xmlnsManager); foreach (XmlNode n in nodes) { string refID = n.Attributes["connectionManagerRefId"].Value; ProjectConnectionManagerInfo pcmi = prjConnInfoList.Find(x => "Package.ConnectionManagers[" + x.ObjectName + "]" == refID); if (pcmi == null) { pcmi = prjConnInfoList.Find(x => "Project.ConnectionManagers[" + x.ObjectName + "]" == refID); } if (pcmi != null) { // If a local connection manager does NOT exists, then point to the project connection manager XmlNode node = root.SelectSingleNode("/DTS:Executable/DTS:ConnectionManagers/DTS:ConnectionManager[@DTS:refId=\"" + pcmi.ObjectName + "\"]", xmlnsManager); if (node == null) { n.Attributes["connectionManagerID"].Value = pcmi.DTSID + ":external"; n.Attributes["connectionManagerRefId"].Value = "Project.ConnectionManagers[" + pcmi.ObjectName + "]"; } } } r.Close(); doc.Save(fileFullPath); } } #endif // Add files to VS Project foreach (var tempFilePath in safePackageFilePaths) { string projectItemFilePath = Path.Combine(projectDirectory, Path.GetFileName(tempFilePath)); File.Copy(tempFilePath, projectItemFilePath, true); project.ProjectItems.AddFromFile(projectItemFilePath); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { try { if (Directory.Exists(tempTargetDirectory)) { Directory.Delete(tempTargetDirectory); } } catch (Exception) { } } }