using BPASmartClient.Helper; using System; using System.Collections.Generic; using System.Linq; using System.Collections.ObjectModel; using System.Text; using System.Threading.Tasks; using System.Windows; namespace BPASmartClient.CustomResource.Pages.Model { public class MessageLog { private volatile static MessageLog _Instance; public static MessageLog GetInstance => _Instance ?? (_Instance = new MessageLog()); private MessageLog() { } public Action UserLog { get; set; } public Action RunLog { get; set; } public ObservableCollection runLogs { get; set; } = new ObservableCollection(); public ObservableCollection userLogs { get; set; } = new ObservableCollection(); public void LogSave() { Sqlite.GetInstance.Save(); Sqlite.GetInstance.Save(); } //public void GetLog() //{ // Sqlite.GetInstance.GetData(); // Sqlite.GetInstance.GetData(); //} public void ShowUserLog(string info) { UserLog userLog = new UserLog() { Date = DateTime.Now.ToString("yyyy-MM-dd"), Time = DateTime.Now.ToString("HH:mm:ss"), Permission = Global.userInfo.permission.ToString(), UserName = Global.userInfo.UserName, LogInfo = info }; Sqlite.GetInstance.Base.Add(userLog); Application.Current.Dispatcher.Invoke(new Action(() => { userLogs.Insert(0, userLog); })); UserLog?.Invoke(info); } public void ShowRunLog(string info) { RunLog runLog = new RunLog() { Date = DateTime.Now.ToString("yyyy-MM-dd"), Time = DateTime.Now.ToString("HH:mm:ss"), RunLogInfo = info }; Sqlite.GetInstance.Base.Add(runLog); Application.Current.Dispatcher.Invoke(new Action(() => { runLogs.Insert(0, runLog); })); RunLog?.Invoke(info); } } }