private _m_WiFi_Watcher_Node ReaderToWiFi(SQLiteDataReader Reader) { _m_WiFi_Watcher_Node mwwn = new _m_WiFi_Watcher_Node(); mwwn.Name = Reader["Name"].ToString(); mwwn.Description = Reader["Description"].ToString(); mwwn.GUID = Reader["GUID"].ToString(); mwwn.Physical_address = Reader["Physical_address"].ToString(); mwwn.State = Reader["State"].ToString(); mwwn.SSID = Reader["SSID"].ToString(); mwwn.BSSID = Reader["BSSID"].ToString(); mwwn.Network_type = Reader["Network_type"].ToString(); mwwn.Radio_type = Reader["Radio_type"].ToString(); mwwn.Authentication = Reader["Authentication"].ToString(); mwwn.Cipher = Reader["Cipher"].ToString(); mwwn.Connection_mode = Reader["Connection_mode"].ToString(); mwwn.Channel = Reader["Channel"].ToString(); mwwn.Receive_rate = Reader["Receive_rate"].ToString(); mwwn.Transmit_rate = Reader["Transmit_rate"].ToString(); mwwn.Signal = Reader["Signal"].ToString(); mwwn.Profile = Reader["Profile"].ToString(); mwwn.Hosted_network_status = Reader["Hosted_network_status"].ToString(); mwwn.date = DateTime.Parse(Reader["date"].ToString()); return(mwwn); }
public void AddWifiToDB(_m_WiFi_Watcher_Node WifiNode) { SQLiteCommand cmd = new SQLiteCommand(dbConnection); cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into WiFiInfo (Name,Description,GUID,Physical_address,State,SSID,BSSID,Network_type,Radio_type,Authentication,Cipher,Connection_mode,Channel,Receive_rate,Transmit_rate,Signal,Profile,Hosted_network_status,date)" + " values (@Name,@Description,@GUID,@Physical_address,@State,@SSID,@BSSID,@Network_type,@Radio_type,@Authentication,@Cipher,@Connection_mode,@Channel,@Receive_rate,@Transmit_rate,@Signal,@Profile,@Hosted_network_status,@date)"; cmd.Parameters.Add("Name", DbType.String).Value = WifiNode.Name; cmd.Parameters.Add("Description", DbType.String).Value = WifiNode.Description; cmd.Parameters.Add("GUID", DbType.String).Value = WifiNode.GUID; cmd.Parameters.Add("Physical_address", DbType.String).Value = WifiNode.Physical_address; cmd.Parameters.Add("State", DbType.String).Value = WifiNode.State; cmd.Parameters.Add("SSID", DbType.String).Value = WifiNode.SSID; cmd.Parameters.Add("BSSID", DbType.String).Value = WifiNode.BSSID; cmd.Parameters.Add("Network_type", DbType.String).Value = WifiNode.Network_type; cmd.Parameters.Add("Radio_type", DbType.String).Value = WifiNode.Radio_type; cmd.Parameters.Add("Authentication", DbType.String).Value = WifiNode.Authentication; cmd.Parameters.Add("Cipher", DbType.String).Value = WifiNode.Cipher; cmd.Parameters.Add("Connection_mode", DbType.String).Value = WifiNode.Connection_mode; cmd.Parameters.Add("Channel", DbType.String).Value = WifiNode.Channel; cmd.Parameters.Add("Receive_rate", DbType.String).Value = WifiNode.Receive_rate; cmd.Parameters.Add("Transmit_rate", DbType.String).Value = WifiNode.Transmit_rate; cmd.Parameters.Add("Signal", DbType.String).Value = WifiNode.Signal; cmd.Parameters.Add("Profile", DbType.String).Value = WifiNode.Profile; cmd.Parameters.Add("Hosted_network_status", DbType.String).Value = WifiNode.Hosted_network_status; cmd.Parameters.Add("date", DbType.DateTime).Value = WifiNode.date; cmd.ExecuteNonQuery(); }
public void StartWatching() { while (keepRunning) { System.Threading.Thread.Sleep(1000); OnExecuteProcessResponse ExecuteResponse = _m_Process_Manager.OnExecuteProcess("netsh.exe", "wlan show interfaces", ProcessOutputType: _m_Child_Process.Enum_ProcessOutputType.Cmd, FullHide: false); string Output = ExecuteResponse.Output; //TODO Add to db if (!Output.Contains("There is no wireless interface on the system")) { _m_WiFi_Watcher_Node mwwn = new _m_WiFi_Watcher_Node(); mwwn.date = DateTime.Now; string[] lines = Output.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { string[] SplitedByColon = line.Split(new[] { " : " }, StringSplitOptions.RemoveEmptyEntries); if (SplitedByColon.Length < 2) { continue; } string PropertyName = SplitedByColon[0].TrimStart().TrimEnd(); if (PropertyName != "") { string PropertyValue = SplitedByColon[1].TrimStart(); if (PropertyValue != "") { if (PropertyName == "Name") { mwwn.Name = PropertyValue; } else if (PropertyName == "Description") { mwwn.Description = PropertyValue; } else if (PropertyName == "GUID") { mwwn.GUID = PropertyValue; } else if (PropertyName == "Physical address") { mwwn.Physical_address = PropertyValue; } else if (PropertyName == "State") { mwwn.State = PropertyValue; } else if (PropertyName == "SSID") { mwwn.SSID = PropertyValue; } else if (PropertyName == "BSSID") { mwwn.BSSID = PropertyValue; } else if (PropertyName == "Network type") { mwwn.Network_type = PropertyValue; } else if (PropertyName == "Radio type") { mwwn.Radio_type = PropertyValue; } else if (PropertyName == "Authentication") { mwwn.Authentication = PropertyValue; } else if (PropertyName == "Cipher") { mwwn.Cipher = PropertyValue; } else if (PropertyName == "Connection mode") { mwwn.Connection_mode = PropertyValue; } else if (PropertyName == "Channel") { mwwn.Channel = PropertyValue; } else if (PropertyName == "Receive rate (Mbps)") { mwwn.Receive_rate = PropertyValue; } else if (PropertyName == "Transmit rate (Mbps)") { mwwn.Transmit_rate = PropertyValue; } else if (PropertyName == "Signal") { mwwn.Signal = PropertyValue; } else if (PropertyName == "Profile") { mwwn.Profile = PropertyValue; } else if (PropertyName == "Hosted network status") { mwwn.Hosted_network_status = PropertyValue; } } } } if (!mwwDB.WifiIsRecordedOrStateChanged(mwwn.Physical_address, mwwn.State))//is new record { mwwDB.AddWifiToDB(mwwn); } } } }