Esempio n. 1
0
        public ProcessHistory GetProcessHistory(string name)
        {
            dbConn.Open();

            string selectString = "SELECT * FROM " + processHistoryTable + " WHERE process_name = '" + name + "';";

            OleDbCommand    selectCommand = new OleDbCommand(selectString, dbConn);
            OleDbDataReader dataReader    = selectCommand.ExecuteReader();

            while (dataReader.Read())
            {
                if (dataReader[0].ToString().Equals(name))
                {
                    ProcessHistory tempHist = new ProcessHistory(name);

                    tempHist.SetHistory(Convert.ToInt32(dataReader[1]), Convert.ToInt32(dataReader[2]),
                                        Convert.ToInt32(dataReader[3]), Convert.ToInt32(dataReader[4]),
                                        Convert.ToInt64(dataReader[5]), Convert.ToInt32(dataReader[6]));

                    dbConn.Close();

                    return(tempHist);
                }
            }

            dbConn.Close();

            // If we haven't returned by now then the item wasn't found
            return(null);
        }
Esempio n. 2
0
        public string InsertProcessHistory(ProcessHistory pHistory)
        {
            string insertString = "INSERT INTO " + processHistoryTable + " VALUES ('" + pHistory.name +
                                  "', '" + pHistory.avgModules + "', '" + pHistory.avgHandles + "', '" + pHistory.avgThreads +
                                  "', '" + pHistory.basePriority + "', '" + pHistory.avgMemUsed + "', '" + pHistory.avgProcessorTime + "');";

            dbConn.Open();

            OleDbCommand insertCommand = new OleDbCommand(insertString, dbConn);

            insertCommand.ExecuteNonQuery();

            dbConn.Close();

            return(insertString);
        }
Esempio n. 3
0
        private static void AddNewProcess(Process newProcess)
        {
            ProcessHistory pInfo = new ProcessHistory();

            pInfo.updated = true;
            pInfo.name    = newProcess.ProcessName;

            try
            {
                pInfo.SetHistory(newProcess.Modules.Count, newProcess.HandleCount, newProcess.Threads.Count,
                                 newProcess.BasePriority, newProcess.PeakWorkingSet64, newProcess.TotalProcessorTime.Milliseconds);
            }
            catch (Exception ex)
            {
            }

            processHistoryList.Add(pInfo);

            // Signal that the new process was added
        }