Esempio n. 1
0
 public EntryLogRepository(AppDbContext appDb, IMyServices myServices)
 {
     _appDb            = appDb;
     _logEntry         = new LogEntry();
     _myServices       = myServices;
     _logListViewModel = new LogListViewModel();
 }
Esempio n. 2
0
        // GET: Log
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page, string startDate = null, string endDate = null, int userId = -1, ErrorType ErrorType = ErrorType.NONE)
        {
            var loggedInUser = userRepository.GetById(Convert.ToInt32(User.Identity.GetUserId()));

            if (loggedInUser.Role == "admin")
            {
                ViewBag.CurrentSort       = sortOrder;
                ViewBag.TimestampSortParm = String.IsNullOrEmpty(sortOrder) ? "timestamp_desc" : "";
                // ViewBag.PrioritySortParm = sortOrder == "Date" ? "date_desc" : "Date";

                if (searchString != null)
                {
                    page = 1;
                }
                else
                {
                    searchString = currentFilter;
                }

                ViewBag.CurrentFilter = searchString;

                DateTime start, end;

                if (String.IsNullOrEmpty(startDate) || String.IsNullOrEmpty(endDate))
                {
                    var dateNow = DateTime.Now.AddMonths(-1);
                    start = DateTime.Now.AddMonths(-1).Date;
                    end   = DateTime.Now.AddDays(1).Date;
                }
                else
                {
                    start = Convert.ToDateTime(startDate);
                    end   = Convert.ToDateTime(endDate);
                }

                ViewBag.StartDate = start.ToString("yyyy-MM-dd");
                ViewBag.EndDate   = end.ToString("yyyy-MM-dd");

                int pageSize   = 25;
                int pageNumber = (page ?? 1);

                ViewBag.ErrorType = ErrorType;

                var logs  = _logRepository.List(sortOrder, searchString, pageSize, pageNumber, start, end, userId, ErrorType);
                var users = userRepository.List();

                var viewModel = new LogListViewModel()
                {
                    Logs   = logs,
                    Users  = users,
                    UserId = userId
                };

                return(View(viewModel));
            }
            else
            {
                throw new Exception("You are not allowed to access this");
            }
        }
Esempio n. 3
0
        public ActionResult LogList()
        {
            LogListViewModel model = new LogListViewModel();

            model.Logs = _logManager.List();

            return(View(model));
        }
Esempio n. 4
0
        public async Task <IActionResult> Index(Guid application)
        {
            var model = new LogListViewModel()
            {
                Application  = application,
                Applications = await Registry.GetApplications(),
                Logs         = await Server.GetLogs(application, DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0)), DateTime.Now, 1, 10)
            };

            return(View(model));
        }
        public object CreateViewModel(DependencyObject sender)
        {
            IWindowFactory   windowFactoryAdd        = new AddLogWindowFactory();
            IWindowFactory   windowFactoryDeleteEdit = new EditDeleteLogWindowFactory();
            LogListViewModel vm     = new LogListViewModel(windowFactoryAdd, windowFactoryDeleteEdit);
            ILogDal          logDal = new LogDal(ConfigurationManager.AppSettings["connection_string"]);

            vm.ServiceLocator.RegisterService <ILogService>(new LogService(logDal));
            vm.ServiceLocator.RegisterService <IReportService>(new PdfReportService(ConfigurationManager.AppSettings["base_directory"], $"{ConfigurationManager.AppSettings["download_directory"]}Reports\\"));
            ObserverSingleton.GetInstance.LogObservers.Add(vm);
            ObserverSingleton.GetInstance.TourObservers.Add(vm);
            return(vm);
        }
        public void ReceivingExceptionEventShouldAddErrorLog()
        {
            var eventAggregator = new EventAggregator();
            var exceptionEvent  = eventAggregator.GetEvent <PubSubEvent <ExceptionEvent> >();
            var viewModel       = new LogListViewModel(eventAggregator);
            var exception       = new IOException("expected message");

            exceptionEvent.Publish(new ExceptionEvent {
                Exception = exception
            });

            var logs = viewModel.Logs;

            logs.Should().NotBeNullOrEmpty();
        }
Esempio n. 7
0
        public ActionResult LogList()
        {
            //if (!_permissionService.Authorize(ThirdStorePermission.KPIReport.ToName()))
            //{
            //    ErrorNotification("You do not have permission to process this page.");
            //    return Redirect("~/");
            //}


            var model = new LogListViewModel();

            model.LogTimeFrom = DateTime.Today;
            model.LogTimeTo   = DateTime.Today;

            return(View(model));
        }
