コード例 #1
0
 // This method is used to re-send the Confirmation Email.
 public void ReSendValidationEmail(string address)
 {
     using (EmailAddressValidationDataContext context =
                new EmailAddressValidationDataContext())
     {
         tblEmailValidation eval = context.tblEmailValidations.Where(
             t => t.EmailAddress == address).FirstOrDefault();
         if (eval != null)
         {
             SendValidationEmail(address, eval.ValidateKey);
         }
     }
 }
コード例 #2
0
        // This method used to sending confirmation Email.
        // We use a simple database table to store the information about the
        // Email addresses which are ready for validation.
        public ValidateEmailResult StartToValidateEmail(string emailaddress)
        {
            // Use Linq to SQL to process the database queries.
            using (EmailAddressValidationDataContext context =
                       new EmailAddressValidationDataContext())
            {
                // Check whether the email address has already been recorded
                // into the database.
                tblEmailValidation eval = context.tblEmailValidations.Where(
                    t => t.EmailAddress == emailaddress).FirstOrDefault();

                if (eval != null)
                {
                    // If yes, return the process of the validation.
                    if (eval.IsValidated)
                    {
                        return(ValidateEmailResult.EmailValidated);
                    }
                    else
                    {
                        return(ValidateEmailResult.EmailValidating);
                    }
                }

                // Generate a unique key to validate the address.
                string querykey = Guid.NewGuid().ToString().Replace("-", "");

                // Send the confirmation Email.
                SendValidationEmail(emailaddress, querykey);

                // If not, create a new record to the database.
                context.tblEmailValidations.InsertOnSubmit(new tblEmailValidation()
                {
                    EmailAddress        = emailaddress,
                    IsValidated         = false,
                    IsSendCheckEmail    = false,
                    ValidatingStartTime = DateTime.Now,
                    ValidateKey         = querykey
                });
                context.SubmitChanges();

                return(ValidateEmailResult.EmailStartToValidate);
            }
        }
コード例 #3
0
ファイル: EmailValidation.cs プロジェクト: tablesmit/OneCode
        // 这个方法用于发送确认邮件.
        // 我们使用一个简单的数据库表来存放待验证的邮箱地址信息.
        public ValidateEmailResult StartToValidateEmail(string emailaddress)
        {
            // 使用Linq to SQL来访问数据库.
            using (EmailAddressValidationDataContext context =
                       new EmailAddressValidationDataContext())
            {
                // 检查邮箱地址在数据库是否已经有相同的.
                tblEmailValidation eval = context.tblEmailValidations.Where(
                    t => t.EmailAddress == emailaddress).FirstOrDefault();

                if (eval != null)
                {
                    // 如果是,返回验证处理的结果.
                    if (eval.IsValidated)
                    {
                        return(ValidateEmailResult.EmailValidated);
                    }
                    else
                    {
                        return(ValidateEmailResult.EmailValidating);
                    }
                }

                // 生成一个唯一键来验证地址.
                string querykey = Guid.NewGuid().ToString().Replace("-", "");

                // 发送确认邮件.
                SendValidationEmail(emailaddress, querykey);

                // 如果不是,在数据库中创建一个新的记录.
                context.tblEmailValidations.InsertOnSubmit(new tblEmailValidation()
                {
                    EmailAddress        = emailaddress,
                    IsValidated         = false,
                    IsSendCheckEmail    = false,
                    ValidatingStartTime = DateTime.Now,
                    ValidateKey         = querykey
                });
                context.SubmitChanges();

                return(ValidateEmailResult.EmailStartToValidate);
            }
        }
コード例 #4
0
 partial void DeletetblEmailValidation(tblEmailValidation instance);
コード例 #5
0
 partial void UpdatetblEmailValidation(tblEmailValidation instance);
コード例 #6
0
 partial void InserttblEmailValidation(tblEmailValidation instance);
コード例 #7
0
 partial void DeletetblEmailValidation(tblEmailValidation instance);
コード例 #8
0
 partial void UpdatetblEmailValidation(tblEmailValidation instance);
コード例 #9
0
 partial void InserttblEmailValidation(tblEmailValidation instance);