Beispiel #1
0
 async Task OnMessage(ProcessEventArgs arg)
 {
     if (ProcessEvent != null)
     {
         await ProcessEvent.Invoke(arg).ConfigureAwait(false);
     }
 }
        async Task OnMessage(ProcessEventArgs arg)
        {
            if (!arg.HasEvent)
            {
                return;
            }

            await _lockContext.Pending(arg).ConfigureAwait(false);

            if (ProcessEvent != null)
            {
                await ProcessEvent.Invoke(arg).ConfigureAwait(false);
            }
        }
        public static void OnFocusChangedHandler(object src, AutomationFocusChangedEventArgs args)
        {
            AutomationElement element = src as AutomationElement;

            if (element != null)
            {
                // To disable user unhandled expection when debugging
                // https://stackoverflow.com/questions/16970642/visual-studio-not-breaking-on-user-unhandled-exceptions
                try
                {
                    string name      = element.Current.Name;
                    int    processId = element.Current.ProcessId;
                    using (Process process = Process.GetProcessById(processId))
                    {
                        if ((process.ProcessName == "cmd" || process.ProcessName == "conhost") && name.Contains("Command Prompt"))
                        {
                            ProcessEvent?.Invoke(null, new ProcessEventArgs {
                                ProcessEvent = ProcessEvents.CMD_WINDOW_FOCUS
                            });
                            Debug.WriteLine("Command Prompt is in focus.");
                        }
                        else if (process.ProcessName == "explorer" && (name == "Open:" || name == "Cancel" || name == "Browse..." || name == "OK"))
                        {
                            ProcessEvent?.Invoke(null, new ProcessEventArgs {
                                ProcessEvent = ProcessEvents.RUN_WINDOW_FOCUS
                            });
                            Debug.WriteLine("Run Window is in focus.");
                            //Console.WriteLine("Name: {0}, ProcessName: {1} is in focus", name, process.ProcessName);
                        }
                        else
                        {
                            ProcessEvent?.Invoke(null, new ProcessEventArgs {
                                ProcessEvent = ProcessEvents.OTHER_FOCUS
                            });
                        }
                    }
                }
                catch (System.Windows.Automation.ElementNotAvailableException)
                {
                    Debug.Write("The target element corresponds to UI that is no longer available.");
                }
            }
        }
Beispiel #4
0
        private void Kernel_ProcessStart(Microsoft.Diagnostics.Tracing.Parsers.Kernel.ProcessTraceData obj)
        {
            if (Filters.Contains(obj.ImageFileName))
            {
                ProcessData ev = new ProcessData()
                {
                    Name        = obj.ImageFileName,
                    CommandLine = obj.CommandLine,
                    Start       = obj.TimeStamp,
                    ProcessID   = obj.ProcessID,
                    UniqueKey   = obj.UniqueProcessKey,
                };

                ProcessDataMap.Add(obj.ProcessID, ev);

                ProcessEvent?.Invoke(ev);

                Task.Run(() => CollectArtifacts(ev));
            }
        }
        public static void EventArrived(object sender, EventArrivedEventArgs e)
        {
            string instanceName = ((ManagementBaseObject)e.NewEvent["TargetInstance"])["Name"].ToString().ToLower();

            switch (instanceName)
            {
            case "cmd.exe":
                ProcessEvent?.Invoke(null, new ProcessEventArgs {
                    ProcessEvent = ProcessEvents.CMD_PROCESS
                });
                Debug.WriteLine("Command prompt has been started ...");
                break;

            //case "eventvwr.msc":
            //    Debug.WriteLine("Event viewer has been started ...");
            //    break;
            case "mmc.exe":
                ProcessEvent?.Invoke(null, new ProcessEventArgs {
                    ProcessEvent = ProcessEvents.MANAGEMENT_CONSOLE_PROCESS
                });
                Debug.WriteLine("Management console has been started ...");
                break;

            case "netstat.exe":
                ProcessEvent?.Invoke(null, new ProcessEventArgs {
                    ProcessEvent = ProcessEvents.NETSTAT_PROCESS
                });
                Debug.WriteLine("Netstat has been started ...");
                break;

            // case "services.exe":
            //    Debug.WriteLine("Services has been started ...");
            //    break;
            default:
                break;
            }
            //Debug.WriteLine("Process started", instanceName);
        }
