Exemple #1
0
        /// <summary>
        /// Add a log to the database
        /// </summary>
        /// <param name="job">The job affecting the log</param>
        /// <param name="time">The timestamp for the log</param>
        public void AddLog(Job job, DateTime time)
        {
            if (job == null)
                throw new ArgumentNullException("job was null");
            if (job.User == null)
                throw new ArgumentNullException("job.User was null");
            if (job.JobId == 0)
                throw new ArgumentNullException("job.JobId was 0");
            if (time == null)
                throw new ArgumentNullException("time was null");

            lock (_objectLock)
            {
                var dbContext = new TaskManagerModelContainer();
                Debug.WriteLine("1 - Inside Log.AddJob(); Event: " + job.StateString + "; jobId: " + job.JobId );
                Log log = new Log();
                log.Event = job.StateString;
                log.Time = time;
                log.JobId = job.JobId;

                dbContext.Logs.AddObject(log);
                Debug.WriteLine("2 - Inside Log.AddJob(); State: " + job.StateString + "; jobId: " + job.JobId + "; logId: " + log.LogId);
                dbContext.SaveChanges();
            }
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TM2SQL_DAO" /> class.
 /// </summary>
 public TM2SQL_DAO()
 {
     _objectLock = new Object();
     _dbContext = new TaskManagerModelContainer();
 }