[英]USE SSIS package parameter inside script task
I have a script task inside a SSIS package, like this,我在 SSIS package 中有一个脚本任务,像这样,
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();
}
As you can see proxy server is hard coded http://abc-proxy-in.abc.net:2020.I want to make the proxy address configurable.I have added a package parameter($project::Proxy_Name) inside my package and I want to use this parameter inside the script task to make it more configurable. As you can see proxy server is hard coded http://abc-proxy-in.abc.net:2020.I want to make the proxy address configurable.I have added a package parameter($project::Proxy_Name) inside my package我想在脚本任务中使用这个参数来使其更具可配置性。 Can you let me know what changes should I make in this code to make it more configurable,as I am not a .net person.
您能否让我知道我应该在此代码中进行哪些更改以使其更具可配置性,因为我不是 .net 人。
It is right there in the script task on how to use them:关于如何使用它们的脚本任务就在那里:
#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();
* */
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.