Ejemplo n.º 1
0
        public void SetUpTest()
        {
            ProviderHelper <SalesforceProvider, ProviderCollection <SalesforceProvider> > .DefaultProvider = new SalesforceProvider();

            var configuration = SalesforceManager.GetConfiguration("salesforce");

            this.Client = configuration.Client;
        }
Ejemplo n.º 2
0
        public void GetSalesforceLimitsTest()
        {
            SLimits limits = SalesforceManager.GetSalesforceLimits(this.Client);

            Assert.IsNotNull(limits);
            Assert.IsNotNull(limits.DailyApiRequests);
            Assert.IsNotNull(limits.DataStorageMb);
            Assert.Pass(string.Format("LIMITS -- Daily Api Requests: {0}/{1} | Data Storage: {2}/{3} Mb", limits.DailyApiRequests.Remaining, limits.DailyApiRequests.Max, limits.DataStorageMb.Remaining, limits.DataStorageMb.Max));
        }
        public void SetUpTest()
        {
            ProviderHelper <SalesforceProvider, ProviderCollection <SalesforceProvider> > .DefaultProvider = new SalesforceProvider();

            var configuration = SalesforceManager.GetConfiguration("salesforce");

            this.Client       = configuration.Client;
            this.ContactsApi  = configuration.Api.ContactsApi;
            this.FieldMapping = configuration.FieldMapping;
        }
        public virtual void Run()
        {
            foreach (var configuration in SalesforceManager.GetConfigurations())
            {
                SLimits limits = SalesforceManager.GetSalesforceLimits(configuration.Client);
                this.loger = new LimitsLoger(configuration.Name, limits);

                this.ProcessLimits(limits);
            }
        }
Ejemplo n.º 5
0
        public void SetUpTest()
        {
            var configuration = SalesforceManager.GetConfiguration("salesforce");

            this.Client      = configuration.Client;
            this.ContactsApi = configuration.Api.ContactsApi;
            this.RolesApi    = configuration.Api.RolesApi;

            this.InitializeRoles("Test-Role-Get", "Test-Role-1");

            this.InitializeUsersInRole("Test-Role-1", "*****@*****.**");
        }
        public void SetUpTest()
        {
            this.profileProvider = new SalesforceProfileProvider();
            this.profileProvider.Initialize("salesforce", new NameValueCollection()
            {
                { "readOnly", "false" }, { "applicationName", "sitecore" }
            });

            var configuration = SalesforceManager.GetConfiguration(this.profileProvider.Name);

            this.Client      = configuration.Client;
            this.ContactsApi = configuration.Api.ContactsApi;
        }
