/// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public bool Send(IMemberShipFactory daoFactory)
        {
            if (daoFactory == null)
            {
                throw new ArgumentNullException("daoFactory");
            }
            if (String.IsNullOrEmpty(Id))
            {
                throw new ArgumentException("Id", "Id is empty");
            }
            User myUsers = daoFactory.CreateUserDao().Get(Id);

            if (myUsers == null)
            {
                throw new ArgumentException("Id", String.Format("can not find any use with id={0}", Id));
            }
            EmailVerifier token = myUsers.Contact.VerifyEmail(30, daoFactory);

            var deleage = new CreateVariablesHandler(user => new Dictionary <string, string>
            {
                { "name", user.Name },
                { "parameters", token.CreateQueryString() }
            });

            OrnamentContext.Configuration.MessagesConfig.VerifyEmailAddress.Publish(daoFactory, deleage, myUsers);

            daoFactory.CreateUserDao().SaveOrUpdate(myUsers);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     ÓÃtemplateÉú³Ésinple message
        /// </summary>
        /// <param name="daoFactory"></param>
        /// <param name="replaceVariabled"></param>
        /// <param name="performers"></param>
        public virtual void Publish(
            IMemberShipFactory daoFactory,
            CreateVariablesHandler replaceVariabled,
            params IPerformer[] performers)
        {
            if (daoFactory == null)
            {
                throw new ArgumentNullException("daoFactory");
            }
            if (replaceVariabled == null)
            {
                throw new ArgumentNullException("replaceVariabled");
            }
            if (performers == null)
            {
                throw new ArgumentNullException("performers");
            }
            var targetuser = new HashSet <User>();

            foreach (IPerformer performer in performers)
            {
                foreach (User user in performer.GetUsers(daoFactory))
                {
                    targetuser.Add(user);
                }
            }


            foreach (User user in targetuser)
            {
                Dictionary <string, string> data = replaceVariabled(user);
                Publish(daoFactory, data, user);
            }
        }
        /// <summary>
        /// </summary>
        /// <param name="daoFactory"></param>
        /// <returns></returns>
        public bool Send(IMemberShipFactory daoFactory)
        {
            if (daoFactory == null) throw new ArgumentNullException("daoFactory");
            if (String.IsNullOrEmpty(Id))
                throw new ArgumentException("Id", "Id is empty");
            User myUsers = daoFactory.CreateUserDao().Get(Id);
            if (myUsers == null)
            {
                throw new ArgumentException("Id", String.Format("can not find any use with id={0}", Id));
            }
            EmailVerifier token = myUsers.Contact.VerifyEmail(30, daoFactory);

            var deleage = new CreateVariablesHandler(user => new Dictionary<string, string>
            {
                {"name", user.Name},
                {"parameters", token.CreateQueryString()}
            });
            OrnamentContext.Configuration.MessagesConfig.VerifyEmailAddress.Publish(daoFactory, deleage, myUsers);

            daoFactory.CreateUserDao().SaveOrUpdate(myUsers);
            return true;
        }