public static List <HTTPDataAnalyzer.Registration.NetworkType> GetNetworkType() { List <HTTPDataAnalyzer.Registration.NetworkType> oldApp = new List <Registration.NetworkType>(); try { using (SQLiteConnection connection = new SQLiteConnection(DBManager.ConnectionString)) { connection.Open(); using (SQLiteCommand selectCommand = new SQLiteCommand("select * from networktype", connection)) { using (SQLiteDataReader dataReader = selectCommand.ExecuteReader()) { while (dataReader.Read()) { HTTPDataAnalyzer.Registration.NetworkType app = new Registration.NetworkType(); app.IPAdress = dataReader["ipaddress"].ToString(); app.MAC = dataReader["mac"].ToString(); app.Type = dataReader["type"].ToString(); oldApp.Add(app); } } } } } catch (Exception ex) { //Registration.ClientRegistrar.Logger.Error(ex); } return(oldApp); }
//static Dictionary<string, RecentAutoRuns> PreviousAutorunpoints = new Dictionary<string, RecentAutoRuns>(); public static byte[] GetConfig(bool isRegister) { string temp = string.Empty; Dictionary <string, RecentApp> currentAppList = new Dictionary <string, RecentApp>(); SystemConfiguration sysConfig = null; if (isRegister) { sysConfig = HTTPDataAnalyzer.ReadQueries.GetSystemConfiguration(); } // return serial; if (sysConfig == null) { sysConfig = new SystemConfiguration(); sysConfig.NetworkTypes = new List <NetworkType>(); sysConfig.RecentApps = new List <RecentApp>(); sysConfig.Autorunpoints = new List <RecentAutoRuns>(); sysConfig.Browsers = BrowsersDetector.GetBrowsers().Select(x => x.Value).ToList(); sysConfig.OfficeApplications = MSOfficeDetector.GetOfficeApps(); Dictionary <string, RecentAutoRuns> currentAutoruns = new Dictionary <string, RecentAutoRuns>(); foreach (var item in winaudits.AutoRunManager.StartAudit()) { RecentAutoRuns recent = new RecentAutoRuns(); recent.AppDetails = item; recent.IsDeleted = false; recent.CollectedDate = DateTime.UtcNow; sysConfig.Autorunpoints.Add(recent); } foreach (var item in winaudits.InstalledAppAuditor.StartAudit()) { RecentApp recent = new RecentApp(); recent.AppDetails = item; recent.IsInstalled = true; recent.CollectedDate = DateTime.UtcNow.ToString(HTTPDataAnalyzer.DBManager.DateTimeFormat); sysConfig.RecentApps.Add(recent); try { if (!currentAppList.ContainsKey(recent.AppDetails.Key)) { currentAppList.Add(recent.AppDetails.Key, recent); } else { //Registration.ClientRegistrar.Logger.Error("====================================================================="); //Registration.ClientRegistrar.Logger.Error("Config 1"); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.DisplayName); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.Key); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.InstallDate); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.Version); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.Is64); //Registration.ClientRegistrar.Logger.Error(recent.IsInstalled); //Registration.ClientRegistrar.Logger.Error(recent.CollectedDate); recent = currentAppList[recent.AppDetails.Key]; //Registration.ClientRegistrar.Logger.Error("Config 2"); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.DisplayName); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.Key); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.InstallDate); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.Version); //Registration.ClientRegistrar.Logger.Error(recent.AppDetails.Is64); //Registration.ClientRegistrar.Logger.Error(recent.IsInstalled); //Registration.ClientRegistrar.Logger.Error(recent.CollectedDate); //Registration.ClientRegistrar.Logger.Error("====================================================================="); } } catch (Exception ex) { //Registration.ClientRegistrar.Logger.Error(ex); } } sysConfig.ChasisType = ChasisTypeFinder.GetChassisType().ToString(); sysConfig.AgentVersion = "0"; sysConfig.TimeZone = GetSystemTimeZoneName(); sysConfig.HostName = Dns.GetHostName(); sysConfig.DomainName = Environment.UserDomainName; foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { if (nic.OperationalStatus.ToString().ToLower() == "up" && nic.NetworkInterfaceType.ToString().ToLower() != "loopback") { NetworkType netTpe = new NetworkType(); foreach (UnicastIPAddressInformation ip in nic.GetIPProperties().UnicastAddresses) { if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { netTpe.IPAdress = ip.Address.ToString(); break; } } if (netTpe.IPAdress == null) { continue; } netTpe.MAC = nic.GetPhysicalAddress().ToString(); netTpe.Type = nic.NetworkInterfaceType.ToString(); sysConfig.NetworkTypes.Add(netTpe); } } sysConfig.Processor = GetProcessor(); sysConfig.BitLevel = OSInfo.Bits; sysConfig.OSEdition = OSInfo.Edition; sysConfig.OSServicePack = OSInfo.ServicePack; sysConfig.OSName = OSInfo.Name; sysConfig.ProductID = ProductID(); sysConfig.AgentID = ConfigHandler.Config.AgentInstaller.AgentID; sysConfig.AgentVersion = ConfigHandler.Config.AgentInstaller.AgentVersion; sysConfig.OSLastUpTime = LastBootUpTime(); sysConfig.Installdate = DateTime.UtcNow; sysConfig.Acrobat = GetAdobeVer(); sysConfig.Java = GetJavaVersion(); sysConfig.Registereduser = Util.GetWindowsUserName(); sysConfig.Flash = GetFlashPlayerVersionString().Replace(",", "."); } if (isRegister) { HTTPDataAnalyzer.InsertQueries.InsertInHostInfo(sysConfig); sysConfig.RecentApps.Clear(); sysConfig.Autorunpoints.Clear(); } else { if (PreviousInstalledApp.Count == 0) { PreviousInstalledApp = HTTPDataAnalyzer.ReadQueries.GetPreviousConfig(); } if (PreviousInstalledApp.Count > 0) { List <RecentApp> tempInstalledApp = new List <RecentApp>(); tempInstalledApp.AddRange(sysConfig.RecentApps); sysConfig.RecentApps.Clear(); for (int i = 0; i < tempInstalledApp.Count; i++) { var appName = tempInstalledApp[i]; if (PreviousInstalledApp.ContainsKey(appName.AppDetails.Key)) { continue; } sysConfig.RecentApps.Add(appName); PreviousInstalledApp.Add(appName.AppDetails.Key, appName); } foreach (var item in PreviousInstalledApp) { if (!currentAppList.ContainsKey(item.Key)) { RecentApp unInstall = PreviousInstalledApp[item.Key]; unInstall.IsInstalled = false; unInstall.CollectedDate = DateTime.UtcNow.ToString(HTTPDataAnalyzer.DBManager.DateTimeFormat); sysConfig.RecentApps.Add(unInstall); } } foreach (RecentApp item in sysConfig.RecentApps) { if (!item.IsInstalled) { if (PreviousInstalledApp.ContainsKey(item.AppDetails.Key)) { PreviousInstalledApp.Remove(item.AppDetails.Key); } } } } //if (PreviousAutorunpoints.Count == 0) //{ // PreviousAutorunpoints = HTTPDataAnalyzer.DBManager.ReadQueries.GetPreviousAutoRuns(); //} //if (PreviousAutorunpoints.Count > 0) //{ // List<RecentAutoRuns> tempAutoRuns = new List<RecentAutoRuns>(); // tempAutoRuns.AddRange(sysConfig.Autorunpoints); // sysConfig.Autorunpoints.Clear(); // for (int i = 0; i < tempAutoRuns.Count; i++) // { // var appName = tempAutoRuns[i]; // if (PreviousAutorunpoints.ContainsKey(appName.AppDetails.FilePath)) // { // continue; // } // sysConfig.Autorunpoints.Add(appName); // PreviousAutorunpoints.Add(appName.AppDetails.FilePath, appName); // } // foreach (var item in PreviousAutorunpoints) // { // if (!currentAutoruns.ContainsKey(item.Key)) // { // RecentAutoRuns unInstall = PreviousAutorunpoints[item.Key]; // unInstall.IsDeleted = false; // sysConfig.Autorunpoints.Add(unInstall); // } // } //} HTTPDataAnalyzer.UpdateQuery.UpdateInHostInfo(sysConfig); } byte[] configByte = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(sysConfig)); return(configByte); }