// クエストデータのダウンロード更新 private void updateQuestData() { if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { MessageBox.Show("ネットワークに接続されていません。", StaticCode.APP_NAME); } else { string datafilename = Application.StartupPath + StaticCode.QUEST_FILE_NAME; string questurl = ConfigurationManager.AppSettings[StaticCode.APP_KEY_QUEST_DATA_URL]; Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); network.DownloadFile( questurl, datafilename, "", "", true, 6000, true, Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing); } loadData(); showNewData(questData); bs.Filter = ""; toolStripStatusLabel.Text = bs.Count + "件"; }
private void SetAdressDialog_Load(object sender, EventArgs e) { try { Port = Convert.ToInt16(lblPort.Text); } catch { XtraMessageBox.Show("端口号不符合要求!请重新设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); return; } if (!aiOiTag.Open(IP, Port)) { XtraMessageBox.Show("打开连接失败,\n请检查IP和端口号是否正确!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); if (!network.Ping(IP)) { XtraMessageBox.Show("控制器IP错误或控制器与本机不在同一个网络!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); return; } }
/// <summary> /// 現在のバージョンの上位バージョンにアップデートします /// </summary> public void Update() { if (String.IsNullOrEmpty(this.downUrl)) { throw new InvalidOperationException("ダウンロード先のURLが指定されていません。先にCheckメソッドを実行してから呼び出してください。"); } var net = new Microsoft.VisualBasic.Devices.Network(); string c = gs.CurrentDirectory; net.DownloadFile(this.downUrl, c + "\\new.zip", "", "", true, 25, true, Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing); net.DownloadFile(this.downUrl + ".txt", c + "\\new.txt", "", "", false, 10, true, Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing); string cc = c + "\\old"; // using (File.Create(cc + "\\browser.exe")) { } //using (File.Create(cc + "\\library.dll")) { } // using (File.Create(cc + "\\plugin.dll")) { } File.Delete(cc + "\\browser.exe"); File.Delete(cc + "\\library.dll"); File.Delete(cc + "\\plugin.dll"); File.Move(c + "\\VIPBrowser.exe", cc + "\\browser.exe"); File.Move(c + "\\VIPBrowserLibrary.dll", cc + "\\library.dll"); File.Move(c + "\\VIPBrowserPlugin.dll", cc + "\\plugin.dll"); Chron.ZIPData zd = new Chron.ZIPData(); zd.ExtractZipFile(c + "\\new.zip", c); Process.Start(c + "\\VIPBrowser.exe", "/up " + Process.GetCurrentProcess().Id); System.Windows.Forms.Application.Exit(); File.Delete(c + "\\lock"); return; }
private void SetAdressDialog_Load(object sender, EventArgs e) { try { Port = Convert.ToInt16(lblPort.Text); } catch { XtraMessageBox.Show("端口号不符合要求!请重新设置!","提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); this.Close(); return; } if (!aiOiTag.Open(IP, Port)) { XtraMessageBox.Show("打开连接失败,\n请检查IP和端口号是否正确!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); if (!network.Ping(IP)) { XtraMessageBox.Show("控制器IP错误或控制器与本机不在同一个网络!", "提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); this.Close(); return; } }
// Pulls together pieces of information that can be useful in tracking down user issues that don't create an error popup private string DumpConfig(MainWindow mainWindow) { PresentationSource source = PresentationSource.FromVisual(mainWindow); System.Drawing.Point CurrentLocation = new System.Drawing.Point((int)mainWindow.Left, (int)mainWindow.Top); // Pull in VisualBasic stuff to make up for C# WPF not having many features accessible for this Microsoft.VisualBasic.Devices.ComputerInfo ComputerInfo = new Microsoft.VisualBasic.Devices.ComputerInfo(); Microsoft.VisualBasic.Devices.Computer Computer = new Microsoft.VisualBasic.Devices.Computer(); Microsoft.VisualBasic.Devices.Network Network = new Microsoft.VisualBasic.Devices.Network(); Microsoft.VisualBasic.Devices.ServerComputer ServerComputer = new Microsoft.VisualBasic.Devices.ServerComputer(); Microsoft.VisualBasic.ApplicationServices.ApplicationBase ApplicationBase = new Microsoft.VisualBasic.ApplicationServices.ApplicationBase(); StringBuilder Detail = new StringBuilder(); string RegistryPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; Detail.AppendLine(string.Format("OS: {0}", Microsoft.Win32.Registry.GetValue(RegistryPath, "ProductName", null))); Detail.AppendLine(string.Format("BLD: {0}", Microsoft.Win32.Registry.GetValue(RegistryPath, "CurrentBuild", null))); Detail.AppendLine(string.Format("LAB: {0}", Microsoft.Win32.Registry.GetValue(RegistryPath, "BuildLab", null))); // Check if the user is running this under Wine Detail.AppendLine(string.Format("WINE: {0}", (Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wine") != null ? true : false))); Detail.AppendLine(string.Format("ADM: {0}", new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator).ToString())); Detail.AppendLine(string.Format("DPI: X: {0}, Y: {1}", source.CompositionTarget.TransformToDevice.M11 * 96, source.CompositionTarget.TransformToDevice.M22 * 96)); Detail.AppendLine(string.Format("PMN: {0}", Computer.Screen.Primary)); Detail.AppendLine(string.Format("RES: X: {0}, Y: {1}", Computer.Screen.Bounds.Width, Computer.Screen.Bounds.Height)); Detail.AppendLine(string.Format("SWA: X: {0}, Y: {1}, W: {2}, H: {3}", Computer.Screen.WorkingArea.X, Computer.Screen.WorkingArea.Y, Computer.Screen.WorkingArea.Width, Computer.Screen.WorkingArea.Height)); Detail.AppendLine(string.Format("BPP: {0}", Computer.Screen.BitsPerPixel)); Detail.AppendLine(string.Format("SDN: {0}", Computer.Screen.DeviceName)); Detail.AppendLine(string.Format("NWK: {0}", System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())); Detail.AppendLine(string.Format("CCN: {0}", System.Globalization.CultureInfo.InstalledUICulture.EnglishName)); Detail.AppendLine(string.Format("SCN: {0}", System.Globalization.CultureInfo.InstalledUICulture.Name)); // Byte -> Megabyte = / 1048576 // Byte -> Gigabyte = / 1073741824 Detail.AppendLine(string.Format("APM: {0}/{1}", (ComputerInfo.AvailablePhysicalMemory / 1048576), (ComputerInfo.TotalPhysicalMemory / 1048576))); // Something is not right with this, the values are WAY too high Detail.AppendLine(string.Format("AVM: {0}/{1}", (ComputerInfo.AvailableVirtualMemory / 1048576), (ComputerInfo.TotalVirtualMemory / 1048576))); Detail.AppendLine(string.Format("VER: {0}", ApplicationBase.Info.Version.ToString())); Detail.AppendLine(string.Format("DIR: {0}", ApplicationBase.Info.DirectoryPath.ToString())); Detail.AppendLine(string.Format("APP: {0}", System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName))); Detail.AppendLine(string.Format("SZE: Width: {0}, Height: {1}", mainWindow.Width, mainWindow.Height)); Detail.AppendLine(string.Format("CLT: Width: {0}, Height: {1}", mainWindow.RenderSize.Width, mainWindow.RenderSize.Height)); // Wrap motherboard information in a try because something can always not work in this, better to skip it all than try for each try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_BaseBoard"); foreach (ManagementObject wmi in searcher.Get()) { Detail.AppendLine(string.Format("MBM: {0}", wmi.GetPropertyValue("Manufacturer").ToString())); Detail.AppendLine(string.Format("MBID: {0}", wmi.GetPropertyValue("Product").ToString())); } } catch { } return(Detail.ToString()); }
static async void MakeRequest() { var queryString = HttpUtility.ParseQueryString(string.Empty); // Request headers //client.DefaultRequestHeaders.Add("Content-Type", "application/octet-stream"); //client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}"); // Request parameters //queryString["analyzesFaceLandmarks"] = "false"; //queryString["analyzesAge"] = "false"; //queryString["analyzesGender"] = "false"; //queryString["analyzesHeadPose"] = "false"; var uri = "http://192.168.43.161:8888/poll" + queryString; var uriimage = "http://192.168.43.161:8888/image" + queryString; HttpResponseMessage response; // Request body //byte[] byteData = Encoding.UTF8.GetBytes("{body}"); //using (var content = new ByteArrayContent(byteData)) //{ // content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >"); // response = await client.PostAsync(uri, content); //} while (true) { try { using (var client = new HttpClient()) { response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { var fm = new Form1(); fm.textBox1.Text = await response.Content.ReadAsStringAsync(); using (var clienti = new HttpClient()) { //fm.pictureBox1.Image = new Bitmap(await clienti.GetStreamAsync(uriimage)); var ntwk = new Microsoft.VisualBasic.Devices.Network(); ntwk.DownloadFile(uriimage, "temp.jpg", "", "", false, 100, true); fm.pictureBox1.Image = new Bitmap("temp.jpg"); } fm.ShowDialog(); } } } catch (Exception e) { Console.WriteLine(e.Message); } await Task.Delay(2000); } }
private void CmdDialog_Load(object sender, EventArgs e) { if (!aiOiTag.Open(IP, Port)) { XtraMessageBox.Show("打开连接失败,\n请检查IP和端口号是否正确!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); if (!network.Ping(IP)) { XtraMessageBox.Show("控制器IP错误或控制器与本机不在同一个网络!", "提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation); this.Close(); return; } }
private void CmdDialog_Load(object sender, EventArgs e) { if (!aiOiTag.Open(IP, Port)) { XtraMessageBox.Show("打开连接失败,\n请检查IP和端口号是否正确!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); if (!network.Ping(IP)) { XtraMessageBox.Show("控制器IP错误或控制器与本机不在同一个网络!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); return; } }
public static void Initialize(string LedCollection) { leds.DelAllProgram(); isActiveLeds.Clear(); string[] ledConfig = LedCollection.Split(';'); Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); foreach (string led in ledConfig) { if (network.Ping(led.Split(',')[1])) { isActiveLeds.Add(Convert.ToInt32(led.Split(',')[0]), led.Split(',')[1]); leds.Add(Convert.ToInt32(led.Split(',')[0])); } else { Logger.Error(Convert.ToInt32(led.Split(',')[0]) + "号LED屏故障,请检查!IP:[" + led.Split(',')[1] + "]"); } } }
private static bool IsOnLineLed(int ledNo) { if (isActiveLeds.ContainsKey(ledNo)) { Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); if (!network.Ping(isActiveLeds[ledNo])) { //Logger.Error(ledNo + "号LED屏故障,请检查!IP:[" + isActiveLeds[ledNo] + "]"); return(false); } else { return(true); } } else { return(false); } }
public override void Initialize(Context context) { base.Initialize(context); Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); string[] ledConfig = context.Attributes["IsActiveLeds"].ToString().Split(';'); foreach (string led in ledConfig) { if (network.Ping(led.Split(',')[1])) { isActiveLeds.Add(Convert.ToInt32(led.Split(',')[0]), led.Split(',')[1]); } else { Logger.Error(Convert.ToInt32(led.Split(',')[0]) + "ºÅLEDÆÁ¹ÊÕÏ£¬Çë¼ì²é£¡IP:[" + led.Split(',')[1] + "]"); } } ledUtil.isActiveLeds = isActiveLeds; }
private bool IsOnLineLed(int ledNo) { if (isActiveLeds.ContainsKey(ledNo)) { Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); if (!network.Ping(isActiveLeds[ledNo])) { THOK.MCP.Logger.Error(ledNo + "��LED�����ϣ����飡IP:[" + isActiveLeds[ledNo] + "]"); return false; } else return true; } else return false; }
/// <summary> /// Tells if the computer is connected to a network or not /// </summary> /// <returns>True = Connected To Network</returns> public static bool isConnectedToNetwork() { Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); return network.IsAvailable; }
/// <summary> /// Tells if the computer is connected to a network or not /// </summary> /// <returns>True = Connected To Network</returns> public static bool isConnectedToNetwork() { Microsoft.VisualBasic.Devices.Network network = new Microsoft.VisualBasic.Devices.Network(); return(network.IsAvailable); }