public static List <OutputFileMonitorResult> GetMonitorResults(string runId, int offset, int numResults)
        {
            var results = new List <OutputFileMonitorResult>();

            using (var cmd = new SQLiteCommand(GET_MONITOR_RESULTS, Connection, Transaction))
            {
                cmd.Parameters.AddWithValue("@run_id", runId);
                cmd.Parameters.AddWithValue("@offset", offset);
                cmd.Parameters.AddWithValue("@limit", numResults);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var obj = new OutputFileMonitorResult()
                        {
                            RowKey     = reader["row_key"].ToString(),
                            Timestamp  = reader["timestamp"].ToString(),
                            Path       = reader["path"].ToString(),
                            OldPath    = reader["old_path"].ToString(),
                            Name       = reader["path"].ToString(),
                            OldName    = reader["old_path"].ToString(),
                            ChangeType = (CHANGE_TYPE)int.Parse(reader["change_type"].ToString(), CultureInfo.InvariantCulture),
                        };
                        results.Add(obj);
                    }
                }
            }
            return(results);
        }
        public ActionResult GetMonitorResults(string RunId, int ResultType, int Offset, int NumResults)
        {
            var results = new List <OutputFileMonitorResult>();

            using (var cmd = new SqliteCommand(GET_MONITOR_RESULTS, DatabaseManager.Connection, DatabaseManager.Transaction))
            {
                cmd.Parameters.AddWithValue("@run_id", RunId);
                cmd.Parameters.AddWithValue("@offset", Offset);
                cmd.Parameters.AddWithValue("@limit", NumResults);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var obj = new OutputFileMonitorResult()
                        {
                            RowKey     = reader["row_key"].ToString(),
                            Timestamp  = reader["timestamp"].ToString(),
                            Path       = reader["path"].ToString(),
                            OldPath    = reader["old_path"].ToString(),
                            Name       = reader["path"].ToString(),
                            OldName    = reader["old_path"].ToString(),
                            ChangeType = (CHANGE_TYPE)int.Parse(reader["change_type"].ToString()),
                        };
                        results.Add(obj);
                    }
                }
            }

            Dictionary <string, object> output = new Dictionary <string, object>();
            var result_count = 0;

            using (var cmd = new SqliteCommand(GET_RESULT_COUNT_MONITORED, DatabaseManager.Connection, DatabaseManager.Transaction))
            {
                cmd.Parameters.AddWithValue("@run_id", RunId);
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        result_count = int.Parse(reader["count(*)"].ToString());
                    }
                }

                output["Results"]    = results;
                output["TotalCount"] = result_count;
                output["Offset"]     = Offset;
                output["Requested"]  = NumResults;
                output["Actual"]     = results.Count;
            }
            return(Json(JsonConvert.SerializeObject(output)));
        }
        public static List <OutputFileMonitorResult> GetMonitorResults(string runId, int offset, int numResults)
        {
            var results = new List <OutputFileMonitorResult>();

            if (MainConnection != null)
            {
                using (var cmd = new SqliteCommand(GET_MONITOR_RESULTS, MainConnection.Connection, MainConnection.Transaction))
                {
                    cmd.Parameters.AddWithValue("@run_id", runId);
                    cmd.Parameters.AddWithValue("@offset", offset);
                    cmd.Parameters.AddWithValue("@limit", numResults);
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var path = reader["path"].ToString();
                            if (!string.IsNullOrEmpty(path))
                            {
                                var obj = new OutputFileMonitorResult(path)
                                {
                                    RowKey     = reader["row_key"].ToString(),
                                    Timestamp  = reader["timestamp"].ToString(),
                                    OldPath    = reader["old_path"].ToString(),
                                    Name       = reader["path"].ToString(),
                                    OldName    = reader["old_path"].ToString(),
                                    ChangeType = (CHANGE_TYPE)int.Parse(reader["change_type"].ToString() ?? "Invalid", CultureInfo.InvariantCulture),
                                };
                                results.Add(obj);
                            }
                        }
                    }
                }
            }
            else
            {
                Log.Debug("Failed to GetMonitorResults. MainConnection was null.");
            }

            return(results);
        }