public DateTime GetDepartureDateTime(DateTime departureDate)
        {
            int departureHour;
            int departureMinute;

            if (int.TryParse(ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_DEPARTURE_HOUR), out departureHour) == false)
            {
                departureHour = Constants.DEFAULT_VALUE_DEPARTURE_HOUR;
            }
            if (int.TryParse(ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_DEPARTURE_MINUTE), out departureMinute) == false)
            {
                departureMinute = Constants.DEFAULT_VALUE_DEPARTURE_MINUTE;
            }
            return(new DateTime(departureDate.Year, departureDate.Month, departureDate.Day, departureHour, departureMinute, 0));;
        }
Exemple #2
0
        public void SendMail(string stationName = "")
        {
            try
            {
                string logFilePath = "Logs\\SystemLog.log." + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");

                if (File.Exists(logFilePath) == false)
                {
                    return;
                }

                string addressToConfig = ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_MAINTAINER_EMAIL_ADDRESS_TO);
                string addressTo       = addressToConfig.Split(',').FirstOrDefault();
                var    ccAdressList    = addressToConfig.Split(',');

                string addressFrom = ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_MAINTAINER_EMAIL_ADDRESS_FROM);
                string password    = ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_MAINTAINER_EMAIL_ADDRESS_PASS);

                SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                client.SendCompleted += new SendCompletedEventHandler(SendMailComplete_Click);
                client.EnableSsl      = true;
                MailAddress from    = new MailAddress(addressFrom, "Maintainer");
                MailAddress to      = new MailAddress(addressTo, "Maintainer");
                MailMessage message = new MailMessage(from, to);
                message.Body    = _content;
                message.Subject = string.Format(_title, stationName);
                message.Attachments.Add(new Attachment(logFilePath));
                NetworkCredential myCreds = new NetworkCredential(addressFrom, password, "");
                client.Credentials = myCreds;

                foreach (var i in ccAdressList)
                {
                    if (i.Equals(addressTo) == false)
                    {
                        message.CC.Add(i);
                    }
                }


                client.Send(message);
            }
            catch (Exception exc)
            {
                AppLogger.logError("[SendMail]", exc.Message);
            }
        }
        public string GetExtenalIp()
        {
            IPAddress address = null;

            string extenalIP = ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_GET_IP_ADDRESS);

            if (string.IsNullOrEmpty(extenalIP))
            {
                return(string.Empty);
            }

            address = Utility.IpAddressUtil.GetExternalAddress(extenalIP);
            if (address == null)
            {
                return(string.Empty);
            }
            else
            {
                return(address.ToString());
            }
        }
Exemple #4
0
        private AutoSendMail()
        {
            _sendingTimer           = new Timer();
            _sendingTimer.AutoReset = true;
            _sendingTimer.Enabled   = true;
            _sendingTimer.Elapsed  += new ElapsedEventHandler(onTimerElapse);

            _sendingTimer.Interval = Constants.AUTOSENDMAIL_TIMER_INTERVAL;

            _currentDate = DateTime.Now;

            try
            {
                string hours = ConfigurationUtil.GetConfig(Constants.FIELD_CONFIGURATION_SEND_MAINTENANCE_MAIL_HOUR);
                _sendMailHours = hours.Split(',').Select(i => int.Parse(i)).ToList();
            }
            catch (Exception exc)
            {
                AppLogger.logError("[onTimerElapse]", exc.Message);
            }
        }