public static void InsertRun(AsaRun run)
        {
            if (run == null)
            {
                return;
            }
            if (MainConnection != null)
            {
                using var cmd = new SQLiteCommand(SQL_INSERT_RUN, MainConnection.Connection, MainConnection.Transaction);
                cmd.Parameters.AddWithValue("@run_id", run.RunId);
                cmd.Parameters.AddWithValue("@type", run.Type);
                cmd.Parameters.AddWithValue("@serialized", JsonConvert.SerializeObject(run));

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (SQLiteException e)
                {
                    Log.Warning(e.StackTrace);
                    Log.Warning(e.Message);
                    AsaTelemetry.TrackTrace(Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Error, e);
                }
            }
            else
            {
                Log.Debug("Failed to InsertRun because MainConnection is null.");
            }
        }
        /// <summary>
        ///     This method distills the output from netstat -a -n -o into a list of ProcessPorts that provide
        ///     a mapping between the process (name and id) and the ports that the process is using.
        /// </summary>
        /// <returns> </returns>
        private static List <ProcessPort> GetNetStatPorts()
        {
            List <ProcessPort> ProcessPorts = new List <ProcessPort>();

            try
            {
                using (Process Proc = new Process())
                {
                    ProcessStartInfo StartInfo = new ProcessStartInfo()
                    {
                        FileName               = "netstat.exe",
                        Arguments              = "-a -n -o",
                        WindowStyle            = ProcessWindowStyle.Hidden,
                        UseShellExecute        = false,
                        RedirectStandardInput  = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    };

                    Proc.StartInfo = StartInfo;
                    Proc.Start();

                    StreamReader StandardOutput = Proc.StandardOutput;
                    StreamReader StandardError  = Proc.StandardError;

                    string NetStatContent = StandardOutput.ReadToEnd() + StandardError.ReadToEnd();

                    if (Proc.ExitCode != 0)
                    {
                        Log.Error("Unable to run netstat.exe. Open ports will not be available.");
                        return(ProcessPorts);
                    }

                    string[] NetStatRows = Regex.Split(NetStatContent, "\r\n");

                    foreach (var _outputLine in NetStatRows)
                    {
                        if (_outputLine == null)
                        {
                            continue;
                        }

                        var outputLine = _outputLine.Trim();

                        string[] Tokens = Regex.Split(outputLine, @"\s+");
                        try
                        {
                            if (Tokens.Length < 4)
                            {
                                continue;
                            }
                            string IpAddress = Regex.Replace(Tokens[1], @"\[(.*?)\]", "1.1.1.1");

                            if (Tokens.Length > 4 && Tokens[0].Equals("TCP"))
                            {
                                if (!Tokens[3].Equals("LISTENING"))
                                {
                                    continue;
                                }
                                ProcessPorts.Add(new ProcessPort(
                                                     GetProcessName(Convert.ToInt32(Tokens[4], CultureInfo.InvariantCulture)),
                                                     Convert.ToInt32(Tokens[4], CultureInfo.InvariantCulture),
                                                     IpAddress.Contains("1.1.1.1") ? $"{Tokens[1]}v6" : $"{Tokens[1]}v4",
                                                     Convert.ToInt32(IpAddress.Split(':')[1], CultureInfo.InvariantCulture)
                                                     ));
                            }
                            else if (Tokens.Length == 4 && (Tokens[0].Equals("UDP")))
                            {
                                ProcessPorts.Add(new ProcessPort(
                                                     GetProcessName(Convert.ToInt32(Tokens[3], CultureInfo.InvariantCulture)),
                                                     Convert.ToInt32(Tokens[3], CultureInfo.InvariantCulture),
                                                     IpAddress.Contains("1.1.1.1") ? $"{Tokens[1]}v6" : $"{Tokens[1]}v4",
                                                     Convert.ToInt32(IpAddress.Split(':')[1], CultureInfo.InvariantCulture)
                                                     ));
                            }
                            else
                            {
                                if (!outputLine.StartsWith("Proto") && !outputLine.StartsWith("Active") && !String.IsNullOrWhiteSpace(outputLine))
                                {
                                    Log.Warning("Primary Parsing error when processing netstat.exe output: {0}", outputLine);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Warning("Secondary Parsing error when processing netstat.exe output: {0}", outputLine);
                            AsaTelemetry.TrackTrace(Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Error, e);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Warning("Error processing open ports: {0}", ex.Message);
            }
            return(ProcessPorts);
        }