Esempio n. 1
0
        private void SendEmail(List <tb_senderror_model> errors, string email)
        {
            StringBuilder sb = new StringBuilder();

            if (errors != null)
            {
                foreach (var e in errors)
                {
                    sb.AppendLine($"【错误id】{e.error_model.id}【任务id】{e.error_model.taskid}【创建时间】{e.error_model.errorcreatetime}【集群id】{e.error_model.nodeid}<br/>");
                }
            }
            string content = sb.ToString();

            if (string.IsNullOrEmpty(content))
            {
                return;
            }
            content += "\r\n详情请查看错误信息表!";
            try
            {
                var _json = new DingTalkService(this.AppConfig["appKey"], this.AppConfig["appsecret"]).SendText(email, content);
                if (Convert.ToInt32(_json["errcode"].ToString()) != 0)
                {
                    OpenOperator.Error($"发送错误钉钉消息失败{_json.ToString()}", null);
                }
            }
            catch (Exception exp)
            {
                OpenOperator.Error("发送错误钉钉消息失败", exp);
            }

            //EmailHelper emailhelper = new EmailHelper();
            //emailhelper.mailFrom = this.AppConfig["sendmailname"];
            //emailhelper.mailPwd = this.AppConfig["password"];
            //emailhelper.mailSubject = "任务调度平台之错误日报" + DateTime.Now.ToString("yyyyMMddHHmmss")+"【系统邮件】";
            //emailhelper.mailBody = content;
            //emailhelper.isbodyHtml = true;    //是否是HTML
            //emailhelper.host = this.AppConfig["sendmailhost"];//如果是QQ邮箱则:smtp:qq.com,依次类推
            //emailhelper.mailToArray = new string[] { email };//接收者邮件集合
            //emailhelper.mailCcArray = new string[] { };//抄送者邮件集合
            //try
            //{
            //    emailhelper.Send();
            //}
            //catch (Exception exp)
            //{
            //    OpenOperator.Error("发送错误邮件错误", exp);
            //}
        }
        private void SendEmail(List <tb_senderror_model> errors, string email)
        {
            StringBuilder sb = new StringBuilder();

            if (errors != null)
            {
                foreach (var e in errors)
                {
                    sb.AppendLine(string.Format("【错误id】{5}【任务id】{0}【任务名】{1}【错误内容】{2}【创建时间】{3}【集群id】{4}<br/>",
                                                e.error_model.taskid, e.taskname, e.error_model.msg, e.error_model.errorcreatetime, e.error_model.nodeid,
                                                e.error_model.id));
                }
            }
            string content = sb.ToString();

            if (string.IsNullOrEmpty(content))
            {
                return;
            }
            content += "\r\n详情请查看错误信息表!";

            EmailHelper emailhelper = new EmailHelper();

            emailhelper.mailFrom    = this.AppConfig["sendmailname"];
            emailhelper.mailPwd     = this.AppConfig["password"];
            emailhelper.mailSubject = "任务调度平台之错误日报" + DateTime.Now.ToString("yyyyMMddHHmmss") + "【系统邮件】";
            emailhelper.mailBody    = content;
            emailhelper.isbodyHtml  = true;                           //是否是HTML
            emailhelper.host        = this.AppConfig["sendmailhost"]; //如果是QQ邮箱则:smtp:qq.com,依次类推
            emailhelper.mailToArray = new string[] { email };         //接收者邮件集合
            emailhelper.mailCcArray = new string[] { };               //抄送者邮件集合
            try
            {
                emailhelper.Send();
            }
            catch (Exception exp)
            {
                OpenOperator.Error("发送错误邮件错误", exp);
            }
        }
Esempio n. 3
0
        public void SendEmail(List <tb_error_log_model> errors, string email)
        {
            StringBuilder sb = new StringBuilder();

            if (errors != null)
            {
                foreach (var e in errors)
                {
                    sb.AppendLine(string.Format("【错误id】{0}【项目】{1}【标识信息】{2}【错误内容】{3}【开发人员】{4}【创建时间】{5}<br/><br/>",
                                                e.id, e.projectname, e.logtag, e.msg, e.developer, e.logcreatetime));
                }
            }
            string content = sb.ToString();

            if (string.IsNullOrEmpty(content))
            {
                return;
            }
            content += "\r\n详情请查看错误信息表!";

            EmailHelper emailhelper = new EmailHelper();

            emailhelper.mailFrom    = this.AppConfig["sendmailname"];
            emailhelper.mailPwd     = this.AppConfig["password"];
            emailhelper.mailSubject = string.Format("监控平台之错误日报" + DateTime.Now.ToString("yyyyMMddHHmmss") + "【系统邮件】【{0}】", this.AppConfig["moreEmailSubject"]);
            emailhelper.mailBody    = content;
            emailhelper.isbodyHtml  = true;                           //是否是HTML
            emailhelper.host        = this.AppConfig["sendmailhost"]; //如果是QQ邮箱则:smtp:qq.com,依次类推
            emailhelper.mailToArray = new string[] { email };         //接收者邮件集合
            emailhelper.mailCcArray = new string[] { };               //抄送者邮件集合
            try
            {
                emailhelper.Send();
            }
            catch (Exception exp)
            {
                OpenOperator.Error("发送错误邮件错误", exp);
            }
        }