Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
 private static bool checkInfo(ref DevInfo e)
 {
     return(e.getUserID() == "" || e.getPassword() == "" || e.getStreamType() == "" || e.getIP() == "" ||
            e.getPort() == "");
 }
Ejemplo n.º 3
0
 private void SetValueForInitCam(ref InitCam initCam, ref Int32 userId, ref Int32 realHandle, DevInfo devInfo, PictureBox pictureBox, ref bool isSetted)
 {
     initCam.DevInfo = new DevInfo();
     if (!isSetted)
     {
         initCam.UserId        = userId;
         initCam.m_lRealHandle = realHandle;
         isSetted = true;
     }
     initCam.DevInfo    = devInfo;
     initCam.PictureBox = pictureBox;
 }