本文整理汇总了C#中Package.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Package.Validate方法的具体用法?C# Package.Validate怎么用?C# Package.Validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package.Validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Learn
public void Learn()
{
string packageLocation = Path.Combine(Path.Combine(location, packageFolder), errorPackageName);
try
{
ssisApplication = new Application();
package = ssisApplication.LoadPackage(packageLocation, null);
DTSExecResult result = package.Validate(null, null, null, null);
//errors = package.Errors;
//foreach (DtsError dtsError in errors)
//{
// Console.WriteLine(dtsError.Description);
// Console.WriteLine(dtsError.Source);
// Console.WriteLine(dtsError.ErrorCode);
//}
package.Execute();
errors = package.Errors;
foreach (DtsError dtsError in errors)
{
Console.WriteLine(dtsError.Description);
Console.WriteLine(dtsError.Source);
Console.WriteLine(dtsError.ErrorCode);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
package.Dispose();
}
}
示例2: ValidatePackage
private void ValidatePackage(Package package)
{
Microsoft.DataTransformationServices.Design.ComponentModel.EventHandlerErrorCollector events = new Microsoft.DataTransformationServices.Design.ComponentModel.EventHandlerErrorCollector();
DTSExecResult result = package.Validate(package.Connections, package.Variables, events, null);
List<string> listOtherErrors = new List<string>();
listOtherErrors.AddRange(RecurseContainersAndGetVariableValidationErrors(package));
foreach (Window w in this.ApplicationObject.Windows)
{
IDesignerHost designer = w.Object as IDesignerHost;
if (designer == null) continue;
EditorWindow win = designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)) as EditorWindow;
if (win == null) continue;
if ((win.PropertiesLinkComponent as Package) == package)
{
AddErrorsToVSErrorList(w, listOtherErrors.ToArray());
break;
}
}
foreach (KeyValuePair<IComponent, ICollection<IComponentErrorInfo>> pair in events.ComponentIssuesMap)
{
IComponent key = pair.Key;
System.Collections.ICollection issues = (System.Collections.ICollection)pair.Value;
IDesignerHost host = (IDesignerHost)packageDesigner.GetType().InvokeMember("DesignerHost", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, packageDesigner, null);
IDesigner containerDesigner = host.GetDesigner(key);
if (containerDesigner != null)
{
Type t = FindBaseType(containerDesigner.GetType(), "DtsContainerDesigner");
if (t == null) continue;
//doesn't work... not sure why... so the following is the equivalent of this one line:
//t.InvokeMember("OnContainerValidated", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, containerDesigner, new object[] { result, issues });
Microsoft.DataTransformationServices.Design.ComponentModel.ComponentValidationEventArgs e = new Microsoft.DataTransformationServices.Design.ComponentModel.ComponentValidationEventArgs(containerDesigner.Component);
e.Issues = issues;
e.ValidationFailed = (issues != null) && (issues.Count > 0);
//doesn't work... not sure why... so the following is the equivalent of this one line:
//containerDesigner.GetType().InvokeMember("RaiseValidationEvent", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, containerDesigner, new object[] { e });
t.InvokeMember("PostTaskListValidationMessages", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance, null, containerDesigner, new object[] { e });
object componentValidationService = t.InvokeMember("componentValidationService", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance, null, containerDesigner, null);
componentValidationService.GetType().InvokeMember("OnValidated", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, componentValidationService, new object[] { e });
}
}
}
示例3: WriteParentPackage
private static void WriteParentPackage(string baseDirectoryPath, Project project,
string parentPackageName, string[] childPackageNames)
{
DTSExecResult dtsExecResult;
IDTSEvents dtsEvents;
if ((object)project == null)
throw new ArgumentNullException(nameof(project));
if ((object)parentPackageName == null)
throw new ArgumentNullException(nameof(parentPackageName));
if ((object)childPackageNames == null)
throw new ArgumentNullException(nameof(childPackageNames));
Console.WriteLine("*** {0} ***", parentPackageName);
using (Package package = new Package())
{
project.PackageItems.Add(package, parentPackageName);
TaskHost executePackageTaskHost;
ExecutePackageTask executePackageTask;
int index;
index = 0;
foreach (string childPackageName in childPackageNames)
{
// create SQL task
executePackageTaskHost = (TaskHost)package.Executables.Add("STOCK:ExecutePackageTask");
executePackageTaskHost.Name = string.Format("Execute Package Task ({0})", index++);
// get inner object
executePackageTask = (ExecutePackageTask)executePackageTaskHost.InnerObject;
executePackageTask.PackageName = childPackageName;
}
WriteParentPackageApplication(baseDirectoryPath, package, parentPackageName);
dtsEvents = new ConsoleEvents();
dtsExecResult = package.Validate(null, null, dtsEvents, null);
}
}