基于NopCommerce的开发框架——缓存、网站设置、系统日志、用户操作日志
2021-04-14 13:26
标签:blog sass core 了解 framework evel ast 映射 rap 基于NopCommerce的开发框架——缓存、网站设置、系统日志、用户操作日志 标签:blog sass core 了解 framework evel ast 映射 rap 原文地址:https://www.cnblogs.com/Alex80/p/12375212.html 一、缓存模块
//cache managers
if (config != null && config.RedisCachingEnabled)
{
builder.RegisterType
protected virtual IList GetAllActivityTypesCached()
{
//cache
string key = string.Format(ACTIVITYTYPE_ALL_KEY);
return _cacheManager.Get(key, () =>
{
var result = new List();
var activityLogTypes = GetAllActivityTypes();
foreach (var alt in activityLogTypes)
{
var altForCaching = new ActivityLogTypeForCaching
{
Id = alt.Id,
SystemKeyword = alt.SystemKeyword,
Name = alt.Name,
Enabled = alt.Enabled
};
result.Add(altForCaching);
}
return result;
});
}
二、设置模块
public class SettingsSource : IRegistrationSource
{
static readonly MethodInfo BuildMethod = typeof(SettingsSource).GetMethod(
"BuildRegistration",
BindingFlags.Static | BindingFlags.NonPublic);
public IEnumerable
public class CommonSettings : ISettings
{
public CommonSettings()
{
IgnoreLogWordlist = new List
public class HomeController : Controller
{
public ILogger _logger;
public IUserActivityService _userActivityService;
public CommonSettings _commonSettings;
public HomeController(
ILogger logger,
IUserActivityService userActivityService,
CommonSettings commonSetting)
{
_logger = logger;
_userActivityService = userActivityService;
_commonSettings = commonSettings;
}
public ActionResult Index()
{
TestSettings();
TestLogger();
return View();
}
private void TestSettings()
{
var s = _commonSettings.IgnoreLogWordlist;
}
private void TestLogger()
{
_logger.InsertLog(LogLevel.Information, "index visit");
_userActivityService.InsertActivity(ActivityLogTypeEnum.AddUser, "添加用户{0},{1}", new string[2] { "aaaa", "bbb" });
}
}
DataProvider: sqlserver
DataConnectionString: Data Source=.;Initial Catalog=nopFramework;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=sa1234
三、日志模块
private void TestLogger()
{
_logger.InsertLog(LogLevel.Information, "index visit");
_userActivityService.InsertActivity(ActivityLogTypeEnum.AddUser, "添加用户{0},{1}", new string[2] { "aaaa", "bbb" });
}
上一篇:Netty——知识点总结
下一篇:Web报文压缩方法
文章标题:基于NopCommerce的开发框架——缓存、网站设置、系统日志、用户操作日志
文章链接:http://soscw.com/essay/75679.html