예제 #1
0
        public static void SendReminderEmail(UsersEntity user, List <ReminderModel.ReminderModel> tickets)
        {
            try
            {
                string emailSubject  = string.Empty;
                string emailBodyBox  = string.Empty;
                string emailBodyData = string.Empty;

                string   basePath             = Path.GetFullPath(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "../../");
                XElement xmlReminderEmailBody = XElement.Load(Path.Combine(basePath, "EmailTemps/ReminderBox.xml"));
                emailSubject = xmlReminderEmailBody.Element("email").Element("subject").Value;
                emailSubject = emailSubject.Replace("{{Date}}", DateTime.Now.Date.ToShortDateString());

                emailBodyBox = xmlReminderEmailBody.Element("email").Element("content").Value;
                emailBodyBox = emailBodyBox.Replace("{{CurrentDateTime}}", DateTime.Now.ToString());

                foreach (var ticket in tickets)
                {
                    string   tempData = string.Empty;
                    XElement xmlData  = XElement.Load(Path.Combine(basePath, "EmailTemps/ReminderData.xml"));
                    tempData = xmlData.Element("content").Value;
                    tempData = tempData
                               .Replace("{{ProjectId}}", ticket.ProjectId.ToString())
                               .Replace("{{ProjectName}}", ticket.ProjectName)
                               .Replace("{{TicketId}}", ticket.TicketId.ToString())
                               .Replace("{{TicketTitle}}", ticket.TicketTitle)
                               .Replace("{{TicketModeifiedOn}}", ticket.ModifiedOn.HasValue ? ticket.ModifiedOn.Value.ToString() : "");

                    emailBodyData += tempData;
                }

                emailBodyBox = emailBodyBox.Replace("{{ReminderData}}", emailBodyData);

                if (SFConfig.Components.EmailSender.SendMail(user.Email, emailSubject, emailBodyBox, true, MailPriority.Normal) == false)
                {
                    LogProvider.WriteLog(string.Format("{0} Send mailbox failure: user:"******" emial:" + user.Email + " emailSubject:" + emailSubject));
                }
            }
            catch (Exception ex)
            {
                LogProvider.WriteLog(ex.ToString());
            }
        }
예제 #2
0
 private static void ConsoleAndLog(string info)
 {
     Console.WriteLine(info);
     LogProvider.WriteLog(info);
 }
예제 #3
0
 private static void WriteLog(string info)
 {
     LogProvider.WriteLog(info);
 }