Beispiel #1
0
 public List<Maticsoft.Model.SysManage.VerifyMail> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.SysManage.VerifyMail> list = new List<Maticsoft.Model.SysManage.VerifyMail>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.SysManage.VerifyMail item = new Maticsoft.Model.SysManage.VerifyMail();
             if ((dt.Rows[i]["UserName"] != null) && (dt.Rows[i]["UserName"].ToString() != ""))
             {
                 item.UserName = dt.Rows[i]["UserName"].ToString();
             }
             if ((dt.Rows[i]["KeyValue"] != null) && (dt.Rows[i]["KeyValue"].ToString() != ""))
             {
                 item.KeyValue = dt.Rows[i]["KeyValue"].ToString();
             }
             if ((dt.Rows[i]["CreatedDate"] != null) && (dt.Rows[i]["CreatedDate"].ToString() != ""))
             {
                 item.CreatedDate = DateTime.Parse(dt.Rows[i]["CreatedDate"].ToString());
             }
             if ((dt.Rows[i]["Status"] != null) && (dt.Rows[i]["Status"].ToString() != ""))
             {
                 item.Status = int.Parse(dt.Rows[i]["Status"].ToString());
             }
             if ((dt.Rows[i]["ValidityType"] != null) && (dt.Rows[i]["ValidityType"].ToString() != ""))
             {
                 item.ValidityType = new int?(int.Parse(dt.Rows[i]["ValidityType"].ToString()));
             }
             list.Add(item);
         }
     }
     return list;
 }
Beispiel #2
0
 public Maticsoft.Model.SysManage.VerifyMail GetModel(string KeyValue)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 UserName,KeyValue,CreatedDate,Status,ValidityType from Accounts_VerifyMail ");
     builder.Append(" where KeyValue=@KeyValue ");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@KeyValue", SqlDbType.NVarChar, 50) };
     cmdParms[0].Value = KeyValue;
     Maticsoft.Model.SysManage.VerifyMail mail = new Maticsoft.Model.SysManage.VerifyMail();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["UserName"] != null) && (set.Tables[0].Rows[0]["UserName"].ToString() != ""))
     {
         mail.UserName = set.Tables[0].Rows[0]["UserName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["KeyValue"] != null) && (set.Tables[0].Rows[0]["KeyValue"].ToString() != ""))
     {
         mail.KeyValue = set.Tables[0].Rows[0]["KeyValue"].ToString();
     }
     if ((set.Tables[0].Rows[0]["CreatedDate"] != null) && (set.Tables[0].Rows[0]["CreatedDate"].ToString() != ""))
     {
         mail.CreatedDate = DateTime.Parse(set.Tables[0].Rows[0]["CreatedDate"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Status"] != null) && (set.Tables[0].Rows[0]["Status"].ToString() != ""))
     {
         mail.Status = int.Parse(set.Tables[0].Rows[0]["Status"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ValidityType"] != null) && (set.Tables[0].Rows[0]["ValidityType"].ToString() != ""))
     {
         mail.ValidityType = new int?(int.Parse(set.Tables[0].Rows[0]["ValidityType"].ToString()));
     }
     return mail;
 }
Beispiel #3
0
 public bool SendRegisterEmail(string username, string EmailUrl)
 {
     string str = Guid.NewGuid().ToString().Replace("-", "");
     Maticsoft.BLL.SysManage.VerifyMail mail = new Maticsoft.BLL.SysManage.VerifyMail();
     Maticsoft.Model.SysManage.VerifyMail model = new Maticsoft.Model.SysManage.VerifyMail {
         UserName = username,
         KeyValue = str,
         CreatedDate = DateTime.Now,
         Status = 0,
         ValidityType = 0
     };
     mail.Add(model);
     int templetId = Globals.SafeInt(ConfigSystem.GetValueByCache("EmailTemplet_Register"), 0);
     Maticsoft.Model.Ms.EmailTemplet modelByCache = this.GetModelByCache(templetId);
     if (modelByCache != null)
     {
         string body = this.ReplaceTag(modelByCache.EmailBody, new string[][] { new string[] { "{Domain}", HttpContext.Current.Request.Url.Authority }, new string[] { "{CreatedDate}", DateTime.Now.ToString("yyyy-MM-dd") }, new string[] { "{SecretKey}", str }, new string[] { "{UserName}", username } });
         try
         {
             Maticsoft.Model.MailConfig config = this.config.GetModel();
             if ((model != null) && !string.IsNullOrWhiteSpace(config.Mailaddress))
             {
                 MailSender.Send(config.SMTPServer, config.Username, DESEncrypt.Decrypt(config.Password), config.Mailaddress, EmailUrl, "", "", modelByCache.EmailSubject, body, true, Encoding.UTF8, true, config.SMTPSSL, null);
                 return true;
             }
             return true;
         }
         catch (Exception exception)
         {
             Maticsoft.Model.SysManage.ErrorLog log = new Maticsoft.Model.SysManage.ErrorLog {
                 Loginfo = "邮件发送失败!错误信息为:" + exception.StackTrace,
                 OPTime = DateTime.Now,
                 Url = "",
                 StackTrace = exception.StackTrace
             };
             Maticsoft.BLL.SysManage.ErrorLog.Add(log);
             return false;
         }
     }
     return false;
 }