示例#1
0
        /// <summary>
        /// Login to SalesForce.
        /// </summary>
        private void Login()
        {
            SalesForceAPI.Partner.Soap          loginClient = PartnerClientFactory.CreateChannel();
            SalesForceAPI.Partner.loginResponse response    = loginClient.login(new SalesForceAPI.Partner.loginRequest(
                                                                                    null,
                                                                                    null,
                                                                                    _credential.Username,
                                                                                    _credential.Password + _credential.Token));
            _session = response.result;
            DisposeClient(loginClient);

            PartnerClientFactory.Endpoint.Address  = new System.ServiceModel.EndpointAddress(_session.serverUrl);
            MetadataClientFactory.Endpoint.Address = new System.ServiceModel.EndpointAddress(_session.metadataServerUrl);
            ApexClientFactory.Endpoint.Address     = new System.ServiceModel.EndpointAddress(_session.serverUrl.Replace("/u/", "/s/"));
            ToolingClientFactory.Endpoint.Address  = new System.ServiceModel.EndpointAddress(_session.serverUrl.Replace("/u/", "/T/"));

            RestBaseUrl = String.Format("https://{0}/services/data/v{1:N1}", new Uri(_session.serverUrl).Host, SalesForceClient.METADATA_VERSION);

            User      = new User(_session.userId, _session.userInfo.userFullName);
            UserEmail = _session.userInfo.userEmail;
        }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="credential">The credential to login with.</param>
        /// <param name="configuration">Used to configure connections.</param>
        public SalesForceSession(SalesForceCredential credential, Configuration configuration)
        {
            if (credential == null)
            {
                throw new ArgumentNullException("credential");
            }
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            _credential    = credential;
            _configuration = configuration;
            _session       = null;
            _lastUsed      = DateTime.Now;

            _partnerClientFactory  = null;
            _metadataClientFactory = null;
            _apexClientFactory     = null;
            _toolingClientFactory  = null;

            User = null;
        }