예제 #1
0
        private void AnalyzePowerRequests(object sender, IdleScanAnalysis analysis)
        {
            string output = QueryPowerRequests();

            var detectedRequests = new HashSet <string>();

            foreach (string key in selectors.Keys)
            {
                foreach (string keyWord in selectors[key])
                {
                    if (output.IndexOf(keyWord, StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        string token = "((" + key + "))";

                        if (!analysis.BusyTokens.Contains(token))
                        {
                            analysis.BusyTokens.Add(token);
                        }

                        if (keepAlive)
                        {
                            analysis.Busy = true;
                        }
                    }
                }
            }
        }
예제 #2
0
파일: PingHost.cs 프로젝트: radtek/Insomnia
 private void ScanHosts(object sender, IdleScanAnalysis analysis)
 {
     foreach (string host in hostsAwake.Union(hostsWatch))
     {
         try
         {
             PingReply reply = ping.Send(host);
             if (reply.Status == IPStatus.Success)
             {
                 if (hostsAwake.Contains(host))
                 {
                     if (!analysis.BusyTokens.Contains(host))
                     {
                         analysis.BusyTokens.Add(host);
                     }
                     analysis.Busy = true;
                 }
                 else
                 {
                     analysis.InfoTokens.Add(host);
                 }
             }
         }
         catch (PingException)
         {
         }
     }
 }
예제 #3
0
        private void OnBusy(object sender, IdleScanAnalysis analysis)
        {
            string tokens = string.Join(", ", analysis.BusyTokens.Where(t => !(t.StartsWith("((") && t.EndsWith("))"))));
            string reason = $"Kein Standby-Modus wegen: {tokens}";

            if (Request?.Reason != reason)
            {
                Request?.Clear();
                Request = new PowerRequest(reason);
            }
        }
예제 #4
0
        private void OnIdle(object sender, IdleScanAnalysis analysis)
        {
            if (analysis.IdleCount > idleMax)
            {
                if (Context.DebugLog)
                {
                    EventLog.WriteEntry("Computer idle", EventLogEntryType.Information, 5);
                }

                Win32API.EnterStandby();
            }
        }
예제 #5
0
 private void ScanSessions(object sender, IdleScanAnalysis analysis)
 {
     foreach (ITerminalServicesSession session in Component <TerminalServer>().Sessions)
     {
         if (session.ConnectionState == ConnectionState.Active)
         {
             if (session.IsRemoteConnected())
             {
                 analysis.BusyTokens.Add($"<{session.ClientName}\\{session.UserName}>");
                 analysis.Busy = true;
             }
         }
     }
 }
예제 #6
0
 private void SavePowerRequests(object sender, IdleScanAnalysis analysis)
 {
     try
     {
         var    now   = DateTime.Now;
         string name  = now.ToString("HHmm") + ".log";
         string today = Path.Combine(requestsDir.FullName, now.ToString("yyyy-MM-dd"));
         string path  = Path.Combine(today, name);
         Directory.CreateDirectory(today);
         File.AppendAllText(path, QueryPowerRequests());
     }
     catch (Exception e)
     {
         EventLog.WriteEntry(e.ToString(), EventLogEntryType.Error);
     }
 }
예제 #7
0
파일: IdleTime.cs 프로젝트: radtek/Insomnia
        private void QueryIdleTimers(object sender, IdleScanAnalysis analysis)
        {
            foreach (User user in users.Values)
            {
                if (user.IdleTime >= 0 && user.IdleTime < Context.Interval)
                {
                    // Ist der Benutzer NICHT bereits über RDP angemeldet?
                    if (!Component <TerminalServer>()[user.SID].IsRemoteConnected())
                    {
                        analysis.BusyTokens.Add("<" + user.Name + ">");
                    }

                    analysis.Busy = true;
                }
            }
        }
예제 #8
0
        private void CheckLastSeen(object sender, IdleScanAnalysis analysis)
        {
            lock (lastSeen)
            {
                foreach (string host in lastSeen.Keys)
                {
                    TimeSpan time = DateTime.Now - lastSeen[host];

                    if (time.TotalMilliseconds < Context.Interval)
                    {
                        if (!analysis.BusyTokens.Contains(host))
                        {
                            analysis.BusyTokens.Add(host);
                        }
                        analysis.Busy = true;
                    }
                }
            }
        }
예제 #9
0
 private void OnIdle(object sender, IdleScanAnalysis analysis)
 {
     Request?.Clear();
     Request = null;
 }