コード例 #1
0
        private void Clean(string serverUrl)
        {
            var client = new Consul.ConsulClient(configuration => { configuration.Address = new Uri(serverUrl); });

            var checks = client.Agent.Checks().Result.Response; // client.Agent.Services().Result.Response;

            foreach (var service in checks.Values)
            {
                if (service.Status != HealthStatus.Passing)
                {
                    // logger.info("unregister : {}", check.getServiceId());
                    Console.WriteLine($"unreginer:{service.ServiceID}");
                    OpenOperator.Log($"unreginer:{service.ServiceID}");
                    client.Agent.ServiceDeregister(service.ServiceID);
                }
            }
        }
コード例 #2
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);
                OpenOperator.Log(_json.ToString());
            }
            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);
            //}
        }