NoticeDataManager.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using ET;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using cfg.GfgCfg;
  5. namespace GFGGame
  6. {
  7. public class NoticeInfo
  8. {
  9. public int noticeId;
  10. public string title;
  11. public long time;//时间戳,单位秒
  12. public string content = "";
  13. public bool readStatus;//对应的读取状态,true为已读
  14. }
  15. public class NoticeDataManager : SingletonBase<NoticeDataManager>
  16. {
  17. private NoticeInfo _lastNoticeInfo;
  18. public NoticeInfo LastNoticeInfo
  19. {
  20. get
  21. {
  22. return _lastNoticeInfo;
  23. }
  24. set
  25. {
  26. _lastNoticeInfo = value;
  27. }
  28. }
  29. private List<NoticeInfo> _noticeInfos = new List<NoticeInfo>();
  30. public List<NoticeInfo> NoticeInfos
  31. {
  32. get
  33. {
  34. return _noticeInfos;
  35. }
  36. }
  37. private Dictionary<int, NoticeInfo> _noticeInfoDic = new Dictionary<int, NoticeInfo>();
  38. public void UpdateNoticeIdList(NoticeInfo noticeInfo)
  39. {
  40. if (!_noticeInfoDic.ContainsKey(noticeInfo.noticeId))
  41. {
  42. _noticeInfoDic.Add(noticeInfo.noticeId, noticeInfo);
  43. }
  44. else
  45. {
  46. _noticeInfoDic[noticeInfo.noticeId] = noticeInfo;
  47. }
  48. NoticeDicToList();
  49. }
  50. public void UpdateNoticeContent(int noticeId, string content)
  51. {
  52. _noticeInfoDic[noticeId].content = content;
  53. _noticeInfoDic[noticeId].readStatus = true;
  54. NoticeDicToList();
  55. }
  56. public void UpdateSystemNoticeRemove(int noticeId)
  57. {
  58. if (_noticeInfoDic.ContainsKey(noticeId)) _noticeInfoDic.Remove(noticeId);
  59. NoticeDicToList();
  60. }
  61. private void NoticeDicToList()
  62. {
  63. _noticeInfos = _noticeInfoDic.Values.ToList();
  64. _noticeInfos.Sort((NoticeInfo a, NoticeInfo b) =>
  65. {
  66. return b.noticeId.CompareTo(a.noticeId);
  67. });
  68. }
  69. public NoticeInfo GetNoticeInfoById(int noticeId)
  70. {
  71. return _noticeInfoDic[noticeId];
  72. }
  73. public List<AdCfg> UpdateShowActivity()
  74. {
  75. List<AdCfg> activitydata = CommonDataManager.Tables.TblAdCfg.DataList;
  76. List<AdCfg> showActivity = new List<AdCfg>();
  77. for (int i = 0; i < activitydata.Count; i++)
  78. {
  79. AdCfg adCfg = activitydata[i];
  80. if (adCfg.ActivityId > 0)
  81. {
  82. if (ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.ActivityId) == null) continue;
  83. ActivityInfo activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.ActivityId);
  84. if (TimeHelper.ServerNow() < activityInfo.StartTime || TimeHelper.ServerNow() > activityInfo.EndTime) continue;
  85. }
  86. if (adCfg.NoticeTips != null && adCfg.NoticeTips != "")
  87. {
  88. if (adCfg.ActivityId != 0)
  89. {
  90. ActivityInfo activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.ActivityId);
  91. if (TimeHelper.ServerNow() < activityInfo.StartTime || TimeHelper.ServerNow() > activityInfo.EndTime)
  92. {
  93. }
  94. else
  95. {
  96. showActivity.Add(adCfg);
  97. continue;
  98. }
  99. }
  100. if (adCfg.StartTime != "" && adCfg.StartTime != null)
  101. {
  102. long startTime = TimeUtil.DateTimeToTimestamp(adCfg.StartTime);
  103. long endTime = TimeUtil.DateTimeToTimestamp(adCfg.EndTime);
  104. if (TimeHelper.ServerNow() < startTime || TimeHelper.ServerNow() > endTime)
  105. {
  106. continue;
  107. }
  108. else
  109. {
  110. showActivity.Add(adCfg);
  111. }
  112. }
  113. }
  114. }
  115. return showActivity;
  116. }
  117. public bool GetRedDotState(string jumpId, int activityID)
  118. {
  119. switch (jumpId)
  120. {
  121. case "DailySignView":
  122. return RedDotDataManager.Instance.GetActivityDay7Red();
  123. case "LuckyBoxView":
  124. return RedDotDataManager.Instance.GetActLuckyBoxRewardRed(ConstLimitTimeActivityType.ActLimitTsy) || RedDotDataManager.Instance.GetLuckyBoxFreeTimes();
  125. case "NewLimitChargeView":
  126. return RedDotDataManager.Instance.GetLimiteChargeRewardRed(activityID);
  127. case "OpenServerActivityView":
  128. return RedDotDataManager.Instance.GetOpenServerRed();
  129. }
  130. return false;
  131. }
  132. }
  133. }