Beispiel #1
0
        public static void WriteLog(LogClassification logClassification, string message, string data)
        {
            using (var db = new UpdateProgramDbContext())
            {
                // Debug log.
                db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                db.Logs.Add(new Log()
                {
                    TimestampUtc     = DateTime.UtcNow,
                    Source           = Assembly.GetEntryAssembly().GetName().Name,
                    ClassificationId = (short)logClassification,
                    Message          = message,
                    Data             = data ?? string.Empty,
                });

                db.SaveChanges();
            }
        }
Beispiel #2
0
        private static void AddProcessTarget(string filePath, string additionalData)
        {
            using (var db = new UpdateProgramDbContext())
            {
                // Debug log.
                db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);

                // Create and insert an entity.
                db.ProcessTargets.Add(new ProcessTarget
                {
                    FilePath                     = filePath,
                    AdditionalData               = additionalData,
                    IsProcessStarted             = false,
                    IsProcessCompleted           = false,
                    InsertedTimestampUtc         = DateTime.UtcNow,
                    ProcessStartedTimestampUtc   = DateTime.MinValue,
                    ProcessCompletedTimestampUtc = DateTime.MinValue,
                });
                db.SaveChanges();
            }
        }