Ejemplo n.º 1
0
        /// <summary>
        ///     发送告警信息
        /// </summary>
        /// <param name="pointCode">监控点简码。通过监控点管理->监控点列表->监控点简码</param>
        /// <param name="errorCode">错误简码。通过监控点管理->监控点列表->监控点简码->查看</param>
        /// <param name="level">级别(自定义的,0至6之间,数字越小级别越高)</param>
        /// <param name="content">内容,可以是数组也可以是字符串,目前暂定数组,内容4万个字符以内</param>
        /// <returns></returns>
        public async Task <string> NoticeAsync(string pointCode, string errorCode, int level, string content)
        {
            var notice = new RmsNotice
            {
                Content     = new Content(content),
                ErrorCode   = errorCode,
                Level       = level,
                PointCode   = pointCode,
                ServiceType = _options.ProjectName
            };

            Check(notice);
            return(await RmsRequest(notice, _options.NoticeUrl));
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     补全服务器信息
 /// </summary>
 /// <param name="notice"></param>
 private void Check(RmsNotice notice)
 {
     if (notice.NoticeTimeStamp <= 0)
     {
         notice.NoticeTimeStamp = GetTimesTamp();
     }
     if (string.IsNullOrEmpty(notice.ServerName))
     {
         notice.ServerName = GetServerName();
     }
     if (string.IsNullOrEmpty(notice.ServerIp))
     {
         notice.ServerIp = GetLocalAddress();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     发送告警信息
 /// </summary>
 /// <param name="noticeMessage"></param>
 /// <returns></returns>
 public async Task <string> NoticeAsync(RmsNotice noticeMessage)
 {
     Check(noticeMessage);
     return(await RmsRequest(noticeMessage, _options.NoticeUrl));
 }