示例#1
0
 internal void OnStop()
 {
     SendMailNotification.SendMail("Fortnite service checker stopped", "");
     UpdateLocalStorage();
     _processStartEvent.Stop();
     _processStopEvent.Stop();
     _processStartEvent.EventArrived -= processStartEvent_EventArrived;
     _processStopEvent.EventArrived  -= processStopEvent_EventArrived;
     StopTimers();
 }
示例#2
0
        private void processStartEvent_EventArrived(object sender, EventArrivedEventArgs e)
        {
            _eventTimer.Stop();
            var processName    = e.NewEvent.Properties["ProcessName"].Value.ToString().Replace(".exe", "");
            var processId      = int.Parse(e.NewEvent.Properties["ProcessID"].Value.ToString());
            var processDetails = new ProcessDetails {
                Name = processName, Pid = processId, StartTime = DateTime.Now
            };

            Common.WriteToLog(string.Format("Process [{0}] started | ID: {1}", processName, processId));
            ProcessesToCheck.AddOrUpdate(processName, processDetails, (newKey, oldValue) => processDetails);
            SendMailNotification.SendMail(string.Format("Game {0} started at: {1}", processName, DateTime.Now), "");
            UpdateProcessTimeStamp(processName, true, true, true);
            _eventTimer.Start();
        }
示例#3
0
        private void _eventKillTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            _eventKillTimer.Stop();
            if (_processToKill.Count > 0)
            {
                foreach (var proc in _processToKill)
                {
                    var procName = "";
                    try
                    {
                        var process = Process.GetProcessById(proc);
                        if (process != null)
                        {
                            procName = process.ProcessName;
                            process.Kill();
                        }
                    }
                    catch (ArgumentException)
                    {
                    }
                    catch (Exception ex)
                    {
                        Common.WriteErrorToLog(ex);
                    }
                    var msg = string.Format("Process name [{0}]  id:{1} killed",
                                            procName, proc);
                    SendMailNotification.SendMail(msg, "");
                    Common.WriteToLog(msg);
                    ProcessDetails processDetails;
                    ProcessesToCheck.TryRemove(procName, out processDetails);
                    Common.WriteToLog(string.Format("Process: {0} removed from checking list", proc));

                    // kill IE to lcose all messages
                    var ieProcs = Process.GetProcessesByName("IEXPLORE");
                    foreach (Process ieProc in ieProcs)
                    {
                        if (ieProc.MainWindowTitle.IndexOf("msg.html") > -1)
                        {
                            ieProc.Kill();
                        }
                    }
                }
                _processToKill.Clear();
            }
            _eventKillTimer.Start();
        }
示例#4
0
        private void UpdateProcessTimeStamp(string processName, bool includeEndTime, bool updateLocalStorage, bool sendMail = false)
        {
            ProcessDetails processDetails;

            ProcessesToCheck.TryGetValue(processName, out processDetails);
            if (processDetails != null)
            {
                processDetails.EndTime   = includeEndTime ? DateTime.Now : DateTime.MinValue;
                processDetails.TotalTime = (DateTime.Now - processDetails.StartTime).TotalMinutes;
                ProcessesToCheck.AddOrUpdate(processName, processDetails, (newKey, oldValue) => processDetails);
                if (sendMail)
                {
                    SendMailNotification.SendMail(
                        string.Format("Game {0} stopped at: {1} Total time played: {2:0.00}", processName, DateTime.Now,
                                      processDetails.TotalTime), "");
                }
            }
            if (updateLocalStorage)
            {
                UpdateLocalStorage();
            }
        }
示例#5
0
 internal void OnStart()
 {
     SendMailNotification.SendMail("Fortnite service checker started", "");
     StartProcessListener();
 }