1
votes

I have a script task inside a SSIS package, like this,

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. 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.

1

1 Answers

1
votes

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();
     * */