コード例 #1
0
        private void LoginAllbutton(ref DevInfo dev, ref Int32 userID, ToolStripMenuItem toolStripMenuItem, ToolStripMenuItem ifActivateLive)
        {
            string DVRIPAddress  = dev.getIP();                //设备IP地址或者域名
            Int16  DVRPortNumber = Int16.Parse(dev.getPort()); //设备服务端口号
            string DVRUserName   = dev.getUserID();            //设备登录用户名
            string DVRPassword   = dev.getPassword();          //设备登录密码

            CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V30();

            //登录设备 Login the device
            userID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
            if (userID < 0)
            {
                iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                str      = "NET_DVR_Login_V30 failed, error code= " + iLastErr; //登录失败,输出错误号
                MessageBox.Show(str);

                return;
            }
            else
            {
                //登录成功
                string tmp = dev.getIP() + "login success!";
                toolStripMenuItem.Text = "Logout";
                if (!IsActivatedLiveAll)
                {
                    IsActivatedLiveAll = IfactivateLiveAll(IsActivatedLiveAll);
                }

                ArgsEvent(tmp);
                ifActivateLive.Enabled = true;
                return;
            }
        }
コード例 #2
0
        private void loginButton(ref DevInfo dev, ref Int32 userID, Int32 realHandler)
        {
            if (userID > 0)
            {
                return;
            }
            if (checkInfo(ref dev))
            {
                string tmp = "Please input IP, Port, User name, Password and StreamType!";
                MessageBox.Show(tmp);
                return;
            }
            if (userID < 0)
            {
                //string DVRIPAddress = textBoxIP.Text; //设备IP地址或者域名
                //Int16 DVRPortNumber = Int16.Parse(textBoxPort.Text);//设备服务端口号
                //string DVRUserName = textBoxUserName.Text;//设备登录用户名
                //string DVRPassword = textBoxPassword.Text;//设备登录密码
                string DVRIPAddress  = dev.getIP();                //设备IP地址或者域名
                Int16  DVRPortNumber = Int16.Parse(dev.getPort()); //设备服务端口号
                string DVRUserName   = dev.getUserID();            //设备登录用户名
                string DVRPassword   = dev.getPassword();          //设备登录密码

                CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V30();

                //登录设备 Login the device
                userID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
                if (userID < 0)
                {
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                    str      = "NET_DVR_Login_V30 failed, error code= " + iLastErr; //登录失败,输出错误号
                    MessageBox.Show(str);

                    return;
                }
                else
                {
                    //登录成功
                    string tmp = dev.getIP() + " login success!";

                    ArgsEvent(tmp);
                }
            }
        }
コード例 #3
0
 private static bool checkInfo(ref DevInfo e)
 {
     return(e.getUserID() == "" || e.getPassword() == "" || e.getStreamType() == "" || e.getIP() == "" ||
            e.getPort() == "");
 }
コード例 #4
0
        private void loginButton(ref DevInfo dev, ref Int32 userID, ref Int32 realHandler, ToolStripMenuItem toolStripMenuItem, ToolStripMenuItem ifActivateLive)
        {
            if (userID >= 0)
            {
                if (realHandler >= 0)
                {
                    MessageBox.Show("Please stop live view firstly");

                    return;
                }

                if (!CHCNetSDK.NET_DVR_Logout(userID))
                {
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                    str      = "NET_DVR_Logout failed, error code= " + iLastErr;
                    MessageBox.Show(str);

                    return;
                }

                ArgsEvent("Logout succeeded");
                userID = -1;
                toolStripMenuItem.Text = "Login";
                if (IsActivatedLiveAll)
                {
                    IsActivatedLiveAll     = IfactivateLiveAll(IsActivatedLiveAll);
                    ifActivateLive.Enabled = false;
                }
            }
            //if (checkInfo(ref dev))
            //{
            //    string tmp = "Please input IP, Port, User name, Password and StreamType!";
            //    MessageBox.Show(tmp);
            //    return;
            //}
            else
            {
                //string DVRIPAddress = textBoxIP.Text; //设备IP地址或者域名
                //Int16 DVRPortNumber = Int16.Parse(textBoxPort.Text);//设备服务端口号
                //string DVRUserName = textBoxUserName.Text;//设备登录用户名
                //string DVRPassword = textBoxPassword.Text;//设备登录密码
                string DVRIPAddress  = dev.getIP();                //设备IP地址或者域名
                Int16  DVRPortNumber = Int16.Parse(dev.getPort()); //设备服务端口号
                string DVRUserName   = dev.getUserID();            //设备登录用户名
                string DVRPassword   = dev.getPassword();          //设备登录密码

                CHCNetSDK.NET_DVR_DEVICEINFO_V30 DeviceInfo = new CHCNetSDK.NET_DVR_DEVICEINFO_V30();

                //登录设备 Login the device
                userID = CHCNetSDK.NET_DVR_Login_V30(DVRIPAddress, DVRPortNumber, DVRUserName, DVRPassword, ref DeviceInfo);
                if (userID < 0)
                {
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                    str      = "NET_DVR_Login_V30 failed, error code= " + iLastErr; //登录失败,输出错误号
                    MessageBox.Show(str);

                    return;
                }
                else
                {
                    //登录成功
                    string tmp = dev.getIP() + " login success!";
                    toolStripMenuItem.Text = "Logout";
                    if (!IsActivatedLiveAll)
                    {
                        IsActivatedLiveAll = IfactivateLiveAll(IsActivatedLiveAll);
                    }
                    ArgsEvent(tmp);
                    ifActivateLive.Enabled = true;
                    return;
                }
            }
        }