158 lines
3.5 KiB
C#
Executable File
158 lines
3.5 KiB
C#
Executable File
using ODK.WPF.Helper;
|
|
using System;
|
|
using APServerClient.APServiceReference;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.ServiceModel;
|
|
|
|
namespace Opsoft.NetCore.O3App.Services.CommonFunction
|
|
{
|
|
public class APClient
|
|
{
|
|
public APClient()
|
|
{
|
|
this.Url = this.GetURL(this.Url);
|
|
BasicHttpBinding binding = new BasicHttpBinding()
|
|
{
|
|
MaxBufferSize = 20000000,
|
|
MaxBufferPoolSize = 20000000,
|
|
MaxReceivedMessageSize = 20000000,
|
|
AllowCookies = true
|
|
};
|
|
EndpointAddress address = new EndpointAddress(this.Url);
|
|
this._Service = new APServiceSoapClient(binding, address);
|
|
}
|
|
|
|
public APClient(string URL)
|
|
{
|
|
string text;
|
|
if (string.IsNullOrEmpty(URL))
|
|
{
|
|
text = this.GetURL(this.Url);
|
|
}
|
|
else
|
|
{
|
|
if (URL.LastIndexOf('/') == URL.Length - 1)
|
|
{
|
|
text = URL.Left(URL.Length - 1);
|
|
}
|
|
else
|
|
{
|
|
text = URL;
|
|
}
|
|
if (string.IsNullOrEmpty(ODKContext.APPath))
|
|
{
|
|
text += "/ODKV60/AP/APService.asmx";
|
|
}
|
|
else
|
|
{
|
|
text = text + "/" + ODKContext.APPath + "/AP/APService.asmx";
|
|
}
|
|
}
|
|
this.Url = text;
|
|
BasicHttpBinding binding = new BasicHttpBinding()
|
|
{
|
|
MaxBufferSize = 20000000,
|
|
MaxBufferPoolSize = 20000000,
|
|
MaxReceivedMessageSize = 20000000,
|
|
AllowCookies = true
|
|
};
|
|
EndpointAddress address = new EndpointAddress(text);
|
|
this._Service = new APServiceSoapClient(binding, address);
|
|
}
|
|
|
|
// Token: 0x06000464 RID: 1124 RVA: 0x0001C82C File Offset: 0x0001AA2C
|
|
protected virtual string GetURL(string WebServiceURL)
|
|
{
|
|
Uri uri = new Uri(WebServiceURL);
|
|
if (this.IsRunTime)
|
|
{
|
|
string result;
|
|
if (string.IsNullOrEmpty(ODKContext.APPath))
|
|
{
|
|
result = this.APServerURL + "/ODKV60/AP/" + uri.Segments[uri.Segments.GetLength(0) - 1];
|
|
}
|
|
else
|
|
{
|
|
result = this.APServerURL + ODKContext.APPath + "/AP/" + uri.Segments[uri.Segments.GetLength(0) - 1];
|
|
}
|
|
return result;
|
|
}
|
|
return WebServiceURL;
|
|
}
|
|
|
|
// Token: 0x17000126 RID: 294
|
|
// (get) Token: 0x06000465 RID: 1125 RVA: 0x0001C8B0 File Offset: 0x0001AAB0
|
|
protected virtual string APServerURL
|
|
{
|
|
get
|
|
{
|
|
string text;
|
|
if (ODKContext.APServer.LastIndexOf('/') == ODKContext.APServer.Length - 1)
|
|
{
|
|
text = "http://" + ODKContext.APServer.Right(ODKContext.APServer.Length - 1);
|
|
}
|
|
else
|
|
{
|
|
text = "http://" + ODKContext.APServer;
|
|
}
|
|
if (ODKContext.APPPort != 80)
|
|
{
|
|
text = text + ":" + ODKContext.APPPort.ToStringEx() + "/";
|
|
}
|
|
else
|
|
{
|
|
text += "/";
|
|
}
|
|
return text;
|
|
}
|
|
}
|
|
|
|
// Token: 0x04000124 RID: 292
|
|
private APServiceSoapClient _Service;
|
|
public APServiceSoapClient Service
|
|
{
|
|
get
|
|
{
|
|
if (_Service == null)
|
|
{
|
|
this.Url = this.GetURL(this.Url);
|
|
BasicHttpBinding binding = new BasicHttpBinding();
|
|
EndpointAddress address = new EndpointAddress(this.Url);
|
|
this._Service = new APServiceSoapClient(binding, address);
|
|
}
|
|
return this._Service;
|
|
}
|
|
}
|
|
|
|
private Uri uri;
|
|
public string Url
|
|
{
|
|
get
|
|
{
|
|
if (!(this.uri == null))
|
|
{
|
|
return this.uri.ToString();
|
|
}
|
|
return string.Empty;
|
|
}
|
|
set
|
|
{
|
|
this.uri = new Uri(value);
|
|
}
|
|
}
|
|
|
|
// Token: 0x17000127 RID: 295
|
|
// (get) Token: 0x0600047C RID: 1148 RVA: 0x000051B3 File Offset: 0x000033B3
|
|
public virtual bool IsRunTime
|
|
{
|
|
get
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|