Esempio n. 1
0
        public void Initialize()
        {
            AllUserGoal.AllUserGoalDicByGoal.Clear();
            AllUserGoal.AllUserGoalDicBySlotID.Clear();
            AllUserGoal.AllUserGoalDicByID.Clear();
            AllUserGoal.RefreshEventSlot.Clear();
            List <AllUserGoalInfo> list = (from x in HeroesContentsLoader.GetTable <AllUserGoalInfo>()
                                           where ServiceCore.FeatureMatrix.IsEnable(x.Feature) && ServiceCore.FeatureMatrix.IsMatchServerCode(x.ServerCode)
                                           select x).ToList <AllUserGoalInfo>();

            foreach (AllUserGoalInfo allUserGoalInfo in list)
            {
                Regex key = new Regex(allUserGoalInfo.Goal, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                if (!AllUserGoal.AllUserGoalDicByGoal.ContainsKey(key))
                {
                    AllUserGoal.AllUserGoalDicByGoal.Add(key, new List <AllUserGoalData>());
                }
                AllUserGoalData allUserGoalData = new AllUserGoalData(allUserGoalInfo);
                if (AllUserGoal.AllUserGoalDicByGoal.ContainsKey(key))
                {
                    AllUserGoal.AllUserGoalDicByGoal[key].Add(allUserGoalData);
                    AllUserGoal.AllUserGoalDicByID.Add(allUserGoalData.GoalID, allUserGoalData);
                }
                if (!AllUserGoal.AllUserGoalDicBySlotID.ContainsKey(allUserGoalInfo.SlotID))
                {
                    AllUserGoal.AllUserGoalDicBySlotID.Add(allUserGoalInfo.SlotID, new List <AllUserGoalData>());
                    AllUserGoal.AllUserGoalDicBySlotID[allUserGoalInfo.SlotID].Add(allUserGoalData);
                }
                else
                {
                    AllUserGoal.AllUserGoalDicBySlotID[allUserGoalInfo.SlotID].Add(allUserGoalData);
                }
                if (!AllUserGoal.RefreshEventSlot.ContainsKey(allUserGoalInfo.StartTime))
                {
                    AllUserGoal.RefreshEventSlot.Add(allUserGoalInfo.StartTime, new List <AllUserGoalData>());
                    AllUserGoal.RefreshEventSlot[allUserGoalInfo.StartTime].Add(allUserGoalData);
                }
                else
                {
                    AllUserGoal.RefreshEventSlot[allUserGoalInfo.StartTime].Add(allUserGoalData);
                }
            }
        }
Esempio n. 2
0
        public AllUserGoalData GetCurrentGoalDataBySlotID(int slotID)
        {
            if (AllUserGoal.AllUserGoalDicBySlotID.ContainsKey(slotID))
            {
                using (List <AllUserGoalData> .Enumerator enumerator = AllUserGoal.AllUserGoalDicBySlotID[slotID].GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AllUserGoalData current = enumerator.Current;
                        if (current.StartTime <= DateTime.UtcNow && DateTime.UtcNow < current.EndTime)
                        {
                            return(current);
                        }
                    }
                    return(null);
                }
            }
            Log <AllUserGoal> .Logger.WarnFormat("GetCurrentGoalDataBySlotID :: AllUserGoalDicBySlotID is not Contains SlotID : {0}", slotID);

            return(null);
        }
Esempio n. 3
0
        public AllUserGoalData GetNextGoalDataBySlotID(int slotID)
        {
            if (AllUserGoal.AllUserGoalDicBySlotID.ContainsKey(slotID))
            {
                using (IEnumerator <AllUserGoalData> enumerator = (from x in AllUserGoal.AllUserGoalDicBySlotID[slotID]
                                                                   orderby x.StartTime
                                                                   select x).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AllUserGoalData current = enumerator.Current;
                        if (DateTime.UtcNow < current.StartTime)
                        {
                            return(current);
                        }
                    }
                    return(null);
                }
            }
            Log <AllUserGoal> .Logger.WarnFormat("GetNextGoalDataBySlotID :: AllUserGoalDicBySlotID is not Contains SlotID : {0}", slotID);

            return(null);
        }