Beispiel #1
0
 private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView.SelectedRows.Count > 0)
     {
         selectedRow = (TaskManagerModel)dataGridView.SelectedRows[0].DataBoundItem;
     }
 }
Beispiel #2
0
        public List <TaskManagerModel> ExtractData()
        {
            List <TaskManagerModel> dataList = new List <TaskManagerModel>();

            List <Process> processes = Process.GetProcesses().ToList();

            //ProcessTimes proc = new ProcessTimes();
            //ProcessData procData = new ProcessData();

            for (int i = 0; i < processes.Count(); i++)
            {
                string userName                 = string.Empty;
                string basePriority             = string.Empty;
                string processModuleName        = string.Empty;
                string processDestinationFolder = string.Empty;
                string cpuUsage                 = string.Empty;

                TaskManagerModel model = null;

                try
                {
                    basePriority      = ParsePriority(processes[i].BasePriority);
                    processModuleName = processes[i].MainModule.ModuleName;
                    string s1, s2, s3;
                    ProcessInfo.Utils.GetProcessInfoByPID(processes[i].Id, out s1, out s2, out s3);
                    userName = s1;

                    processDestinationFolder = processes[i].MainModule.FileName;

                    // cpuUsage = processes[i].TotalProcessorTime.Milliseconds.ToString();
                }
                catch (Win32Exception e)
                {
                    processModuleName = string.Format("{0}.exe", processes[i].ProcessName);
                    userName          = "******";
                }
                finally
                {
                    model = new TaskManagerModel()
                    {
                        ProcessName              = Convert.ToString(processes[i].ProcessName),
                        ProcessPID               = processes[i].Id,
                        ThreadCount              = processes[i].Threads.Count,
                        UserName                 = userName,
                        BasePriority             = basePriority,
                        ProcessModuleName        = processModuleName,
                        ProcessDestinationFolder = processDestinationFolder,
                    };

                    dataList.Add(model);
                }
            }

            return(dataList);
        }
Beispiel #3
0
        public List<TaskManagerModel> ExtractData()
        {
            List<TaskManagerModel> dataList = new List<TaskManagerModel>();

            List<Process> processes = Process.GetProcesses().ToList();
            //ProcessTimes proc = new ProcessTimes();
            //ProcessData procData = new ProcessData();

            for (int i = 0; i < processes.Count(); i++)
            {
                string userName = string.Empty;
                string basePriority = string.Empty;
                string processModuleName = string.Empty;
                string processDestinationFolder = string.Empty;
                string cpuUsage = string.Empty;

                TaskManagerModel model = null;

                try
                {
                    basePriority = ParsePriority(processes[i].BasePriority);
                    processModuleName = processes[i].MainModule.ModuleName;
                    string s1, s2, s3;
                    ProcessInfo.Utils.GetProcessInfoByPID(processes[i].Id, out s1, out s2, out s3);
                    userName = s1;

                    processDestinationFolder = processes[i].MainModule.FileName;

                    // cpuUsage = processes[i].TotalProcessorTime.Milliseconds.ToString();
                }
                catch (Win32Exception e)
                {
                    processModuleName = string.Format("{0}.exe", processes[i].ProcessName);
                    userName = "******";
                }
                finally
                {
                    model = new TaskManagerModel()
                    {
                        ProcessName = Convert.ToString(processes[i].ProcessName),
                        ProcessPID = processes[i].Id,
                        ThreadCount = processes[i].Threads.Count,
                        UserName = userName,
                        BasePriority = basePriority,
                        ProcessModuleName = processModuleName,
                        ProcessDestinationFolder = processDestinationFolder,
                      
                    };

                    dataList.Add(model);
                }

            }

            return dataList; 
        }