当前位置: 首页>>代码示例>>C#>>正文


C# Application.SaveToXml方法代码示例

本文整理汇总了C#中Application.SaveToXml方法的典型用法代码示例。如果您正苦于以下问题:C# Application.SaveToXml方法的具体用法?C# Application.SaveToXml怎么用?C# Application.SaveToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application的用法示例。


在下文中一共展示了Application.SaveToXml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test2A

        public static void Test2A()
        {
            Package p = new Package();
            Executable e = p.Executables.Add("STOCK:PipelineTask");
            TaskHost thMainPipe = e as TaskHost;
            thMainPipe.Name = "mainPipe";

            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;
            Application app = new Application();
            app.SaveToXml("Test2A.dtsx", p, null);
            Console.WriteLine("done");
            Console.ReadLine();
        }
开发者ID:ismailmu,项目名称:SSISGen,代码行数:13,代码来源:Test2.cs

示例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();
        }
开发者ID:nofuture-git,项目名称:31g,代码行数:101,代码来源:_SSISCondSplitExample.cs

示例3: SavePackage

		public void SavePackage(String path)
		{
			Application app = new Application();
			app.SaveToXml(path, package, null);

		}
开发者ID:japj,项目名称:sqlsrvintegrationsrv,代码行数:6,代码来源:PackageGeneration.cs

示例4: Test1C

        //menggunakan langsung komponent SSIS nya seperti komponen FileSystemTask dan BulkInsertTask
        //sehingga perlu import reference masing - masing komponent
        public static void Test1C()
        {
            Package p = new Package();
            // Add a File System task to the package.
            Executable exec1 = p.Executables.Add("STOCK:FileSystemTask");
            TaskHost thFileSystemTask = exec1 as TaskHost;
            thFileSystemTask.Name = "fileSystemTask";

            // Add a Bulk Insert task to the package.
            Executable exec2 = p.Executables.Add("STOCK:BulkInsertTask");
            TaskHost thBulkInsertTask = exec2 as TaskHost;
            thBulkInsertTask.Name = "bulkInsertTask";

            // Iterate through the package Executables collection.
            Executables pExecs = p.Executables;
            foreach (Executable pExec in pExecs)
            {
                TaskHost taskHost = (TaskHost)pExec;
                if (taskHost.InnerObject is Microsoft.SqlServer.Dts.Tasks.FileSystemTask.FileSystemTask)
                {
                    // Do work with FileSystemTask here.
                    Console.WriteLine("Found task of type {0}", taskHost.InnerObject.ToString());
                }
                else if (taskHost.InnerObject is Microsoft.SqlServer.Dts.Tasks.BulkInsertTask.BulkInsertTask)
                {
                    // Do work with BulkInsertTask here.
                    Console.WriteLine("Found task of type {0}", taskHost.InnerObject.ToString());
                }
                // Add additional statements to check InnerObject, if desired.
            }
            PrecedenceConstraint pcFlow = p.PrecedenceConstraints.Add(thFileSystemTask, thBulkInsertTask);
            pcFlow.Value = DTSExecResult.Success;
            Application app = new Application();
            app.SaveToXml("Test1C.dtsx", p, null);
            Console.Read();
        }
开发者ID:ismailmu,项目名称:SSISGen,代码行数:38,代码来源:Test1.cs

示例5: Test1E

        public static void Test1E()
        {
            Package p = new Package();
            // Add a File System task to the package.
            Executable exec1 = p.Executables.Add("STOCK:FileSystemTask");
            TaskHost thFileSystemTask = exec1 as TaskHost;
            thFileSystemTask.Name = "fileSystemTask";

            ConnectionManager ConMgr = p.Connections.Add("OLEDB");
            ConMgr.ConnectionString = "Data Source=.;User ID=sa;Initial Catalog=AdventureWorksDW2014;Provider=SQLNCLI11.1;Password=sa123";
            ConMgr.Name = "SSIS Connection Manager for OLE DB";
            ConMgr.Description = "OLE DB connection to the AdventureWorks database.";
            Application app = new Application();
            app.SaveToXml("Test1E.dtsx", p, null);
            Console.WriteLine("done");
            Console.Read();
        }
开发者ID:ismailmu,项目名称:SSISGen,代码行数:17,代码来源:Test1.cs

示例6: WriteParentPackageApplication

		private static void WriteParentPackageApplication(string baseDirectoryPath, Package package, string parentPackageName)
		{
			Application application;
			IDTSEvents dtsEvents;

			if ((object)package == null)
				throw new ArgumentNullException(nameof(package));

			if ((object)parentPackageName == null)
				throw new ArgumentNullException(nameof(parentPackageName));

			dtsEvents = new ConsoleEvents();
			application = new Application();

			application.SaveToXml(Path.Combine(baseDirectoryPath, parentPackageName), package, dtsEvents);
		}
开发者ID:textmetal,项目名称:main,代码行数:16,代码来源:Program.cs

