Example #1
0
        protected override void OnStart(string[] args)
        {
            SLog.WriteLog("====================================================");

            try
            {
                #region 根据消息发送类型配置启动时钟

                tmMail.Enabled = false;

                if (MsgSentTypes.Contains(type_Mail))
                {
                    tmMail.Enabled = true;
                    tmMail.Start();
                }

                #endregion
            }
            catch (Exception ex)
            {
                SLog.WriteLogWithDefaultTime(string.Format("服务启动失败,详细:{0}", ex.Message));
            }

            SLog.WriteLogWithDefaultTime("服务正常启动。");
        }
Example #2
0
        /// <summary>
        /// 初始化时钟
        /// </summary>
        private void InitializeTimers()
        {
            try
            {
                tmMail.Interval = Convert.ToDouble(interval_Mail);

                SLog.WriteLog(string.Format("服务时钟时间间隔初始化:邮件服务{0}.单位:秒/一次。",
                                            tmMail.Interval / 1000));
            }
            catch (Exception ex)
            {
                SLog.WriteLogWithDefaultTime(ex.Message);
            }
        }
Example #3
0
 /// <summary>
 /// 邮件服务时钟
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tmMail_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     try
     {
         tmMail.Enabled = false;
         //发送邮件提醒
         serviceBLL.SendMail();
         tmMail.Enabled = true;
     }
     catch (Exception ex)
     {
         SLog.WriteLogWithDefaultTime(string.Format("邮件发送失败,详细:{0}", ex.Message));
     }
 }
Example #4
0
        /// <summary>
        /// 委托实现:发送邮件
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        bool delegate_SendMail(MessageEntity msg)
        {
            try
            {
                SMessage.SendMail(msg);

                DBOperate.SaveMessageLog(msg, Enum_MessageType.Mail.ToString(), null);
                SLog.WriteLogWithDefaultTime(msg.EMails + "发送成功");

                return(msg.IsSended);
            }
            catch (Exception ex)
            {
                DBOperate.SaveMessageLog(msg, Enum_MessageType.Mail.ToString(), ex.Message);
                SLog.WriteLogWithDefaultTime(string.Format("发送失败:{0} 出现问题:{1}", msg.EMails, ex.Message));
                return(false);
            }
        }
Example #5
0
 protected override void OnStop()
 {
     SLog.WriteLogWithDefaultTime("服务关闭。");
     SLog.WriteLog("====================================================");
 }