using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Sog; using ProtoCSStruct; namespace Mail { public static class PushSvc { public static void OnTick(long second) { TickPushCfgDescEveryDay(second); } public static long m_lastPushCfgDescTime = 0; private static void TickPushCfgDescEveryDay(long nowSecond) { //没有配置推送时间 if (MailServerUtils.GetServerConfig().pushToAll == false) { return; } //foreach (var pushCfgDesc in PushCfgDescMgr.Instance.ItemTable) //{ // //没有配置推送内容,不处理 // if (string.IsNullOrEmpty(pushCfgDesc.Value.pushContent)) // { // continue; // } // //只有这分钟有机会 // long startTime; // // 单次推送类型 // if (pushCfgDesc.Value.pushType == 1) // { // startTime = ConfigStringTimeParse.ParseConfigTime(pushCfgDesc.Value.pushTime); // } // else // { // startTime = ConfigStringTimeParse.ParseDailyConfigTime(nowSecond, pushCfgDesc.Value.pushTime); // } // long endTime = startTime + 60; // //在一个时间段内合法 // if (nowSecond > startTime && nowSecond <= endTime && m_lastPushCfgDescTime < startTime) // { // m_lastPushCfgDescTime = nowSecond; // //获取推送内容 // string strMessage = Sog.Lang.LanguageUtils.GetLanguageString(pushCfgDesc.Value.pushContent,Sog.Lang.LanguageUtils.DEFAULT_LANGUAGE); // if (pushCfgDesc.Value.pushContentParam != 0) // { // strMessage = pushCfgDesc.Value.pushContentParam.ToString() + strMessage; // } // if (pushCfgDesc.Value.pushMailToAll == 1) // { // PushMailToAllOnline(" ", strMessage); // } // TraceLog.Debug("PushSvc.TickPushCfgDescEveryDay push cfgDesc {0} mail to all at {1}", pushCfgDesc.Key, nowSecond); // break; // } //} } private static void PushMailToAllOnline(string title, string strMessage) { var uids = MailServerUtils.GetMailServerData().m_playerTable.Where(o => o.Value.IsOnline == true).Select(i => i.Key); foreach (long uid in uids) { DBMail sendMail = new DBMail(); sendMail.Uid = uid; sendMail.Title.SetString(""); sendMail.Content.SetString(strMessage); sendMail.MailType = 0; MailSendWithRule.SendMail(ref sendMail); } TraceLog.Debug("PushSvc.PushMailToAllOnline push Mail to all online"); } } }