Commit 56a8a829 authored by 黄奎's avatar 黄奎

缓存修改

parent 26422b2a
using Edu.Common.Plugin;
using Edu.CacheManager.Base;
using Edu.Common.Plugin;
using Edu.Module.Course;
using Edu.Module.Customer;
using Edu.Module.Duty;
......@@ -40,6 +41,13 @@ namespace Edu.WebApi.Timers
/// </summary>
private static readonly PaperModule paperModule = new PaperModule();
/// <summary>
/// 使用redis第几号库
/// </summary>
static readonly int REDIS_DB3 = 3;
static readonly RedisHelper redis = new RedisHelper(REDIS_DB3);
/// <summary>
/// 课程顾问部和市场部数据统计
/// </summary>
......@@ -87,7 +95,7 @@ namespace Edu.WebApi.Timers
timer4 = new System.Timers.Timer()
{
Interval = (1000 * 60) * (1 * 10 ) //10分中执行一次
Interval = (1000 * 60) * (1 * 10) //10分中执行一次
};
timer4.Elapsed += new System.Timers.ElapsedEventHandler(UpdateAuditThroughStudent);
timer4.Enabled = true;
......@@ -113,9 +121,9 @@ namespace Edu.WebApi.Timers
finishGuest.Elapsed += new System.Timers.ElapsedEventHandler(DealGuestFinish);
finishGuest.Enabled = true;
marketTimer= new System.Timers.Timer()
marketTimer = new System.Timers.Timer()
{
Interval = (1000) * (1) //1秒检测一次 00:30:00 每天执行一次
Interval = (1000 * 60) * (1) //1小时检查一次
};
marketTimer.Elapsed += new System.Timers.ElapsedEventHandler(DealMarketConsultantData);
marketTimer.Enabled = true;
......@@ -146,6 +154,7 @@ namespace Edu.WebApi.Timers
private static int marketconsultant_Timer = 0;
private static string createMarkDataKey = "createMarkDataKey";
/// <summary>
/// 定时生成市场部和课程顾问部数据统计
/// </summary>
......@@ -153,20 +162,20 @@ namespace Edu.WebApi.Timers
/// <param name="e"></param>
public static void DealMarketConsultantData(object sender, System.Timers.ElapsedEventArgs e)
{
if (Interlocked.Exchange(ref marketconsultant_Timer, 1) == 0)
if (Interlocked.Exchange(ref marketconsultant_Timer,1) == 0)
{
int intHour = e.SignalTime.Hour;
int intMinute = e.SignalTime.Minute;
int intSecond = e.SignalTime.Second;
// 定制时间;比如 在00:30:00 的时候执行某个函数
int iHour = 00;
int iMinute = 30;
int iSecond = 00;
// 设置每天的
if (intHour == iHour && intMinute == iMinute && intSecond == iSecond)
var currentDate = DateTime.Now;
string cacheData = redis.Get(createMarkDataKey);
if (string.IsNullOrEmpty(cacheData))
{
redis.Set(createMarkDataKey, Common.ConvertHelper.FormatDate(currentDate));
cacheData = Common.ConvertHelper.FormatDate(currentDate);
}
if (!string.IsNullOrEmpty(cacheData) && cacheData != Common.ConvertHelper.FormatDate(currentDate))
{
marketConsultantModule.CreateConsultantDataModule(DateTime.Now);
marketConsultantModule.CreateMarketDataModule(DateTime.Now);
redis.Set(createMarkDataKey, Common.ConvertHelper.FormatDate(currentDate));
marketConsultantModule.CreateConsultantDataModule(currentDate);
marketConsultantModule.CreateMarketDataModule(currentDate);
}
Interlocked.Exchange(ref marketconsultant_Timer, 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment