public static void WriteNext() { WriteQueue.TryDequeue(out WriteObject objIn); try { using var cmd = new SqliteCommand(SQL_INSERT_COLLECT_RESULT, Connection, Transaction); cmd.Parameters.AddWithValue("@run_id", objIn.RunId); cmd.Parameters.AddWithValue("@row_key", CryptoHelpers.CreateHash(JsonConvert.SerializeObject(objIn.ColObj))); cmd.Parameters.AddWithValue("@identity", objIn.ColObj.Identity); cmd.Parameters.AddWithValue("@serialized", JsonConvert.SerializeObject(objIn.ColObj, Formatting.None, new JsonSerializerSettings() { DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore })); cmd.Parameters.AddWithValue("@result_type", objIn.ColObj.ResultType); cmd.ExecuteNonQuery(); } catch (SqliteException) { Log.Debug($"Error writing {objIn.ColObj.Identity} to database."); } catch (NullReferenceException) { Log.Debug($"Was this a valid WriteObject. It looked null. {JsonConvert.SerializeObject(objIn)}"); } }
public static void Write(CollectObject obj, string runId) { var cmd = new SqliteCommand(SQL_INSERT_COLLECT_RESULT, Connection, Transaction); cmd.Parameters.AddWithValue("@run_id", runId); cmd.Parameters.AddWithValue("@row_key", CryptoHelpers.CreateHash(JsonConvert.SerializeObject(obj))); cmd.Parameters.AddWithValue("@identity", obj.Identity); cmd.Parameters.AddWithValue("@serialized", JsonConvert.SerializeObject(obj)); cmd.Parameters.AddWithValue("@result_type", obj.ResultType); cmd.ExecuteNonQuery(); }