Thursday, October 06, 2011

Powershell calling a web service

$results2=6

switch ($results2)
{
36 {write-host the value be thirty36}
}




get-help date

$mydate = get-date | Out-String

$mydate = get-date
$mydate = $mydate.ToString()

$mydate
get-date
# HI 96801 - Honolulu
# AK 99501
# NY 10001
# AZ 85001


#Generated Form Function
function GenerateForm {
########################################################################
# Generated By: niglen
########################################################################

#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
#endregion

# setup proxy NIGEL
#$ws=New-WebServiceProxy -uri http://ws.cdyne.com/WeatherWS/Weather.asmx?WSDL





#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$groupBox2 = New-Object System.Windows.Forms.GroupBox
$pictureBox2 = New-Object System.Windows.Forms.PictureBox
$pictureBox1 = New-Object System.Windows.Forms.PictureBox
$groupBox1 = New-Object System.Windows.Forms.GroupBox
$richTextBox1 = New-Object System.Windows.Forms.RichTextBox
$progressBar1 = New-Object System.Windows.Forms.ProgressBar
$label1 = New-Object System.Windows.Forms.Label
$button1 = New-Object System.Windows.Forms.Button
$textBox1 = New-Object System.Windows.Forms.TextBox
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects

#$pictureBox2 | get-member

#----------------------------------------------
#Generated Event Script Blocks
#----------------------------------------------
#Provide Custom Code for events specified in PrimalForms.
$button1_OnClick=
{
$progressBar1.PerformStep()
$progressBar1.PerformStep()
$ws2=New-WebServiceProxy -uri http://ws.cdyne.com/WeatherWS/Weather.asmx?WSDL
$progressBar1.PerformStep()
write-host completed making the proxy
$ws2 | get-member

write-host you clicked the button I am working...
$thezip = $textBox1.text
write-host the value you keyed into the text box is
write-host $thezip

$results = $ws2.getcityweatherbyZip($thezip)
write-host made it here
$results.State
$results.Description
$results.Temperature
$results.Wind
$results.City

$myresults=$results
$progressBar1.PerformStep()
$richTextBox1.text = "State: "
$richTextBox1.text += $results.State+"`n"
$richTextBox1.text += "Description: "
$richTextBox1.text += $results.Description+"`n"
$richTextBox1.text += "Temperature "
$richTextBox1.text += $results.Temperature+"`n"
$richTextBox1.text += "Wind Speed and Direction "
$richTextBox1.text += $results.Wind+"`n"
$richTextBox1.text += "City: "
$richTextBox1.text += $results.City+"`n"


if ($results.Temperature -lt 60) {
$pictureBox2.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\nigel_dressed_warm.jpg')
$pictureBox2.BackgroundImageLayout = 2 }

if ($results.Temperature -gt 59) {
$pictureBox2.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\nigel_hot_weather2.jpg')
$pictureBox2.BackgroundImageLayout = 2 }

$pictureBox2 | get-member

if ($results.Description -like "*rain*") {
$pictureBox1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\rain.jpg')
$pictureBox1.BackgroundImageLayout = 2 }

if ($results.Description -like "*Cloudy*") {
$pictureBox1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\cloud.jpg')
$pictureBox1.BackgroundImageLayout = 2 }

if ($results.Description -like "*partly*") {
$pictureBox1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\partly.jpg')
$pictureBox1.BackgroundImageLayout = 1 }

$progressbar1.Value=0

}

$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}

#----------------------------------------------
#region Generated Form Code
$form1.Text = "The Nigel Weather Application a Web Services Example "
$form1.Name = "form1"
$form1.BackgroundImage = [System.Drawing.Image]::FromFile('G:\FILES\bluebackground2.jpg')
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 1169
$System_Drawing_Size.Height = 768
$form1.ClientSize = $System_Drawing_Size

$groupBox2.Name = "groupBox2"

$groupBox2.Text = "Clothing Suggested"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 694
$System_Drawing_Size.Height = 590
$groupBox2.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 397
$System_Drawing_Point.Y = 137
$groupBox2.Location = $System_Drawing_Point
$groupBox2.TabStop = $False
$groupBox2.TabIndex = 5
$groupBox2.DataBindings.DefaultDataSourceUpdateMode = 0

