1.初始化项目。保险起见bin目录完整提交 2.基于现场代码为调整过的初始项目(此次提交还未解决代码差异问题)
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
// Token: 0x02000004 RID: 4
|
||||
public class ConnectedManager
|
||||
{
|
||||
// Token: 0x0600000A RID: 10 RVA: 0x00002650 File Offset: 0x00000850
|
||||
public bool isOpen(string url)
|
||||
{
|
||||
bool flag = string.IsNullOrEmpty(url);
|
||||
bool result;
|
||||
if (flag)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ping ping = new Ping();
|
||||
Uri uri = new Uri(url);
|
||||
bool flag2 = ping.Send(uri.Host, 150).Status == IPStatus.Success;
|
||||
result = flag2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Token: 0x0600000B RID: 11 RVA: 0x000026A4 File Offset: 0x000008A4
|
||||
public string GetUrl(string url)
|
||||
{
|
||||
string result;
|
||||
try
|
||||
{
|
||||
bool flag = string.IsNullOrEmpty(url);
|
||||
if (flag)
|
||||
{
|
||||
result = "-1";
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpWebRequest httpWebRequest = WebRequest.Create(url) as HttpWebRequest;
|
||||
httpWebRequest.Method = "GET";
|
||||
httpWebRequest.ContentType = "application/json";
|
||||
HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
|
||||
StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.UTF8);
|
||||
string text = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
httpWebResponse.Close();
|
||||
result = text;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
result = "-2";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Token: 0x0600000C RID: 12 RVA: 0x00002750 File Offset: 0x00000950
|
||||
public string PostForUrl(string url, string postdb)
|
||||
{
|
||||
string result;
|
||||
try
|
||||
{
|
||||
bool flag = string.IsNullOrEmpty(url);
|
||||
if (flag)
|
||||
{
|
||||
result = "-1";
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(postdb);
|
||||
HttpWebRequest httpWebRequest = WebRequest.Create(url) as HttpWebRequest;
|
||||
ConnectedManager.SetHeaderValue(httpWebRequest.Headers, "owl-ois-adapter-tag", "HUAXIAO");
|
||||
httpWebRequest.Method = "POST";
|
||||
httpWebRequest.ContentType = "application/json";
|
||||
httpWebRequest.ContentLength = (long)bytes.Length;
|
||||
Stream requestStream = httpWebRequest.GetRequestStream();
|
||||
requestStream.Write(bytes, 0, bytes.Length);
|
||||
requestStream.Close();
|
||||
HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;
|
||||
StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.UTF8);
|
||||
string text = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
httpWebResponse.Close();
|
||||
result = text;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("服务错误:" + ex.ToString() + "提示:" + ex.StackTrace);
|
||||
result = "-2";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Token: 0x0600000D RID: 13 RVA: 0x00002860 File Offset: 0x00000A60
|
||||
public static void SetHeaderValue(WebHeaderCollection header, string name, string value)
|
||||
{
|
||||
PropertyInfo property = typeof(WebHeaderCollection).GetProperty("InnerCollection", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
bool flag = property != null;
|
||||
if (flag)
|
||||
{
|
||||
NameValueCollection nameValueCollection = property.GetValue(header, null) as NameValueCollection;
|
||||
nameValueCollection[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user