Esempio n. 1
0
        public static void Log(string message, string type, string username, string context, string header)
        {
            //JohnM re-enabled DB logging for web
            //If from web, log to DB, if command line log to console
            if (HttpRuntime.AppDomainAppId != null) {
                using (var db = new MySelfieEntities())
                {
                    var entity = new WebLog();

                    entity.Message = message;
                    entity.TimeStamp = DateTime.UtcNow;
                    entity.Type = type;
                    entity.UserName = username;
                    entity.Context = context;
                    entity.Status = "new";
                    //entity.Header = header;

                    db.WebLogs.Add(entity);
                    db.SaveChanges();
                }
            }
            else {
                Console.WriteLine(message);
            }
        }
Esempio n. 2
0
        public static void Log(string message, string type, string username, string context, string header, MySelfieEntities db, bool saveChanges)
        {
            var entity = new WebLog();

            entity.Message = message;
            entity.TimeStamp = DateTime.UtcNow;
            entity.Type = type;
            entity.UserName = username;
            entity.Context = context;
            entity.Status = "new";
            //entity.Header = header;

            db.WebLogs.Add(entity);

            if (saveChanges)
                db.SaveChanges();
        }