From a0ede150686a218c92b901b1f20aef12a9913890 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期五, 14 九月 2018 09:36:59 +0800
Subject: [PATCH] 1930【1.0.15】【主干】功能预告跳转八卦炉激活,功能预告界面未关闭

---
 System/SystemSetting/SetPrivateModel.cs | 1138 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 578 insertions(+), 560 deletions(-)

diff --git a/System/SystemSetting/SetPrivateModel.cs b/System/SystemSetting/SetPrivateModel.cs
index 07fafc4..5fae90a 100644
--- a/System/SystemSetting/SetPrivateModel.cs
+++ b/System/SystemSetting/SetPrivateModel.cs
@@ -1,560 +1,578 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using TableConfig;
-using LitJson;
-
-namespace Snxxz.UI
-{
-    public class SetPrivateModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
-    {
-        DailyQuestModel m_dailyModel;
-        DailyQuestModel dailyModel
-        {
-            get { return m_dailyModel ?? (m_dailyModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); }
-        }
-        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
-
-        public List<int> hangUpPushlist = new List<int>();
-        public event Action RefreshFreeTimeAct;
-        public Dictionary<int, List<string>> pushAtcivityKeyDict = new Dictionary<int, List<string>>();
-        public const string VIPEXPERIENCERECORD = "VipExperienceRecord";
-        public override void Init()
-        {
-            hangUpPushlist.Clear();
-            hangUpPushlist.Add((int)PushNotifyType.FreeTime);
-            hangUpPushlist.Add((int)PushNotifyType.BossRefresh);
-            hangUpPushlist.Add((int)PushNotifyType.PrivateChat);
-            hangUpPushlist.Add((int)PushNotifyType.TJDead);
-            hangUpPushlist.Add((int)PushNotifyType.TJWGTimeNoEnough);
-         
-        }
-
-        public void OnBeforePlayerDataInitialize()
-        {
-
-        }
-        public void OnAfterPlayerDataInitialize()
-        {
-
-        }
-
-        public void OnPlayerLoginOk()
-        {
-            SetActivityPushKey();
-            InitPushNotifyStr();
-            SetActivityPush();
-            LocalSave.SetBool(VIPEXPERIENCERECORD, vipModel.IsVipExperience());
-            vipModel.OnVipTimeEvent -= SetVipPushNotifyByVipExperience;
-            vipModel.OnVipTimeEvent += SetVipPushNotifyByVipExperience;
-            GlobalTimeEvent.Instance.minuteEvent -= RefreshDailyQuest;
-            GlobalTimeEvent.Instance.minuteEvent += RefreshDailyQuest;
-        }
-
-        public override void UnInit()
-        {
-          
-        }
-
-        public void SetActivityPushKey()
-        {
-            pushAtcivityKeyDict.Clear();
-            List<int> dailyIdlist = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
-            for (int i = 0; i < dailyIdlist.Count; i++)
-            {
-                List<string> keylist = new List<string>();
-                pushAtcivityKeyDict.Add(dailyIdlist[i], keylist);
-                SetPushKeylist(dailyIdlist[i], keylist);
-            }
-        }
-
-        private void SetPushKeylist(int dailyId, List<string> keylist)
-        {
-            DailyQuestOpenTime dailyQuestOpenTime;
-            dailyModel.TryGetOpenTime(dailyId, out dailyQuestOpenTime);
-            foreach (var weekday in dailyQuestOpenTime.openTimes.Keys)
-            {
-                List<HourMinute> hourMinutelist = dailyQuestOpenTime.openTimes[weekday];
-                for (int i = 0; i < hourMinutelist.Count; i++)
-                {
-                    string key = StringUtility.Contact(dailyId,weekday,hourMinutelist[i].hourBegin);
-                    keylist.Add(key);
-                }
-            }
-        }
-
-        #region 澶勭悊鏈嶅姟鍣ㄦ暟鎹�
-        public Dictionary<int, bool> pushSetDict = new Dictionary<int, bool>();
-        public int startHour { get; set; }
-        public int startMinute { get; set; }
-        public int endHour { get; set; }
-        public int endMinute { get; set; }
-
-        public void SetServerPushModel(HB202_tagMCPushNotificationsSetting setting)
-        {
-            pushSetDict.Clear();
-            int switchBtnLength = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit).Count + hangUpPushlist.Count;
-            for (int i = 0; i < switchBtnLength; i++)
-            {
-                bool isOpen = MathUtility.GetBitValue(setting.OnoffBit, (ushort)i);
-                DesignDebug.Log("SetServerPushModel:" + i + "bool:" + isOpen);
-                pushSetDict.Add(i, isOpen);
-            }
-            AnalysisFreeTime(setting.TimeStr);
-        }
-
-        private void AnalysisFreeTime(string timeStr)
-        {
-            string[] timeArray = timeStr.Split('-');
-            for (int i = 0; i < timeArray.Length; i++)
-            {
-                string[] hourAndMinute = timeArray[i].Split(':');
-                if (i == 0)
-                {
-                    startHour = int.Parse(hourAndMinute[0]);
-                    startMinute = int.Parse(hourAndMinute[1]);
-                }
-                else if (i == 1)
-                {
-                    endHour = int.Parse(hourAndMinute[0]);
-                    endMinute = int.Parse(hourAndMinute[1]);
-                }
-            }
-        }
-
-        private string GetContactFreeTime()
-        {
-            return StringUtility.Contact(startHour.ToString("D2"), ":", startMinute.ToString("D2"), "-", endHour.ToString("D2"), ":", endMinute.ToString("D2"));
-        }
-
-        public void SendPushNotifyQuest(int pushSet)
-        {
-            string freeTimeStr = GetContactFreeTime();
-            CB205_tagCMPushNotificationsSetting setting = new CB205_tagCMPushNotificationsSetting();
-            setting.OnoffBit = (uint)pushSet;
-            setting.TimeLen = (byte)freeTimeStr.Length;
-            setting.TimeStr = freeTimeStr;
-            GameNetSystem.Instance.SendInfo(setting);
-        }
-
-        public void SetActivityPush()
-        {
-            List<int> dailyIdlist = GetOpenDailyIdlist(true);
-            for (int i = 0; i < dailyIdlist.Count; i++)
-            {
-                bool isOpen = GetSwitchStateByIndex(GetSwitchIndexById(dailyIdlist[i]));
-                if (isOpen)
-                {
-                    List<JsonData> pushNotifylist = GetPushJsonData(dailyIdlist[i]);
-                    for (int j = 0; j < pushNotifylist.Count; j++)
-                    {
-                        SDKUtility.Instance.GeTui_SendLocalMessage(pushNotifylist[j]);
-                    }
-                }
-            }
-        }
-
-        public void RemoveActivityPush(int dailyId)
-        {
-            List<string> keylist = pushAtcivityKeyDict[dailyId];
-            for (int i = 0; i < keylist.Count; i++)
-            {
-                SDKUtility.Instance.GeTui_RemoveLocalMessage(keylist[i]);
-            }
-        }
-
-        public void AddActivityPush(int dailyId)
-        {
-            var config = ConfigManager.Instance.GetTemplate<DailyQuestConfig>(dailyId);
-            if (config == null || !FuncOpen.Instance.IsFuncOpen(config.UnLockFuncID)) return;
-
-            List<JsonData> pushNotifylist = GetPushJsonData(dailyId);
-            for (int j = 0; j < pushNotifylist.Count; j++)
-            {
-                SDKUtility.Instance.GeTui_SendLocalMessage(pushNotifylist[j]);
-            }
-        }
-
-        public List<JsonData> GetPushJsonData(int dailyId)
-        {
-            var config = ConfigManager.Instance.GetTemplate<DailyQuestConfig>(dailyId);
-            string content = Language.Get("SetUpPrivate102", UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName).TrimEnd(), config.Title);
-            List<JsonData> pushNotifylist = new List<JsonData>();
-            List<string> pushKeylist = null;
-            List<int> pushNotifyTimelist = GetPushNotifyTime(dailyId,out pushKeylist);
-            for (int i = 0; i < pushNotifyTimelist.Count; i++)
-            {
-                if(i < pushKeylist.Count)
-                {
-                    JsonData _params = new JsonData();
-                    _params["code"] = 2005;
-                    _params["id"] = pushKeylist[i];// id 閲嶈, 鏍囩ず姣忎釜閫氱煡鐨勬洿鏂版垨鑰呯Щ闄�
-                    _params["title"] = Language.Get("SetUpPrivate103");// 鎺ㄩ�佹爣棰�
-                    _params["subtitle"] = "";// 鍓爣棰�
-                    _params["content"] = content;// 鍏蜂綋鍐呭
-                    _params["badge"] = -1;// 瑙掓爣
-
-                    // 浠ヤ笅涓哄喅瀹氬簲璇ュ涔呭悗寮瑰嚭姝ら�氱煡
-                    System.TimeSpan ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
-                    long ret = System.Convert.ToInt64(ts.TotalSeconds) + pushNotifyTimelist[i];// 琛ㄧず3绉掑悗
-                    _params["fireTime"] = ret;
-                    pushNotifylist.Add(_params);
-                }
-            }
-
-            return pushNotifylist;
-        }
-
-        private List<int> GetPushNotifyTime(int dailyId,out List<string> pushKey)
-        {
-            List<int> pushDelaySecond = new List<int>();
-            pushKey = new List<string>();
-            DailyQuestOpenTime dailyQuestOpenTime;
-            dailyModel.TryGetOpenTime(dailyId, out dailyQuestOpenTime);
-            foreach (var weekday in dailyQuestOpenTime.openTimes.Keys)
-            {
-                int day = weekday > 0 ? weekday : 7;
-                int curDay = (int)TimeUtility.ServerNow.DayOfWeek > 0 ? (int)TimeUtility.ServerNow.DayOfWeek : 7;
-                List <HourMinute> hourMinutelist = dailyQuestOpenTime.openTimes[weekday];
-                int remainDay = day - curDay;
-                if (remainDay < 0)
-                {
-                    remainDay = 7 + remainDay;
-                }
-                for (int i = 0; i < hourMinutelist.Count; i++)
-                {
-                    int remainHour = hourMinutelist[i].hourBegin - TimeUtility.ServerNow.Hour;
-                    int remainMinute = hourMinutelist[i].minuteBegin - TimeUtility.ServerNow.Minute;
-                    if(remainDay <= 0)
-                    {
-                        if (remainHour < 0)
-                        {
-                            remainDay = 7;
-                        }
-                        else if (remainHour == 0 && remainMinute < 0)
-                        {
-                            remainDay = 7;
-                        }
-                    }
-                    int remainSecond = remainDay * 24 * 60 * 60 + remainHour * 60 * 60 + remainMinute * 60;
-                    if (remainSecond > 120)
-                    {
-                        string key = StringUtility.Contact(dailyId,weekday,hourMinutelist[i].hourBegin);
-                        pushKey.Add(key);
-                        pushDelaySecond.Add(remainSecond);
-                    }
-                }
-            }
-            return pushDelaySecond;
-        }
-
-        #endregion
-
-        StringBuilder pushSB = new StringBuilder();
-        public void InitPushNotifyStr()
-        {
-            int playerLv = PlayerDatas.Instance.baseData.LV;
-            if (playerLv > 1)
-                return;
-
-            pushSB.Length = 0;
-            List<int> indexlist = pushSetDict.Keys.ToList();
-            for (int i = indexlist.Count - 1; i > -1; i--)
-            {
-                if (i < hangUpPushlist.Count)
-                {
-                    if (vipModel.IsVipActive() || vipModel.IsVipExperience())
-                    {
-                        pushSetDict[indexlist[i]] = true;
-                    }
-                    else
-                    {
-                        pushSetDict[indexlist[i]] = false;
-                    }
-                }
-                else
-                {
-                    pushSetDict[indexlist[i]] = true;
-                }
-
-                if (pushSetDict[indexlist[i]])
-                {
-                    pushSB.Append("1");
-                }
-                else
-                {
-                    pushSB.Append("0");
-                }
-            }
-
-            int pushSet = Convert.ToInt32(pushSB.ToString(),2);
-            SendPushNotifyQuest(pushSet);
-        }
-
-        public void SetVipPushNotify(int vipLv)
-        {
-            pushSB.Length = 0;
-            List<int> indexlist = pushSetDict.Keys.ToList();
-            for (int i = indexlist.Count - 1; i > -1; i--)
-            {
-                if (i < hangUpPushlist.Count)
-                {
-                    if (vipLv > 0 
-                        && !vipModel.IsVipExperience())
-                    {
-                        pushSetDict[indexlist[i]] = true;
-                    }
-                    else if(vipLv < 1
-                        && !vipModel.IsVipExperience())
-                    {
-                        pushSetDict[indexlist[i]] = false;
-                    }
-                }
-
-                if (pushSetDict[indexlist[i]])
-                {
-                    pushSB.Append("1");
-                }
-                else
-                {
-                    pushSB.Append("0");
-                }
-            }
-            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
-            SendPushNotifyQuest(pushSet);
-        }
-
-        public void SetVipPushNotifyByVipExperience()
-        {
-            bool recordVipExper = LocalSave.GetBool(VIPEXPERIENCERECORD);
-            pushSB.Length = 0;
-            List<int> indexlist = pushSetDict.Keys.ToList();
-            for (int i = indexlist.Count - 1; i > -1; i--)
-            {
-                if (i < hangUpPushlist.Count)
-                {
-                    if (vipModel.IsVipExperience()
-                        && !recordVipExper
-                        && PlayerDatas.Instance.baseData.VIPLv < 1)
-                    {
-                        pushSetDict[indexlist[i]] = true;
-                    }
-                    else if(!vipModel.IsVipExperience() 
-                        && PlayerDatas.Instance.baseData.VIPLv < 1)
-                    {
-                        pushSetDict[indexlist[i]] = false;
-                    }
-                }
-
-                if (pushSetDict[indexlist[i]])
-                {
-                    pushSB.Append("1");
-                }
-                else
-                {
-                    pushSB.Append("0");
-                }
-            }
-            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
-            SendPushNotifyQuest(pushSet);
-            LocalSave.SetBool(VIPEXPERIENCERECORD,vipModel.IsVipExperience());
-        }
-
-        public void RefreshPushSet(int switchIndex, bool isOpen)
-        {
-            pushSB.Length = 0;
-            List<int> indexlist = pushSetDict.Keys.ToList();
-            for (int i = indexlist.Count - 1; i > -1; i--)
-            {
-                if (indexlist[i] == switchIndex)
-                {
-                    pushSetDict[indexlist[i]] = isOpen;
-                }
-                if (pushSetDict[indexlist[i]])
-                {
-                    pushSB.Append("1");
-                }
-                else
-                {
-                    pushSB.Append("0");
-                }
-            }
-            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
-            SendPushNotifyQuest(pushSet);
-        }
-
-        List<int> openDailylist = new List<int>();
-        public List<int> GetOpenDailyIdlist(bool isFunclimit = false)
-        {
-            openDailylist.Clear();
-            var quests = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
-            for (int i = 0; i < quests.Count; i++)
-            {
-                DailyQuestOpenTime dailyQuestOpenTime;
-                dailyModel.TryGetOpenTime(quests[i], out dailyQuestOpenTime);
-                var config = ConfigManager.Instance.GetTemplate<DailyQuestConfig>(quests[i]);
-                if(isFunclimit)
-                {
-                    if (dailyQuestOpenTime.IsValidServerOpenTime() && FuncOpen.Instance.IsFuncOpen(config.UnLockFuncID))
-                    {
-                        openDailylist.Add(quests[i]);
-                    }
-                }
-                else
-                {
-                    if (dailyQuestOpenTime.IsValidServerOpenTime())
-                    {
-                        openDailylist.Add(quests[i]);
-                    }
-                }
-
-            }
-            return openDailylist;
-        }
-
-        public bool GetSwitchStateByIndex(int index)
-        {
-            if (pushSetDict.ContainsKey(index))
-            {
-                return pushSetDict[index];
-            }
-            return false;
-        }
-
-        public void GetDailyInfoById(int id, out string title, out string week, out string time)
-        {
-            var config = ConfigManager.Instance.GetTemplate<DailyQuestConfig>(id);
-            DailyQuestOpenTime dailyQuestOpenTime;
-            dailyModel.TryGetOpenTime(id, out dailyQuestOpenTime);
-            week = dailyQuestOpenTime.ToOpenTimeString();
-            title = config.Title;
-            time = "";
-            foreach (var weekday in dailyQuestOpenTime.openTimes.Keys)
-            {
-                List<HourMinute> hourMinutelist = dailyQuestOpenTime.openTimes[weekday];
-                time = StringUtility.Contact(hourMinutelist[0].hourBegin > 9 ? hourMinutelist[0].hourBegin.ToString() : "0" + hourMinutelist[0].hourBegin, ":", hourMinutelist[0].minuteBegin > 9 ? hourMinutelist[0].minuteBegin.ToString() : "0" + hourMinutelist[0].minuteBegin);
-                break;
-            }
-        }
-
-        public int GetSwitchIndexById(int id)
-        {
-            var quests = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
-            for (int i = 0; i < quests.Count; i++)
-            {
-                if (quests[i] == id)
-                {
-                    return i + hangUpPushlist.Count;
-                }
-            }
-            return -1;
-        }
-
-        /// <summary>
-        /// type 1 寮�濮嬫椂闂� 2 缁撴潫鏃堕棿
-        /// </summary>
-        /// <param name="type"></param>
-        public void SetRefreshFreeTimeEvent(int type, int hour, int minute)
-        {
-            switch (type)
-            {
-                case 1:
-                    startHour = hour;
-                    startMinute = minute;
-                    break;
-                case 2:
-                    endHour = hour;
-                    endMinute = minute;
-                    break;
-            }
-            pushSB.Length = 0;
-            List<int> indexlist = pushSetDict.Keys.ToList();
-            for(int i = indexlist.Count - 1; i > -1; i--)
-            {
-                if (pushSetDict[indexlist[i]])
-                {
-                    pushSB.Append("1");
-                }
-                else
-                {
-                    pushSB.Append("0");
-                }
-            }
-            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
-            SendPushNotifyQuest(pushSet);
-            if (RefreshFreeTimeAct != null)
-            {
-                RefreshFreeTimeAct();
-            }
-        }
-
-
-        private void RefreshDailyQuest()
-        {
-            foreach (var dailyQuest in dailyModel.GetDailyQuestlist().Values)
-            {
-                var isUnLocked = TestDailyQuestUnLock(dailyQuest.id);
-                if (isUnLocked)
-                {
-                    ModelCenter.Instance.GetModel<SetPrivateModel>().CheckActivityOpenTime(dailyQuest.id);
-                }
-            }
-        }
-        public bool TestDailyQuestUnLock(int _dailyQuestId)
-        {
-            switch ((DailyQuestType)_dailyQuestId)
-            {
-                case DailyQuestType.FairyLeague:
-                case DailyQuestType.FairyFeast:
-                case DailyQuestType.FairyTask:
-                    var _dailyConfig = ConfigManager.Instance.GetTemplate<DailyQuestConfig>(_dailyQuestId);
-                    return PlayerDatas.Instance.baseData.Family > 0 &&
-                        (_dailyConfig.UnLockFuncID == 0 || FuncOpen.Instance.IsFuncOpen(_dailyConfig.UnLockFuncID));
-                case DailyQuestType.RuneTowerSweep:
-                    return ModelCenter.Instance.GetModel<RuneTowerModel>().yesterdayPassFloor > 0;
-                default:
-                    var dailyConfig = ConfigManager.Instance.GetTemplate<DailyQuestConfig>(_dailyQuestId);
-                    return dailyConfig.UnLockFuncID == 0 || FuncOpen.Instance.IsFuncOpen(dailyConfig.UnLockFuncID);
-            }
-        }
-
-
-        public void CheckActivityOpenTime(int dailyId)
-        {
-            bool isOpen = GetSwitchStateByIndex(GetSwitchIndexById(dailyId));
-            if (!isOpen)
-                return;
-
-            DailyQuestOpenTime openTime;
-            dailyModel.TryGetOpenTime(dailyId, out openTime);
-            var dayOfWeek = (int)TimeUtility.ServerNow.DayOfWeek;
-            if (openTime.openTimes.ContainsKey(dayOfWeek))
-            {
-                var hourMinutes = openTime.openTimes[dayOfWeek];
-                for (int i = 0; i < hourMinutes.Count; i++)
-                {
-                    var minutes = TimeUtility.ServerNow.Hour * 60 + TimeUtility.ServerNow.Minute;
-                    float minuteOffset = (hourMinutes[i].hourBegin * 60 + hourMinutes[i].minuteBegin) - minutes;
-                    if (minuteOffset <= 2 && minuteOffset > 0)
-                    {
-                        RemoveActivityPush(dailyId);
-                    }
-                    else if (minuteOffset < 0 && minuteOffset >= -2)
-                    {
-                        AddActivityPush(dailyId);
-                    }
-                }
-            }
-        }
-
-        public enum PushNotifyType
-        {
-            FreeTime = 0, //鍏嶆墦鎵版椂闂村紑鍏�
-            BossRefresh = 1, //鍏虫敞BOSS
-            PrivateChat = 2,  //绉佽亰
-            TJDead = 3,  //鑴辨満姝讳骸
-            TJWGTimeNoEnough, //鑴辨満澶栨寕鏃堕棿涓嶈冻
-        }
-    }
-}
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using TableConfig;
+using LitJson;
+
+namespace Snxxz.UI
+{
+    public class SetPrivateModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
+    {
+        DailyQuestModel m_dailyModel;
+        DailyQuestModel dailyModel
+        {
+            get { return m_dailyModel ?? (m_dailyModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); }
+        }
+        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
+
+        public List<int> hangUpPushlist = new List<int>();
+        public event Action RefreshFreeTimeAct;
+        public Dictionary<int, List<string>> pushAtcivityKeyDict = new Dictionary<int, List<string>>();
+        public const string VIPEXPERIENCERECORD = "VipExperienceRecord";
+        public override void Init()
+        {
+            hangUpPushlist.Clear();
+            hangUpPushlist.Add((int)PushNotifyType.FreeTime);
+            hangUpPushlist.Add((int)PushNotifyType.BossRefresh);
+            hangUpPushlist.Add((int)PushNotifyType.PrivateChat);
+            hangUpPushlist.Add((int)PushNotifyType.TJDead);
+            hangUpPushlist.Add((int)PushNotifyType.TJWGTimeNoEnough);
+
+        }
+
+        public void OnBeforePlayerDataInitialize()
+        {
+
+        }
+        public void OnAfterPlayerDataInitialize()
+        {
+
+        }
+
+        public void OnPlayerLoginOk()
+        {
+            SetActivityPushKey();
+            InitPushNotifyStr();
+            SetActivityPush();
+            LocalSave.SetBool(VIPEXPERIENCERECORD, vipModel.IsVipExperience());
+            vipModel.OnVipTimeEvent -= SetVipPushNotifyByVipExperience;
+            vipModel.OnVipTimeEvent += SetVipPushNotifyByVipExperience;
+            GlobalTimeEvent.Instance.minuteEvent -= RefreshDailyQuest;
+            GlobalTimeEvent.Instance.minuteEvent += RefreshDailyQuest;
+        }
+
+        public override void UnInit()
+        {
+
+        }
+
+        public void SetActivityPushKey()
+        {
+            pushAtcivityKeyDict.Clear();
+            List<int> dailyIdlist = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
+            for (int i = 0; i < dailyIdlist.Count; i++)
+            {
+                List<string> keylist = new List<string>();
+                pushAtcivityKeyDict.Add(dailyIdlist[i], keylist);
+                SetPushKeylist(dailyIdlist[i], keylist);
+            }
+        }
+
+        private void SetPushKeylist(int dailyId, List<string> keylist)
+        {
+            DailyQuestOpenTime dailyQuestOpenTime;
+            dailyModel.TryGetOpenTime(dailyId, out dailyQuestOpenTime);
+
+            for (int weekDay = 0; weekDay < 7; weekDay++)
+            {
+                var hourMinutelist = dailyQuestOpenTime.GetHourMinuteByWeek(weekDay);
+                if (hourMinutelist != null)
+                {
+                    for (int j = 0; j < hourMinutelist.Count; j++)
+                    {
+                        var key = StringUtility.Contact(dailyId, weekDay, hourMinutelist[j].hourBegin);
+                        keylist.Add(key);
+                    }
+                }
+            }
+        }
+
+        #region 澶勭悊鏈嶅姟鍣ㄦ暟鎹�
+        public Dictionary<int, bool> pushSetDict = new Dictionary<int, bool>();
+        public int startHour { get; set; }
+        public int startMinute { get; set; }
+        public int endHour { get; set; }
+        public int endMinute { get; set; }
+
+        public void SetServerPushModel(HB202_tagMCPushNotificationsSetting setting)
+        {
+            pushSetDict.Clear();
+            int switchBtnLength = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit).Count + hangUpPushlist.Count;
+            for (int i = 0; i < switchBtnLength; i++)
+            {
+                bool isOpen = MathUtility.GetBitValue(setting.OnoffBit, (ushort)i);
+                pushSetDict.Add(i, isOpen);
+            }
+            AnalysisFreeTime(setting.TimeStr);
+        }
+
+        private void AnalysisFreeTime(string timeStr)
+        {
+            string[] timeArray = timeStr.Split('-');
+            for (int i = 0; i < timeArray.Length; i++)
+            {
+                string[] hourAndMinute = timeArray[i].Split(':');
+                if (i == 0)
+                {
+                    startHour = int.Parse(hourAndMinute[0]);
+                    startMinute = int.Parse(hourAndMinute[1]);
+                }
+                else if (i == 1)
+                {
+                    endHour = int.Parse(hourAndMinute[0]);
+                    endMinute = int.Parse(hourAndMinute[1]);
+                }
+            }
+        }
+
+        private string GetContactFreeTime()
+        {
+            return StringUtility.Contact(startHour.ToString("D2"), ":", startMinute.ToString("D2"), "-", endHour.ToString("D2"), ":", endMinute.ToString("D2"));
+        }
+
+        public void SendPushNotifyQuest(int pushSet)
+        {
+            string freeTimeStr = GetContactFreeTime();
+            CB205_tagCMPushNotificationsSetting setting = new CB205_tagCMPushNotificationsSetting();
+            setting.OnoffBit = (uint)pushSet;
+            setting.TimeLen = (byte)freeTimeStr.Length;
+            setting.TimeStr = freeTimeStr;
+            GameNetSystem.Instance.SendInfo(setting);
+        }
+
+        public void SetActivityPush()
+        {
+            List<int> dailyIdlist = GetOpenDailyIdlist(true);
+            for (int i = 0; i < dailyIdlist.Count; i++)
+            {
+                bool isOpen = GetSwitchStateByIndex(GetSwitchIndexById(dailyIdlist[i]));
+                if (isOpen)
+                {
+                    List<JsonData> pushNotifylist = GetPushJsonData(dailyIdlist[i]);
+                    for (int j = 0; j < pushNotifylist.Count; j++)
+                    {
+                        SDKUtility.Instance.GeTui_SendLocalMessage(pushNotifylist[j]);
+                    }
+                }
+            }
+        }
+
+        public void RemoveActivityPush(int dailyId)
+        {
+            List<string> keylist = pushAtcivityKeyDict[dailyId];
+            for (int i = 0; i < keylist.Count; i++)
+            {
+                SDKUtility.Instance.GeTui_RemoveLocalMessage(keylist[i]);
+            }
+        }
+
+        public void RemoveActivityPushByKey(int dailyId, string pushKey)
+        {
+            if (pushAtcivityKeyDict[dailyId].Contains(pushKey))
+            {
+                SDKUtility.Instance.GeTui_RemoveLocalMessage(pushKey);
+            }
+        }
+
+        public void AddActivityPush(int dailyId)
+        {
+            var config = Config.Instance.Get<DailyQuestConfig>(dailyId);
+            if (config == null || !FuncOpen.Instance.IsFuncOpen(config.UnLockFuncID)) return;
+
+            List<JsonData> pushNotifylist = GetPushJsonData(dailyId);
+            for (int j = 0; j < pushNotifylist.Count; j++)
+            {
+                SDKUtility.Instance.GeTui_SendLocalMessage(pushNotifylist[j]);
+            }
+        }
+
+
+        public List<JsonData> GetPushJsonData(int dailyId)
+        {
+            var config = Config.Instance.Get<DailyQuestConfig>(dailyId);
+            string content = Language.Get("SetUpPrivate102", UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName).TrimEnd(), config.Title);
+            List<JsonData> pushNotifylist = new List<JsonData>();
+            List<string> pushKeylist = null;
+            List<int> pushNotifyTimelist = GetPushNotifyTime(dailyId, out pushKeylist);
+            for (int i = 0; i < pushNotifyTimelist.Count; i++)
+            {
+                if (i < pushKeylist.Count)
+                {
+                    JsonData _params = new JsonData();
+                    _params["code"] = 2005;
+                    _params["id"] = pushKeylist[i];// id 閲嶈, 鏍囩ず姣忎釜閫氱煡鐨勬洿鏂版垨鑰呯Щ闄�
+                    _params["title"] = Language.Get("SetUpPrivate103");// 鎺ㄩ�佹爣棰�
+                    _params["subtitle"] = "";// 鍓爣棰�
+                    _params["content"] = content;// 鍏蜂綋鍐呭
+                    _params["badge"] = -1;// 瑙掓爣
+                    // 浠ヤ笅涓哄喅瀹氬簲璇ュ涔呭悗寮瑰嚭姝ら�氱煡
+                    System.TimeSpan ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
+                    long ret = System.Convert.ToInt64(ts.TotalSeconds) + pushNotifyTimelist[i];// 琛ㄧず3绉掑悗
+                    _params["fireTime"] = ret;
+                    pushNotifylist.Add(_params);
+                }
+            }
+
+            return pushNotifylist;
+        }
+
+        private List<int> GetPushNotifyTime(int dailyId, out List<string> pushKey)
+        {
+            List<int> pushDelaySecond = new List<int>();
+            pushKey = new List<string>();
+            DailyQuestOpenTime dailyQuestOpenTime;
+            dailyModel.TryGetOpenTime(dailyId, out dailyQuestOpenTime);
+
+            for (int weekDay = 0; weekDay < 7; weekDay++)
+            {
+                var hourMinutelist = dailyQuestOpenTime.GetHourMinuteByWeek(weekDay);
+                if (hourMinutelist != null)
+                {
+                    int day = weekDay > 0 ? weekDay : 7;
+                    int curDay = (int)TimeUtility.ServerNow.DayOfWeek > 0 ? (int)TimeUtility.ServerNow.DayOfWeek : 7;
+                    int remainDay = day - curDay;
+                    if (remainDay < 0)
+                    {
+                        remainDay = 7 + remainDay;
+                    }
+                    for (int i = 0; i < hourMinutelist.Count; i++)
+                    {
+                        int remainHour = hourMinutelist[i].hourBegin - TimeUtility.ServerNow.Hour;
+                        int remainMinute = hourMinutelist[i].minuteBegin - TimeUtility.ServerNow.Minute;
+                        if (remainDay <= 0)
+                        {
+                            if (remainHour < 0)
+                            {
+                                remainDay = 7;
+                            }
+                            else if (remainHour == 0 && remainMinute < 0)
+                            {
+                                remainDay = 7;
+                            }
+                        }
+                        int remainSecond = remainDay * 24 * 60 * 60 + remainHour * 60 * 60 + remainMinute * 60;
+                        if (remainSecond > 120)
+                        {
+                            string key = StringUtility.Contact(dailyId, weekDay, hourMinutelist[i].hourBegin);
+                            pushKey.Add(key);
+                            pushDelaySecond.Add(remainSecond);
+                        }
+                    }
+                }
+
+            }
+
+            return pushDelaySecond;
+        }
+
+        #endregion
+
+        StringBuilder pushSB = new StringBuilder();
+        public void InitPushNotifyStr()
+        {
+            int playerLv = PlayerDatas.Instance.baseData.LV;
+            if (playerLv > 1)
+                return;
+
+            pushSB.Length = 0;
+            List<int> indexlist = pushSetDict.Keys.ToList();
+            for (int i = indexlist.Count - 1; i > -1; i--)
+            {
+                if (i < hangUpPushlist.Count)
+                {
+                    if (vipModel.IsVipActive() || vipModel.IsVipExperience())
+                    {
+                        pushSetDict[indexlist[i]] = true;
+                    }
+                    else
+                    {
+                        pushSetDict[indexlist[i]] = false;
+                    }
+                }
+                else
+                {
+                    pushSetDict[indexlist[i]] = true;
+                }
+
+                if (pushSetDict[indexlist[i]])
+                {
+                    pushSB.Append("1");
+                }
+                else
+                {
+                    pushSB.Append("0");
+                }
+            }
+
+            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
+            SendPushNotifyQuest(pushSet);
+        }
+
+        public void SetVipPushNotify(int vipLv)
+        {
+            pushSB.Length = 0;
+            List<int> indexlist = pushSetDict.Keys.ToList();
+            for (int i = indexlist.Count - 1; i > -1; i--)
+            {
+                if (i < hangUpPushlist.Count)
+                {
+                    if (vipLv > 0
+                        && !vipModel.IsVipExperience())
+                    {
+                        pushSetDict[indexlist[i]] = true;
+                    }
+                    else if (vipLv < 1
+                        && !vipModel.IsVipExperience())
+                    {
+                        pushSetDict[indexlist[i]] = false;
+                    }
+                }
+
+                if (pushSetDict[indexlist[i]])
+                {
+                    pushSB.Append("1");
+                }
+                else
+                {
+                    pushSB.Append("0");
+                }
+            }
+            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
+            SendPushNotifyQuest(pushSet);
+        }
+
+        public void SetVipPushNotifyByVipExperience()
+        {
+            bool recordVipExper = LocalSave.GetBool(VIPEXPERIENCERECORD);
+            pushSB.Length = 0;
+            List<int> indexlist = pushSetDict.Keys.ToList();
+            for (int i = indexlist.Count - 1; i > -1; i--)
+            {
+                if (i < hangUpPushlist.Count)
+                {
+                    if (vipModel.IsVipExperience()
+                        && !recordVipExper
+                        && PlayerDatas.Instance.baseData.VIPLv < 1)
+                    {
+                        pushSetDict[indexlist[i]] = true;
+                    }
+                    else if (!vipModel.IsVipExperience()
+                        && PlayerDatas.Instance.baseData.VIPLv < 1)
+                    {
+                        pushSetDict[indexlist[i]] = false;
+                    }
+                }
+
+                if (pushSetDict[indexlist[i]])
+                {
+                    pushSB.Append("1");
+                }
+                else
+                {
+                    pushSB.Append("0");
+                }
+            }
+            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
+            SendPushNotifyQuest(pushSet);
+            LocalSave.SetBool(VIPEXPERIENCERECORD, vipModel.IsVipExperience());
+        }
+
+        public void RefreshPushSet(int switchIndex, bool isOpen)
+        {
+            pushSB.Length = 0;
+            List<int> indexlist = pushSetDict.Keys.ToList();
+            for (int i = indexlist.Count - 1; i > -1; i--)
+            {
+                if (indexlist[i] == switchIndex)
+                {
+                    pushSetDict[indexlist[i]] = isOpen;
+                }
+                if (pushSetDict[indexlist[i]])
+                {
+                    pushSB.Append("1");
+                }
+                else
+                {
+                    pushSB.Append("0");
+                }
+            }
+            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
+            SendPushNotifyQuest(pushSet);
+        }
+
+        List<int> openDailylist = new List<int>();
+        public List<int> GetOpenDailyIdlist(bool isFunclimit = false)
+        {
+            openDailylist.Clear();
+            var quests = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
+            for (int i = 0; i < quests.Count; i++)
+            {
+                DailyQuestOpenTime dailyQuestOpenTime;
+                dailyModel.TryGetOpenTime(quests[i], out dailyQuestOpenTime);
+                var config = Config.Instance.Get<DailyQuestConfig>(quests[i]);
+                if (isFunclimit)
+                {
+                    if (dailyQuestOpenTime.IsValidServerOpenTime() && FuncOpen.Instance.IsFuncOpen(config.UnLockFuncID))
+                    {
+                        openDailylist.Add(quests[i]);
+                    }
+                }
+                else
+                {
+                    if (dailyQuestOpenTime.IsValidServerOpenTime())
+                    {
+                        openDailylist.Add(quests[i]);
+                    }
+                }
+
+            }
+            return openDailylist;
+        }
+
+        public bool GetSwitchStateByIndex(int index)
+        {
+            if (pushSetDict.ContainsKey(index))
+            {
+                return pushSetDict[index];
+            }
+            return false;
+        }
+
+        public void GetDailyInfoById(int id, out string title, out string week, out string time)
+        {
+            var config = Config.Instance.Get<DailyQuestConfig>(id);
+            DailyQuestOpenTime dailyQuestOpenTime;
+            dailyModel.TryGetOpenTime(id, out dailyQuestOpenTime);
+            week = dailyQuestOpenTime.ToOpenTimeString();
+            title = config.Title;
+            time = "";
+
+            for (int i = 0; i < 7; i++)
+            {
+                var hourMinutelist = dailyQuestOpenTime.GetHourMinuteByWeek(i);
+                if (hourMinutelist != null)
+                {
+                    time = StringUtility.Contact(hourMinutelist[0].hourBegin > 9 ? hourMinutelist[0].hourBegin.ToString() : "0" + hourMinutelist[0].hourBegin, ":", hourMinutelist[0].minuteBegin > 9 ? hourMinutelist[0].minuteBegin.ToString() : "0" + hourMinutelist[0].minuteBegin);
+                    break;
+                }
+            }
+        }
+
+        public int GetSwitchIndexById(int id)
+        {
+            var quests = dailyModel.GetDailyQuests(DailyQuestModel.DailyQuestCategory.TimeLimit);
+            for (int i = 0; i < quests.Count; i++)
+            {
+                if (quests[i] == id)
+                {
+                    return i + hangUpPushlist.Count;
+                }
+            }
+            return -1;
+        }
+
+        /// <summary>
+        /// type 1 寮�濮嬫椂闂� 2 缁撴潫鏃堕棿
+        /// </summary>
+        /// <param name="type"></param>
+        public void SetRefreshFreeTimeEvent(int type, int hour, int minute)
+        {
+            switch (type)
+            {
+                case 1:
+                    startHour = hour;
+                    startMinute = minute;
+                    break;
+                case 2:
+                    endHour = hour;
+                    endMinute = minute;
+                    break;
+            }
+            pushSB.Length = 0;
+            List<int> indexlist = pushSetDict.Keys.ToList();
+            for (int i = indexlist.Count - 1; i > -1; i--)
+            {
+                if (pushSetDict[indexlist[i]])
+                {
+                    pushSB.Append("1");
+                }
+                else
+                {
+                    pushSB.Append("0");
+                }
+            }
+            int pushSet = Convert.ToInt32(pushSB.ToString(), 2);
+            SendPushNotifyQuest(pushSet);
+            if (RefreshFreeTimeAct != null)
+            {
+                RefreshFreeTimeAct();
+            }
+        }
+
+
+        private void RefreshDailyQuest()
+        {
+            foreach (var dailyQuest in dailyModel.GetDailyQuestlist().Values)
+            {
+                var isUnLocked = TestDailyQuestUnLock(dailyQuest.id);
+                if (isUnLocked)
+                {
+                    ModelCenter.Instance.GetModel<SetPrivateModel>().CheckActivityOpenTime(dailyQuest.id);
+                }
+            }
+        }
+        public bool TestDailyQuestUnLock(int _dailyQuestId)
+        {
+            switch ((DailyQuestType)_dailyQuestId)
+            {
+                case DailyQuestType.FairyLeague:
+                case DailyQuestType.FairyFeast:
+                case DailyQuestType.FairyTask:
+                    var _dailyConfig = Config.Instance.Get<DailyQuestConfig>(_dailyQuestId);
+                    return PlayerDatas.Instance.baseData.Family > 0 &&
+                        (_dailyConfig.UnLockFuncID == 0 || FuncOpen.Instance.IsFuncOpen(_dailyConfig.UnLockFuncID));
+                case DailyQuestType.RuneTowerSweep:
+                    return ModelCenter.Instance.GetModel<RuneTowerModel>().yesterdayPassFloor > 0;
+                default:
+                    var dailyConfig = Config.Instance.Get<DailyQuestConfig>(_dailyQuestId);
+                    return dailyConfig.UnLockFuncID == 0 || FuncOpen.Instance.IsFuncOpen(dailyConfig.UnLockFuncID);
+            }
+        }
+
+
+        public void CheckActivityOpenTime(int dailyId)
+        {
+            bool isOpen = GetSwitchStateByIndex(GetSwitchIndexById(dailyId));
+            if (!isOpen)
+                return;
+
+            DailyQuestOpenTime openTime;
+            dailyModel.TryGetOpenTime(dailyId, out openTime);
+            var dayOfWeek = (int)TimeUtility.ServerNow.DayOfWeek;
+            var hourMinutes = openTime.GetHourMinuteByWeek(dayOfWeek);
+            if (hourMinutes != null)
+            {
+                for (int i = 0; i < hourMinutes.Count; i++)
+                {
+                    var minutes = TimeUtility.ServerNow.Hour * 60 + TimeUtility.ServerNow.Minute;
+                    float minuteOffset = (hourMinutes[i].hourBegin * 60 + hourMinutes[i].minuteBegin) - minutes;
+                    if (minuteOffset <= 2 && minuteOffset > 0)
+                    {
+                        string key = StringUtility.Contact(dailyId, dayOfWeek, hourMinutes[i].hourBegin);
+                        RemoveActivityPushByKey(dailyId, key);
+                    }
+                }
+            }
+        }
+
+        public enum PushNotifyType
+        {
+            FreeTime = 0, //鍏嶆墦鎵版椂闂村紑鍏�
+            BossRefresh = 1, //鍏虫敞BOSS
+            PrivateChat = 2,  //绉佽亰
+            TJDead = 3,  //鑴辨満姝讳骸
+            TJWGTimeNoEnough, //鑴辨満澶栨寕鏃堕棿涓嶈冻
+        }
+    }
+}

--
Gitblit v1.8.0