Exemplo n.º 1
0
        public static bool EnoughTimeAfterFirstLaunch()
        {
            //check how long after first launch
            DateTime now = DateTime.Now;
            string   firstLaunchTimeStr = PreferencesUtil.GetString(FIRST_LAUNCH_TIME);
            DateTime firstLaunchTime    = new DateTime();

            try
            {
                firstLaunchTime = Convert.ToDateTime(firstLaunchTimeStr);
            }
            catch (Exception e)
            {
                SetFirstTimeLaunchTimestr(DateTime.Now);
                return(false);
            }

            if ((now - firstLaunchTime).TotalDays < GetEventCriteria(KEY_MIN_DAY_AFTER_FIRST_LAUNCH))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static bool SatisfyCriteria()
        {
            //We only pop up the rating when user is online
            if (!AppServices.IsConnectedToInternet())
            {
                return(false);
            }

            //Check whether it is enough time after first launch
            if (!EnoughTimeAfterFirstLaunch())
            {
                return(false);
            }

            if (AlreadyPopup())
            {
                if (!RemindMeLaterClicked())
                {
                    //if not in reminder me status
                    return(false);
                }

                //if and only if the customer clicked remind_me_later, we can pop up
                DateTime now = DateTime.Now;
                string   remindMeLaterTimeStr = PreferencesUtil.GetString(REMIND_ME_LATER_CLICK_TIME);
                DateTime remindMeLaterTime    = new DateTime();

                try
                {
                    remindMeLaterTime = Convert.ToDateTime(remindMeLaterTimeStr);
                }
                catch (Exception e)
                {
                    remindMeLaterTimeStr = DateTime.Now.ToString();
                    remindMeLaterTime    = DateTime.Now;

                    PreferencesUtil.SetString(REMIND_ME_LATER_CLICK_TIME, remindMeLaterTimeStr);
                }

                //if it is less than 5 day after user click reminder me later, we cannot pop up
                if ((now - remindMeLaterTime).TotalDays < GetEventCriteria(KEY_TIME_GAP_BETWEEN_REMINDER_ME))
                {
                    return(false);
                }

                //continue to see whether it satisfy other conditions
            }

            Dictionary <int, bool> groupSatisfy = new Dictionary <int, bool>();

            foreach (var item in keyGroup)
            {
                if (!groupSatisfy.ContainsKey(item.Value))
                {
                    groupSatisfy.Add(item.Value, false);
                }
            }

            //iterate all other criteria
            foreach (var key in keys)
            {
                if (key == CRITERIA_PREFIX + KEY_TIME_GAP_BETWEEN_REMINDER_ME)
                {
                    //already iterated
                    continue;
                }

                if (GetEventCount(key) < GetEventCriteria(key))
                {
                    if (!keyGroup.ContainsKey(key))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (keyGroup.ContainsKey(key))
                    {
                        groupSatisfy[keyGroup[key]] = true;
                    }
                }
            }

            //check whether all criteria group has satisfy the condition
            foreach (var item in groupSatisfy)
            {
                if (!item.Value)
                {
                    return(false);
                }
            }


            return(true);
        }
Exemplo n.º 3
0
 public static string GetFirstTimeLaunchTimestr()
 {
     return(PreferencesUtil.GetString(FIRST_LAUNCH_TIME));
 }