public ERRORCODE SetLoginInfo(LOGIN_INFO loginInfo) { ERRORCODE nErrorCode = OIAS_SetLoginInfo(hClient, loginInfo);; return(nErrorCode); }
public override void RegisterDevice(Device device) { if (mapDriver.ContainsKey(device.id)) { return; } OIASClient oiasClient = new OIASClient(); oiasClient.Notify += new OIASClient.OIASNotifyEventHandler(cbOIASNotifyRecvProc); mapDriver.Add(device.id, oiasClient); LOGIN_INFO loginInfo = new LOGIN_INFO(); loginInfo.hostIP = device.ip; loginInfo.hostPort = device.port; loginInfo.userName = device.user; loginInfo.password = device.pwd; oiasClient.SetLoginInfo(loginInfo); if (!oiasClient.HasSessionFault && oiasClient.Login() == 0) { OBJECT_LIST list = new OBJECT_LIST(); IntPtr listPtr = new IntPtr(Marshal.SizeOf(list)); if (oiasClient.ListFault(list) == 0) { if (list.count > 0) { int[] itemAddresses = new int[list.count]; Marshal.Copy(list.items, itemAddresses, 0, list.count); for (int i = 0; i < list.count; i++) { NOTIFY_INFO subNotifyInfo = new NOTIFY_INFO(); IntPtr itemPtr = new IntPtr(itemAddresses[i]); Marshal.PtrToStructure(itemPtr, subNotifyInfo); if (subNotifyInfo.objectType == "sensor") { ParseSensorEvent(subNotifyInfo.objectName, subNotifyInfo.eventName); } if (DataReceived != null) { string msg = string.Format("历史事件:IP:{0},name:{1}, event:{2},description:{3}", device.ip, subNotifyInfo.objectName, subNotifyInfo.eventName, subNotifyInfo.description); DataReceived(msg); } } } } if (DataReceived != null) { DataReceived("start success"); } OnConnectEH(device, 0); } else { if (DataReceived != null) { DataReceived("start failure"); } OnConnectEH(device, 1); } }
public static extern ERRORCODE OIAS_SetLoginInfo(HCLIENT hClient, LOGIN_INFO loginInfo);