private static void showMobileSpecificContent(MobileSpecificContent content, PhoneApplicationPage pageContext) { previousMobileSpecificContentId = content.Id; lastShownMobileSpecificContent = DateTime.Now; pageContext.NavigationService.Navigate(new Uri("/Screens/MobileSpecificScreen.xaml", UriKind.Relative)); IsolatedStorageSettings.ApplicationSettings["Content"] = content; IsolatedStorageSettings.ApplicationSettings["LastShownContentDate"] = DateTime.Now; IsolatedStorageSettings.ApplicationSettings["LastShownContentId"] = previousMobileSpecificContentId; isToShowAgain = false; }
public static List <MobileSpecificContent> ParseMobileLift(String response) { List <MobileSpecificContent> mobileContents = new List <MobileSpecificContent>(); XDocument doc = XDocument.Parse(response); var contents = doc.Descendants(KEY_MOBILE_LIFT); foreach (var content in contents) { MobileSpecificContent mobSpecificContent = new MobileSpecificContent(); mobSpecificContent.Id = int.Parse(content.Attribute(KEY_ID).Value); if (content.Element(KEY_DESCRIPTION) != null) { mobSpecificContent.Description = content.Element(KEY_DESCRIPTION).Value; } if (content.Element(KEY_TITLE) != null) { mobSpecificContent.Title = content.Element(KEY_TITLE).Value; } if (content.Element(KEY_HOURS_TO_SHOW) != null) { mobSpecificContent.HoursToShowAgain = int.Parse(content.Element(KEY_HOURS_TO_SHOW).Value); } if (content.Element(KEY_LINK_TExT) != null) { mobSpecificContent.LinkText = content.Element(KEY_LINK_TExT).Value; } if (content.Element(KEY_STARTDATE) != null) { mobSpecificContent.StartDate = DateTime.Parse(content.Element(KEY_STARTDATE).Value); } if (content.Element(KEY_ENDDATE) != null) { mobSpecificContent.EndDate = DateTime.Parse(content.Element(KEY_ENDDATE).Value); } if (content.Element(KEY_LINK_URL) != null) { mobSpecificContent.LinkURL = content.Element(KEY_LINK_URL).Value; } mobileContents.Add(mobSpecificContent); } return(mobileContents); }
protected override void OnNavigatedTo(NavigationEventArgs e) { gotContent = App.content; MapFields(); }
public static void CheckForContentData(List <MobileSpecificContent> contentList, PhoneApplicationPage pageContext) { if (IsolatedStorageSettings.ApplicationSettings.Contains("Content")) { App.content = (MobileSpecificContent)IsolatedStorageSettings.ApplicationSettings["Content"]; } if (IsolatedStorageSettings.ApplicationSettings.Contains("LastShownContentDate")) { App.lastShownMobileSpecificContent = (DateTime)IsolatedStorageSettings.ApplicationSettings["LastShownContentDate"]; } if (IsolatedStorageSettings.ApplicationSettings.Contains("LastShownContentId")) { App.previousMobileSpecificContentId = (int)IsolatedStorageSettings.ApplicationSettings["LastShownContentId"]; } if (content == null) { DateTime now = DateTime.Now; foreach (var specificContent in contentList) { if (specificContent.StartDate.CompareTo(now) <= 0 && specificContent.EndDate.CompareTo(now) >= 0) { content = specificContent; previousMobileSpecificContentId = content.Id; showMobileSpecificContent(content, pageContext); break; } } } else { if (content != null && previousMobileSpecificContentId != content.Id) { foreach (MobileSpecificContent specificContent in contentList) { DateTime now = DateTime.Now; if (specificContent.StartDate.CompareTo(now) <= 0 && specificContent.EndDate.CompareTo(now) >= 0) { content = specificContent; previousMobileSpecificContentId = content.Id; showMobileSpecificContent(content, pageContext); break; } } } else if (isToShowAgain) { DateTime now = DateTime.Now; DateTime shouldShow = lastShownMobileSpecificContent.AddHours(content.HoursToShowAgain); if (now.CompareTo(shouldShow) > 0) { foreach (MobileSpecificContent specificContent in contentList) { if (specificContent.StartDate.CompareTo(now) <= 0 && specificContent.EndDate.CompareTo(now) >= 0) { content = specificContent; previousMobileSpecificContentId = content.Id; showMobileSpecificContent(content, pageContext); break; } } } } } }