Archived
1
0

Broke everything; #220: Fixed

This commit is contained in:
Michael Gordeev
2018-12-09 13:41:00 +03:00
parent 1a6447a4aa
commit f16be876c6
19 changed files with 201 additions and 145 deletions
+23 -20
View File
@@ -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,
+1 -1
View File
@@ -11,7 +11,7 @@
<AssemblyName>FoxTube.Background</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17134.0</TargetPlatformVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
+5 -5
View File
@@ -12,8 +12,8 @@ namespace FoxTube.Background
template.LoadXml($@"<toast activationType='foreground' launch='changelog|{version}'>
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='http://foxgame.hol.es/FoxTubeAssets/WhatsNewThumb.png'/>
<image placement='appLogoOverride' hint-crop='circle' src='http://foxgame.hol.es/FoxTubeAssets/NewsAvatar.png'/>
<image placement='hero' src='http://foxgame-studio.000webhostapp.com/FoxTubeAssets/WhatsNewThumb.png'/>
<image placement='appLogoOverride' hint-crop='circle' src='http://foxgame-studio.000webhostapp.com/FoxTubeAssets/NewsAvatar.png'/>
<text>Changelog</text>
<text>See what's new in version {version}</text>
</binding>
@@ -31,7 +31,7 @@ namespace FoxTube.Background
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='{thumbnail.Replace("&", "%26")}'/>
<image placement='appLogoOverride' hint-crop='circle' src='{avatar.Replace("&", "%26") ?? "http://foxgame.hol.es/FoxTubeAssets/LogoAvatar.png"}'/>
<image placement='appLogoOverride' hint-crop='circle' src='{avatar.Replace("&", "%26") ?? "http://foxgame-studio.000webhostapp.com/FoxTubeAssets/LogoAvatar.png"}'/>
<text>{title}</text>
<text>{channel} uploaded a new video</text>
</binding>
@@ -53,8 +53,8 @@ namespace FoxTube.Background
template.LoadXml($@"<toast activationType='foreground' launch='inbox|{id}'>
<visual>
<binding template='ToastGeneric'>
<image placement='hero' src='{thumbnail ?? "http://foxgame.hol.es/FoxTubeAssets/AnnouncementThumb.png"}'/>
<image placement='appLogoOverride' hint-crop='circle' src='{avatar ?? "http://foxgame.hol.es/FoxTubeAssets/LogoAvatar.png"}'/>
<image placement='hero' src='{thumbnail ?? "http://foxgame-studio.000webhostapp.com/FoxTubeAssets/AnnouncementThumb.png"}'/>
<image placement='appLogoOverride' hint-crop='circle' src='{avatar ?? "http://foxgame-studio.000webhostapp.com/FoxTubeAssets/LogoAvatar.png"}'/>
<text>{header}</text>
<text hint-maxLines='5'>{content}</text>
</binding>