Ejemplo n.º 1
0
        internal HttpResult GetHtml(string url, string postData = "", Dictionary <string, string> headers = null)
        {
            Core.HttpHelper http = new Core.HttpHelper();
            HttpItem        item = new HttpItem()
            {
                URL       = url,
                Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
            };

            if (!string.IsNullOrEmpty(postData))
            {
                item.Method   = "post";
                item.Postdata = postData;
            }
            if (headers != null)
            {
                foreach (var header in headers)
                {
                    item.Header.Add(header.Key, header.Value);
                }
            }
            var result = http.GetHtml(item);

            return(result);
        }
        /// <summary>
        /// 重载基类算法,查看队列服务是否正常
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var mqAddress  = JobParamsDoc.Text("MQAddress");
            var mqPassWord = JobParamsDoc.Text("MQAuthorization");

            //http://192.168.185.173:15672/api/queues
            Core.HttpHelper http = new Core.HttpHelper();
            HttpItem        item = new HttpItem()
            {
                URL       = mqAddress,
                Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
            };

            item.Header.Add("Authorization", "Basic YW50YXBvczphbnRhcG9z");
            var result = http.GetHtml(item);

            if (result.StatusCode != System.Net.HttpStatusCode.OK)
            {
                var messageInfo = new PushMessageInfo()
                {
                    content        = "RabbitMQ服务停止预警",
                    approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                    errorMessage   = $"{mqAddress}rabbitMQ队列服务出错",
                    customerCode   = SysAppConfig.CustomerCode,
                    logType        = "1"
                };
                return(messageInfo.ToJson());
            }
            return(string.Empty);
        }