ИСПОЛЬЗУЙТЕ параметр пакета SSIS внутри задачи сценария - PullRequest
1 голос
/ 08 мая 2020

У меня есть задача сценария внутри пакета SSIS, например,

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();
        }

Как видите, прокси-сервер жестко запрограммирован http://abc-proxy-in.abc.net: 2020. Я хочу сделать адрес прокси настраивается. Я добавил параметр пакета ($ project :: Proxy_Name) в свой пакет, и я хочу использовать этот параметр внутри задачи сценария, чтобы сделать его более настраиваемым. Не могли бы вы сообщить мне, какие изменения мне следует внести в этот код, чтобы сделать его более настраиваемым, поскольку я не человек. net.

1 Ответ

1 голос
/ 08 мая 2020

Это прямо в задаче скрипта о том, как их использовать:

#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();
     * */
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...