show message only if files exist

This commit is contained in:
jonas@geiger-natur.de
2025-01-05 17:19:16 +01:00
parent b6f36c62a0
commit ecc2d531eb

View File

@@ -40,24 +40,27 @@ while ($true) {
}
#NOTIFICATION
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
if($files.Count -gt 0)
{
#NOTIFICATION
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").Item(0).AppendChild($toastXml.CreateTextNode("Files synchronized")) > $null
$toastXml.GetElementsByTagName("text").Item(1).AppendChild($toastXml.CreateTextNode("$($counter) of $($files.Count)")) > $null
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").Item(0).AppendChild($toastXml.CreateTextNode("Files synchronized")) > $null
$toastXml.GetElementsByTagName("text").Item(1).AppendChild($toastXml.CreateTextNode("$($counter) of $($files.Count)")) > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
$toast.Tag = "DownloadsFileSync"
$toast.Group = "DownloadsFileSync"
$toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(1)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
$toast.Tag = "DownloadsFileSync"
$toast.Group = "DownloadsFileSync"
$toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(1)
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("DownloadsFileSync")
$notifier.Show($toast);
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("DownloadsFileSync")
$notifier.Show($toast);
}
#START-SLEEP