Broke everything; #220: Fixed
This commit is contained in:
@@ -24,30 +24,33 @@ namespace FoxTube.Background
|
||||
|
||||
public async void Run(IBackgroundTaskInstance taskInstance)
|
||||
{
|
||||
def = taskInstance.GetDeferral();
|
||||
try
|
||||
{
|
||||
def = taskInstance.GetDeferral();
|
||||
|
||||
if (settings.Values["lastCheck"] == null)
|
||||
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now));
|
||||
else lastCheck = XmlConvert.ToDateTime(settings.Values["lastCheck"] as string, XmlDateTimeSerializationMode.Unspecified);
|
||||
{
|
||||
settings.Values.Add("lastCheck", DateTime.UtcNow.ToString());
|
||||
def.Complete();
|
||||
return;
|
||||
}
|
||||
else
|
||||
lastCheck = DateTime.Parse(settings.Values["lastCheck"] as string);
|
||||
|
||||
//ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, $"{DateTime.Now} Retrieving videos since", lastCheck.ToString(), null, null));
|
||||
|
||||
bool[] notificationsSettings = JsonConvert.DeserializeObject<bool[]>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json")));
|
||||
if (notificationsSettings[0])
|
||||
CheckAnnouncements();
|
||||
if (notificationsSettings[1])
|
||||
CheckAccount();
|
||||
}
|
||||
catch
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
lastCheck = DateTime.Now;
|
||||
settings.Values["lastCheck"] = DateTime.UtcNow.ToString();
|
||||
def.Complete();
|
||||
}
|
||||
|
||||
ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, "Background task initialized. Retrieving videos since", lastCheck.ToString(), null, null));
|
||||
|
||||
bool[] notificationsSettings = JsonConvert.DeserializeObject<bool[]>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json")));
|
||||
if(notificationsSettings[0])
|
||||
CheckAnnouncements();
|
||||
if(notificationsSettings[1])
|
||||
CheckAccount();
|
||||
|
||||
settings.Values["lastCheck"] = XmlConvert.ToString(DateTime.Now, "YYYY-MM-DDThh:mm:ss");
|
||||
|
||||
def.Complete();
|
||||
ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, "Background task complete", DateTime.Now.ToString(), null, null));
|
||||
}
|
||||
|
||||
async void CheckAccount()
|
||||
@@ -77,8 +80,8 @@ namespace FoxTube.Background
|
||||
try
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(XmlReader.Create("http://foxgame.hol.es/foxtube-messages.xml"));
|
||||
if ((XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss") - lastCheck.ToUniversalTime()).TotalSeconds > 0)
|
||||
doc.Load(XmlReader.Create("http://foxgame-studio.000webhostapp.com/foxtube-messages.xml"));
|
||||
if ((DateTime.Parse((doc["posts"].FirstChild as XmlElement).GetAttribute("time")) - lastCheck).TotalSeconds > 0)
|
||||
ToastNotificationManager.CreateToastNotifier().Show(
|
||||
Notification.GetInternalToast(doc["posts"].FirstChild["id"].InnerText,
|
||||
doc["posts"].FirstChild["header"].InnerText,
|
||||
|
||||
Reference in New Issue
Block a user