コード例 #1
0
 private void SystemNetzwerkControl_Load(object sender, EventArgs e)
 {
     GetWifiName();
     GetEthernetName();
     GetBluetoothName();
     lbInfoWLAN.Text   = infoDevice.GetLocalIPAddress();
     lbInfoEXTERN.Text = infoDevice.GetExternalIp();
     lbInfoMAC.Text    = infoDevice.GetMACAddress();
 }
コード例 #2
0
        public void Connect()
        {
            try
            {
                this.listView1.Items.Clear();
                Ping      ping      = new Ping();
                PingReply pingReply = ping.Send("h2618679.stratoserver.net");
                if (pingReply.Status == IPStatus.Success)
                {
                    //bunifuImageButtonLogo.Image = Resources.p_logo001;
                    bunifuImageButtonKontaktPhone.Image = Resources.p_logo001;
                    bunifuImageButtonLogo.Image         = Resources.suc_icon;
                    strLog.AppendLine(string.Format("{0} - Ping server success! \r\n", DateTime.Now.ToString(CultureInfo.InvariantCulture)));
                }
                else
                {
                    //bunifuImageButtonLogo.Image = Resources.p_logo002;
                    bunifuImageButtonKontaktPhone.Image = Resources.p_logo002;
                    bunifuImageButtonLogo.Image         = Resources.er_icon;
                    strLog.AppendLine(string.Format("{0} - Ping server false! \r\n", DateTime.Now.ToString(CultureInfo.InvariantCulture)));
                }
                bunifuImageButton1.Image = Resources.suc_icon;
                bunifuImageButton2.Image = Resources.suc_icon;
                bunifuImageButton3.Image = Resources.suc_icon;
                var firewall = CheckFireWall();
                var windef   = CheckWindownDefender();
                if (firewall)
                {
                    bibFireWall.Image = Resources.wr_icon;
                }
                else
                {
                    bibFireWall.Image = Resources.suc_icon;
                }
                if (windef)
                {
                    bibDef.Image = Resources.wr_icon;
                }
                else
                {
                    bibDef.Image = Resources.suc_icon;
                }
                if (firewall || windef)
                {
                    bunifuImageButtonKontaktPhone.Image = Resources.p_logo003;
                }
                else
                {
                    bunifuImageButtonKontaktPhone.Image = Resources.p_logo001;
                }
                //var ipaddress = GetLocalIPv4(NetworkInterfaceType.Ethernet);

                var ipaddress = infoDevice.GetLocalIPAddress();
                strLog.AppendLine(string.Format("Get Ip: {0}\r\n", ipaddress));
                var ipmac = infoDevice.GetMACAddress();
                strLog.AppendLine(string.Format("Get mac: {0}\r\n", ipmac.ToString()));

                var osname      = HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName");
                var productName = Environment.UserName;// HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "RegisteredOwner");

                var opt   = new IO.Options();
                var query = String.Format("clientIp={0}&name={1}&mac={2}&os={3}&systemTime={4}&clientId={5}&description={6}&socket={7}", ipaddress, productName, ipmac, osname, DateTime.Now.ToString(), "", productName, "");
                opt.QueryString = query;
                opt.ForceNew    = true;
                opt.Port        = 8080;
                opt.Hostname    = "h2618679.stratoserver.net";
                opt.Timeout     = 300000;
                strLog.AppendLine(string.Format("Connect server:\r\n"));
                var socket = IO.Socket("http://h2618679.stratoserver.net:8080", opt);
                RegistryUtil.SetCongifValueToRegistry(RegistryType.ConnectStatus, "true");
                //var socket = IO.Socket("http://h2618679.stratoserver.net:8080");
                // Upon a connection event, update our status
                //socket.On(Socket.EVENT_CONNECT, () =>
                //{
                //    //UpdateStatus("Connected");
                //});
                // Upon temperature data, update our temperature status
                //socket.On("temperature", (data) =>
                //{
                //    var temperature = new { temperature = "" };
                //    var tempValue = JsonConvert.DeserializeAnonymousType((string)data, temperature);
                //    UpdateTemp((string)tempValue.temperature);
                //});
            }
            catch (System.Exception exall)
            {
                RegistryUtil.SetCongifValueToRegistry(RegistryType.ConnectStatus, "false");
                strLog.AppendLine(string.Format("{0} - Connect error: {1}\r\n", DateTime.Now.ToString(CultureInfo.InvariantCulture), exall.Message));
                LogUtil.WriteLogExeption(strLog.ToString());
            }
        }