コード例 #1
0
        public void RemoveUserFromEngagementPlan(object sender, Args.RegisterUserEventArgs args)
        {
            var signupStateId  = AnalyticsHelper.GetState("Registered", Sitecore.Data.ID.Parse(args.EventItem.PlanId));
            var removedStateId = AnalyticsHelper.GetState("Deregistered", Sitecore.Data.ID.Parse(args.EventItem.PlanId));

            AutomationManager.Provider.ChangeUserState(args.User.Profile.UserName, signupStateId.Guid, removedStateId.Guid);
        }
        public List <string> GetRegistered(EventItem eventItem)
        {
            var stateVisitors =
                AutomationManager.Provider.GetStateVisitors(
                    AnalyticsHelper.GetState("Registered", Sitecore.Data.ID.Parse(eventItem.PlanId)).Guid);

            return(stateVisitors);
        }
        public bool RemoveUser(EventItem eventItem, User user)
        {
            var signupStateId  = AnalyticsHelper.GetState("Registered", Sitecore.Data.ID.Parse(eventItem.PlanId));
            var removedStateId = AnalyticsHelper.GetState("Deregistered", Sitecore.Data.ID.Parse(eventItem.PlanId));

            AutomationManager.Provider.ChangeUserState(user.Profile.UserName, signupStateId.Guid, removedStateId.Guid);

            return(true);
        }
        public bool AddUser(EventItem eventItem, User user)
        {
            var removedState   = AnalyticsHelper.GetState("Deregistered", Sitecore.Data.ID.Parse(eventItem.PlanId));
            var signupState    = AnalyticsHelper.GetState("Registered", Sitecore.Data.ID.Parse(eventItem.PlanId));
            var stateVisistors = AutomationManager.Provider.GetStateVisitors(removedState.Guid);

            if (stateVisistors.Any(t => t == user.Profile.UserName))
            {
                AutomationManager.Provider.ChangeUserState(user.Profile.UserName, removedState.Guid, signupState.Guid);
            }

            AutomationManager.Provider.CreateAutomationState(user.Profile.UserName, eventItem.PlanId, signupState.ToGuid());
            return(true);
        }