public static void SetFirstTimeLaunchTimestr(DateTime tm) { string firstLaunchTimeStr = tm.ToString(); PreferencesUtil.SetString(FIRST_LAUNCH_TIME, firstLaunchTimeStr); }
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); }
public static void ClickReminderMe() { PreferencesUtil.SetBoolean(REMIND_ME_LATER_CLICK, true); PreferencesUtil.SetString(REMIND_ME_LATER_CLICK_TIME, DateTime.Now.ToString()); }