private void GetConnectedSystemInfo()
        {
            //Start Client
            AsynchronousClient client          = new AsynchronousClient();
            string             recievedMessage = client.StartClient("/get", _ip);

            if (recievedMessage.Contains("<global>"))
            {
                //Getting Activities And System Model From Message
                ActivitiesViewModel[] activities;
                GlobalSystemModel     systemModel = ManageSystemInformations
                                                    .ConverMessageToGlobalSystemModel(recievedMessage, out activities);

                //Add Or Update This System
                using (UnitOfWork uow = new UnitOfWork())
                {
                    ManageSystemInformations manageSystem = new ManageSystemInformations(uow, false);
                    manageSystem.AddOrUpdateSystem(systemModel);
                }

                //Fill The Controls
                CleanControls();
                FillControlsWithInfo(systemModel, activities);
            }
            else
            {
                MessageBox.Show(recievedMessage);
                this.Close();
            }
        }
Ejemplo n.º 2
0
        public static GlobalSystemModel ConverMessageToGlobalSystemModel(string message, out ActivitiesViewModel[] activities)
        {
            GlobalSystemModel systemModel = new GlobalSystemModel();

            //get global info
            systemModel.System = ConvertMessageToSystems(message);

            //get CPU
            systemModel.CPU = ConvertMessageToCPU(message);

            //get GPUs
            systemModel.GPUs = ConvertMessageToGPUArray(message);

            systemModel.OperatingSystems = ConvertMessageTOperatingSystemsList(message);

            systemModel.Drivers = ConvertMessageToDriversList(message);

            systemModel.RAM = ConvertMessageToRAM(message);

            systemModel.NetworkAdapters = ConvertMessageToNetworkAdaptersList(message);

            systemModel.SoundCards = ConvertMessageToSoundCardsList(message);

            systemModel.Printers = ConvertMessageToPrintersList(message);

            activities = ConvertMessageToActivities(message);

            return(systemModel);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public async Task AddOrUpdateSystem(GlobalSystemModel systemModel)
        {
            int systemId = _uof.SystemsRepository.CheckSystemExists(systemModel.System.UniqMotherBoardId);

            if (systemId == -1)
            {
                //Add New System
                _uof.SystemsRepository.Insert(systemModel.System);
                _uof.Save();
            }
            else
            {
                systemModel.System.SystemId = systemId;
            }

            string finalMessage = CheckGlobalModel(systemModel, false);
        }
Ejemplo n.º 6
0
        //TODO: Has One
        #region Checks

        public string CheckGlobalModel(GlobalSystemModel systemModel, bool isOwned)
        {
            int    systemId     = 0;
            string finalMessage = "";


            //Checking Global System And Getting SystemId For Other Entities
            if (isOwned)
            {
                systemId      = CheckOwnedSystem(systemModel.System, out string resultMessage);
                finalMessage += resultMessage;
            }
            else
            {
                systemId = systemModel.System.SystemId;
            }


            //Checking CPU
            finalMessage += CheckCPU(systemModel.CPU, systemId);


            //TODO: Delete Drivers That Exists In Database But Not In System Model
            //Checking Drivers
            finalMessage += CheckDrivers(systemModel.Drivers, systemId);

            //_uof.Save();

            //Checking GPUs
            finalMessage += CheckGPU(systemModel.GPUs, systemId);


            //Checking Operating System
            finalMessage += CheckOperatingSystems(systemModel.OperatingSystems, systemId);


            //Checking Network Adapters
            finalMessage += CheckNetworkAdapters(systemModel.NetworkAdapters, systemId);


            //Checking RAM
            finalMessage += CheckRAM(systemModel.RAM, systemId);


            //Checking Sound Cards
            finalMessage += CheckSoundCards(systemModel.SoundCards, systemId);


            //Checking CDROMs
            finalMessage += CheckCdRoms(systemModel.CDROMs, systemId);



            //Checking Printers
            //For some reasons i decided to not insert printers now
            //7 days later: i don't remember those reasons so i just do it
            finalMessage += CheckPrinters(systemModel.Printers, systemId);

            _uof.Save();
            return(finalMessage);
        }
        private void FillControlsWithInfo(GlobalSystemModel systemModel, ActivitiesViewModel[] activities)
        {
            try
            {
                //System
                motherboardLabel.Text = systemModel.System.UniqMotherBoardId;
                nameLabel.Text        = systemModel.System.Name;

                //CPU
                cpuNameLabel.Text  = systemModel.CPU.Name;
                cpuCoresLabel.Text = systemModel.CPU.Cores.ToString();

                //RAM
                ramLabel.Text = systemModel.RAM.Memory.SizeSuffix();

                //Operating Systems
                osList.Items.AddRange(systemModel.OperatingSystems.Select(os => os.Name).ToArray());

                //Network Adapters
                networkAdaptersList.Items.AddRange(systemModel.NetworkAdapters.Select(na => na.Name).ToArray());

                //Sound Cards
                soundCardsList.Items.AddRange(systemModel.SoundCards.Select(s => s.Name).ToArray());

                //GPU
                gpuList.Items.AddRange(systemModel.GPUs.Select(g => g.Name).ToArray());

                //Printers
                printersList.Items.AddRange(systemModel.Printers.Select(p => p.Name).ToArray());

                //Drivers
                foreach (var driver in systemModel.Drivers)
                {
                    if (this.driversDataGrid.InvokeRequired)
                    {
                        driversDataGrid.Invoke(new Action(() =>
                        {
                            driversDataGrid.Rows.Add(driver.DiskName,
                                                     driver.Address,
                                                     driver.TotalSpace.SizeSuffix(),
                                                     driver.AvailableSpace.SizeSuffix());
                        }));
                    }
                    else
                    {
                        driversDataGrid.Invoke(new Action(() =>
                        {
                            driversDataGrid.Rows.Add(driver.DiskName,
                                                     driver.Address,
                                                     driver.TotalSpace.SizeSuffix(),
                                                     driver.AvailableSpace.SizeSuffix());
                        }));
                    }
                }

                //Activities
                foreach (ActivitiesViewModel activity in activities)
                {
                    activitiesText.Text += $"({activity.ShamsiDate}) - {activity.Description}" + Environment.NewLine;
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 8
0
        public static string GetHardwareInfoToSend()
        {
            GlobalSystemModel systemModel = GetGlobalSystemModel().Result;

            string finalMessage = "";


            //Adding global system
            finalMessage += $"<global><UniqMotherBoardId>{systemModel.System.UniqMotherBoardId}" +
                            $"<Name>{systemModel.System.Name}</global>";

            //Adding CPU
            finalMessage += $"<cpu><Name>{systemModel.CPU.Name}<Cores>{systemModel.CPU.Cores}</cpu>";


            //Adding GPUs
            string gpuMessage = "";

            if (systemModel.GPUs.Any())
            {
                foreach (GPUs gpu in systemModel.GPUs)
                {
                    gpuMessage += $"<Name>{gpu.Name}<AdapterRAM>{gpu.AdapterRAM}<split>";
                }

                gpuMessage = gpuMessage.Substring(0, gpuMessage.Length - 7);
            }

            finalMessage += $"<gpu>{gpuMessage}</gpu>";



            //Adding Operating Systems
            string osMessage = "";

            foreach (OpratingSystems os in systemModel.OperatingSystems)
            {
                osMessage += $"<Name>{os.Name}<Architecture>{os.Architecture}<Version>{os.Version}<split>";
            }

            osMessage     = osMessage.Substring(0, osMessage.Length - 7);
            finalMessage += $"<operatingSystems>{osMessage}</operatingSystems>";



            //Adding RAM
            finalMessage += $"<ram><Memory>{systemModel.RAM.Memory}</ram>";



            //Adding Network Adapters
            string networkAdaptersMessage = "";

            if (systemModel.NetworkAdapters.Any())
            {
                foreach (NetworkAdapters networkAdapter in systemModel.NetworkAdapters)
                {
                    networkAdaptersMessage += $"<Name>{networkAdapter.Name}<split>";
                }

                networkAdaptersMessage = networkAdaptersMessage
                                         .Substring(0, networkAdaptersMessage.Length - 7);
            }

            finalMessage += $"<networkAdapters>{networkAdaptersMessage}</networkAdapters>";



            //Adding Drivers
            string driversMessage = "";

            foreach (Drivers driver in systemModel.Drivers)
            {
                driversMessage += $"<DiskName>{driver.DiskName}<Address>{driver.Address}<Type>{driver.Type}<AvailableSpace>{driver.AvailableSpace}<TotalSpace>{driver.TotalSpace}<split>";
            }

            driversMessage = driversMessage.Substring(0, driversMessage.Length - 7);
            finalMessage  += $"<drivers>{driversMessage}</drivers>";



            //Adding Sound Cards
            string soundCardsMessage = "";

            if (systemModel.SoundCards.Any())
            {
                foreach (SoundCards soundCard in systemModel.SoundCards)
                {
                    soundCardsMessage += $"<Name>{soundCard.Name}<split>";
                }

                soundCardsMessage = soundCardsMessage.Substring(0, soundCardsMessage.Length - 7);
            }

            finalMessage += $"<soundCards>{soundCardsMessage}</soundCards>";



            //Adding Printers
            string printersMessage = "";

            if (systemModel.Printers.Any())
            {
                foreach (Printers printer in systemModel.Printers)
                {
                    printersMessage += $"<Name>{printer.Name}<IsLocal>{printer.IsLocal}<IsNetwork>{printer.IsNetwork}<split>";
                }

                printersMessage = printersMessage.Substring(0, printersMessage.Length - 7);
            }

            finalMessage += $"<printers>{printersMessage}</printers>";


            //Adding CD-ROMs
            string cdRomsMessage = "";

            if (systemModel.CDROMs.Any())
            {
                foreach (CdROMs cdROM in systemModel.CDROMs)
                {
                    cdRomsMessage += $"<Description>{cdROM.Description}<Address>{cdROM.Address}<MediaType>{cdROM.MediaType}<split>";
                }

                cdRomsMessage = cdRomsMessage.Substring(0, cdRomsMessage.Length - 7);
            }

            finalMessage += $"<cdroms>{cdRomsMessage}</cdroms>";


            return(finalMessage);
        }