Esempio n. 1
0
 static void cnn_Updated(object sender, UpdateEventArgs e)
 {
 }
        void OnDatabaseUpdate(object sender, UpdateEventArgs e)
        {
            Debug.WriteLine($"RecordService: {e.Event} - {e.Database}.{e.Table} - {e.RowId}");

            Update(e);
        }
        /// <summary>
        /// Called when the database recieves an update event.
        /// This method inserts newly items into the GUI when new
        /// items are inserted into the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DatabaseUpdated(object sender, UpdateEventArgs e)
        {
            if (!e.Event.Equals(UpdateEventType.Insert)) return;
            var query = $"SELECT * FROM {_table} WHERE Id={(int) e.RowId}";
            var command = new SQLiteCommand(query, _dbConnection);
            var reader = command.ExecuteReader();

            //Fill entry list with entries to be shown
            while (reader.Read())
            {
                var entry = new TableStruct()
                {
                    Id = (long) reader["Id"],
                    ViewIndex = DataContext.Entries.Count+1,
                    Rank = (int) reader["Rank"],
                    Date = (DateTime) reader["Date"]
                };
                entry.PropertyChanged += EntryChanged;
                Application.Current.Dispatcher.Invoke(delegate
                {
                    DataContext.Entries.Add(entry);
                });
            }
        }
        void RecordService_Update(UpdateEventArgs e)
        {
            if (r_IsFinalized || e.Database != "main" || e.Table != "ranking_point_bonus")
                return;

            using (var rCommand = RecordService.Instance.CreateCommand())
            {
                rCommand.CommandText = "SELECT point FROM ranking_point_bonus WHERE sortie = @sortie;";
                rCommand.Parameters.AddWithValue("@sortie", e.RowId);

                ExtraOperationBonus += Convert.ToInt32(rCommand.ExecuteScalar());
                OnPropertyChanged(nameof(TotalScore));
            }
        }