public virtual List <ISalesforceContact> FindByFieldValue(string fieldName, object fieldValue, ComparisonOperator comparisonOperator, int pageIndex, int pageSize)
        {
            var query = string.Format("SELECT {0} FROM {1} WHERE {2} {3}",
                                      this.FieldNamesString,
                                      this.ContactObjectName,
                                      fieldName,
                                      ComparisonOperatorParser.Parse(comparisonOperator, fieldValue.ToString()));

            return(this.GetContactsWithPaging(query, pageIndex, pageSize));
        }
Example #2
0
        public virtual SalesforceRole Get(string roleName)
        {
            Assert.ArgumentNotNullOrEmpty(roleName, "roleName");

            var query = string.Format("SELECT Id, {0} FROM {1} WHERE {0} {2}"
                                      , this.RoleFieldName
                                      , this.RoleObjectName
                                      , ComparisonOperatorParser.Parse(ComparisonOperator.Equals, roleName));

            return(this.Client.QueryAll <SalesforceRole>(query).FirstOrDefault());
        }
Example #3
0
        public virtual bool DeleteUserFromRole(string roleName, string loginName)
        {
            var roleAssociation = this.Client.QueryAll <RoleAssociation>(string.Format(
                                                                             "SELECT Id FROM {0}__c WHERE {1}__r.{5} {2} AND {3}__r.Name {4}",
                                                                             this.RoleAssociationObjectName,
                                                                             this.RelatedContactFieldName,
                                                                             ComparisonOperatorParser.Parse(ComparisonOperator.Equals, loginName),
                                                                             this.RelatedSitecoreRoleFieldName,
                                                                             ComparisonOperatorParser.Parse(ComparisonOperator.Equals, roleName),
                                                                             this.FieldMapping.Login)).FirstOrDefault();

            return(roleAssociation != null && this.Client.HttpDelete(string.Format("sobjects/{0}__c/{1}", this.RoleAssociationObjectName, roleAssociation.Id)));
        }
        public virtual int GetTotalInactiveByLoginName(string loginName, ComparisonOperator comparisonOperatorByName, DateTime inactiveSinceDate)
        {
            string expression = ComparisonOperatorParser.Parse(comparisonOperatorByName, loginName);

            return
                (this.Client.Query <int>(
                     string.Format(
                         "SELECT count() FROM {0} WHERE {4} <='{1}' AND {3} {2}",
                         this.ContactObjectName,
                         inactiveSinceDate,
                         expression,
                         this.FieldMapping.Login,
                         this.FieldMapping.LastActivityDate)).TotalSize);
        }
Example #5
0
        public virtual List <SalesforceRole> GetRolesForUser(string loginName)
        {
            Assert.ArgumentNotNullOrEmpty(loginName, "loginName");

            var query = string.Format(
                "SELECT {0}__r.Id, {0}__r.Name FROM {1}__c WHERE {2}__r.{3} {4}",
                this.RelatedSitecoreRoleFieldName,
                this.RoleAssociationObjectName,
                this.RelatedContactFieldName,
                this.FieldMapping.Login,
                ComparisonOperatorParser.Parse(ComparisonOperator.Equals, loginName));

            return(this.GetRolesByQuery(query));
        }
        public virtual ISalesforceContact Get(string loginName)
        {
            var query = string.Format(
                "SELECT {0} FROM {1} WHERE {3} {2}",
                this.FieldNamesString,
                this.ContactObjectName,
                ComparisonOperatorParser.Parse(ComparisonOperator.Equals, loginName),
                this.FieldMapping.Login);

            var response = this.Client.Query <Dictionary <string, object> >(query);

            var properties = response.Records.FirstOrDefault();

            return(properties != null ? new SalesforceContact(this.FieldMapping, properties) : null);
        }
        public virtual List <ISalesforceContact> FindInactiveByLoginName(string loginName, ComparisonOperator comparisonOperatorByName, DateTime inactiveSinceDate, int pageIndex, int pageSize)
        {
            string nameExpression = ComparisonOperatorParser.Parse(comparisonOperatorByName, loginName);

            var query = string.Format(
                "SELECT {0} FROM {1} WHERE {5} <='{2}' AND {4} {3}",
                this.FieldNamesString,
                this.ContactObjectName,
                inactiveSinceDate,
                nameExpression,
                this.FieldMapping.Login,
                this.FieldMapping.LastActivityDate);

            return(this.GetContactsWithPaging(query, pageIndex, pageSize));
        }
