public void Add(string user, string remote, string message)
        {
            Actionlog newLog = new Actionlog();

            newLog.User       = user;
            newLog.UserRemote = remote;
            newLog.Message    = message;
            newLog.Time       = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            _context.Add(newLog);
            _context.SaveChanges();
        }
Exemplo n.º 2
0
        private void Log(RouteData routeData, long time)
        {
            var      controllerName = routeData.Values["controller"];
            var      actionName     = routeData.Values["action"];
            TimeSpan t            = TimeSpan.FromMilliseconds(time);
            string   readabletime = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms",
                                                  t.Hours,
                                                  t.Minutes,
                                                  t.Seconds,
                                                  t.Milliseconds);

            using (ParkingManagementContext contextdb = new ParkingManagementContext())
            {
                Actionlog log = new Actionlog()
                {
                    ControllerDescrption = controllerName.ToString(),
                    ActionExectionInfo   = actionName.ToString(),
                    ExectionTime         = readabletime.ToString()
                };
                contextdb.Actionlogs.Add(log);
                contextdb.SaveChanges();
            }
        }