private void initPrivate(MvcContext ctx) { IAppContext context = new AppContext(); long appId = ctx.route.appId; context.Id = appId; // ID Type appType = ctx.controller.utils.getAppType(); if (appType == null) { ctx.utils.setAppContext(context); return; } if (appId <= 0) { context.setAppType(appType); ctx.utils.setAppContext(context); return; } IApp app = getAppById(appType, appId, ctx.owner.obj); if (app == null) { if (appId == 1) { context.setAppType(appType); ctx.utils.setAppContext(context); return; } else { ctx.utils.setAppContext(context); ctx.utils.endMsg(lang.get("exAppNotFound") + ": appType=" + appType, HttpStatus.NotFound_404); } } else { context.obj = app; // objApp context.setAppType(app.GetType()); // type ctx.utils.setAppContext(context); IAppStats stats = app as IAppStats; if (stats != null) { refreshStats(stats); } } }
private static void refreshStats( IAppStats app ) { if (DateTime.Now.Subtract( app.TodayTime ).Days > 0) { int num = app.TodayTopicCount + app.TodayPostCount; if (num > app.PeakPostCount) { app.PeakPostCount = num; } app.TodayPostCount = 0; app.TodayTopicCount = 0; app.TodayVisitCount = 0; app.TodayTime = DateTime.Now; db.update( app ); } }
private static void refreshStats(IAppStats app) { if (DateTime.Now.Subtract(app.TodayTime).Days > 0) { int num = app.TodayTopicCount + app.TodayPostCount; if (num > app.PeakPostCount) { app.PeakPostCount = num; } app.TodayPostCount = 0; app.TodayTopicCount = 0; app.TodayVisitCount = 0; app.TodayTime = DateTime.Now; db.update(app); } }