98 lines
2.3 KiB
C#
98 lines
2.3 KiB
C#
using System;
|
|
using U8Login;
|
|
|
|
|
|
namespace U8ApiInterface
|
|
{
|
|
public class U8LoginContext : IDisposable
|
|
{
|
|
|
|
|
|
private static U8LoginContext _u8LoginContext;
|
|
|
|
public static U8LoginContext Instance
|
|
{
|
|
get
|
|
{
|
|
|
|
if (_u8LoginContext == null)
|
|
{
|
|
_u8LoginContext = new U8LoginContext();
|
|
}
|
|
return _u8LoginContext;
|
|
}
|
|
}
|
|
|
|
|
|
private UFSoft.U8.Framework.Login.UI.clsLogin clsLogin;
|
|
|
|
private clsLogin _clslogin;
|
|
|
|
private U8LoginContext()
|
|
{
|
|
clsLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();
|
|
}
|
|
|
|
public clsLogin ClsLogin
|
|
{
|
|
get
|
|
{
|
|
if (this._clslogin == null)
|
|
{
|
|
this.Login();
|
|
}
|
|
return this._clslogin;
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (clsLogin != null)
|
|
{
|
|
clsLogin.SubLogout(AccID);
|
|
clsLogin.ShutDown();
|
|
clsLogin = null;
|
|
}
|
|
|
|
}
|
|
public string UserId { get; set; } = "003";
|
|
|
|
public string PassWord { get; set; } = "123456";
|
|
|
|
public string Server { get; set; } = "192.168.0.242";
|
|
|
|
public string AccID { get; set; } = "u8@889";
|
|
|
|
public string Serial { get; set; }
|
|
|
|
public void Login()
|
|
{
|
|
var a = clsLogin.GetDataSource("192.168.0.250");
|
|
|
|
if (!clsLogin.login("DP", "wx998", "nx123456", "192.168.0.250","2020-12-31", AccID, Serial))
|
|
{
|
|
throw new Exception(clsLogin.ErrDescript);
|
|
}
|
|
|
|
if (clsLogin.SubLogin("ST") == null)
|
|
{
|
|
throw new Exception(clsLogin.ErrDescript);
|
|
}
|
|
this._clslogin = new clsLoginClass();
|
|
if (!_clslogin.ConstructLogin(clsLogin.userToken))
|
|
{
|
|
throw new Exception(_clslogin.ShareString);
|
|
}
|
|
_clslogin.set_TaskId(clsLogin.GetTaskID("ST"));
|
|
|
|
//U8EnvContext u8EnvContext = new U8EnvContext
|
|
//{
|
|
// U8Login = this._clslogin
|
|
//};
|
|
|
|
//return true;
|
|
|
|
}
|
|
}
|
|
}
|