public void Send() { try { Miami.Substitute.Dal.Template template = new Miami.Substitute.Dal.Template(); DataRowView drv = template.LoadTemplateByName(type.ToString()); if (drv != null && drv["Text"].ToString().Length > 0) { MailAddressCollection ññTemp = cc; bool testMode = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["UseTestEmailAddress"]); if (testMode) { cc = new MailAddressCollection(); to = new MailAddressCollection(); to.Add(System.Configuration.ConfigurationManager.AppSettings["TestEmailAddress"]); } MailMessage myMail = new MailMessage(); myMail.From = from; foreach (MailAddress item in to) { myMail.To.Add(item); } foreach (MailAddress item in cc) { myMail.CC.Add(item); } myMail.Subject = Fill(drv["Header"].ToString()); myMail.Body = Fill(drv["Text"].ToString()); myMail.Priority = MailPriority.Normal; myMail.IsBodyHtml = true; Dal.MailLog mailLog = new Miami.Substitute.Dal.MailLog(); mailLog.AddNew(); mailLog.LocationId = LocationId; mailLog.MailFrom = myMail.From.Address; mailLog.MailTo = myMail.To.ToString(); if (ññTemp.Count > 0) { mailLog.MailTo += " , cc: " + ññTemp.ToString(); } mailLog.MailType = type.ToString(); mailLog.Subject = myMail.Subject; mailLog.SendDate = DateTime.Now; mailLog.Message = myMail.Body; mailLog.Save(); int countLogs = mailLog.GetAllMailLogByLocationId(LocationId).Count; if (countLogs > 1000) { mailLog.DeleteMailLog(LocationId, countLogs - 1000); } SmtpClient smtpClient = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["SmtpServer"]); smtpClient.Send(myMail); } } catch { } }
/// <summary> /// 通知 /// </summary> /// <param name="noticeType"></param> /// <param name="isAlive"></param> public void Nodify(NoticeType noticeType, bool isAlive) { //Debug.LogErrorFormat("Nodify:: NoticeType = {0} isAlive = {1}", noticeType, isAlive); BaseNotice notice; if (noticeDic.TryGetValue(noticeType, out notice)) { notice.Notify(notice, isAlive); if (notice.parent != null) { checkNotice(notice.parent); } } else { Debug.LogError("【Nodify】Not exist target NoticeType : " + noticeType.ToString()); } }