public FiltersCollectionSource(LogsViewModel logsViewModel)
 {
     Items = new List <string> {
         "Fatal", "Error", "Warn", "Info", "Trace", "Debug"
     };
     ViewModel = logsViewModel;
 }
Beispiel #2
0
        public async Task <IActionResult> Logs()
        {
            var user = await GetCurrentUserAsync();

            var myFiles = await _dbContext
                          .UploadRecords
                          .Where(t => t.UploaderId == user.Id)
                          .OrderByDescending(t => t.UploadTime)
                          .ToListAsync();

            var myfilesOnOSS = await _ossApiService.ViewMultiFilesAsync(myFiles.Select(t => t.FileId).ToArray());

            // find all out-dated records.
            var outdatedRecords = myFiles.Where(t => myfilesOnOSS.Items.Any(p => p.FileKey == t.FileId) == false).ToList();

            if (outdatedRecords.Any())
            {
                _dbContext.UploadRecords.RemoveRange(outdatedRecords);
                await _dbContext.SaveChangesAsync();
            }
            var model = new LogsViewModel(user, 1, "File upload logs")
            {
                Files   = myfilesOnOSS.Items,
                Records = myFiles
            };

            return(View(model));
        }
        public FormsApp(IBluetoothLowEnergyAdapter adapter, IUserDialogs dialogs)
        {
            InitializeComponent();

            m_dialogs = dialogs;
            var logsVm = new LogsViewModel();

            SystemLog.Instance.AddSink(logsVm);

            var bleAssembly = adapter.GetType().GetTypeInfo().Assembly.GetName();

            Log.Info(bleAssembly.Name + "@" + bleAssembly.Version);


            var bleScanViewModel = new BleDeviceScannerViewModel(
                bleAdapter: adapter,
                dialogs: dialogs);

            m_rootPage = new NavigationPage(
                new TabbedPage
            {
                Title    = "BLE.net Sample App",
                Children = { new BleDeviceScannerPage(bleScanViewModel), new LogsPage(logsVm) }
            });

            MainPage = m_rootPage;
        }
