Exemplo n.º 1
0
 public void RemoveHistoricalOcrData(NpgsqlConnection connection, HistoricalOcrData historicData)
 {
     try
     {
         _log.WriteLog(LogLevel.Info,
                       $"Remove historicalData with path <'{historicData.FullFilePath}'> from (Postgres) database \n");
         using (var command = GetCommand(connection,
                                         $"DELETE FROM historical_ocr_data WHERE fullfilepath = '{historicData.FullFilePath}'"))
         {
             command.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         _log.WriteLog(LogLevel.Error,
                       "Error while removing historic data. Error details: \n" + ex.Message + "\n");
     }
 }
Exemplo n.º 2
0
 public void InsertOcrData(NpgsqlConnection connection, HistoricalOcrData histoticData, VanguardDoc docs)
 {
     try
     {
         _log.WriteLog(LogLevel.Info,
                       $"Insert ocrData with path <'{histoticData.FullFilePath}'> into (Postgres) database \n");
         using (var command = GetCommand(connection,
                                         "INSERT INTO \"public\".\"ocr_data\" (\"DocId\", \"TenantId\", \"ErrorMessage\", \"StatusId\"," +
                                         $" \"Data\", \"createdAt\", \"updatedAt\") VALUES({docs.DocId}, {histoticData.TenantId},  '{null}', {histoticData.StatusId}, '{histoticData.Data}'," +
                                         $" '{histoticData.CreatedAt}', '{histoticData.UpdatedAt}') " +
                                         "ON CONFLICT ON CONSTRAINT ocr_data_pkey " +
                                         $"DO UPDATE SET \"ErrorMessage\" = '{null}', \"StatusId\" = {histoticData.StatusId}," +
                                         $"\"createdAt\" = '{histoticData.CreatedAt}', \"updatedAt\" = '{histoticData.UpdatedAt}'"))
         {
             command.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         _log.WriteLog(LogLevel.Error, "Error while inserting ocr data. Error details: \n" + ex.Message + "\n");
     }
 }