/ Tools / TranscriptAnalysis / Program.cs
Program.cs
 1  using CodexPlugin.OverwatchSupport;
 2  using Logging;
 3  using OverwatchTranscript;
 4  using TranscriptAnalysis;
 5  
 6  public static class Program
 7  {
 8      private static readonly ILog log = new ConsoleLog();
 9  
10      public static void Main(string[] args)
11      {
12          Log("Transcript Analysis");
13          if (!args.Any())
14          {
15              Log("Please pass a .owts file");
16              Console.ReadLine();
17              return;
18          }
19  
20          if (!File.Exists(args[0]))
21          {
22              Log("File doesn't exist: " + args[0]);
23              Console.ReadLine();
24              return;
25          }
26  
27          var reader = OpenReader(args[0]);
28          AppDomain.CurrentDomain.ProcessExit += (e, s) =>
29          {
30              CloseReader(reader);
31          };
32  
33          var header = reader.GetHeader<OverwatchCodexHeader>("cdx_h");
34          var receivers = new ReceiverSet(args[0], log, reader, header);
35          receivers.InitAll();
36  
37          var processor = new Processor(log, reader);
38          processor.RunAll();
39  
40          receivers.FinishAll();
41  
42          CloseReader(reader);
43          Log("Done.");
44          Console.ReadLine();
45      }
46  
47      private static ITranscriptReader OpenReader(string filepath)
48      {
49          try
50          {
51              Log($"Opening: '{filepath}'");
52              return Transcript.NewReader(filepath);
53          }
54          catch (Exception ex)
55          {
56              Log("Failed to open file for reading: " + ex);
57              Console.ReadLine();
58              Environment.Exit(1);
59              return null;
60          }
61      }
62  
63      private static void CloseReader(ITranscriptReader reader)
64      {
65          try
66          {
67              Log("Closing...");
68              reader.Close();
69          }
70          catch (Exception ex)
71          {
72              Log("Failed to close reader: " + ex);
73          }
74      }
75  
76      private static void Log(string msg)
77      {
78          log.Log(msg);
79      }
80  }