//Updates computer information form public void UpdateComputerInformation(int ConnectionId, string Info) { string[] InfoArray = Info.Split(','); List <string> InfoList = new List <string>(InfoArray); foreach (ComputerInformation CI in Application.OpenForms.OfType <ComputerInformation>()) { if (CI.Visible && CI.ConnectionID == ConnectionId && CI.Update) { CI.lbInformation.Items.Clear(); CI.lbInformation.Items.AddRange(InfoList.ToArray <string>()); CI.lbInformation.Items.Remove(""); return; } } CI = new ComputerInformation(); CI.Show(); CI.ConnectionID = ConnectionId; CI.Text = "Computer Information - " + CI.ConnectionID; if (CI.ConnectionID == ConnectionId) { CI.lbInformation.Items.Clear(); CI.lbInformation.Items.AddRange(InfoList.ToArray()); CI.lbInformation.Items.Remove(""); } }
public ComputerInformationReceivedEventArgs(ComputerInformation computerInformation, bool redirect, ushort administration) { ComputerInformation = computerInformation; Redirect = redirect; Administration = administration; }
public void UpdateComputerInformation(int ConnectionId, string Info) { string[] InfoArray = Info.Split(','); List <string> InfoList = new List <string>(InfoArray); if (CI.Visible && CI.Text == "Computer Information - " + ConnectionId) { CI.lbInformation.Items.Clear(); CI.lbInformation.Items.AddRange(InfoList.ToArray <string>()); CI.lbInformation.Items.Remove(""); } else { CI = new ComputerInformation(); CI.Show(); CI.ConnectionID = ConnectionId; CI.Text = "Computer Information - " + CI.ConnectionID; if (CI.ConnectionID == ConnectionId) { CI.lbInformation.Items.Clear(); CI.lbInformation.Items.AddRange(InfoList.ToArray()); CI.lbInformation.Items.Remove(""); } } }
public async Task AddComputer(ComputerInformation computerInformation) { var computer = _mapper.Map <Computer>(computerInformation); await _context.Computers.AddAsync(computer); await _context.SaveChangesAsync(); }
public async Task UpdateComputer(ComputerInformation computerInformation) { var computer = _mapper.Map <Computer>(computerInformation); _context.Update(computer); await _context.SaveChangesAsync(); }
public async Task AddComputer(ComputerInformation computerInformation) { var log = new Log() { Name = "AddComputer", Time = DateTime.Now }; await _collection.InsertOneAsync(log); await _repository.AddComputer(computerInformation); }
public async Task UpdateComputer(ComputerInformation computerInformation) { var log = new Log() { Name = "UpdateComputer", Time = DateTime.Now, Index = computerInformation.ComputerId }; await _collection.InsertOneAsync(log); await _repository.UpdateComputer(computerInformation); }
static void LoopIt() { Console.WriteLine($"Reporting data to {_infoMonitorUrl}"); while (_running) { //GET DATA HERE. This is just an example, you can use your own object in your data collection agent var data = new Information() { Computer = ComputerInformation.Get(), Processes = ProcessInformation.Get(), RDPUsers = RDPUserInformation.Get(), NICs = NICInformation.Get() }; string json = JsonSerializer.Serialize(data); var sender = WebRequest.Create(_infoMonitorUrl); sender.Method = "POST"; sender.ContentType = "application/json"; sender.ContentLength = json.Length; using (var sw = new StreamWriter(sender.GetRequestStream())) { sw.Write(json); sw.Close(); } try { var response = (HttpWebResponse)sender.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Console.WriteLine($"{DateTime.Now}\tUpdate sent!"); } else { Console.WriteLine($"{DateTime.Now}\tServer replied {response.StatusCode}"); } } catch (Exception ex) { Console.WriteLine($"{DateTime.Now}\t{ex.GetType().FullName}: {ex.Message}"); } Thread.Sleep(_updateDelayMs); } }
public void SendComputerInformation(ComputerInformation computerInformation) { try { var data = new Serializer(typeof(ComputerInformation)).Serialize(computerInformation); lock (_sendLock) { Connection.BinaryWriter.Write((byte)FromClientPackage.ResponseToAdministration); Connection.BinaryWriter.Write(data.Length + 6); Connection.BinaryWriter.Write((byte)ResponseType.CommandResponse); Connection.BinaryWriter.Write(BitConverter.GetBytes(4)); //Computer Information ID Connection.BinaryWriter.Write((byte)CommandResponse.Successful); Connection.BinaryWriter.Write(data); } } catch (Exception ex) { ReportError(ex, MethodBase.GetCurrentMethod().Name); } }
static void Main(string[] args) { var handle = GetConsoleWindow(); ShowWindow(handle, SW_HIDE); LogMaker lm = new LogMaker(); Settings st = new Settings(); st.SeparationSymbol = ':'; st.EndOfLineType = Settings.EOLType.CRLF; String ip = st.GetValue("server"); String port = st.GetValue("port"); lm.Log("Запуск программы."); if (!Pgs.SetDatabaseConnectionWithRole(ip, port, "guest")) { lm.Log($"Ошибка подключения к базе с параметрами [{ip}] [{port}]."); return; } Computer currentComputer = new Computer(); try { ComputerInformation nw = new ComputerInformation(); currentComputer._MAC = nw.GetMACAddress(); currentComputer._Name = nw.GetName(); currentComputer._Ip = nw.GetIp(); currentComputer._Os = nw.GetOs(); List <Software> soft = nw.GetSoftwareCollection(); foreach (Software s in soft) { currentComputer.AddSoftware(s); } List <string> view = new List <string>(); ComputerInformation ci = new ComputerInformation(); ci.ScanFromCpuZ(); currentComputer.AddHardware(ci.GetCpu()); currentComputer.AddHardware(ci.GetMotherboard()); foreach (Hardware h in ci.GetGpus()) { currentComputer.AddHardware(h); } foreach (Hardware h in ci.GetRams()) { currentComputer.AddHardware(h); } foreach (Hardware h in ci.GetHdds()) { currentComputer.AddHardware(h); } String audnum = st.GetValue("auditory_number"); currentComputer._AuditNumber = audnum; Pgs.AddComputerAndOs(currentComputer); Pgs.AddSoftwareToComputer(currentComputer); Pgs.AddHardwareToComputer(currentComputer); lm.Log("Данные успешно отправлены."); } catch (Exception ex) { lm.Log("Ошибка при работе с данными: " + ex.Message); } }
public async Task <IActionResult> UpdateComputer(ComputerInformation computerInformation) { await _service.UpdateComputer(computerInformation); return(Ok()); }
private void _computerInformationCommand_ComputerInformationReceived(object sender, ComputerInformation e) { IsLoading = false; Information = e; }
public ComputerInformationViewModel(ComputerInformation computerInformation) { ComputerInformation = computerInformation; }