/// <summary>
        /// Logins current binding.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="userInfoResponse">The user info response.</param>
        /// <returns>Login result.</returns>
        public bool Login(TokenResponse token, UserInfoResponse userInfoResponse)
        {
            if (!_loggedIn)
            {
                if (userInfoResponse.urls.ContainsKey("partner"))
                {
                    _binding.Url = userInfoResponse.urls["partner"].Replace("{version}", "25.0");
                    _binding.SessionHeaderValue = new SessionHeader
                    {
                        sessionId = token.access_token
                    };
                }
                else // throw if worng OAuth URL format (no partner URL)
                {
                    throw (new InvalidOperationException(Errors.ERR_WRONG_OAUTH_URL_FORMAT));
                }

                _salesforceGlobals = _binding.describeGlobal(); var info = GetUserInfo();

                _userInfo = new UserInfo
                {
                    UserSFID         = userInfoResponse.user_id,
                    OrganizationSFID = userInfoResponse.organization_id,
                    OrganizationName = info.organizationName
                };

                _loggedIn = true;
            }

            return(_loggedIn);
        }
        /// <summary>
        /// Logins current binding.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="token">The token.</param>
        /// <returns>Login result.</returns>
        public bool Login(string username, string password, string token)
        {
            if (!_loggedIn)
            {
                LoginResult loginResult = _binding.login(username, String.Concat(password, token));

                _binding.Url = loginResult.serverUrl;
                _binding.SessionHeaderValue = new SessionHeader
                {
                    sessionId = loginResult.sessionId
                };

                _salesforceGlobals = _binding.describeGlobal();

                _userInfo = new UserInfo
                {
                    UserSFID         = loginResult.userId,
                    OrganizationSFID = loginResult.userInfo.organizationId,
                    OrganizationName = loginResult.userInfo.organizationName
                };

                _loggedIn = true;
            }

            return(_loggedIn);
        }
Beispiel #3
0
        /// <summary>
        /// Returns a list of tables from salesforce
        /// </summary>
        /// <returns></returns>
        public List <string> GatTablesList()
        {
            sobjectsNames = new List <string>();
            DescribeGlobalResult dgr = binding.describeGlobal();

            for (int i = 0; i < dgr.sobjects.Length; i++)
            {
                sobjectsNames.Add(dgr.sobjects[i].name);
            }

            return(sobjectsNames);
        }
Beispiel #4
0
        public List <string> GatTableNameList()
        {
            List <string>        sobjectsNames = new List <string>();
            DescribeGlobalResult dgr           = _binding.describeGlobal();

            foreach (var obj in dgr.sobjects)
            {
                sobjectsNames.Add(obj.name);
            }

            return(sobjectsNames);
        }
Beispiel #5
0
        public List <string> GetTableNameList()
        {
            List <string>        sobjectsNames = new List <string>();
            DescribeGlobalResult dgr           = salesforceSoapService.describeGlobal();

            foreach (var obj in dgr.sobjects)
            {
                sobjectsNames.Add(obj.name);
            }

            return(sobjectsNames);
        }
        /// <summary>
        /// Logins current binding.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="userInfoResponse">The user info response.</param>
        /// <param name="userInfo">The user info.</param>
        /// <returns>
        /// Login result.
        /// </returns>
        public bool Login(TokenResponse token, UserInfoResponse userInfoResponse, out UserInfo userInfo)
        {
            if (!this._loggedIn)
            {
                // Set connection data

                if (userInfoResponse.urls.ContainsKey("partner"))
                {
                    this._binding.Url = userInfoResponse.urls["partner"].Replace("{version}", "26.0");
                    this._binding.SessionHeaderValue = new SessionHeader()
                    {
                        sessionId = token.access_token
                    };
                }
                else
                {
                    throw (new InvalidOperationException());
                }

                // Describe Salesforce globals

                this._salesforceGlobals = this._binding.describeGlobal();

                // Get user info from Salesforce

                var info = this.GetUserInfo();

                this._userInfo = new UserInfo()
                {
                    UserSFID         = userInfoResponse.user_id,
                    OrganizationSFID = userInfoResponse.organization_id,
                    OrganizationName = info.organizationName
                };

                userInfo = this._userInfo;

                // Set logged in flag

                this._loggedIn = true;
            }
            else
            {
                userInfo = null;
            }

            return(this._loggedIn);
        }
Beispiel #7
0
        public void DescribeGlobalResultClass_Properties_TestGetterAndSetter()
        {
            // Arrange
            var testEntity           = new DescribeGlobalResult();
            var privateObject        = new PrivateObject(testEntity);
            var propertiesDictionary = new Dictionary <string, object>()
            {
                ["encoding"]     = DummyString,
                ["maxBatchSize"] = DummyInt,
                ["sobjects"]     = new DescribeGlobalSObjectResult[] { },
            };

            // Act
            SetProperties(privateObject, propertiesDictionary);

            // Assert
            AssertProperties(privateObject, propertiesDictionary);
        }
        /// <summary>
        /// Logins current binding.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <param name="token">The token.</param>
        /// <param name="userInfo">The user info.</param>
        /// <returns>
        /// Login result.
        /// </returns>
        public bool Login(string username, string password, string token, out UserInfo userInfo)
        {
            if (!this._loggedIn)
            {
                // Try to get login result

                LoginResult loginResult = this._binding.login(username, String.Concat(password, token));

                // Set connection data

                this._binding.Url = loginResult.serverUrl;
                this._binding.SessionHeaderValue = new SessionHeader()
                {
                    sessionId = loginResult.sessionId
                };

                // Describe Salesforce globals

                this._salesforceGlobals = this._binding.describeGlobal();

                // Fill user info

                this._userInfo = new UserInfo()
                {
                    UserSFID         = loginResult.userId,
                    OrganizationSFID = loginResult.userInfo.organizationId,
                    OrganizationName = loginResult.userInfo.organizationName
                };

                userInfo = this._userInfo;

                // Set logged in flag

                this._loggedIn = true;
            }
            else
            {
                userInfo = null;
            }

            return(this._loggedIn);
        }
Beispiel #9
0
        /**
         * To determine the objects that are available to the logged-in
         * user, the sample client application executes a describeGlobal
         * call, which returns all of the objects that are visible to
         * the logged-in user. This call should not be made more than
         * once per session, as the data returned from the call likely
         * does not change frequently. The DescribeGlobalResult is
         * simply echoed to the console.
         */
        private void describeGlobalSample()
        {
            try
            {
                // describeGlobal() returns an array of object results that
                // includes the object names that are available to the logged-in user.
                DescribeGlobalResult dgr = binding.describeGlobal();

                Console.WriteLine("\nDescribe Global Results:\n");
                // Loop through the array echoing the object names to the console
                for (int i = 0; i < dgr.sobjects.Length; i++)
                {
                    Console.WriteLine(dgr.sobjects[i].name);
                }
            }
            catch (SoapException e)
            {
                Console.WriteLine("An exception has occurred: " + e.Message +
                                  "\nStack trace: " + e.StackTrace);
            }
        }
Beispiel #10
0
        internal DescribeGlobalSObjectResult[] GetObjects()
        {
            DescribeGlobalResult describeGlobalResult = _sforceService.describeGlobal();

            return(describeGlobalResult.sobjects);
        }