Example #8
0
        public virtual List <string> GetUsersInRole(string roleName)
        {
            Assert.ArgumentNotNullOrEmpty(roleName, "roleName");

            var query = string.Format(
                "SELECT {1}.{0} FROM {1} WHERE Id IN (SELECT ContactId FROM {2} WHERE {3}.{4} {5})",
                this.FieldMapping.Login,
                this.ContactObjectName,
                this.RoleAssociationObjectName,
                this.RoleObjectName,
                this.RoleFieldName,
                ComparisonOperatorParser.Parse(ComparisonOperator.Equals, roleName));

            return(this.GetUsersByQuery(query));
        }
Example #9
0
        public virtual List <SalesforceRole> GetRolesForUser(string loginName)
        {
            Assert.ArgumentNotNullOrEmpty(loginName, "loginName");

            var query = string.Format(
                "SELECT Id, {0} FROM {1} WHERE Id IN (SELECT CampaignId FROM {2} WHERE {3}.{4} {5})",
                this.RoleFieldName,
                this.RoleObjectName,
                this.RoleAssociationObjectName,
                this.ContactObjectName,
                this.FieldMapping.Login,
                ComparisonOperatorParser.Parse(ComparisonOperator.Equals, loginName));

            return(this.Client.QueryAll <SalesforceRole>(query).ToList());
        }
Example #10
0
        public virtual List <string> GetUsersInRole(string roleName)
        {
            Assert.ArgumentNotNullOrEmpty(roleName, "roleName");

            string expression = ComparisonOperatorParser.Parse(ComparisonOperator.Equals, roleName);

            var query = string.Format(
                "SELECT {0}__r.{4} FROM {1}__c WHERE {2}__r.Name {3}",
                this.RelatedContactFieldName,
                this.RoleAssociationObjectName,
                this.RelatedSitecoreRoleFieldName,
                expression,
                this.FieldMapping.Login);

            return(this.GetUsersByQuery(query));
        }
Example #11
0
        public virtual bool DeleteUserFromRole(string roleName, string loginName)
        {
            Assert.ArgumentNotNullOrEmpty(roleName, "roleName");
            Assert.ArgumentNotNullOrEmpty(loginName, "loginName");

            var query = string.Format("SELECT Id FROM {2} WHERE {0}.{1} {3} and {4}.{5} {6}",
                                      this.ContactObjectName,
                                      this.FieldMapping.Login,
                                      this.RoleAssociationObjectName,
                                      ComparisonOperatorParser.Parse(ComparisonOperator.Equals, loginName),
                                      this.RoleObjectName,
                                      this.RoleFieldName,
                                      ComparisonOperatorParser.Parse(ComparisonOperator.Equals, roleName)
                                      );

            var roleAssociation = this.Client.QueryAll <RoleAssociation>(query).FirstOrDefault();

            if (roleAssociation != null)
            {
                return(this.Client.HttpDelete(string.Format("sobjects/{0}/{1}", this.RoleAssociationObjectName, roleAssociation.Id)));
            }

            return(false);
        }
        public virtual int GetTotalCountByFieldValue(string fieldName, object fieldValue, ComparisonOperator comparisonOperator)
        {
            string expression = ComparisonOperatorParser.Parse(comparisonOperator, fieldValue.ToString());

            return(this.Client.Query <int>(string.Format("SELECT count() FROM {0} WHERE {1} {2}", this.ContactObjectName, fieldName, expression)).TotalSize);
        }
Example #13
0
        public virtual SalesforceRole Get(string roleName)
        {
            var query = string.Format("SELECT Id, Name FROM {0}__c WHERE Name {1}", this.RoleObjectName, ComparisonOperatorParser.Parse(ComparisonOperator.Equals, roleName));

            return(this.Client.QueryAll <SalesforceRole>(query).FirstOrDefault());
        }