public void SaveToDatabaseComputerDetailsData() { DataManager dataManager = new FullDataManager(); var computerSummary = dataManager.GetComputerSummary(); var context1 = new MetricsContext(); ComputerDetail computerDetail = new ComputerDetail() { Name = computerSummary.Name, User = computerSummary.User, Cpu = computerSummary.Cpu, Ram = computerSummary.Ram, VideoCard = computerSummary.VideoCard, Ip = computerSummary.Ip.ToString() }; if (context1.ComputerDetails.Count() != 0) { if (context1.ComputerDetails.Last().Name != computerDetail.Name) { context1.Add(computerDetail); context1.SaveChanges(); } } else { context1.Add(computerDetail); context1.SaveChanges(); } }
//Updates static computer data to database public void UpadatStaticeComputerData() { context.Database.EnsureCreated(); bool t = false; // Is the computer already in the list var manager = new FullDataManager(); var summary = manager.GetComputerSummary(); context = new MetricsContext(); computerDetail = new ComputerDetail(); computerDetail.Cpu = summary.Cpu; computerDetail.Ip = summary.Ip.ToString(); computerDetail.Name = summary.Name; computerDetail.Ram = summary.Ram; computerDetail.VideoCard = summary.VideoCard; computerDetail.User = summary.User; //Checks if computer like this already exists in the databae, if it doesnt, it creates a new one foreach (var computerD in context.ComputerDetails) { if (computerD.Name == computerDetail.Name) { t = true; computerDetail = computerD; // } } if (!t) { context.Add(computerDetail); } }
static void Main(string[] args) { var dataManager = new FullDataManager(); WriteLine("If you want computer summary write 'CS' , \n" + "if you want application list write 'AL', \n" + "if you want hardware list write 'HL': \n"); var option = ReadLine(); WriteLine(); switch (option) { case "CS": PrintComputerSummary(dataManager); break; case "HL": PrintHardwareList(dataManager); break; case "AL": PrintApplicationList(dataManager); break; default: WriteLine("Wrong command please try again!"); break; } ReadLine(); }
public WinFormsQueries() { _dataManager = new FullDataManager(); _context = new MetricsContext(); _context.Database.EnsureCreated(); ComputerSummary = _dataManager.GetComputerSummary(); }
private NewUsageData GetData() { FullDataManager dataManager = new FullDataManager(); NewUsageData newUsageData = new NewUsageData(); newUsageData.MemoryUsage = dataManager.FreeSpace(); newUsageData.ProcessorUsage = dataManager.GetComputerCpuUsage(); newUsageData.TimeStamp = DateTime.Now; return(newUsageData); }
static void Main(string[] args) { var dataManager = new FullDataManager(); var computername = dataManager.GetMetric("computername"); Console.WriteLine($"Computer Name: {computername}"); var cpuUsage = dataManager.GetMetric("cpuusage"); Console.WriteLine($"Current CPU usage: {cpuUsage}%"); Console.ReadLine(); }
public Form1() { InitializeComponent(); fullDataManager = new FullDataManager(); cpuChart.Series.Clear(); cpuChart.Series.Add("cpu usage"); cpuChart.Series[0].XValueType = ChartValueType.DateTime; cpuChart.ChartAreas[0].AxisX.LabelStyle.Format = "hh-mm-ss"; RamChart.Series.Clear(); RamChart.Series.Add("ram usage"); RamChart.Series[0].XValueType = ChartValueType.DateTime; RamChart.ChartAreas[0].AxisX.LabelStyle.Format = "hh-mm-ss"; }
public void UpdateDynamicComputerData() { var usageData = new UsageData(); var manager = new FullDataManager(); usageData.AvailableDiskSpaceGb = Int32.Parse(manager.GetMetric(ComputerMetrics.AvailableDiskSpace)); usageData.AverageDiskQueueLength = Int32.Parse(manager.GetMetric(ComputerMetrics.AverageDiskQueueLength)); usageData.CpuUsage = Int32.Parse(manager.GetMetric(ComputerMetrics.CpuUsage)); usageData.RamUsage = Int32.Parse(manager.GetMetric(ComputerMetrics.RamUsage)); usageData.Time = DateTime.Now; computerDetail.UsageDataCollection.Add(usageData); context.UsageDatas.Add(usageData); context.SaveChanges(); }
static void Main(string[] args) { var dataManager = new FullDataManager(); dataManager.GetComputerSummary(); Console.WriteLine("\nHardware list: \n"); foreach (var item in dataManager.GetHardwareList()) { Console.WriteLine(item); } Console.WriteLine("\nApplication list: \n"); foreach (var item in dataManager.GetApplicationList()) { Console.WriteLine(item); } }
static void AddComputerUsageData(Object o) { var fullDataManager = new FullDataManager(); var computersummary = fullDataManager.GetComputerSummary(); using (var _ctx = new MetricsContext()) { var metrics = _ctx.ComputerMetrics.FirstOrDefault(p => p.Name == computersummary.Name); metrics.UsageDatas.Add(new UsageData() { AvailableDiskSpaceGb = computersummary.AvailableDiskSpaceGb, AverageDiskQueueLength = computersummary.AverageDiskQueueLength, CpuUsage = computersummary.CpuUsage, RamUsage = computersummary.RamUsage, Time = DateTime.Now, }); _ctx.SaveChanges(); } }
static void AddComputerMetrics() { var fullDataManager = new FullDataManager(); var computersummary = fullDataManager.GetComputerSummary(); using (var _ctx = new MetricsContext()) { var metrics = _ctx.ComputerMetrics.FirstOrDefault(p => p.Name == computersummary.Name); if (metrics == null) { metrics = _ctx.ComputerMetrics.Create(); metrics.Cpu = computersummary.Cpu; metrics.Ip = computersummary.Ip.ToString(); metrics.Name = computersummary.Name; metrics.Ram = computersummary.Ram; metrics.User = computersummary.User; metrics.VideoCard = computersummary.VideoCard; _ctx.ComputerMetrics.Add(metrics); _ctx.SaveChanges(); } } }
static void Main(string[] args) { var fullDataManager = new FullDataManager(); //fullDataManager.GetHardwareListFromRemote(); var hardwareList = fullDataManager.GetHardwareList(); var applicationsList = fullDataManager.GetApplicationList(); Console.WriteLine("Hardware: "); foreach (var hard in hardwareList) { Console.WriteLine(hard); } Console.WriteLine("-------------------"); Console.WriteLine("Applications:"); foreach (var app in applicationsList) { Console.WriteLine(app); } Console.WriteLine("-------------------"); Console.ReadLine(); }