本文整理汇总了C#中Package.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Package.Dispose方法的具体用法?C# Package.Dispose怎么用?C# Package.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Main
//.........这里部分代码省略.........
myVirtualInputColCondSplit,
vColumn.LineageID,
DTSUsageType.UT_READONLY);
}
//conditional transform
var newOutputCollection = myTransformMeta.OutputCollection.New();
newOutputCollection.Name = "MyConditionalSplitName";
newOutputCollection.HasSideEffects = false;
newOutputCollection.ExclusionGroup = 1;
newOutputCollection.ExternalMetadataColumnCollection.IsUsed = false;
newOutputCollection.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
newOutputCollection.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
newOutputCollection.ErrorOrTruncationOperation = "Computation";//WTH is this?
newOutputCollection.SynchronousInputID = myTransformMeta.InputCollection[0].ID;
//transformation condition
IDTSCustomProperty100 myCondSplitProps = newOutputCollection.CustomPropertyCollection.New();
myCondSplitProps.ContainsID = true;
myCondSplitProps.Name = "Expression";
myCondSplitProps.Value = "[WORKING_OFC_CODE] == \"1276\""; //SSIS Expression are not the same as T-SQL
myCondSplitProps.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;
myCondSplitProps = newOutputCollection.CustomPropertyCollection.New();
myCondSplitProps.Name = "FriendlyExpression";
myCondSplitProps.Value = "[WORKING_OFC_CODE] == \"1276\"";
myCondSplitProps.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;
myCondSplitProps = newOutputCollection.CustomPropertyCollection.New();
myCondSplitProps.Name = "EvaluationOrder";
myCondSplitProps.Value = "0";
myCondSplitProps.ExpressionType = DTSCustomPropertyExpressionType.CPET_NOTIFY;
//destination OLEDB Component
var myNativeDest = myMainPipe.ComponentMetaDataCollection.New();
myNativeDest.ComponentClassID = "DTSAdapter.OLEDBDestination";
var myManagedDest = myNativeDest.Instantiate();
myManagedDest.ProvideComponentProperties();
//destination requires a connection
if (myNativeDest.RuntimeConnectionCollection.Count > 0)
{
myNativeDest.RuntimeConnectionCollection[0].ConnectionManager =
DtsConvert.GetExtendedInterface(myPackage.Connections[1]);
myNativeDest.RuntimeConnectionCollection[0].ConnectionManagerID = myPackage.Connections[1].ID;
}
myManagedDest.SetComponentProperty("AccessMode", 3);
myManagedDest.SetComponentProperty("OpenRowset", "[dbo].[wwhs_app]");
myManagedDest.AcquireConnections(null);
myManagedDest.ReinitializeMetaData();
myManagedDest.ReleaseConnections();
var myTransformToDestPath = myMainPipe.PathCollection.New();
myTransformToDestPath.AttachPathAndPropagateNotifications(myTransformMeta.OutputCollection["MyConditionalSplitName"],
myNativeDest.InputCollection[0]);
IDTSInput100 destInputCollection = myNativeDest.InputCollection[0];
IDTSVirtualInput100 destInputVirtualCollection = destInputCollection.GetVirtualInput();
foreach(IDTSVirtualInputColumn100 vColumn in destInputVirtualCollection.VirtualInputColumnCollection)
{
IDTSInputColumn100 cCol = myManagedDest.SetUsageType(destInputCollection.ID,
destInputVirtualCollection,
vColumn.LineageID,
DTSUsageType.UT_READWRITE);
var cinputColumnName = vColumn.Name;
var columnExists = (from item in
destInputCollection.ExternalMetadataColumnCollection.Cast
<IDTSExternalMetadataColumn100>()
where item.Name == cinputColumnName
select item).Count();
if(columnExists > 0)
{
myManagedDest.MapInputColumn(destInputCollection.ID,
cCol.ID,
destInputCollection.ExternalMetadataColumnCollection[vColumn.Name].
ID);
}
}
var myApplication = new Application();
myApplication.SaveToXml(@"C:\Projects\31g\trunk\temp\MySSISPackageFromCode.dtsx", myPackage, null);
myPackage.Execute();
myPackage.Dispose();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
Console.ReadKey();
}