Esempio n. 1
0
        private void PrintHardwareInformation()
        {
            try
            {
                logger.LogInformation(string.Empty);
                logger.LogInformation("--------------Hardware information----------------");
                logger.LogInformation("CPU Information:");
                var processorNames = HardwareInformationHelper.GetProcessorName();
                for (int i = 0; i < processorNames.Count; i++)
                {
                    logger.LogInformation($"{i + 1}. {processorNames[i]}");
                }
                logger.LogInformation($"Number of total available logical cores: {Environment.ProcessorCount}");

                logger.LogInformation("\r\nRAM Information:");
                logger.LogInformation($"Total available memory:{GC.GetGCMemoryInfo().TotalAvailableMemoryBytes / 1024 / 1024} MB");

                logger.LogInformation("\r\nDisk Information:");
                logger.LogInformation(HardwareInformationHelper.GetDiskModel(Environment.CurrentDirectory.First()));
                logger.LogInformation("--------------Hardware information----------------");
                logger.LogInformation(string.Empty);
            }
            catch (Exception ex)
            {
                logger.LogError($"Unable to obtain full hardware information: {ex.Message}");
            }
        }
        public static string ReadRequest(string request)
        {
            switch (request)
            {
            case "/get":
                return(GetAnswer());

            case "/getshort":
                return(HardwareInformationHelper.GetShortHardwareInfoToSend());

            default:
                return("Invalid Request");
            }
        }
Esempio n. 3
0
        public async Task <string> UpdateOwnedSystem()
        {
            GlobalSystemModel systemModel = await HardwareInformationHelper.GetGlobalSystemModel();

            string finalMessage = "";


            return(await Task.Run(() =>
            {
                finalMessage = CheckGlobalModel(systemModel, true);


                return finalMessage;
            }));
        }
        private async void ShowMySystemInfo()
        {
            ActivitiesViewModel[] activities;
            GlobalSystemModel     systemModel = await HardwareInformationHelper.GetGlobalSystemModel();

            using (UnitOfWork uow = new UnitOfWork())
            {
                ManageSystemInformations systemInformations =
                    new ManageSystemInformations(uow, false);
                activities = systemInformations.GetSystemActivitiesToShow().ToArray();
            }

            CleanControls();
            FillControlsWithInfo(systemModel, activities);
        }
Esempio n. 5
0
        public int CheckOwnedSystem(Systems model, out string resultMessage)
        {
            resultMessage = "";

            //Checking System
            if (_uof.SystemsRepository.IsThisSystemExists(out Systems system))
            {
                model.SystemId = system.SystemId;

                //Check if system has any changes
                if (HardwareInformationHelper
                    .CheckGlobalSystemChanges(system, model, out resultMessage))
                {
                    string msg = "اطلاعات سیستم بروزرسانی شد.";
                    _uof.SystemsRepository.Update(model);

                    if (_recordChanges)
                    {
                        _uof.ActivitiesRepository.Insert(new Activities()
                        {
                            Description = msg, EventDate = DateTime.Now
                        });
                    }

                    _uof.Save();
                    resultMessage += $" {msg}<newLine>";
                }
            }
            else
            {
                string msg = "اطلاعات سیستم ثبت شد.";
                _uof.SystemsRepository.Insert(model);
                if (_recordChanges)
                {
                    _uof.ActivitiesRepository.Insert(new Activities()
                    {
                        Description = msg, EventDate = DateTime.Now
                    });
                }
                _uof.Save();
                resultMessage += $"{msg}<newLine>";
            }

            return(model.SystemId);
        }
        public static string GetAnswer()
        {
            string answer     = "";
            string activities = "";

            answer += HardwareInformationHelper.GetHardwareInfoToSend();

            using (UnitOfWork uow = new UnitOfWork())
            {
                ManageSystemInformations systemInformations =
                    new ManageSystemInformations(uow, false);
                activities = systemInformations.GetSystemActvities();
            }

            answer += activities;

            return(answer);
        }
Esempio n. 7
0
        public string CheckCPU(CPUs model, int systemId)
        {
            string finalMessage = "";

            model.SystemId = systemId;

            if (_uof.CpuRepository.IsSystemCpuExists(systemId, out CPUs cpu))
            {
                //if it exists check the different and update
                if (HardwareInformationHelper
                    .CheckSystemCpuChanges(cpu, model, out string resultMessage))
                {
                    string msg = "اطلاعات پردازنده بروزرسانی شد.";
                    model.CpuId = cpu.CpuId;
                    _uof.CpuRepository.Update(model);
                    if (_recordChanges)
                    {
                        _uof.ActivitiesRepository.Insert(new Activities()
                        {
                            Description = msg, EventDate = DateTime.Now
                        });
                    }
                    finalMessage += resultMessage;
                    finalMessage += $"{msg}<newLine>";
                }
            }
            else
            {
                string msg = "اطلاعات پردازنده ثبت شد.";
                _uof.CpuRepository.Insert(model);
                if (_recordChanges)
                {
                    _uof.ActivitiesRepository.Insert(new Activities()
                    {
                        Description = msg, EventDate = DateTime.Now
                    });
                }
                finalMessage += $"{msg}<newLine>";
            }

            return(finalMessage);
        }
Esempio n. 8
0
        //TODO: Has One
        public string CheckDrivers(IEnumerable <Drivers> modelList, int systemId)
        {
            string finalMessage = "";

            foreach (Drivers driver in modelList)
            {
                driver.SystemId = systemId;

                //Check if disk is external
                if (driver.Type.ToLower().Equals("removable"))
                {
                    //TODO: Do The Thing For Removable Drivers
                    continue;
                }
                //Checking if the disk is fixed
                else if ((driver.Type.ToLower().Equals("fixed")))
                {
                    //If disk already saved in database
                    if (_uof.DriverRepository.IsDriverExists(systemId, driver.Address,
                                                             out Drivers existingDriver))
                    {
                        //Check for driver changes
                        //resultMessage: changes that recognized
                        if (HardwareInformationHelper
                            .CheckDriverChanges(existingDriver, driver, out string resultMessage))
                        {
                            //adding detected changes to return message
                            if (!string.IsNullOrEmpty(resultMessage))
                            {
                                finalMessage += resultMessage;
                            }

                            driver.DriverId = existingDriver.DriverId;
                            _uof.DriverRepository.Update(driver);

                            //Save Activities
                            if ((_recordChanges) && (!string.IsNullOrEmpty(resultMessage)))
                            {
                                string[] actArray = resultMessage.Split(new string[] { "<newLine>" },
                                                                        StringSplitOptions.RemoveEmptyEntries);

                                foreach (string activity in actArray)
                                {
                                    _uof.ActivitiesRepository.Insert(new Activities()
                                    {
                                        Description = activity,
                                        EventDate   = DateTime.Now
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        _uof.DriverRepository.Insert(driver);
                        if (_recordChanges)
                        {
                            _uof.ActivitiesRepository.Insert(new Activities()
                            {
                                Description = $"درایو {driver.Address} ثبت شد.",
                                EventDate   = DateTime.Now
                            });
                        }
                    }
                }
            }

            finalMessage += "درایور های سیستم چک و بروزرسانی شد.<newLine>";

            return(finalMessage);
        }