Exemplo n.º 1
0
        public void addEvents(IList<LogEvent> events)
        {
            using (LogEventDataContext context = new LogEventDataContext(ConnectionString))
            {
                foreach (LogEvent e in events)
                {
                    LogEvent le = new LogEvent();
                    e.Time = DeviceTools.GetUnixTime(DateTime.Now);

                    // add the new logEvent to the context
                    context.LogEvents.InsertOnSubmit(e);
                }

                context.SubmitChanges();
            }
        }
Exemplo n.º 2
0
        public void DeleteLogEvent(int id)
        {
            //LogEventDataContext context;
            using (LogEventDataContext context = new LogEventDataContext(ConnectionString))
            {
                IQueryable<LogEvent> query =
                            from le in context.LogEvents
                            where le.EventId == id
                            select le;

                LogEvent leToDelete = query.FirstOrDefault();

                //context.LogEvents.Attach(leToDelete);
                context.LogEvents.DeleteOnSubmit(leToDelete);
                context.SubmitChanges();
            }
        }
Exemplo n.º 3
0
        public void addEvent(JObject sensorEvent, String url)
        {
            using (LogEventDataContext context = new LogEventDataContext(ConnectionString))
            {
                // create a new LogEvent instance
                LogEvent le = new LogEvent();
                le.sensorEvent = sensorEvent.ToString();
                le.Time = DeviceTools.GetUnixTime(DateTime.Now);
                le.relativeUrl = url;

                // add the new logEvent to the context
                context.LogEvents.InsertOnSubmit(le);
                try
                {
                    // save changes to the database
                    context.SubmitChanges();
                }
                catch (System.SystemException e)
                {
                    System.Diagnostics.Debug.WriteLine("SQLException" + e);
                }
            }
        }