예제 #1
0
        public void DownloadStringCompleted(object client, DownloadStringCompletedEventArgs response)
        {
            if (response.Cancelled)
            {
                lblStatus.Text      = "Canceled.";
                lblStatus.ForeColor = Color.Black;
                return;
            }
            WebClientExt wcc = (WebClientExt)client;
            string       ip  = wcc.BaseUrl.Split('/')[2];

            if (ip.Split('.')[3] == "254")
            {
                scanStatus          = 2;
                lblStatus.Text      = "Scan Net Segment Finished,Find " + lbUsers.Items.Count + " Cam.";
                btnScanAllNet.Text  = "Scan Finished";
                lblStatus.ForeColor = Color.Green;

                scanTick.Enabled = false;
                scanTick.Stop();
                btnExportXLS.Enabled   = true;
                btnGetUserList.Enabled = true;
            }
            if (response.Error != null)
            {
                //lblStatus.Text = "An error occurred";
                //lblStatus.ForeColor = Color.Red;
                Console.WriteLine(((WebClientExt)client).BaseUrl + response.Error.Message);

                return;
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(response.Result);
            XmlNodeList DeviceInfos = doc.GetElementsByTagName("DeviceInfo");
            XmlNode     Devinfo     = DeviceInfos[0];

            CamInfo temp = new CamInfo
            {
                DeviceID     = Devinfo["deviceID"].InnerText,
                FirewVersion = Devinfo["firmwareVersion"].InnerText,
                MacAddress   = Devinfo["macAddress"].InnerText,
                Model        = Devinfo["model"].InnerText
            };

            //TODO:
            //temp.UserList =

            //CamIp

            temp.Ipaddress = ip;


            allCamInfo.Add(temp);

            lbUsers.Items.Add(temp.Ipaddress);
            lblStatus.Text      = "Loaded " + temp.Ipaddress + " Cam info";
            lblStatus.ForeColor = Color.Green;
        }
예제 #2
0
        /// <summary>
        /// Scan the specific net segment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnScanAllNet_Click(object sender, EventArgs e)
        {
            if (scanStatus != 0)
            {
                MessageBox.Show(scanStatus == 1?"Scanning ...Please wait it finished!":"Click Clear button if start a new scan!");
                return;
            }
            scanTick.Enabled       = true;
            btnGetUserList.Enabled = false;
            scanTick.Start();
            lbUsers.Items.Clear();
            scanStatus             = 1;
            lblStatus.Text         = "Scanning net Segment...";
            lblStatus.ForeColor    = Color.Orange;
            btnSetPassword.Enabled = false;
            btnScanAllNet.Text     = "Scanning Net...";
            WebClientExt wc = new WebClientExt(int.Parse(txbOutTime.Text));

            wc.DownloadStringCompleted += DownloadStringCompleted;

            string[] AllIP = txtIP.Text.Split('.');

            for (int i = 0; i < 255; i++)
            {
                if (scanStatus != 1)
                {
                    return;
                }
                AllIP[3] = i.ToString();
                string url = string.Join(".", AllIP);

                if (wc.IsBusy)
                {
                    lblStatus.Text = "Scanning " + url + "...";
                    WebClientExt wc1 = new WebClientExt(int.Parse(txbOutTime.Text));
                    wc1.DownloadStringCompleted += DownloadStringCompleted;
                    wc1.DownloadStringAsync(new Uri(GetURLBase(url) + "System/deviceInfo?" + BackdoorAuthArg));
                    continue;
                }

                wc.DownloadStringAsync(new Uri(GetURLBase(url) + "System/deviceInfo?" + BackdoorAuthArg));
            }

            //May be add userlist with this
            //wc.
        }