C# 在脚本任务中使用SSIS包参数
我在SSIS包中有一个脚本任务,如下所示C# 在脚本任务中使用SSIS包参数,c#,.net,ssis,script-task,ssis-2017,C#,.net,Ssis,Script Task,Ssis 2017,我在SSIS包中有一个脚本任务,如下所示 public ReadListItemsSPOnline(string siteUrl, string email, string password, int requestTimeout) { _clientContext = new ClientContext(siteUrl); var securePassword = new SecureString(); f
public ReadListItemsSPOnline(string siteUrl, string email, string password, int requestTimeout)
{
_clientContext = new ClientContext(siteUrl);
var securePassword = new SecureString();
foreach (char c in password) securePassword.AppendChar(c);
String[] BypssArr = { "XXXXXX$" };
myProxy = new System.Net.WebProxy();
**myProxy.Address = new Uri("http://abc-proxy-in.abc.net:2020");**
myProxy.UseDefaultCredentials = true;
myProxy.BypassList = BypssArr;
System.Net.WebRequest.DefaultWebProxy = myProxy;
_clientContext.ExecutingWebRequest += (s, e) =>
{
//e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
e.WebRequestExecutor.WebRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
};
_clientContext.Credentials = new SharePointOnlineCredentials(email, securePassword);
_clientContext.RequestTimeout = requestTimeout;
_clientContext.Load(_clientContext.Web);
_clientContext.ExecuteQuery();
}
正如您所看到的,代理服务器是硬编码的,我希望使代理地址可配置。我在包中添加了一个包参数($project::proxy_Name),我希望在脚本任务中使用此参数使其更可配置。
由于我不是.net用户,您能告诉我应该对此代码进行哪些更改以使其更具可配置性吗。关于如何使用它们的脚本任务中有:
#region Help: Using Integration Services variables and parameters in a script
/* To use a variable in this script, first ensure that the variable has been added to
* either the list contained in the ReadOnlyVariables property or the list contained in
* the ReadWriteVariables property of this script task, according to whether or not your
* code needs to write to the variable. To add the variable, save this script, close this instance of
* Visual Studio, and update the ReadOnlyVariables and
* ReadWriteVariables properties in the Script Transformation Editor window.
* To use a parameter in this script, follow the same steps. Parameters are always read-only.
*
* Example of reading from a variable:
* DateTime startTime = (DateTime) Dts.Variables["System::StartTime"].Value;
*
* Example of writing to a variable:
* Dts.Variables["User::myStringVariable"].Value = "new value";
*
* Example of reading from a package parameter:
* int batchId = (int) Dts.Variables["$Package::batchId"].Value;
*
* Example of reading from a project parameter:
* int batchId = (int) Dts.Variables["$Project::batchId"].Value;
*
* Example of reading from a sensitive project parameter:
* int batchId = (int) Dts.Variables["$Project::batchId"].GetSensitiveValue();
* */