示例7: Main

        static void Main(string[] args)
        {
            // Create the package and Data Flow Component

            Package package = new Package();
            Connections pkgConns = package.Connections;

            Executable e = package.Executables.Add("STOCK:PipelineTask");
            TaskHost thMainPipe = e as TaskHost;
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;
            Console.Write(thMainPipe.Name);
            thMainPipe.Name = "Data Flow Task";

            // Add the Flat File connection
            ConnectionManager connectionManagerFlatFile = package.Connections.Add("FLATFILE");
            connectionManagerFlatFile.ConnectionString = @"C:\Temp\FlatFile.csv";
            connectionManagerFlatFile.Name = "FlatFile";
            connectionManagerFlatFile.Properties["Format"].SetValue(connectionManagerFlatFile, "Delimited");
            connectionManagerFlatFile.Properties["ColumnNamesInFirstDataRow"].SetValue(connectionManagerFlatFile, true);

            // Get native flat file connection
            RuntimeWrapper.IDTSConnectionManagerFlatFile100 connectionFlatFile = connectionManagerFlatFile.InnerObject as RuntimeWrapper.IDTSConnectionManagerFlatFile100;

            // Create the source component.
            IDTSComponentMetaData100 source =
              dataFlowTask.ComponentMetaDataCollection.New();
            source.ComponentClassID = "DTSAdapter.FlatFileSource";
            CManagedComponentWrapper srcDesignTime = source.Instantiate();
            srcDesignTime.ProvideComponentProperties();

            // The ProvideComponentProperties method creates a default output.
            srcDesignTime.ProvideComponentProperties();
            // Assign the connection manager.
            source.RuntimeConnectionCollection[0].ConnectionManager =
              DtsConvert.GetExtendedInterface(connectionManagerFlatFile);

            IDTSComponentMetaData100 scd =
                dataFlowTask.ComponentMetaDataCollection.New();
            scd.ComponentClassID = "DTSTransform.SCD";
            scd.Name = "SCD";
            scd.Description = "This is STD";
            CManagedComponentWrapper SCD_Wrapper = scd.Instantiate();
            SCD_Wrapper.ProvideComponentProperties();

            // Create the destination component.
            IDTSComponentMetaData100 destination =
              dataFlowTask.ComponentMetaDataCollection.New();
            destination.ComponentClassID = "DTSAdapter.OleDbDestination";
            CManagedComponentWrapper destDesignTime = destination.Instantiate();
            destDesignTime.ProvideComponentProperties();

            // Create the path.
            IDTSPath100 path = dataFlowTask.PathCollection.New();
            path.AttachPathAndPropagateNotifications(source.OutputCollection[0],
              scd.InputCollection[0]);

            IDTSPath100 path2 = dataFlowTask.PathCollection.New();
            path2.AttachPathAndPropagateNotifications(scd.OutputCollection[0],
              destination.InputCollection[0]);

            //  string pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            Application app = new Application();
             //   Package p = app.LoadPackage(pkg, null);
            app.SaveToXml("myXMLPackage.dtsx", package, null);

            // Now that the package is loaded, we can query on
            // its properties.
            int n = package.Configurations.Count;
            DtsProperty p2 = package.Properties["VersionGUID"];
            DTSProtectionLevel pl = package.ProtectionLevel;

            Console.WriteLine("Number of configurations = " + n.ToString());
            Console.WriteLine("VersionGUID = " + (string)p2.GetValue(package));
            Console.WriteLine("ProtectionLevel = " + pl.ToString());
            Console.Read();
        }
开发者ID:jmietola,项目名称:xAPI,代码行数:77,代码来源:Class1.cs

示例8: Test2D

        public static void Test2D()
        {
            Application app = new Application();
            Package p = new Package();
            Executable e = p.Executables.Add("STOCK:PipelineTask");

            ConnectionManager cm = p.Connections.Add("OLEDB");
            cm.Name = "OLEDB ConnectionManager";
            cm.ConnectionString = "Data Source=(local);Initial Catalog=AdventureWorksDW2014;Provider=SQLOLEDB.1;Integrated Security=SSPI;";

            TaskHost thMainPipe = e as TaskHost;
            thMainPipe.Name = "mainPipe";
            MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

            IDTSComponentMetaData100 comp1 = dataFlowTask.ComponentMetaDataCollection.New();
            comp1.Name = "OLEDBSource";
            comp1.ComponentClassID = "DTSAdapter.OLEDBSource.4";

            CManagedComponentWrapper instance = comp1.Instantiate();

            instance.ProvideComponentProperties();

            if (comp1.RuntimeConnectionCollection.Count > 0)
            {
                comp1.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(p.Connections[0]);
                comp1.RuntimeConnectionCollection[0].ConnectionManagerID = p.Connections[0].ID;

            }

            instance.SetComponentProperty("AccessMode",2);
            //awas besar kecil berpengaruh
            //SqlCommand --> no error
            //SQLCommand --> error
            instance.SetComponentProperty("SqlCommand","SELECT * FROM DimCustomer");

            instance.AcquireConnections(null);
            instance.ReinitializeMetaData();
            instance.ReleaseConnections();

            IDTSComponentMetaData100 comp2 = dataFlowTask.ComponentMetaDataCollection.New();
            comp2.Name = "OLEDBDestination";
            comp2.ComponentClassID = "DTSAdapter.OleDbDestination.4";

            CManagedComponentWrapper instance2 = comp2.Instantiate();

            instance2.ProvideComponentProperties();

            // Create the path
            IDTSPath100 path = dataFlowTask.PathCollection.New();
            path.AttachPathAndPropagateNotifications(comp1.OutputCollection[0],comp2.InputCollection[0]);

            app.SaveToXml("Test2C.dtsx", p, null);
            Console.WriteLine("done");
            Console.ReadLine();
        }
