如何解决在Windows下使用R发送通知
我目前正在使用R语言在银行中记录/更新我的桌子:
const UserPage = ({ match,location }) => {
const { params: { userId } } = match;
return (
<>
<p>
<strong>User ID: </strong>
{userId}
</p>
<p>
<strong>User Name: </strong>
{users[userId - 1].name}
</p>
</>
);
};
我的这个脚本更新了postgres数据库中R中的表,它是由Windows任务自动不时运行的。 我需要知道何时记录或不记录信息,可能是屏幕上的警报格式,还是引起人们注意的东西。
注意:我知道有“ r.out”,但是它会覆盖,不会在出现问题或类似问题时发出警告。
解决方法
您可以致电Windows Powershell:
- 运行powershell和authorize script execution:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
- 创建一个notification script并使用
system
执行它:
MessageScript <-'
[CmdletBinding()]
$ErrorActionPreference = "Stop"
$notificationTitle = "{Message}"
[Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications,ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
#Convert to .NET type for XML manipuration
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null
#Convert back to WinRT type
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($toastXml.OuterXml)
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml)
$toast.Tag = "PowerShell"
$toast.Group = "PowerShell"
$toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(5)
#$toast.SuppressPopup = $true
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PowerShell")
$notifier.Show($toast);
'
showMessage <- function(MessageScript,Message) {
system('powershell',input=glue::glue(MessageScript),show.output.on.console=F)}
showMessage(MessageScript,Message = 'this is a test')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。