Beispiel #1
0
        public bool LoginCam()
        {
            if (!m_bInit)
            {
                // MessageBox.Show("Library Initialization Failed");
                return(false);
            }

            //Obtain Device User Information
            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int            error      = 0;

            m_nLoginID = NETClient.NETLogin(ipCamGlobal1, ushort.Parse("37777"),
                                            "admin", "admin", out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                m_nChannelNum = deviceInfo.byChanNum;
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    // MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON   = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    //  MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                }
            }

            NET_DEVICEINFO deviceInfo2 = new NET_DEVICEINFO();
            int            error2      = 0;

            m_nLoginID2 = NETClient.NETLogin(ipCamGlobal2, ushort.Parse("37777"),
                                             "admin", "admin", out deviceInfo2, out error2);
            if (m_nLoginID2 > 0)
            {
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID2, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON2  = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON2 == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID2, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID2, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                } //else
            }     //if login


            NET_DEVICEINFO deviceInfo3 = new NET_DEVICEINFO();
            int            error3      = 0;

            m_nLoginID3 = NETClient.NETLogin(ipCamGlobal3, ushort.Parse("37777"),
                                             "admin", "admin", out deviceInfo3, out error3);
            if (m_nLoginID3 > 0)
            {
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID3, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON3  = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON3 == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID3, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID3, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                } //else
            }     //if login

            NET_DEVICEINFO deviceInfo4 = new NET_DEVICEINFO();
            int            error4      = 0;

            m_nLoginID4 = NETClient.NETLogin(ipCamGlobal4, ushort.Parse("37777"),
                                             "admin", "admin", out deviceInfo4, out error4);
            if (m_nLoginID4 > 0)
            {
                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID4, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    //MessageBox.Show("Query device ability failed");
                    return(false);
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON4  = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON4 == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID4, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //   MessageBox.Show("Get Snap Capability Set Failed!");
                        return(false);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else//json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID4, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    // MessageBox.Show("Get Snap Configuration Failed!");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                } //else
            }     //if login

            return(true);
        }//Method
Beispiel #2
0
        private void Login_Click(object sender, EventArgs e)
        {
            if (!m_bInit)
            {
                MessageBox.Show("Library Initialization Failed");
                return;
            }

            //Obtain Device User Information
            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int            error      = 0;

            m_nLoginID = NETClient.NETLogin(this.textBoxIP.Text.ToString(), ushort.Parse(this.textBoxPort.Text.ToString()),
                                            this.textBoxUser.Text.ToString(), this.textBoxPsw.Text.ToString(), out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                this.Login.Enabled  = false;
                this.Logout.Enabled = true;
                m_nChannelNum       = deviceInfo.byChanNum;
                for (int i = 0; i < m_nChannelNum; ++i)
                {
                    this.comboBoxChannel.Items.Add(i.ToString());
                }

                //query json ability.
                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                if (bRet == false)
                {
                    //MessageBox.Show(ConvertString("Query device ability failed."));
                    MessageBox.Show("Query device ability failed");
                    return;
                }


                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON   = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        MessageBox.Show("Get Snap Capability Set Failed!");
                        return;
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }
                else //json
                {
                    InitSnapConfigExUI(0);
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);
                if (!bRet)
                {
                    MessageBox.Show("Get Snap Configuration Failed!");
                    return;
                }
                else
                {
                    for (int i = 0; i < 32; ++i)
                    {
                        m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                                  , typeof(NETDEV_SNAP_CFG));
                    }
                }

                if (this.comboBoxChannel.Items.Count > 0)
                {
                    this.comboBoxChannel.SelectedIndex = 0;
                }

                this.buttonGet.Enabled   = true;
                this.buttonSet.Enabled   = true;
                this.buttonStart.Enabled = true;
                this.buttonStop.Enabled  = true;
            }
        }
Beispiel #3
0
        /// <summary>
        /// string [0]status [1] result
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="username"></param>
        /// <param name="passwod"></param>
        /// <returns></returns>
        public List <string> Login(string ip, string port, string username, string passwod)
        {
            List <string> list = new List <string>();

            if (!m_bInit)
            {
                list.Add("未初始化或者初始化失败");
                return(list);
            }

            NET_DEVICEINFO deviceInfo = new NET_DEVICEINFO();
            int            error      = 0;

            m_nLoginID = NETClient.NETLogin(ip, (ushort)Convert.ToInt32(port), username, passwod, out deviceInfo, out error);

            if (m_nLoginID > 0)
            {
                m_nChannelNum = deviceInfo.byChanNum;

                Int32  dwRetLen   = 0;
                IntPtr pDevEnable = new IntPtr();
                pDevEnable = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)));
                bool bRet = NETClient.NETQuerySystemInfo(m_nLoginID, NET_SYS_ABILITY.ABILITY_DEVALL_INFO, pDevEnable,
                                                         Marshal.SizeOf(typeof(NET_DEV_ENABLE_INFO)), ref dwRetLen, 1000);
                NET_DEV_ENABLE_INFO devEnable = new NET_DEV_ENABLE_INFO();
                devEnable = (NET_DEV_ENABLE_INFO)Marshal.PtrToStructure(pDevEnable, typeof(NET_DEV_ENABLE_INFO));
                m_bJSON   = devEnable.IsFucEnable[(Int32)NET_FUN_SUPPORT.EN_JSON_CONFIG] > 0 ? true : false;

                if (m_bJSON == false)
                {
                    int    nRetLen      = 0;
                    IntPtr pStuSnapAttr = new IntPtr();
                    pStuSnapAttr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)));
                    bool nRet = NETClient.NETQueryDevState(m_nLoginID, (int)NETClient.NET_DEVSTATE_SNAP
                                                           , pStuSnapAttr, Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)), ref nRetLen, 1000);
                    if (nRet == false || nRetLen != Marshal.SizeOf(typeof(NET_SNAP_ATTR_EN)))
                    {
                        //MessageBox.Show("查询设备状态失败");
                        list.Add("查询设备状态失败");
                        return(list);
                    }
                    else
                    {
                        m_stuSnapAttr = (NET_SNAP_ATTR_EN)Marshal.PtrToStructure(pStuSnapAttr, typeof(NET_SNAP_ATTR_EN));
                    }
                }

                IntPtr pSnapCfg = new IntPtr();
                pSnapCfg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32);
                UInt32 dwRetConfig = 0;
                bRet = NETClient.NETGetDevConfig(m_nLoginID, CONFIG_COMMAND.NET_DEV_SNAP_CFG, -1, pSnapCfg, (UInt32)Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)) * 32, ref dwRetConfig, 1000);

                for (int i = 0; i < 32; ++i)
                {
                    m_stuSnapCfg[i] = (NETDEV_SNAP_CFG)Marshal.PtrToStructure((IntPtr)((UInt32)pSnapCfg + i * Marshal.SizeOf(typeof(NETDEV_SNAP_CFG)))
                                                                              , typeof(NETDEV_SNAP_CFG));
                }
            }
            list.Add("登陆成功");
            return(list);
        }