示例#1
0
文件: DAO.cs 项目: Prechtig/BDSA2012
 /// <summary>
 /// Add a LogEntry to the database
 /// </summary>
 /// <param name="entry">The LogEntry to add</param>
 public static bool AddLogEntry(LogEntry entry)
 {
     using (var context = new OOADEntities())
     {
         logEntry dbEntry = new logEntry();
         dbEntry.jobId = entry.JobId;
         dbEntry.state = entry.State.ToString();
         dbEntry.timeStamp = entry.TimeStamp;
         //If the user doesn't exist in the db, we'll get a NPE
         try { dbEntry.userId = entry.JobOwner.Id; }
         catch (NullReferenceException) { return false; }
         context.logEntries.AddObject(dbEntry);
         context.SaveChanges();
         return true;
     }
 }
示例#2
0
 public void AddLogEntryTest()
 {
     LogEntry entry = new LogEntry(0, 1, 4, DateTime.Now, "Queued");
     Assert.IsTrue(DAO.AddLogEntry(entry));
 }