Example #1
0
        public static SqlCommand GetInsertRawDataQuery(RawDataEntry entry, SqlConnection sqlConnection)
        {
            String rawObject = (entry.RawContent == null) ? "" : JsonConvert.SerializeObject(entry.RawContent);
            String command   = @"INSERT INTO RAWDATATABLE (source,author,timestamp,content,rawcontent) 
                                VALUES (@source,@author,@timestamp,@content,@rawcontent)";

            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            sqlCommand.Parameters.AddWithValue("@source", entry.Source);
            sqlCommand.Parameters.AddWithValue("@author", entry.Author);
            sqlCommand.Parameters.AddWithValue("@timestamp", entry.TimeStamp);
            sqlCommand.Parameters.AddWithValue("@content", entry.Content);
            sqlCommand.Parameters.AddWithValue("@rawcontent", rawObject);
            return(sqlCommand);
        }
Example #2
0
 public static void RecordRawData(RawDataEntry entry)
 {
     try
     {
         if (SqlConnection.State != System.Data.ConnectionState.Open)
         {
             SqlConnection.Open();
         }
         SqlCommand sqlCommand = DBQueries.GetInsertRawDataQuery(entry, SqlConnection);
         sqlCommand.ExecuteNonQuery();
     }
     catch (Exception e)
     {
         Console.WriteLine("Committing to SQL failed for RecordRawData with exception: {0}", e);
     }
 }
Example #3
0
        public static IEnumerable <RawDataEntry> GetRawDataForAnalyzer(String AnalyzerId)
        {
            List <RawDataEntry> result = new List <RawDataEntry>();

            try
            {
                if (SqlConnection.State != System.Data.ConnectionState.Open)
                {
                    SqlConnection.Open();
                }
                SqlCommand sqlCommand = DBQueries.GetAnalyzerMarkerQuery(AnalyzerId, SqlConnection);
                String     id         = sqlCommand.ExecuteScalar().ToString();

                sqlCommand = DBQueries.GetRetrieveRawRecordsForProcessingQuery(id, SqlConnection);
                using (SqlDataReader reader = sqlCommand.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            RawDataEntry entry = new RawDataEntry
                            {
                                Id        = reader.GetInt32(0).ToString(),
                                Source    = reader.GetString(1),
                                Author    = reader.GetString(2),
                                TimeStamp = reader.GetDateTime(3),
                                Content   = reader.GetString(4)
                            };
                            result.Add(entry);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Committing to SQL failed for GetRawDataForAnalyzer with exception: {0}", e);
            }
            return(result);
        }