开发者ID:ismailmu,项目名称:SSISGen,代码行数:55,代码来源:Test2.cs

示例9: Test2E


//.........这里部分代码省略.........
            #region "DataFlowTasks"
                Executable e = p.Executables.Add("STOCK:PipelineTask");
                TaskHost thMainPipe = e as TaskHost;
                thMainPipe.Name = "mainPipe";

                MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

                IDTSComponentMetaData100 comp1 = dataFlowTask.ComponentMetaDataCollection.New();
                comp1.Name = "OLEDBSource";
                comp1.ComponentClassID = "DTSAdapter.OLEDBSource.4";

                CManagedComponentWrapper instance = comp1.Instantiate();

                instance.ProvideComponentProperties();

                if (comp1.RuntimeConnectionCollection.Count > 0)
                {
                    comp1.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(p.Connections[0]);
                    comp1.RuntimeConnectionCollection[0].ConnectionManagerID = p.Connections[0].ID;

                }

                instance.SetComponentProperty("AccessMode", 2);
                instance.SetComponentProperty("SqlCommand", "SELECT * FROM DimCustomer");

                instance.AcquireConnections(null);
                instance.ReinitializeMetaData();
                instance.ReleaseConnections();

                IDTSComponentMetaData100 comp2 = dataFlowTask.ComponentMetaDataCollection.New();
                comp2.Name = "OLEDBDestination";
                comp2.ComponentClassID = "DTSAdapter.OleDbDestination.4";

                CManagedComponentWrapper instance2 = comp2.Instantiate();

                instance2.ProvideComponentProperties();

                if (comp2.RuntimeConnectionCollection.Count > 0)
                {
                    comp2.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(p.Connections[0]);
                    comp2.RuntimeConnectionCollection[0].ConnectionManagerID = p.Connections[0].ID;

                }

                instance2.SetComponentProperty("AccessMode", 3);
                instance2.SetComponentProperty("FastLoadMaxInsertCommitSize", 50000000);
                instance2.SetComponentProperty("FastLoadOptions", "TABLOCK,CHECK_CONSTRAINTS,ROWS_PER_BATCH = 500000");
                instance2.SetComponentProperty("OpenRowset", "DimCustomerDump");

                // Create the path
                IDTSPath100 path = dataFlowTask.PathCollection.New();
                path.AttachPathAndPropagateNotifications(comp1.OutputCollection[0], comp2.InputCollection[0]);

                instance2.AcquireConnections(null);
                instance2.ReinitializeMetaData();
                instance2.ReleaseConnections();

                //methode 1
                foreach (IDTSOutputColumn100 col1 in comp1.OutputCollection[0].OutputColumnCollection)
                {

                    for (int i = 0; i < comp2.InputCollection[0].ExternalMetadataColumnCollection.Count; i++)
                    {
                        string col2Name = comp2.InputCollection[0].ExternalMetadataColumnCollection[i].Name;
                        //CustomerKey exluded because Identity Column
                        if (col1.Name.ToUpper().Equals(col2Name.ToUpper()) && !(col2Name.Equals("CustomerKey")))
                        {
                            IDTSInputColumn100 vCol = comp2.InputCollection[0].InputColumnCollection.New();
                            vCol.LineageID = col1.ID;
                            vCol.ExternalMetadataColumnID = comp2.InputCollection[0].ExternalMetadataColumnCollection[i].ID;
                            vCol.UsageType = DTSUsageType.UT_READONLY;
                        }
                    }
                }

                ////methode 2
                //IDTSInput100 input = comp2.InputCollection[0];
                //IDTSVirtualInput100 vInput = input.GetVirtualInput();

                ////set column in OLEDB Source
                //foreach (IDTSVirtualInputColumn100 vColumn in vInput.VirtualInputColumnCollection)
                //{
                //       instance2.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READONLY);
                //}
                instance.AcquireConnections(null);
                instance.ReinitializeMetaData();
                instance.ReleaseConnections();
            #endregion

            #region "Flow"
                PrecedenceConstraint pcFlow = p.PrecedenceConstraints.Add(thExecuteSQLTask, thMainPipe);
                pcFlow.EvalOp = DTSPrecedenceEvalOp.ExpressionAndConstraint;
                pcFlow.Value = DTSExecResult.Success;
                pcFlow.Expression = "@[User::Enable] == \"Y\"";
            #endregion

            app.SaveToXml("Test2C.dtsx", p, null);
            Console.WriteLine("done");
            Console.ReadLine();
        }
开发者ID:ismailmu,项目名称:SSISGen,代码行数:101,代码来源:Test2.cs


注:本文中的Application.SaveToXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。