public bool Init(string devName, string username, string pwd, string ip, string port) { H264_DVR_DEVICEINFO dvrdevInfo = new H264_DVR_DEVICEINFO(); dvrdevInfo.Init(); int nError; SDK_HANDLE nLoginID = NetSDK.H264_DVR_Login( ip.Trim(), ushort.Parse(port.Trim()), username, pwd, ref dvrdevInfo, out nError, SocketStyle.TCPSOCKET); if (nLoginID > 0) { devInfo.szDevName = devName; devInfo.lLoginID = nLoginID; devInfo.nPort = Int32.Parse(port); devInfo.szIpaddress = ip; devInfo.szUserName = username; devInfo.szPsw = pwd; devInfo.NetDeviceInfo = dvrdevInfo; status = 1; return(true); } return(false); }
public void Login(LoginInfo logininfo) { H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO(); OutDev.Init(); int nError = 0; loginUserId = XMNetSDK.H264_DVR_Login(logininfo.Ip, (ushort)logininfo.Port, logininfo.UserName, logininfo.Password, ref OutDev, out nError, SocketStyle.TCPSOCKET); if (loginUserId <= 0) { int nErr = XMNetSDK.H264_DVR_GetLastError(); throw new Exception("[雄迈]登录失败:" + nErr); } XMNetSDK.H264_DVR_SetupAlarmChan(loginUserId); }
public void ReConnect(object source, System.Timers.ElapsedEventArgs e) { foreach (DEV_INFO devinfo in dictDiscontDev.Values) { H264_DVR_DEVICEINFO OutDev = new H264_DVR_DEVICEINFO(); int nError = 0; int lLogin = NETSDK.H264_DVR_Login(devinfo.szIpaddress, (ushort)devinfo.nPort, devinfo.szUserName, devinfo.szPsw, out OutDev, out nError, SocketStyle.TCPSOCKET); if (lLogin <= 0) { int nErr = NETSDK.H264_DVR_GetLastError(); if (nErr == (int)SDK_RET_CODE.H264_DVR_PASSWORD_NOT_VALID) { MessageBox.Show(("Password Error")); } else if (nErr == (int)SDK_RET_CODE.H264_DVR_LOGIN_USER_NOEXIST) { MessageBox.Show(("User Not Exist")); } return; } dictDiscontDev.Remove(devinfo.lLoginID); ClientDemo clientForm = new ClientDemo(); foreach (Form form in Application.OpenForms) { if (form.Name == "ClientDemo") { clientForm = (ClientDemo)form; break; } } DEV_INFO devAdd = new DEV_INFO(); devAdd = devinfo; devAdd.lLoginID = lLogin; foreach (TreeNode node in clientForm.devForm.DevTree.Nodes) { if (node.Name == "Device") { DEV_INFO dev = (DEV_INFO)node.Tag; if (dev.lLoginID == devinfo.lLoginID) { node.Text = devAdd.szDevName; node.Tag = devAdd; node.Name = "Device"; foreach (TreeNode channelnode in node.Nodes) { CHANNEL_INFO chInfo = (CHANNEL_INFO)channelnode.Tag; if (chInfo.nWndIndex > -1) { clientForm.m_videoform[chInfo.nWndIndex].ConnectRealPlay(ref devAdd, chInfo.nChannelNo); Thread.Sleep(10); } } break; } } } dictDevInfo.Add(lLogin, devAdd); NETSDK.H264_DVR_SetupAlarmChan(lLogin); } if (0 == dictDiscontDev.Count) { timerDisconnect.Enabled = false; timerDisconnect.Stop(); } }