Beispiel #6
0
 /// <summary>
 /// 消息委托
 /// </summary>
 /// <param name="updateToTrayTooltip">是否更新托盘图标的工具提示</param>
 /// <param name="msg">输出到日志框</param>
 private void ShowMsg(bool updateToTrayTooltip, string msg)
 {
     ProcessEvent?.Invoke(updateToTrayTooltip, msg);
 }
        /// <summary>
        /// Asignamos los datos a las evaluaciones y las guardamos en la base de datos
        /// Serializamos los alumnos con sus atributos
        /// </summary>
        /// <param name="alumno"></param>
        /// <param name="proxAlumno"></param>
        void Evaluar(Alumno alumno, Alumno proxAlumno)
        {
            _swatch.Start();
            Evaluacion evaluacion;
            Random     random = new Random();

            Array          values        = Enum.GetValues(typeof(EObservaciones));
            EObservaciones randomEObserv = (EObservaciones)values.GetValue(random.Next(values.Length));

            int   idAlumno   = alumno.IdAlumno;
            int   idAulas    = random.Next(1, _aulas.Count);
            int   idDocentes = random.Next(1, _docentes.Count);
            int   notaUno    = random.Next(1, 10);
            int   notaDos    = random.Next(1, 10);
            float nf         = ((notaUno + notaDos) / 2);

            evaluacion = new Evaluacion(idAlumno, idDocentes, idAulas, notaUno, notaDos, nf, randomEObserv.ToString());

            c.GuardarEvaluaciones(evaluacion);

            alumno.NotaUno   = notaUno;
            alumno.NotaDos   = notaDos;
            alumno.NotaFinal = nf;

            if (evaluacion.NotaFinal >= 6)
            {
                alumno.GuardarAlumnosAprobados(alumno);
            }
            else
            {
                alumno.GuardarAlumnosDesaprobados(alumno);
            }

            this._evaluaciones.Add(evaluacion);

            string docente = "Docente no establecido.";

            foreach (Docente item in _docentes)
            {
                if (item.Id == idDocentes)
                {
                    // Actualiza docente.
                    docente = item.ToString();
                }
            }

            string aula = string.Empty;

            foreach (Aula item in _aulas)
            {
                if (item.IdAula == idAulas)
                {
                    // Actualiza aula.
                    aula = item.ToString();
                }
            }

            alumnosEvaluados.Add(alumno);
            Thread.Sleep(TIEMPOEVALUACION);
            _swatch.Stop();

            ProcessEventArgs parametrosEvento = new ProcessEventArgs()
            {
                AlumnoEvaluado     = alumno.ToString(),
                Aula               = aula,
                Docente            = docente,
                ProximoAlumno      = proxAlumno,
                TiempoTranscurrido = $"Tiempo transcurrido:{_swatch.Elapsed.ToString()}"
            };

            ProcessEvent?.Invoke(this, parametrosEvento);
        }
Beispiel #8
0
 private void NotifyEvent(FileScannerProcessEventArgs args)
 {
     ProcessEvent?.Invoke(this, args);
 }
Beispiel #9
0
 private void NotifyEvent(ProcessType processType, InnerType innerType = InnerType.NA)
 {
     ProcessEvent?.Invoke(this, new FileScannerProcessEventArgs(processType, innerType));
 }
Beispiel #10
0
        private void ProcessButton_Click(object sender, EventArgs e)
        {
            ProcessEvent?.Invoke(InputAmountBox.Value, DescriptionBox.Text);

            ClearForm();
        }