$form1.Controls.Add($groupBox2)
$pictureBox2.TabIndex = 1
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 373
$System_Drawing_Size.Height = 350
$pictureBox2.Size = $System_Drawing_Size


$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 195
$System_Drawing_Point.Y = 203
$pictureBox2.Location = $System_Drawing_Point


$pictureBox2.TabStop = $False
$pictureBox2.Name = "pictureBox2"
$pictureBox2.DataBindings.DefaultDataSourceUpdateMode = 0

$groupBox2.Controls.Add($pictureBox2)

$pictureBox1.TabIndex = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 370
$System_Drawing_Size.Height = 141
$pictureBox1.Size = $System_Drawing_Size


$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 199
$System_Drawing_Point.Y = 39
$pictureBox1.Location = $System_Drawing_Point


$pictureBox1.TabStop = $False
$pictureBox1.Name = "pictureBox1"
$pictureBox1.DataBindings.DefaultDataSourceUpdateMode = 0

$groupBox2.Controls.Add($pictureBox1)


$groupBox1.Name = "groupBox1"

$groupBox1.Text = "Weather Details"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 337
$System_Drawing_Size.Height = 551
$groupBox1.Size = $System_Drawing_Size
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 41
$System_Drawing_Point.Y = 126
$groupBox1.Location = $System_Drawing_Point
$groupBox1.TabStop = $False
$groupBox1.TabIndex = 4
$groupBox1.DataBindings.DefaultDataSourceUpdateMode = 0

$form1.Controls.Add($groupBox1)
$richTextBox1.Name = "richTextBox1"
$richTextBox1.Text = ""
$richTextBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 14
$System_Drawing_Point.Y = 30
$richTextBox1.Location = $System_Drawing_Point
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 310
$System_Drawing_Size.Height = 505
$richTextBox1.Size = $System_Drawing_Size
$richTextBox1.TabIndex = 0

$groupBox1.Controls.Add($richTextBox1)


$progressBar1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 267
$System_Drawing_Size.Height = 23
$progressBar1.Size = $System_Drawing_Size
$progressBar1.TabIndex = 3
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 403
$System_Drawing_Point.Y = 50
$progressBar1.Location = $System_Drawing_Point
$progressBar1.Name = "progressBar1"
$progressBar1.Step = 50

$form1.Controls.Add($progressBar1)

$label1.TabIndex = 2
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 84
$System_Drawing_Size.Height = 20
$label1.Size = $System_Drawing_Size
$label1.Text = "ZIP CODE"
$label1.Font = New-Object System.Drawing.Font("MS Reference Sans Serif",9.75,0,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 54
$System_Drawing_Point.Y = 54
$label1.Location = $System_Drawing_Point
$label1.DataBindings.DefaultDataSourceUpdateMode = 0
$label1.Name = "label1"

$form1.Controls.Add($label1)

$button1.TabIndex = 1
$button1.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 34
$System_Drawing_Size.Height = 33
$button1.Size = $System_Drawing_Size
$button1.UseVisualStyleBackColor = $True

$button1.Image = [System.Drawing.Image]::FromFile('G:\FILES\Search.PNG')
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 345
$System_Drawing_Point.Y = 47
$button1.Location = $System_Drawing_Point
$button1.DataBindings.DefaultDataSourceUpdateMode = 0
$button1.add_Click($button1_OnClick)

$form1.Controls.Add($button1)

$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 195
$System_Drawing_Size.Height = 20
$textBox1.Size = $System_Drawing_Size
$textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$textBox1.Name = "textBox1"
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 144
$System_Drawing_Point.Y = 54
$textBox1.Location = $System_Drawing_Point
$textBox1.TabIndex = 0
$textBox1.Text = "96801"
$form1.Controls.Add($textBox1)

#endregion Generated Form Code

#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null

} #End Function

#Call the Function
GenerateForm

0 Comments:

Post a Comment

<< Home