2015-11-17 update 1 add Delian Server
This commit is contained in:
@@ -6,17 +6,89 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ModBus.Net.FBox
|
namespace ModBus.Net.FBox
|
||||||
{
|
{
|
||||||
public static class Constants
|
public enum SignalRServer
|
||||||
{
|
{
|
||||||
public const string BaseAddress = "https://account.flexem.com/core";
|
FBoxServer = 0,
|
||||||
|
DelianServer = 1
|
||||||
|
}
|
||||||
|
|
||||||
public const string AuthorizeEndpoint = BaseAddress + "/connect/authorize";
|
public class Constants
|
||||||
public const string LogoutEndpoint = BaseAddress + "/connect/endsession";
|
{
|
||||||
public const string TokenEndpoint = BaseAddress + "/connect/token";
|
public SignalRServer SignalRServer = SignalRServer.FBoxServer;
|
||||||
public const string UserInfoEndpoint = BaseAddress + "/connect/userinfo";
|
|
||||||
public const string IdentityTokenValidationEndpoint = BaseAddress + "/connect/identitytokenvalidation";
|
public string BaseAddress
|
||||||
public const string TokenRevocationEndpoint = BaseAddress + "/connect/revocation";
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (SignalRServer)
|
||||||
|
{
|
||||||
|
case SignalRServer.FBoxServer:
|
||||||
|
{
|
||||||
|
return "https://account.flexem.com/core";
|
||||||
|
}
|
||||||
|
case SignalRServer.DelianServer:
|
||||||
|
{
|
||||||
|
return "https://id.data.hzdelian.com/core";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "https://account.flexem.com/core";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AuthorizeEndpoint
|
||||||
|
{
|
||||||
|
get { return BaseAddress + "/connect/authorize"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string LogoutEndpoint
|
||||||
|
{
|
||||||
|
get { return BaseAddress + "/connect/endsession"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TokenEndpoint
|
||||||
|
{
|
||||||
|
get { return BaseAddress + "/connect/token"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UserInfoEndpoint
|
||||||
|
{
|
||||||
|
get {return BaseAddress + "/connect/userinfo"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string IdentityTokenValidationEndpoint
|
||||||
|
{
|
||||||
|
get {return BaseAddress + "/connect/identitytokenvalidation"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TokenRevocationEndpoint
|
||||||
|
{
|
||||||
|
get {return BaseAddress + "/connect/revocation"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AspNetWebApiSampleApi
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (SignalRServer)
|
||||||
|
{
|
||||||
|
case SignalRServer.FBoxServer:
|
||||||
|
{
|
||||||
|
return "http://fbox360.com/api/client/";
|
||||||
|
}
|
||||||
|
case SignalRServer.DelianServer:
|
||||||
|
{
|
||||||
|
return "http://wl.data.hzdelian.com/api/client/";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "http://fbox360.com/api/client/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public const string AspNetWebApiSampleApi = "http://fbox360.com/api/client/";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace ModBus.Net.FBox
|
|||||||
public string UserId { get; set; }
|
public string UserId { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string SigninAdditionalValues { get; set; }
|
public string SigninAdditionalValues { get; set; }
|
||||||
|
public SignalRServer SignalRServer { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SignalRConnector : BaseConnector
|
public class SignalRConnector : BaseConnector
|
||||||
@@ -36,8 +37,21 @@ namespace ModBus.Net.FBox
|
|||||||
private bool _connected;
|
private bool _connected;
|
||||||
public override bool IsConnected { get { return _connected; } }
|
public override bool IsConnected { get { return _connected; } }
|
||||||
|
|
||||||
|
private Constants _constants;
|
||||||
|
private Constants Constants
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_constants == null) _constants = new Constants();
|
||||||
|
return _constants;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public SignalRConnector(string machineId, SignalRSigninMsg msg)
|
public SignalRConnector(string machineId, SignalRSigninMsg msg)
|
||||||
{
|
{
|
||||||
|
Constants.SignalRServer = msg.SignalRServer;
|
||||||
|
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||||
ConnectionToken = machineId;
|
ConnectionToken = machineId;
|
||||||
if (_oauth2 == null)
|
if (_oauth2 == null)
|
||||||
{
|
{
|
||||||
@@ -50,7 +64,7 @@ namespace ModBus.Net.FBox
|
|||||||
_httpClient2 = new Dictionary<string, HttpClient>();
|
_httpClient2 = new Dictionary<string, HttpClient>();
|
||||||
_machineData = new Dictionary<string, Dictionary<string, double>>();
|
_machineData = new Dictionary<string, Dictionary<string, double>>();
|
||||||
_machineDataType = new Dictionary<string, Dictionary<string, Type>>();
|
_machineDataType = new Dictionary<string, Dictionary<string, Type>>();
|
||||||
GroupNameUid = new Dictionary<string, string>();
|
GroupNameUid = new Dictionary<string, string>();
|
||||||
var tokenResponse = _oauth2.RequestResourceOwnerPasswordAsync
|
var tokenResponse = _oauth2.RequestResourceOwnerPasswordAsync
|
||||||
(
|
(
|
||||||
msg.UserId,
|
msg.UserId,
|
||||||
@@ -77,15 +91,18 @@ namespace ModBus.Net.FBox
|
|||||||
await _httpClient2[ConnectionToken].PostAsync("dmon/group/" + GroupNameUid[ConnectionToken] + "/start",
|
await _httpClient2[ConnectionToken].PostAsync("dmon/group/" + GroupNameUid[ConnectionToken] + "/start",
|
||||||
null);
|
null);
|
||||||
_connected = true;
|
_connected = true;
|
||||||
|
Console.WriteLine("SignalR Connected success");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("SignalR Connected failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("SignalR Connected failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,15 +368,18 @@ namespace ModBus.Net.FBox
|
|||||||
await _httpClient2[ConnectionToken].PostAsync("dmon/group/" + GroupNameUid[ConnectionToken] + "/stop",
|
await _httpClient2[ConnectionToken].PostAsync("dmon/group/" + GroupNameUid[ConnectionToken] + "/stop",
|
||||||
null);
|
null);
|
||||||
_connected = false;
|
_connected = false;
|
||||||
|
Console.WriteLine("SignalR Disconnect success");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("SignalR Disconnect failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("SignalR Disconnect failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user