Esempio n. 8
0
        public IActionResult Index()
        {
            var authUser = AuthController.GetAuthUser(User);

            var rsult = _weightLogLogic.GetAllBy(authUser);
            var bmis  = _weightLogLogic
                        .GetAllBy(authUser)
                        .Select(weightlog => new BMIViewModel
            {
                BMI      = Math.Round((weightlog.Weight / (authUser.Length * authUser.Length / 10000)), 2, MidpointRounding.AwayFromZero),
                Lenght   = authUser.Length,
                Weight   = weightlog.Weight,
                DateTime = weightlog.DateTime
            }).ToList();

            CaloriesOverViewModel caloriesOverViewModel = null;
//            var num = _foodlogLogic.GetAllBy(authUser).Aggregate(0, (current, foodlog) => current + foodlog.Article.Calories);
//            if (_goalLogLogic.GetLastBy(authUser) != null && _foodlogLogic.GetAllBy(authUser) != null)
//            {
//                caloriesOverViewModel.ConsumedCalories = num;
//                caloriesOverViewModel.GoalLog = _goalLogLogic.GetLastBy(authUser);
//                caloriesOverViewModel.CaloriesOver = _foodlogLogic.GetAllBy(authUser).Aggregate(0,(current, foodlog) => current + foodlog.Article.Calories) - _goalLogLogic.GetLastBy(authUser).Calories;
//            }

            var viewModel = new LogListViewModel
            {
                FoodlogsBreakfast = _foodlogLogic
                                    .GetAllBy(authUser)
                                    .Where(f => f.DateTime.Hour >= 1 && f.DateTime.Hour < 11),

                FoodlogsLunch = _foodlogLogic
                                .GetAllBy(authUser)
                                .Where(f => f.DateTime.Hour >= 11 && f.DateTime.Hour < 17),

                FoodlogsSupper = _foodlogLogic
                                 .GetAllBy(authUser)
                                 .Where(f => f.DateTime.Hour >= 17 && f.DateTime.Hour < 23),

                BMIs = bmis,

                GoalLogs = _goalLogLogic.GetAllBy(authUser),

                CaloriesOverViewModel = caloriesOverViewModel
            };

            return(View(viewModel));
        }
Esempio n. 9
0
 public ActionResult Log()
 {
     LogListViewModel vModel = new LogListViewModel();
     vModel.LogList = new List<LogViewModel>();
     UserOperateLog vUserOperateLog = new UserOperateLog();
     LogEF[] vLogList = vUserOperateLog.GetAllLog();
     foreach( LogEF log in vLogList)
     {
         LogViewModel vLogModel = new LogViewModel();
         vLogModel.ID = log.ID.Value;
         vLogModel.UserID = log.UserID.Value;
         vLogModel.UserName = log.UserName;
         vLogModel.Type = log.Type;
         vLogModel.OperateTime = log.OperateTime.Value;
         vModel.LogList.Add(vLogModel);
     }
     return View(vModel);
 }
Esempio n. 10
0
        // GET: Log
        public ActionResult Index()
        {
            LogListViewModel ListViewModel = new LogListViewModel()
            {
                Items = new List <PersonInfoViewModel>()
            };

            foreach (var item in _logservice.GetAll())
            {
                PersonInfoViewModel vm = new PersonInfoViewModel()
                {
                    MemberId = item.MemberId,
                    LogId    = item.LogId,
                    DateTime = item.DateTime,
                    //Content = _logservice.Readtext(item.Path)
                };
                ListViewModel.Items.Add(vm);
            }
            return(View(ListViewModel.Items));
        }
Esempio n. 11
0
        public async Task <IActionResult> Index(
            string logLevel = "",
            int pageNumber  = 1,
            int pageSize    = -1,
            string sort     = "desc")
        {
            ViewData["Title"]   = "System Log";
            ViewData["Heading"] = "System Log";

            int itemsPerPage = logManager.LogPageSize;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            var model = new LogListViewModel
            {
                LogLevel = logLevel
            };
            PagedQueryResult result;

            if (sort == "desc")
            {
                result = await logManager.GetLogsDescending(pageNumber, itemsPerPage, logLevel);
            }
            else
            {
                result = await logManager.GetLogsAscending(pageNumber, itemsPerPage, logLevel);
            }

            model.TimeZoneId = await timeZoneIdResolver.GetUserTimeZoneId();

            model.LogPage = result.Items;

            model.Paging.CurrentPage  = pageNumber;
            model.Paging.ItemsPerPage = itemsPerPage;
            model.Paging.TotalItems   = result.TotalItems;

            return(View(model));
        }