Ejemplo n.º 7
0
        private void updateMember()
        {
            var membershipManager = new MembershipManager();

            try
            {
                //set current user/member
                this.CurrentMember = membershipManager.UpdateMember(this.registeringUser);

                if (mode != Constants.QueryStrings.Registration.ModeEdit)
                {
                    this.CurrentUser = membershipManager.GetUser(this.CurrentMember.MemberId);


                    //SalesforceManager sfMgr = new SalesforceManager("*****@*****.**",
                    //                                                 "8f9C3Ayq",
                    //                                                 "hlY0jOIILtogz3sQlLUtmERlu");

                    SalesforceManager sfMgr = new SalesforceManager(Constants.SALESFORCE_USERNAME,
                                                                    Constants.SALESFORCE_PASSWORD,
                                                                    Constants.SALESFORCE_TOKEN);
                    if (sfMgr.LoggedIn)
                    {
                        try
                        {
                            SalesforceActionResult result = sfMgr.CreateWebsiteMemberAsContact(this.CurrentMember, CurrentUser.Email);
                            if (result.Success == false)
                            {
                                Response.Write("<!-- Error 401 -->");
                            }
                        }
                        catch (Exception)
                        {
                            Response.Write("<!-- Error 501 -->");
                        }
                    }
                    else
                    {
                        Response.Write("<!-- Error 601 -->");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);
            try
            {
                if (SalesforceSettings.Disabled)
                {
                    LogHelper.Info("Salesforce connector is disabled.", this);
                    return;
                }

                if (MainUtil.GetBool(config["disabled"], false))
                {
                    LogHelper.Info(string.Format("Provider is disabled. Provider name: {0}", this.Name), this);
                    return;
                }

                var configuration = SalesforceManager.GetConfiguration(name);
                if (configuration == null)
                {
                    LogHelper.Error("Initialization failed. Configuration is null.", this);
                    return;
                }

                this.ContactsApi          = configuration.Api.ContactsApi;
                this.FieldMapping         = configuration.FieldMapping;
                this.ProfileConfiguration = configuration.Profile;
                this.Cache = configuration.Cache;

                this.SaleforcePropertyNames = configuration.Profile.Properties.Select(i => i.SalesforceName).ToArray();

                this.ApplicationName = config["applicationName"];

                this.ReadOnly = MainUtil.GetBool(config["readOnly"], false);

                this.Initialized = true;
            }
            catch (Exception ex)
            {
                this.Initialized = false;

                LogHelper.Error(string.Format("Provider initialization error. Provider name: {0}", this.Name), this, ex);
            }
        }
Ejemplo n.º 9
0
        public void SetUpTest()
        {
            this.membershipProvider = new SalesforceMembershipProvider();
            this.membershipProvider.Initialize(
                "salesforce",
                new NameValueCollection
            {
                { "applicationName", "sitecore" },
                { "readOnly", "false" },
                { "enablePasswordReset", "true" },
                { "minRequiredPasswordLength", "1" },
                { "passwordStrengthRegularExpression", ".*" },
                { "minRequiredNonalphanumericCharacters", "0" },
                { "maxInvalidPasswordAttempts", "5" },
                { "passwordAttemptWindow", "0" },
                { "requiresUniqueEmail", "true" }
            });

            var configuration = SalesforceManager.GetConfiguration("salesforce");

            this.Client      = configuration.Client;
            this.ContactsApi = configuration.Api.ContactsApi;
        }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Connecting to salesforce");

            string fname = context.Request.QueryString["fname"];
            string lname = context.Request.QueryString["lname"];
            string email = context.Request.QueryString["email"];


            SalesforceManager sfMgr = new SalesforceManager("*****@*****.**", "8f9C3Ayq", "hlY0jOIILtogz3sQlLUtmERlu");

            if (sfMgr.LoggedIn)
            {
                //we are logged into salesforce.
                Member m = new Member();
                m.MemberId = Guid.NewGuid(); //adding in a random guid
                m.UserId   = Guid.NewGuid(); //add in a random user id guid

                m.allowConnections  = true;
                m.allowNewsletter   = false;
                m.emailSubscription = true;
                m.FirstName         = fname;
                m.hasOtherChildren  = false;
                m.isFacebookUser    = true;
                m.isPrivate         = true;
                m.LastName          = lname;
                m.PersonalityType   = new Guid("8B7EB70D-64B2-45B9-B06E-6AA5CB6FE983");//Optimisic Parent

                //m.Phone = 7811112222; //member phone & db need to be updated . int32 is too small for a phone number

                m.Role = new Guid("2BF9D7BE-2E40-432C-ADE7-A25C80B9B9EE");//Father

                Random random       = new Random();
                int    randomNumber = random.Next(0, 10000);
                m.ScreenName = "dummyuser_" + randomNumber.ToString();
                m.ZipCode    = "01111";

                Journey j = new Journey();
                j.Key   = new Guid("0642E401-8E66-4C69-89C6-294C257456C8");
                j.Value = "Still Figuring it Out";
                m.Journeys.Add(j);

                Interest intr = new Interest();
                intr.Key   = new Guid("110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9");
                intr.Value = "Assisted Living";
                m.Interests.Add(intr);

                Interest intr2 = new Interest();
                intr2.Key   = new Guid("3C185099-76B4-49DD-80D4-A069A3F55FA1");
                intr2.Value = "Homework and Study Skills";
                m.Interests.Add(intr2);

                //setting up a couple of issues for children
                Issue issueOne = new Issue();
                issueOne.Key   = new Guid("3390C210-0B22-48FD-A411-881F956EDC0C");
                issueOne.Value = "Listening";
                Issue issueTwo = new Issue();
                issueTwo.Key   = new Guid("1D338D37-CF4E-4C1C-9499-EBA6C0A2BBA0");
                issueTwo.Value = "Math";

                //setting up a couple of diagnosis values for children
                Diagnosis d1 = new Diagnosis();
                d1.Key   = new Guid("A66286A0-CD70-4FDD-9D13-9CF1C90EFC4A");
                d1.Value = "Receptive Language Disorder";
                Diagnosis d2 = new Diagnosis();
                d2.Key   = new Guid("7A035CC2-D6BD-4332-9518-7AB22083F652");
                d2.Value = "ADHD";

                //setting up a couple of grade values for children
                Grade g1 = new Grade();
                g1.Key   = new Guid("E26222FB-07CD-413B-9127-9050B6D2D037");
                g1.Value = "Grade 1";
                Grade g2 = new Grade();
                g2.Key   = new Guid("E0B459C0-548A-4E6C-854A-E8F475416F12");
                g2.Value = "Grade 10";

                //setting up status values for children
                Guid iepStatus        = new Guid("FBE464C6-0E52-45C5-A1E9-660CB3C6B688"); //yes
                Guid section504Status = new Guid("55F38A58-7506-454E-95E5-0ECE22A3B99C"); //in progress
                Guid evaluationStatus = new Guid("990FB117-F12E-4E3C-898B-8A9EB217FCFD"); //yes
                //------------------------------------------
                //test child 1
                //------------------------------------------
                Child childOne = new Child();
                childOne.ChildId          = Guid.NewGuid();//random new child guid for testing purposes
                childOne.Gender           = "boy";
                childOne.Nickname         = "Bobby";
                childOne.IEPStatus        = iepStatus;
                childOne.Section504Status = section504Status;
                childOne.EvaluationStatus = evaluationStatus;

                childOne.Issues.Add(issueOne);
                childOne.Issues.Add(issueTwo);
                childOne.Grades.Add(g1);
                childOne.Diagnoses.Add(d1);
                childOne.Diagnoses.Add(d2);
                m.Children.Add(childOne);
                //------------------------------------------
                //test child 2
                //------------------------------------------
                Child childTwo = new Child();
                childTwo.ChildId          = Guid.NewGuid();//random new guid for testing
                childTwo.Gender           = "boy";
                childTwo.Nickname         = "Tommy";
                childTwo.IEPStatus        = iepStatus;
                childTwo.Section504Status = section504Status;
                childTwo.EvaluationStatus = evaluationStatus;

                childTwo.Grades.Add(g2);
                childTwo.Issues.Add(issueOne);
                childTwo.Issues.Add(issueTwo);
                m.Children.Add(childTwo);

                try
                {
                    SalesforceActionResult result = sfMgr.CreateWebsiteMemberAsContact(m, email);

                    if (result.Success == true)
                    {
                        context.Response.Write(Environment.NewLine + "Contact (" + fname + " " + lname + ") is 'saved' to salesforce at: (" + sfMgr.SalesforceURL + ")"
                                               + Environment.NewLine + "Message: " + result.Message);
                    }
                    else
                    {
                        context.Response.Write(Environment.NewLine + "Contact (" + fname + " " + lname + ") is not saved to salesforce at: (" + sfMgr.SalesforceURL + ")"
                                               + Environment.NewLine + "Message: " + result.Message);
                    }
                }
                catch (Exception ex)
                {
                    context.Response.Write(Environment.NewLine + "An error occured during in RunSalesfroceUpsert.ashx.cs " +
                                           Environment.NewLine + "Message: " + ex.Message +
                                           Environment.NewLine + "Stack Trace: " + ex.StackTrace);
                }
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            base.Initialize(name, config);

            try
            {
                if (SalesforceSettings.Disabled)
                {
                    LogHelper.Info("Salesforce connector is disabled.", this);
                    return;
                }

                if (MainUtil.GetBool(config["disabled"], false))
                {
                    LogHelper.Info(string.Format("Provider is disabled. Provider name: {0}", this.Name), this);
                    return;
                }

                var configuration = SalesforceManager.GetConfiguration(name);
                if (configuration == null)
                {
                    LogHelper.Error("Initialization failed. Configuration is null.", this);
                    return;
                }

                this.ApplicationName = config["applicationName"];

                this.ReadOnly = MainUtil.GetBool(config["readOnly"], false);

                this.enablePasswordReset                  = MainUtil.GetBool(config["enablePasswordReset"], true);
                this.minRequiredPasswordLength            = MainUtil.GetInt(config["minRequiredPasswordLength"], 7);
                this.minRequiredNonalphanumericCharacters = MainUtil.GetInt(config["minRequiredNonalphanumericCharacters"], 0);
                this.maxInvalidPasswordAttempts           = MainUtil.GetInt(config["maxInvalidPasswordAttempts"], 5);
                this.passwordAttemptWindow                = MainUtil.GetInt(config["passwordAttemptWindow"], 0);
                this.passwordStrengthRegularExpression    = StringUtil.GetString(new[] { config["passwordStrengthRegularExpression"], string.Empty }).Trim();

                this.requiresQuestionAndAnswer = MainUtil.GetBool(config["requiresQuestionAndAnswer"], false);

                if (!string.IsNullOrEmpty(this.PasswordStrengthRegularExpression))
                {
                    try
                    {
                        new Regex(this.PasswordStrengthRegularExpression);
                    }
                    catch (ArgumentException exception)
                    {
                        throw new ProviderException(exception.Message, exception);
                    }
                }

                this.requiresUniqueEmail = MainUtil.GetBool(config["requiresUniqueEmail"], false);

                this.Client       = configuration.Client;
                this.ContactsApi  = configuration.Api.ContactsApi;
                this.FieldMapping = configuration.FieldMapping;
                this.Cache        = configuration.Cache;

                this.Initialized = true;
            }
            catch (Exception ex)
            {
                this.Initialized = false;

                LogHelper.Error(string.Format("Provider initialization error. Provider name: {0}", this.Name), this, ex);
            }
        }