Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public List <Log> GetLogs()
        {
            List <Log> logs = new LogRepo().GetAll().ToList();

            logs.Reverse();
            return(logs);
        }
Exemplo n.º 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);
        }
Exemplo 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);
 }
Exemplo n.º 5
0
    public static Dispatcher Configure()
    {
        var dispatcher = new Dispatcher();
        dispatcher.Register<AppendToLogCommand>(q =>
            {
                var repo = new LogRepo();
                AppendToLog.Append(repo, q);
            });

        return dispatcher;
    }
Exemplo n.º 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);
 }
Exemplo n.º 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
     });
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 10
0
 public LogService()
 {
     this._logRepo = new LogRepo();
 }
Exemplo n.º 11
0
 public static void Append(LogRepo repo, AppendToLogCommand c)
 {
     repo.Log(c.Id);
 }
Exemplo n.º 12
0
 public IEnumerable <Models.Log> Get(Int32 max = 20)
 {
     return(LogRepo.All().OrderByDescending(l => l.TimeStamp));
 }