就像一些在 cmets 中所说的那样,更好的答案是不使用代理,而是在 SSISDB 中调用 SSIS 任务本身。这意味着您可以同时多次运行任务(使用 Agent 不可能),并且可以传递参数。
根据您的设置,您可能希望创建一个存储过程,为您的特定任务调用 SSISDB 中的相关 SP,而不是在应用程序中全部调用它们。在我看来,我发现这更容易,因为您有更多的控制权,并且只需要在包装上有人更改时更改一个位置。
这是一个示例,但可能会帮助您了解这个想法:
USE SSISDB;
GO
--I'm going to create the SPs in a new schema in SSISDB, however, you can create this elsewhere if you want
--Create the new schema
CREATE SCHEMA app;
GO
--Create the proc, I've made up some parameters
CREATE PROC app.UploadTask @FileName sql_variant, @FileDate date, @RetryNum int AS
DECLARE @execution_id bigint;
--Create the execution
EXEC [catalog].create_execution @package_name = N'UploadDocument.dtsx', --Made up package name
@execution_id = @execution_id OUTPUT,
@folder_name = N'FTP Packages', --Madeup name
@project_name = N'FileTranfers', --Madeup Project Name
@use32bitruntime = FALSE,
@reference_id = NULL;
--Add the paramters
EXEC [catalog].set_execution_parameter_value @execution_id = @execution_id,
@object_type = 30,
@parameter_name = N'FileName',
@parameter_value = @FileName;
EXEC [catalog].set_execution_parameter_value @execution_id = @execution_id,
@object_type = 30,
@parameter_name = N'SubmissionDate',
@parameter_value = @FileDate;
EXEC [catalog].set_execution_parameter_value @execution_id = @execution_id,
@object_type = 30,
@parameter_name = N'Retries',
@parameter_value = @RetryNum;
--Set the logging level
EXEC [catalog].set_execution_parameter_value @execution_id = @execution_id,
@object_type = 50,
@parameter_name = N'LOGGING_LEVEL',
@parameter_value = 1;
--This is optional, comment out or delete the following if you do not want it
--Set the package to run synchronously
EXEC [catalog].set_execution_parameter_value @execution_id = @execution_id,
@object_type = 50,
@parameter_name = N'SYNCHRONIZED',
@parameter_value = 1;
--And now, run the package
EXEC [catalog].start_execution @execution_id;
GO
--Now a sample call:
EXEC app.UploadTask @FileName = N'\\YourFileFile\SomeShare\SomeFolder\YourFile.txt', --It's important this is a nvarchar, varchar won't work!
@FileDate = '20180704',
@RetryNum = 3;
任何问题,请尽管提问。