-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
58 lines (58 loc) · 2.13 KB
/
Copy pathProgram.cs
File metadata and controls
58 lines (58 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
namespace ConsoleApp2
{
class Program
{
public class Thread1
{
public static void DoWork()
{
while (true)
{
Console.WriteLine("getting events");
var logName = "Security";
var query =
"*[System[(EventID=4801) and " +
"TimeCreated[timediff(@SystemTime) <= 300000]]]";
var logQuery = new EventLogQuery(logName,
PathType.LogName, query);
var logReader = new EventLogReader(logQuery);
var eventCounter = 0;
var records = new List<EventRecord>();
for (var er = logReader.ReadEvent(); null != er; er = logReader.ReadEvent())
{
records.Add(er);
eventCounter++;
}
Console.WriteLine(eventCounter + " events");
if (eventCounter > 0)
{
var accountSid = "ABC123-CHANGEME";
var authToken = "ABC123-CHANGEME";
TwilioClient.Init(accountSid, authToken);
var message = MessageResource.Create(
body: "Unlocked your PC",
from: new Twilio.Types.PhoneNumber("+12228675309"),
to: new Twilio.Types.PhoneNumber("+13338675309")
);
}
Thread.Sleep(250000);
}
}
}
static void Main(string[] args)
{
var p = Process.GetCurrentProcess();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
Console.WriteLine("Priority is set to: " + p.PriorityClass);
var thread1 = new Thread(Thread1.DoWork);
thread1.Start();
}
}
}