示例#1
0
        private async static Task DoLogAsync(string message, Exception exception, LogType logType, bool sync)
        {
            if (IsEnabledLogInDb)
            {
                using (var dbContext = (IEntityFrameworkDbContext)Activator.CreateInstance(DbContext))
                {
                    using (var logRepository = new LogRepo(dbContext))
                    {
                        using (var sqlServerLogger = (IAsyncLogger)Activator.CreateInstance(SqlLogger, logRepository))
                        {
                            if (sync)
                            {
                                sqlServerLogger.Log(message, exception, logType);
                            }
                            else
                            {
                                await sqlServerLogger.LogAsync(message, exception, logType);
                            }
                        }
                    }
                }
            }

            fileLogger.Log(message, exception, logType);
        }
示例#2
0
        public List <Log> GetLogs()
        {
            List <Log> logs = new LogRepo().GetAll().ToList();

            logs.Reverse();
            return(logs);
        }
示例#3
0
        private static void OnRenamed(object source, RenamedEventArgs e)
        {
            var o = e.OldName;
            var n = e.Name;

            LogRepo.Create(Timestamp.Now, e.ChangeType.ToString(), e.FullPath, e.OldName);
            ConsoleLogger.Log(Timestamp.Now + " File: {0} renamed to {1}", o, n);
        }
示例#4
0
 private static void OnChanged(object source, FileSystemEventArgs e)
 {
     //<<<<<<<<<<TODO>>>>>>>>>>>>
     //if file = text lo posso leggere
     //tell to signalr
     //distingui r/rw/eccetera
     //recupera IDseriale della macchina
     //<<<<<<<<<<OOOO>>>>>>>>>>>>
     LogRepo.Create(Timestamp.Now, e.ChangeType.ToString(), e.FullPath);
     ConsoleLogger.Log("Directory Watcher >> File: {0} {1} ", e.FullPath, e.ChangeType);
 }
示例#5
0
    public static Dispatcher Configure()
    {
        var dispatcher = new Dispatcher();
        dispatcher.Register<AppendToLogCommand>(q =>
            {
                var repo = new LogRepo();
                AppendToLog.Append(repo, q);
            });

        return dispatcher;
    }
示例#6
0
 private static void OnChanged(object source, FileSystemEventArgs e)
 {
     //<<<<<<<<<<TODO>>>>>>>>>>>>
     //if file = text lo posso leggere
     //tell to signalr
     //distingui r/rw/eccetera
     //recupera IDseriale della macchina
     //<<<<<<<<<<OOOO>>>>>>>>>>>>
     LogRepo.Create(Timestamp.Now, e.ChangeType.ToString(), e.FullPath);
     //Console.WriteLine(Timestamp.Now  + " File: " + e.FullPath + " " + e.ChangeType);
 }
示例#7
0
 public async Task Insert(DbInsertContext context, LogRepo l)
 {
     await repository.InsertAsync(new TestRepositoryOperation()
     {
         TestName      = context.TestName,
         IndexInTest   = context.IndexInTest,
         UserName      = context.UserName,
         ScenarioNames = context.ScenarioNames,
         PageName      = context.PageName,
         MessageName   = context.MessageName,
         EntityName    = l.EntityType.GetFriendlyName(),
         Operation     = l.Operation
     });
 }
示例#8
0
 private void SetRepo()
 {
     _ingredientRepo  = new IngredientRepo(_context);
     _tableRepo       = new TableRepo(_context);
     _reservationRepo = new ReservationRepo(_context);
     _categoryRepo    = new CategoryRepo(_context);
     _salesRepo       = new SaleRepo(_context);
     _occupancyRepo   = new OccupanciesRepo(_context);
     _recipeRepo      = new RecipeRepo(_context);
     _productRepo     = new ProductRepo(_context);
     _supplierRepo    = new SupplierRepo(_context);
     _subCategoryRepo = new SubCategoryRepo(_context);
     _logRepo         = new LogRepo(_context);
 }
示例#9
0
        public static void log(BaseController baseController, Product productImport = null)
        {
            string ip         = baseController.Request.UserHostAddress;
            string email      = (string)(baseController.Session["User"] ?? "Anonymous");
            string action     = baseController.ControllerContext.RouteData.Values["action"].ToString();
            string controller = baseController.ControllerContext.RouteData.Values["controller"].ToString();
            string httpMethod = baseController.ControllerContext.HttpContext.Request.HttpMethod;

            string param = "";

            if (productImport == null)
            {
                param = getParam(baseController);
            }
            else
            {
                param = getParam(baseController, productImport);
            }

            if (baseController.ModelState.Keys.Count > 0)
            {
                foreach (string key in baseController.ModelState.Keys)
                {
                    string value = baseController.ModelState[key].Value.AttemptedValue;
                    param = param + "" + key + "=" + value + ",  ";
                }
            }

            DateTime now  = DateTime.Now;
            long     time = now.Ticks;

            var logRepo = new LogRepo();
            Log log     = new Log
            {
                Id         = 0,
                Date       = time,
                Username   = email,
                IP         = ip,
                Controller = controller,
                Action     = action,
                HttpMethod = httpMethod,
                Params     = param
            };

            logRepo.Create(log);
        }
示例#10
0
 public LogService()
 {
     this._logRepo = new LogRepo();
 }
示例#11
0
 public static void Append(LogRepo repo, AppendToLogCommand c)
 {
     repo.Log(c.Id);
 }
示例#12
0
 public IEnumerable <Models.Log> Get(Int32 max = 20)
 {
     return(LogRepo.All().OrderByDescending(l => l.TimeStamp));
 }