Esempio n. 12
0
        public ActionResult Journal(int page = 1)
        {
            var pageCount = (_journalService.RecordsCount() / RecordsOnPage) +
                            (_journalService.RecordsCount() % RecordsOnPage != 0 ? 1 : 0);

            if (page > pageCount)
            {
                return(HttpNotFound());
            }

            var logs   = _journalService.GetRecords(null, RecordsOnPage * (page - 1), RecordsOnPage);
            var logsVm = Mapper.Map <IEnumerable <LibraryLogRecord>, IEnumerable <LibraryLogRecordViewModel> >(logs);

            var model = new LogListViewModel()
            {
                PageCount   = pageCount,
                CurrentPage = page,
                Logs        = logsVm
            };

            return(View(model));
        }
Esempio n. 13
0
        public ActionResult LogList(DataSourceRequest command, LogListViewModel model)
        {
            var logDS = _logService.SearchGumtreeFeeds(
                model.SearchMessage,
                model.LogTimeFrom,
                model.LogTimeTo,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize);


            var logGridViewList = logDS.Select(i => i.ToModel());

            var gridModel = new DataSourceResult()
            {
                Data = logGridViewList, Total = logDS.TotalCount
            };

            //return View();
            return(new JsonResult
            {
                Data = gridModel
            });
        }
Esempio n. 14
0
        public PartialViewResult LogList(string message, DateTime?startTime, DateTime?endTime, int pageIndex = 1)
        {
            LogListViewModel     model  = new LogListViewModel();
            AdminLogSearchResult result = adminLogService.GetPageList(message, startTime, endTime, null, pageIndex, pageSize);

            model.AdminLogs = result.AdminLogs;

            //分页
            Pagination pager = new Pagination();

            pager.PageIndex  = pageIndex;
            pager.PageSize   = pageSize;
            pager.TotalCount = result.TotalCount;

            if (result.TotalCount <= pageSize)
            {
                model.Page = "";
            }
            else
            {
                model.Page = pager.GetPagerHtml();
            }
            return(PartialView("LogListPaging", model));
        }
Esempio n. 15
0
        public async Task <IActionResult> ViewLog(
            int pageNumber = 1,
            int pageSize   = -1,
            string sort    = "desc")
        {
            ViewData["Title"]   = "System Log";
            ViewData["Heading"] = "System Log";

            int itemsPerPage = uiOptions.DefaultPageSize_LogView;

            if (pageSize > 0)
            {
                itemsPerPage = pageSize;
            }

            var model = new LogListViewModel();

            if (sort == "desc")
            {
                model.LogPage = await systemInfo.GetLogsDescending(pageNumber, itemsPerPage);
            }
            else
            {
                model.LogPage = await systemInfo.GetLogsAscending(pageNumber, itemsPerPage);
            }

            model.TimeZone = await timeZoneResolver.GetUserTimeZone();

            var count = await systemInfo.GetLogItemCount();

            model.Paging.CurrentPage  = pageNumber;
            model.Paging.ItemsPerPage = itemsPerPage;
            model.Paging.TotalItems   = count;

            return(View(model));
        }
Esempio n. 16
0
        public static LogListViewModel GetLogByUser(string username, int type)
        {
            Entities entities = new Entities();
            var      result   = entities.Log.Where(x => x.Username.Equals(username));

            if (type == (int)Constants.Constants.LOG_FILTER_TYPE.INCOME_EXPENSE)
            {
                result = result.Where(x => x.LogType == (int)Constants.Constants.LOG_TYPE.INCOME || x.LogType == (int)Constants.Constants.LOG_TYPE.EXPENSE);
            }
            else if (type == (int)Constants.Constants.LOG_FILTER_TYPE.OTHERS)
            {
                result = result.Where(x => x.LogType != (int)Constants.Constants.LOG_TYPE.INCOME && x.LogType != (int)Constants.Constants.LOG_TYPE.EXPENSE);
            }

            var stocks          = entities.Assets.Where(x => x.AssetType == (int)Constants.Constants.ASSET_TYPE.STOCK && !x.DisabledDate.HasValue).ToList();
            LogListViewModel rs = new LogListViewModel
            {
                Type   = type,
                List   = result.OrderBy(x => x.Date).ToList(),
                Stocks = stocks
            };

            return(rs);
        }
        // GET: Log
        public ActionResult Index(int type)
        {
            LogListViewModel model = LogQueries.GetLogByUser(UserQueries.GetCurrentUsername(), type);

            return(View(model));
        }
Esempio n. 18
0
 public LogView(LogListViewModel viewModel)
 {
     InitializeComponent();
     DataContext = ViewModel = viewModel;
 }