private void deleteFromDB(LogEvent logevent)
 {
     using (LogEventDataContext logDb = new LogEventDataContext(LogEventDataContext.ConnectionString))
     {
         if (!logDb.DatabaseExists())
         {
             System.Diagnostics.Debug.WriteLine(this.GetType().Name + ": DB does not exist");
             return;
         }
         logDb.DeleteLogEvent(logevent.EventId);
     }
 }
        private void SendMessages()
        {
            System.Diagnostics.Debug.WriteLine(this.GetType().Name +  ".SendMessages");

            using (LogEventDataContext logDb = new LogEventDataContext(LogEventDataContext.ConnectionString))
            {
                if (!logDb.DatabaseExists())
                {
                    System.Diagnostics.Debug.WriteLine(this.GetType().Name + ": DB does not exist");
                    return;
                }
                List<LogEvent> events = logDb.GetLogEvents();
                foreach (LogEvent e in events)
                {
                    SendMessage(e);
                }
            }
            System.Diagnostics.Debug.WriteLine(this.GetType().Name + ".AsyncSendMessages event handler finished");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void GetLogData()
        {
            const string ConnectionString = @"Data Source = 'isostore:/LogEventDB.sdf';";

            using (LogEventDataContext logDBContext = new LogEventDataContext(ConnectionString))
            {
                if (!logDBContext.DatabaseExists())
                {
                    // create database if it does not exist
                    try
                    {
                        logDBContext.CreateDatabase();
                    }
                    catch (InvalidOperationException ioe)
                    {
                        System.Diagnostics.Debug.WriteLine("InvalidOperationException while creating database..." + ioe);
                    }
                }
                GetLogEvents(logDBContext);
            }
        }