コード例 #1
0
        public ClassificationCounts GetCountsBySubjectId(string id)
        {
            string query = GetCurrentClassificationCount(id);
            ClassificationCounts counts = new ClassificationCounts();

            using (SQLiteConnection connection = new SQLiteConnection($"Data Source={App.DatabasePath}"))
            {
                try
                {
                    connection.Open();
                    SQLiteCommand    command = new SQLiteCommand(query, connection);
                    SQLiteDataReader reader  = command.ExecuteReader();
                    while (reader.Read())
                    {
                        int total    = Convert.ToInt32(reader["classifications_count"]);
                        int smooth   = Convert.ToInt32(reader["smooth"]);
                        int features = Convert.ToInt32(reader["features"]);
                        int star     = Convert.ToInt32(reader["star"]);
                        counts = new ClassificationCounts(total, smooth, features, star);
                    }
                }
                catch (SQLiteException exception)
                {
                    string ErrorMessage = $"Error Connecting to Database. Error: {exception.Message}";
                    Messenger.Default.Send(ErrorMessage, "DatabaseError");
                }
                return(counts);
            }
        }
コード例 #2
0
        public async Task UpdateDBFromGraphQL(string id)
        {
            ClassificationCounts counts = await _graphQLService.GetReductionAsync(id);

            if (counts.Total > 0)
            {
                UpdateSubject(id, counts);
            }
        }
コード例 #3
0
        public void UpdateSubject(string id, ClassificationCounts counts)
        {
            string query = UpdateSubjectCounts(id, counts);

            using (SQLiteConnection connection = new SQLiteConnection($"Data Source={App.DatabasePath}"))
            {
                try
                {
                    connection.Open();
                    SQLiteCommand command = new SQLiteCommand(query, connection);
                    command.ExecuteNonQuery();
                }
                catch (SQLiteException exception)
                {
                    string ErrorMessage = $"Error Connecting to Database. Error: {exception.Message}";
                    Messenger.Default.Send(ErrorMessage, "DatabaseError");
                }
            }
        }
コード例 #4
0
 string UpdateSubjectCounts(string id, ClassificationCounts counts)
 {
     return($"update Subjects set classifications_count = {counts.Total}, smooth = {counts.Smooth}, features = {counts.Features}, star = {counts.Star} where subject_id = {id}");
 }
コード例 #5
0
        public ClassificationCounts IncrementAndUpdateCounts(Classification classification, ClassificationCounts counts)
        {
            switch (classification.Annotations[0].Value)
            {
            case 0:
                counts.Smooth += 1;
                break;

            case 1:
                counts.Features += 1;
                break;

            case 2:
                counts.Star += 1;
                break;
            }
            counts.Total += 1;
            UpdateSubject(classification.Links.Subjects[0], counts);
            return(counts);
        }
コード例 #6
0
        public ClassificationCounts IncrementClassificationCount(Classification classification)
        {
            ClassificationCounts counts = GetCountsBySubjectId(classification.Links.Subjects[0]);

            return(IncrementAndUpdateCounts(classification, counts));
        }