Exemple #1
0
 private void StartNotificationProcess()
 {
     try
     {
         AppFileLogger.getInstance().Log("On Start Fired..!!", MessageType.LOG);
         NotificationController controller = new NotificationController();
         controller.SendNotification();
         AppFileLogger.getInstance().Log("end of on ..!!", MessageType.LOG);
     }
     catch (Exception ex)
     {
         try
         {
             AppFileLogger.getInstance().Log(ex.Message, MessageType.ERROR);
         }
         catch (Exception innerEx)
         {
             var sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\ERROR.txt");
             sw.WriteLine(DateTime.Now);
             sw.WriteLine(innerEx.Message);
             sw.Flush();
             sw.Close();
         }
     }
 }
Exemple #2
0
        public void ShouldCreate_and_writetoFile()
        {
            //Arrange
            AppFileLogger logger = AppFileLogger.getInstance();

            //Act
            logger.Log("Hello", MessageType.ERROR);
            logger.Log("Thank you", MessageType.WARNING);

            //Assert
        }
Exemple #3
0
 private double getMilliseconds()
 {
     try
     {
         var milliSecond = ConfigurationManager.AppSettings["timer.interval.milliseconds"];
         return(double.Parse(milliSecond));
     }
     catch (Exception ex)
     {
         AppFileLogger.getInstance().Log("App setting file of service (timer.interval.hours)", MessageType.ERROR);
     }
     return(1);
 }
        private void Smtp_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            var userState = (MailMessage)e.UserState;

            if (e.Error != null)
            {
                AppFileLogger.getInstance().Log("email sending failed for :" + userState.To, MessageType.ERROR);
                AppFileLogger.getInstance().Log("email sending failed reason :" + e.Error.Message, MessageType.ERROR);
            }
            else
            {
                AppFileLogger.getInstance().Log("email sending success for :" + userState.To, MessageType.LOG);
            }
        }
 public void Add(EmailHistory contact)
 {
     if (!String.IsNullOrEmpty(contact.ContactID))
     {
         using (var sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + EMAIL_HISTORY_FILE, true))
         {
             sw.WriteLine(contact.ContactID + ","
                          + contact.Name + ","
                          + contact.LastEmailSent.ToShortDateString() + ","
                          + contact.TotalReminders);
             sw.Flush();
             sw.Close();
         }
     }
     else
     {
         AppFileLogger.getInstance().Log("No field values for EmailedContacts", MessageType.WARNING);
     }
 }
        public void SendEmail(string to, string subject, string content)
        {
            MailMessage mail = new MailMessage();

            mail.To.Add(to);
            mail.From    = new MailAddress(this._userId);
            mail.Subject = subject;


            mail.Body       = content;
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential
                                             (this._userId, this._pwd);// Enter seders User name and password
            smtp.EnableSsl = true;
            object userState = mail;

            smtp.SendCompleted += Smtp_SendCompleted;
            try
            {
                // smtp.SendAsync(mail, userState);
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                AppFileLogger.getInstance()
                .Log("email sending failed ," +
                     " check internet connection :" + ex.Message, MessageType.ERROR);
                throw;
            }
            AppFileLogger.getInstance().Log("email Queued to SMTPServier for:" + to, MessageType.LOG);
        }