用户成功提交请求后,如何让表单重置/关闭?我正在使用 Powershell ise 进行测试,直到我真正 X 出来,脚本才关闭。这是我目前的功能。
感谢这个论坛上的人们,我的表格工作正常。我还有另一个我正在努力解决的问题。用户点击提交按钮后如何让表单重置?我现在必须退出表单才能结束脚本。
#region gui events {
$btn1.Add_Click({ sendRequest; thankyou })
#endregion events }
#endregion GUI }
function sendRequest()
{
# API Key
$FDApiKey="api key"
#################################################
# Force TLS1.2 as Powershell defaults to TLS 1.0 and Freshdesk will fail connections
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
# Prep
$pair = "$($FDApiKey):$($FDApiKey)"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$FDHeaders = @{ Authorization = $basicAuthValue }
##################################################
$Body = @{
description = $description.Text
email = $email.Text
subject = $subject.Text
type = $request.Text
priority = 1
status = 2
}
Invoke-WebRequest "https://clasd.freshdesk.com/api/v2/tickets/" `
-Headers $FDHeaders `
-ContentType "application/json" `
-Method Post `
-Body ($Body | ConvertTo-JSON)
}
function thankyou ()
{
[System.Windows.Forms.MessageBox]::Show("Your ticket has been submitted!" , "Status")
}
#Write your logic code here
[void]$Form.ShowDialog()