Beispiel #4
0
        public ActionResult Logs()
        {
            LogsViewModel model = new LogsViewModel();

            model.AppLogs = _appLogSrv.GetLogsAll();
            return(View(model));
        }
        public IActionResult Log(string searchLog)
        {
            ViewData["Logs"] = DateTime.UtcNow.Date.ToString();
            DirectoryInfo d = new DirectoryInfo(_environment.WebRootPath + "//nlogs"); //Assuming Test is your Folder

            FileInfo[]    Files = d.GetFiles("*.log");                                 //Getting Text files
            string        str   = "";
            List <string> list  = new List <string>();
            List <string> list2 = new List <string>();
            Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >();

            foreach (FileInfo file in Files)
            {
                //FileStream fileStream = new FileStream("~/nlogs/" + file.Name, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                list2 = new List <string>();
                string myfile = _environment.WebRootPath + "//nlogs//" + file.Name;
                try
                {
                    using (FileStream fileStream = new FileStream(myfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        using (StreamReader streamReader = new StreamReader(fileStream))
                        {
                            while (streamReader.Peek() >= 0)
                            {
                                list2.Add(streamReader.ReadLine());
                            }
                            //allText = streamReader.ReadToEnd();
                        }
                    }
                }catch { }



                str = file.Name;
                //string path = @"~\nglogs\" + file.Name;
                //StreamReader sr = new StreamReader(GenerateStreamFromString(path));
                //var logText = "";
                //while(sr.Peek() >= 0)
                //{
                //    logText += sr.ReadLine() + '@';

                //}
                dict.Add(str, list2);
                list.Add(str);
                //list.Add(Convert.ToString(file));
            }
            if (!String.IsNullOrEmpty(searchLog))
            {
                var temp = list.Where(s => s != null);
                list = temp.Where(s => s.ToUpper().Contains(searchLog.ToUpper())).ToList();
            }
            var model = new LogsViewModel
            {
                LogFileNames = dict,
                LogFileList  = list
            };

            return(View(model));
        }
Beispiel #6
0
        public string ResetPassword(int id)
        {
            string msg  = string.Empty;
            var    user = _context.AsQueryable <User>().Where(x => x.ID == id).FirstOrDefault();

            if (user != null)
            {
                try
                {
                    user.Password = ThreeDES.Encrypt("Password1");  //DEFAULT PASSWORD: Password1
                    _context.Update <User>(user);
                    _context.SaveChanges();
                }
                catch (Exception ex)
                {
                    LogsViewModel error = new LogsViewModel()
                    {
                        ActionType   = ActionType.Error.ToString(),
                        Description  = ex.Message + "\n" + ex.StackTrace,
                        ModifiedBy   = "User Service Error : ResetPassword()",
                        DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm")
                    };
                    new LogsService().Create(error);
                    msg = "Unexpected error encountered. Please contact your system administrator.";
                }
            }

            return(msg);
        }
 private void ShowLogs(JobModel obj)
 {
     CurrentViewModel = new LogsViewModel
     {
         LogModels = new ObservableCollection <LogModel>(_logModels.Where(model => model.Id == obj.Id)),
     };
 }
Beispiel #8
0
        public void DeleteCrewBySchedule(int scheduleID, int loggedUserID)
        {
            string msg = string.Empty;

            try
            {
                //_context.ExecuteTSQL( string.Format( "{0}", scheduleID ) );
                var crews = _context.AsQueryable <ScheduleCrew>().Where(x => x.ScheduleID == scheduleID).ToList();
                if (crews.Count() > 0)
                {
                    foreach (var crew in crews)
                    {
                        this.DeleteCrew(crew.ID);
                    }
                }

                msg = "Schedule deleted.";
            }
            catch (Exception ex)
            {
                LogsViewModel error = new LogsViewModel()
                {
                    ActionType   = ActionType.Error.ToString(),
                    Description  = ex.Message + "\n" + ex.StackTrace,
                    ModifiedBy   = "Calendar Service Error : DeleteCrewBySchedule()",
                    DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm")
                };
                new LogsService().Create(error);
                msg = "Unexpected error encountered. Please contact your system administrator.";
            }
        }
        public string Delete(int id)
        {
            //NOTE: Original Logic is to delete, but we change it to just deactivate the user.
            string msg = string.Empty;

            try
            {
                Data.Entities.Destination destination = _context.AsQueryable <Data.Entities.Destination>().Where(x => x.ID == id).FirstOrDefault();
                if (destination != null)
                {
                    _context.Remove <Data.Entities.Destination>(destination);
                    _context.SaveChanges();
                    msg = "Destination deleted.";
                }
            }
            catch (Exception ex)
            {
                LogsViewModel error = new LogsViewModel()
                {
                    ActionType   = ActionType.Error.ToString(),
                    Description  = ex.Message + "\n" + ex.StackTrace,
                    ModifiedBy   = "Destination Service Error : Delete()",
                    DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm")
                };
                new LogsService().Create(error);
                msg = "Unexpected error encountered. Please contact your system administrator.";
            }
            return(msg);
        }
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="updatetime"></param>
        /// <param name="page"></param>
        /// <param name="count"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public ViewResult Index(DateTime?updatetime, int?page = 0, int?count = 10, int?index = 0)
        {
            logsRspository _ilogsRspository = new logsRspository();

            updatetime = updatetime ?? DateTime.Now;
            List <LoggerInfo> lstLog = new List <LoggerInfo>();

            lstLog = _ilogsRspository.GetLogs(page ?? 0, count ?? 0, index ?? 0).ToList();
            foreach (var item in lstLog)
            {
                switch (item.Logger)
                {
                case "InventoryPushController":
                    item.Logger = "推送库存 oms-ecnall";
                    break;

                case "InventoryController":
                    item.Logger = "推送商品档案 oms-ecnall";
                    break;

                default:
                    break;
                }
            }
            LogsViewModel model = new LogsViewModel()
            {
                page  = 0,
                count = 10,
                info  = lstLog,
                index = lstLog?[0].Id ?? 0
            };

            return(View(model));
        }
 public LogsPage()
 {
     InitializeComponent();
     BindingContext = _viewModel = new LogsViewModel();
     DataTypeLogList.HeightRequest = 4.3 * CompanyLogList.RowHeight;
     CompanyLogList.HeightRequest  = 4.3 * CompanyLogList.RowHeight;
 }
Beispiel #12
0
        public string DeleteCrew(int id)
        {
            string msg = string.Empty;

            try
            {
                ScheduleCrew crew = _context.AsQueryable <ScheduleCrew>().Where(x => x.ID == id).FirstOrDefault();
                if (crew != null)
                {
                    _context.Remove <ScheduleCrew>(crew);
                    _context.SaveChanges();
                    msg = "Crew deleted.";
                }
            }
            catch (Exception ex)
            {
                LogsViewModel error = new LogsViewModel()
                {
                    ActionType   = ActionType.Error.ToString(),
                    Description  = ex.Message + "\n" + ex.StackTrace,
                    ModifiedBy   = "Calendar Service Error : DeleteCrew()",
                    DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm")
                };
                new LogsService().Create(error);
                msg = "Unexpected error encountered. Please contact your system administrator.";
            }
            return(msg);
        }
 public async Task ShowLogs()
 {
     if (LogsViewModel != null)
     {
         await LogsViewModel.Show();
     }
 }
Beispiel #14
0
        public string Create(LogsViewModel model)
        {
            string msg = string.Empty;

            try
            {
                Logs log = new Logs()
                {
                    ActionType   = model.ActionType,
                    Description  = model.Description,
                    DateModified = DateTime.Parse(model.DateModified),
                    ModifiedBy   = model.ModifiedBy
                };
                _context.Add <Logs>(log);
                _context.SaveChanges();
                msg = "Log Created.";
            }
            catch (Exception ex)
            {
                LogsViewModel error = new LogsViewModel()
                {
                    ActionType   = ActionType.Error.ToString(),
                    Description  = ex.Message + "\n" + ex.StackTrace,
                    ModifiedBy   = "Log Service Error",
                    DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm")
                };
                this.Create(error);
                msg = "Unexpected error encountered. Please contact your system administrator.";
            }

            return(msg);
        }
        public TabbedMainViewModel(
            ExecutionContextFactory executionContextFactory,
            IEnumerable <IMainTab> mainTabs,
            IEnumerable <IInitializationStep> initializationSteps,
            ProductInformation productInformation = null,
            LogsViewModel logsViewModel           = null,
            SettingsViewModel settingsViewModel   = null)
            :
            base(executionContextFactory)
        {
            ProductInformation = productInformation;
            LogsViewModel      = logsViewModel;
            SettingsViewModel  = settingsViewModel;

            _initializationSteps = initializationSteps
                                   .OrderBy(x => x.Order)
                                   .ToList();

            List <IMainTab> tabs = mainTabs
                                   .OrderBy(x => x.Order)
                                   .ToList();

            FixedHeaderCount = tabs.Count(x => x.IsFixed);

            Items.AddRange(tabs);
            ActiveItem = Items.FirstOrDefault();

            ExecutionContext.EventAggregator.SubscribeOnPublishedThread(this);

            if (ProductInformation != null)
            {
                DisplayName = $"{ProductInformation.ProgramName} - {ProductInformation.Version}";
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            logview          = new LogsViewModel(this);
            this.DataContext = logview;
        }
Beispiel #17
0
        public async Task <IActionResult> Logs(int?id)
        {
            ViewData["routeID"] = id;
            if (id == null)
            {
                return(NotFound());
            }

            var competition = await _context.Competitions
                              .Include(c => c.CompetitionCategories)
                              .ThenInclude(c1 => c1.Challenges)
                              .Include(t => t.Teams)
                              .AsNoTracking()
                              .FirstOrDefaultAsync(m => m.ID == id);

            var teamChallenge = await _context.TeamChallenges
                                .ToListAsync();

            if (competition == null)
            {
                return(NotFound());
            }

            LogsViewModel logsViewModel = new LogsViewModel();

            logsViewModel.Competition   = competition;
            logsViewModel.TeamChallenge = teamChallenge;

            return(View(logsViewModel));
        }
        public string Update(AircraftViewModel model)
        {
            string msg = string.Empty;

            try
            {
                AircraftType aircraft = _context.AsQueryable <AircraftType>().Where(x => x.ID == model.ID).FirstOrDefault();
                bool         isExists = false;

                #region Check if new name changed
                if (aircraft.Name.Trim().ToUpper() != model.Name.Trim().ToUpper())
                {
                    int ctr = _context.AsQueryable <AircraftType>().Where(x => x.Name.Trim() == model.Name.Trim()).Count();
                    if (ctr > 0)
                    {
                        isExists = true;
                    }
                }
                #endregion

                if (isExists)
                {
                    msg = "Aircraft name already exists.";
                }
                else
                {
                    if (!string.IsNullOrEmpty(model.Name))
                    {
                        aircraft.Name = model.Name;
                    }
                    if (!string.IsNullOrEmpty(model.Description))
                    {
                        aircraft.Description = model.Description;
                    }
                    aircraft.DateModified = DateTime.Now;

                    if (aircraft != null)
                    {
                        _context.Update <AircraftType>(aircraft);
                        _context.SaveChanges();
                    }
                    msg = "Aircraft updated.";
                }
            }
            catch (Exception ex)
            {
                LogsViewModel error = new LogsViewModel()
                {
                    ActionType   = ActionType.Error.ToString(),
                    Description  = ex.Message + "\n" + ex.StackTrace,
                    ModifiedBy   = "Aircraft Service Error : Update()",
                    DateModified = DateTime.Now.ToString("MM/dd/yyyy HH:mm")
                };
                new LogsService().Create(error);
                msg = "Unexpected error encountered. Please contact your system administrator.";
                //log error
            }
            return(msg);
        }
 public LogsWidget(LogsViewModel viewModel)
 {
     this.viewModel = viewModel;
     BuildView();
     viewModel.Clients.CollectionChanged  += Clients_CollectionChanged;
     viewModel.PropertyChanged            += ViewModel_PropertyChanged;
     LogsViewModel.Logs.CollectionChanged += Logs_CollectionChanged;
 }
Beispiel #20
0
        public LogsPage()
        {
            InitializeComponent();
            BindingContext = new LogsViewModel();
            logAccess      = new LogFileAccess();

            Task.Run(async() => { await ReadLogFile(); });
        }
Beispiel #21
0
        public ActionResult Logs()
        {
            var model = new LogsViewModel();

            model.Entries = _logsRepository.GetAll().ToList();

            return(View(model));
        }
 public MainViewModelPack(
     LogsViewModel logsViewModel,
     ManageRepositoryViewModel manageRepositoryViewModel,
     ManageFilterViewModel manageFilterViewModel,
     ManageFilterBindingsViewModel manageFilterBindingsViewModel)
 {
     ManageFilterViewModel         = manageFilterViewModel;
     LogsViewModel                 = logsViewModel;
     ManageRepositoryViewModel     = manageRepositoryViewModel;
     ManageFilterBindingsViewModel = manageFilterBindingsViewModel;
 }
Beispiel #23
0
        public ListViewPage()
        {
            InitializeComponent();

            //fetching items for the listview
            vm = new LogsViewModel();
            //listLogs.ItemsSource = vm.Logs;
            BindingContext = vm;
            //Timer for auto refresh using refresh data function
            Device.StartTimer(TimeSpan.FromSeconds(15), refreshData);
        }
Beispiel #24
0
        public ActionResult Index()
        {
            var vm = new LogsViewModel()
            {
                Files         = dataFlowDbContext.Files.Where(x => x.Status != FileStatusEnum.DELETED).Include(x => x.Agent).Take(1000).OrderByDescending(x => x.CreateDate).ToList(),
                LogIngestions = dataFlowDbContext.LogIngestions.Take(1000).OrderByDescending(x => x.Date).ToList(),
                NLogs         = dataFlowDbContext.NLogs.Take(1000).OrderByDescending(x => x.Logged).ToList()
            };

            return(View(vm));
        }
        public LogsView(LogsViewModel vm)
            : base(vm)
        {
            InitializeComponent();

            vm.ScrollTo.RegisterHandler(x =>
            {
                MainGrid.ScrollIntoView(x.Input);
                x.SetOutput(Unit.Default);
            });
        }
Beispiel #26
0
        public IActionResult Logs(LogsViewModel logs)
        {
            if (ModelState.IsValid)
            {
                LogsViewModel model = _admin.GetLogsByDate(logs);
                return(View(model));
            }

            return(View(new LogsViewModel {
                Date = null, Text = "За указанную дату нет логов!"
            }));
        }
Beispiel #27
0
        public async Task <ActionResult> Index(int?pageNumber)
        {
            var results = await LogsDao.List(this, pageNumber);

            var model = new LogsViewModel
            {
                PageNumber = 0,
                Entries    = results
            };

            return(View(model));
        }
Beispiel #28
0
        public IActionResult Index()
        {
            //string date = DateTime.Now.ToString("yyyyMMdd");
            //string text = "";
            try
            {
                // string text = System.IO.File.ReadAllText(@"..\wwwroot\Logs\logs-"+date+".txt");
                // string path = Path.Combine(AppContext.BaseDirectory, "Logs");
                long          maxreturnsize = 500 * 1000 * 1024;
                LogsViewModel log           = new LogsViewModel();
                var           file          = new DirectoryInfo("Logs")
                                              .GetFiles("*")
                                              .OrderBy(f => f.Name)
                                              .LastOrDefault();
                if (file == null)
                {
                    return(StatusCode((int)HttpStatusCode.OK, ""));
                }
                using (var fs = new FileStream(file.FullName, FileMode.Open,
                                               FileAccess.Read, FileShare.ReadWrite))
                {
                    if (fs.Length > maxreturnsize)
                    {
                        fs.Position = fs.Length - maxreturnsize;
                    }
                    using (StreamReader sr = new StreamReader(fs))
                    {
                        log.Logs = sr.ReadToEnd();
                    }
                }
                //    string[] lines = System.IO.File.ReadAllLines(path + "\\logs-" + date + ".txt");

                // Display the file contents by using a foreach loop.
                // foreach (string line in lines)
                //{
                // Use a tab to indent each line of the file.
                //     text += " \r\n " + line;
                //Console.WriteLine("\t" + line);
                // }
                return(StatusCode((int)HttpStatusCode.OK, log.Logs));
                //return View(log);
            }
            catch (Exception ex)
            {
                LogsViewModel log = new LogsViewModel()
                {
                    Logs = ex.ToString()
                };
                _logger.LogError(ex, "Read log file ");
                return(StatusCode((int)HttpStatusCode.InternalServerError, log.Logs));
            }
        }
        public LogsPage(string text, int intervalInSeconds)
        {
            InitializeComponent();
            //username displayed on the logs page
            unLabel.Text = "Welcome " + text;

            //fetching items for the listview
            vm             = new LogsViewModel();
            BindingContext = vm;

            //timer for auto refresh using refresh data function
            Device.StartTimer(TimeSpan.FromSeconds(intervalInSeconds), refreshData);
        }
Beispiel #30
0
        public LogsViewModel GetData(int page = 1, string ipAddressFilter = "", string userName = "")
        {
            var model = new LogsViewModel();

            var paged = CustomDatabase.GetLogEntries(page, 50, ipAddressFilter, userName);

            model.CurrentPage  = paged.CurrentPage;
            model.TotalPages   = paged.TotalPages;
            model.TotalEntries = paged.TotalItems;
            model.Entries      = paged.Items;

            return(model);
        }