Esempio n. 1
0
 public void addNewProcessHandleToQueueAndBottom(ProcessHandle ph)
 {
     if(processQueueIsLocked) { return; }
     processQueueIsLocked = true;
     processQueue.Add(ph);
     bottom.addNewProcessHandle(ph);
     processQueueIsLocked = false;
 }
Esempio n. 2
0
        public void addToDataView(ProcessHandle ph)
        {
            ProcessHandleDataGridViewRow processHandleDataGridViewRow = new ProcessHandleDataGridViewRow(ph);
            string dir = ph.getProcessCaller().getDirectory();

            DirectoryDataGridViewTextBoxCell pid        = new DirectoryDataGridViewTextBoxCell(ph.getPID());
            DirectoryDataGridViewTextBoxCell directory  = new DirectoryDataGridViewTextBoxCell(dir);
            DirectoryDataGridViewTextBoxCell command    = new DirectoryDataGridViewTextBoxCell(ph.getProcessCaller().getCmd());
            DirectoryDataGridViewTextBoxCell cpu        = new DirectoryDataGridViewTextBoxCell(ph.getCPUUsage());
            DirectoryDataGridViewTextBoxCell ram        = new DirectoryDataGridViewTextBoxCell(ph.getRAMUsage());
            DirectoryDataGridViewTextBoxCell runTime    = new DirectoryDataGridViewTextBoxCell(ph.getRunningTime());
            DirectoryDataGridViewTextBoxCell blocker    = new DirectoryDataGridViewTextBoxCell(ph.getBlockedBy() != null ? ph.getBlockedBy().getPID() : "");
            DataGridViewButtonCell kill                 = new DataGridViewButtonCell();

            if (dir.Length > 50){
                int i = dir.Length;
                int num = 20;
                while (i > 50){
                    i--;
                    num++;
                }
                dir = dir.Substring(0, 5) + "....." + dir.Substring(num);
            }
            pid.Value = ph.getPID();
            directory.Value = dir;
            command.Value = ph.getProcessCaller().getCmd();
            cpu.Value = ph.getCPUUsage();
            ram.Value = ph.getRAMUsage();
            runTime.Value = ph.getRunningTime();
            blocker.Value = ph.getBlockedBy() != null ? ph.getBlockedBy().getPID() : "";
            kill.Value = "KILL";

            processHandleDataGridViewRow.Cells.Add(pid);
            processHandleDataGridViewRow.Cells.Add(directory);
            processHandleDataGridViewRow.Cells.Add(command);
            processHandleDataGridViewRow.Cells.Add(cpu);
            processHandleDataGridViewRow.Cells.Add(ram);
            processHandleDataGridViewRow.Cells.Add(runTime);
            processHandleDataGridViewRow.Cells.Add(blocker);
            processHandleDataGridViewRow.Cells.Add(kill);

            this.bottomUserControlProcessHandleDataGridView.Rows.Add(processHandleDataGridViewRow);
        }
Esempio n. 3
0
 public void addNewProcessHandle(ProcessHandle ph)
 {
     processHandles.Add(ph);
     addToDataView(ph);
 }
Esempio n. 4
0
 public override void Handle()
 {
     this.ph = new CommandLine(ph.getProcessCaller()).run(ph);
 }
Esempio n. 5
0
 public ProcessThreadHandler(ProcessHandle ph)
 {
     this.ph = ph;
 }
 public ProcessHandleDataGridViewRow(ProcessHandle ph)
 {
     this.ph = ph;
 }
Esempio n. 7
0
 public ProcessHandle setBlockedBy(ProcessHandle blockedBy)
 {
     this.blockedBy = blockedBy; return this;
 }
        private void goButton_Click(object sender, EventArgs e)
        {
            if(!goButton.Enabled)  return;
            goButton.Enabled = false;
            List<ProcessCaller> pcs = new List<ProcessCaller>();

            foreach (DirectoryDataGridViewRow directoryDataGridViewRow in this.operationControlCommandsDataGridView.Rows){

                if (directoryDataGridViewRow.Cells[2] is DataGridViewCheckBoxCell){
                    if (!(bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[2]).EditedFormattedValue){
                        continue;
                    }
                }
                ProcessCaller pc = new ProcessCaller("cmd.exe");

                if (directoryDataGridViewRow.Cells[0] is DirectoryDataGridViewTextBoxCell){
                    pc.setDirectory(((DirectoryDataGridViewTextBoxCell)directoryDataGridViewRow.Cells[0]).getDirectory());
                }
                if (directoryDataGridViewRow.Cells[1] is DataGridViewComboBoxCell){

                    pc.setCmd(PreloadedConfigurationGetterService.getInstance().getCommand(this.configFile, ((string)((DataGridViewComboBoxCell)directoryDataGridViewRow.Cells[1]).Value).Trim() ));
                }

                if (directoryDataGridViewRow.Cells[3] is DataGridViewCheckBoxCell){ //display

                    pc.setPrefix((bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[3]).EditedFormattedValue ? "/k" : "/c");
                }

                if (directoryDataGridViewRow.Cells[4] is DataGridViewCheckBoxCell){ //autoexit
                    if ((bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[4]).EditedFormattedValue){
                        pc.setAutoExit();
                    }
                }
                if (directoryDataGridViewRow.Cells[5] is DataGridViewCheckBoxCell){ //wait for exit
                    if ((bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[5]).EditedFormattedValue
                        || !(bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[5]).Visible){
                        pc.setWaitForExit();
                    }
                }

                pc.setSpecial("");
                pcs.Add(pc);
                //string text3 = "/c " + directory.ToCharArray()[0] + ": && cd " + directory + " && " + directory;
                //Console.WriteLine(text3);
            }

            //ProcessThreadHandler
            Cursor.Current = Cursors.WaitCursor;
            try{
                ProcessHandle blocker = null;
                foreach (ProcessCaller pc in pcs){
                    if (pc.echo()){
                        cmdTextBox.Text = pc.getCmd();
                    }
                    ProcessHandle ph			= new ProcessHandle(pc);
                    ProcessThreadHandler pht	= new ProcessThreadHandler(ph);

                    Thread handleCommand = new Thread(new ThreadStart(pht.Handle));
                    handleCommand.Start();

                    if(pc.waitForExit()){
                        ph.setBlockedBy(blocker);
                    }

                    blocker = ph;

                    ((UserControlForm)this.Parent).addNewProcessHandleToQueueAndBottom(ph);
                }
            }
            finally { Cursor.Current = Cursors.Default; }
            goButton.Enabled = true;
        }
Esempio n. 9
0
 public abstract ProcessHandle run(ProcessHandle ph);
Esempio n. 10
0
 public void addToProcessQueue(ProcessHandle ph)
 {
     this.processQueue.Add(ph);
 }
Esempio n. 11
0
 public bool removeProcessHandleIfExists(ProcessHandle ph)
 {
     if(processQueue.Contains(ph)){
         processQueue.Remove(ph); return true;
     }
     return false;
 }