private async void MainForm_Load(object sender, EventArgs e)
        {
            ChangeButtonsEnable(false);

            ActivitiesText.Text = "در حال بارگزاری..." + Environment.NewLine + ActivitiesText.Text;

            ProgramStartupHelper.CheckApplicationStartupRegistry(Application.ExecutablePath);

            //checking global system information in startup
            using (UnitOfWork uof = new UnitOfWork())
            {
                ManageSystemInformations manageSystem = new ManageSystemInformations(uof, true);
                ActivitiesText.Text = (await manageSystem.UpdateOwnedSystem())
                                      .Replace("<newLine>", Environment.NewLine) + Environment.NewLine + ActivitiesText.Text;
            }

            //Getting system ips
            LoadLocalIPs();

            ChangeButtonsEnable(true);

            //Starting server to communicate with other nodes
            //if (!string.IsNullOrEmpty(Properties.Settings.Default.LocalNetworkIP))
            //{
            //    ServerStartButton_Click(ServerStartButton, EventArgs.Empty);
            //}
        }
        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();
            }
        }
예제 #3
0
        private async Task UpdateLocalNodesInfo()
        {
            //Getting connected systems
            IpAddressManagement ipManagement = new IpAddressManagement();
            var localIps = await ipManagement.StartGettingHosts(_ipAddress);

            await Task.Run(() =>
            {
                foreach (string ip in localIps)
                {
                    //Starting client
                    AsynchronousClient client = new AsynchronousClient();
                    string recievedMessage    = client.StartClient("/getshort", ip);

                    if (recievedMessage.Contains("<system>"))
                    {
                        //Get short system model
                        ShortSystemModel systemModel =
                            ManageSystemInformations.ConvertMessageToShortSystemModel(recievedMessage);

                        systemModel.SystemIp = ip;

                        //Adding system to data grid view
                        if (this.nodesDataGrid.InvokeRequired)
                        {
                            nodesDataGrid.Invoke(new Action(() =>
                            {
                                nodesDataGrid.Rows.Add(systemModel.SystemIp, systemModel.SystemName, systemModel.Cpu);
                            }));
                        }
                        else
                        {
                            nodesDataGrid.Rows.Add(systemModel.SystemIp, systemModel.SystemName, systemModel.Cpu);
                        }
                    }
                    else
                    {
                        //This happens when getting message from other system fails
                        //Adding system to data grid view
                        if (this.nodesDataGrid.InvokeRequired)
                        {
                            nodesDataGrid.Invoke(new Action(() =>
                            {
                                nodesDataGrid.Rows.Add(ip, "", "");
                            }));
                        }
                        else
                        {
                            nodesDataGrid.Rows.Add(ip, "", "");
                        }
                    }
                }
            });
        }
        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);
        }
        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);
        }