23. Januar 2018 18:36
function GenerateSymbolsBC
{
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
function GenerateSymbolsForDatabase
{
[CmdletBinding()]param (
[String]$Server,
[String]$Database,
[String]$ObjectFilter)
$NAVFolder = 'C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client'
if ($ObjectFilter -ne '')
{$Command = """$NAVFolder\finsql.exe"" command=generatesymbolreference,servername=$Server,database=$Database,filter=$ObjectFilter"}
else
{$Command = """$NAVFolder\finsql.exe"" command=generatesymbolreference,servername=$Server,database=$Database"}
Write-host $Command
cmd /c $Command
}
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Generate Symbols"
$objForm.Size = New-Object System.Drawing.Size(300,300)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$script:x=$objTextBox.Text;$script:x2=$objTextBox2.Text;$script:x3=$objTextBox3.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,220)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$script:x=$objTextBox.Text;$script:x2=$objTextBox2.Text;$script:x3=$objTextBox3.Text;$objForm.Close()})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,220)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
#############
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Server"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objLabel2 = New-Object System.Windows.Forms.Label
$objLabel2.Location = New-Object System.Drawing.Size(10,65)
$objLabel2.Size = New-Object System.Drawing.Size(280,20)
$objLabel2.Text = "Database"
$objForm.Controls.Add($objLabel2)
$objTextBox2 = New-Object System.Windows.Forms.TextBox
$objTextBox2.Location = New-Object System.Drawing.Size(10,85)
$objTextBox2.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox2)
$objLabel3 = New-Object System.Windows.Forms.Label
$objLabel3.Location = New-Object System.Drawing.Size(10,105)
$objLabel3.Size = New-Object System.Drawing.Size(280,20)
$objLabel3.Text = "Object Filter"
$objForm.Controls.Add($objLabel3)
$objTextBox3 = New-Object System.Windows.Forms.TextBox
$objTextBox3.Location = New-Object System.Drawing.Size(10,125)
$objTextBox3.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox3)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
#Write-host "$x $x2 $x3"
if (($x -ne '') -and ($x2 -ne '') -and ($x3 -eq ''))
{GenerateSymbolsForDatabase -Server $x -Database $x2}
elseif (($x -ne '') -and ($x2 -ne '') -and ($x3 -ne ''))
{GenerateSymbolsForDatabase -Server $x -Database $x2 -ObjectFilter $x3}
else
{
[System.Windows.Forms.MessageBox]::Show("Please enter server and database. Object Filter is an option.")
Write-Error 'Please enter server and database. Object Filter is an option.'
}
}
GenerateSymbolsBC
function GenerateSymbolsNAV
{
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
function GenerateSymbolsForDatabase
{
[CmdletBinding()]param (
[String]$Server,
[String]$Database,
[String]$ObjectFilter)
$NAVFolder = 'C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client'
if ($ObjectFilter -ne '')
{$Command = """$NAVFolder\finsql.exe"" command=generatesymbolreference,servername=$Server,database=$Database,filter=$ObjectFilter"}
else
{$Command = """$NAVFolder\finsql.exe"" command=generatesymbolreference,servername=$Server,database=$Database"}
Write-host $Command
cmd /c $Command
}
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Generate Symbols"
$objForm.Size = New-Object System.Drawing.Size(300,300)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$script:x=$objTextBox.Text;$script:x2=$objTextBox2.Text;$script:x3=$objTextBox3.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,220)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$script:x=$objTextBox.Text;$script:x2=$objTextBox2.Text;$script:x3=$objTextBox3.Text;$objForm.Close()})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,220)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
#############
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Server"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objLabel2 = New-Object System.Windows.Forms.Label
$objLabel2.Location = New-Object System.Drawing.Size(10,65)
$objLabel2.Size = New-Object System.Drawing.Size(280,20)
$objLabel2.Text = "Database"
$objForm.Controls.Add($objLabel2)
$objTextBox2 = New-Object System.Windows.Forms.TextBox
$objTextBox2.Location = New-Object System.Drawing.Size(10,85)
$objTextBox2.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox2)
$objLabel3 = New-Object System.Windows.Forms.Label
$objLabel3.Location = New-Object System.Drawing.Size(10,105)
$objLabel3.Size = New-Object System.Drawing.Size(280,20)
$objLabel3.Text = "Object Filter"
$objForm.Controls.Add($objLabel3)
$objTextBox3 = New-Object System.Windows.Forms.TextBox
$objTextBox3.Location = New-Object System.Drawing.Size(10,125)
$objTextBox3.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox3)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
#Write-host "$x $x2 $x3"
if (($x -ne '') -and ($x2 -ne '') -and ($x3 -eq ''))
{GenerateSymbolsForDatabase -Server $x -Database $x2}
elseif (($x -ne '') -and ($x2 -ne '') -and ($x3 -ne ''))
{GenerateSymbolsForDatabase -Server $x -Database $x2 -ObjectFilter $x3}
else
{
[System.Windows.Forms.MessageBox]::Show("Please enter server and database. Object Filter is an option.")
Write-Error 'Please enter server and database. Object Filter is an option.'
}
}
GenerateSymbolsNAV
26. Januar 2018 11:15
Kowa hat geschrieben:Running C/SIDE and AL Side-by-Side
ImplicitType=Integer
12. Februar 2018 00:08
function GenerateSymbolsSQLMgt
{
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
function GenerateSymbolsForDatabase
{
[CmdletBinding()]param (
[String]$Server,
[String]$Database,
[String]$ObjectFilter)
$NAVFolder = 'C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client'
if ($ObjectFilter -ne '')
{$Command = """$NAVFolder\finsql.exe"" command=generatesymbolreference,servername=$Server,database=$Database,filter=$ObjectFilter"}
else
{$Command = """$NAVFolder\finsql.exe"" command=generatesymbolreference,servername=$Server,database=$Database"}
Write-host $Command
cmd /c $Command
}
function Get-DBList($server)
{
$script:DatabaseName = @{}
$srv = New-Object 'Microsoft.SqlServer.Management.Smo.Server' $server
[int]$i = 0
foreach($sqlDatabase in $srv.Databases)
{
$i++
#[string]$ts = "$i"
#write-host "$i,$sqlDatabase"
$DatabaseName.Add($i,$sqlDatabase)
}
foreach($databaseID in $databasename.keys)
{
$DBname = $databasename[$databaseID]
$DBname2 = $DBname.ToString()
$DBname2 = $DBname2.trimstart('[')
$DBname2 = $DBname2.trimend(']')
$IsSystemDatabase = ($DBname2 -like 'master') -or ($DBname2 -like 'tempdb') -or ($DBname2 -like 'model') -or ($DBname2 -like 'msdb') -or ($DBname2.startswith('ReportServer'))
if (-not $IsSystemDatabase)
{$comboBox1.Items.add($DBname2)}
}
}
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Generate Symbols"
$objForm.Size = New-Object System.Drawing.Size(300,300)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$script:x=$objTextBox.Text;$script:x2=$comboBox1.Text;$script:x3=$objTextBox3.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
{$objForm.Close()}})
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(95,220)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$script:x=$objTextBox.Text;$script:x2=$ComboBox1.Text;$script:x3=$objTextBox3.Text;$objForm.Close()})
$objForm.Controls.Add($OKButton)
$GetDBButton = New-Object System.Windows.Forms.Button
$GetDBButton.Location = New-Object System.Drawing.Size(5,220)
$GetDBButton.Size = New-Object System.Drawing.Size(95,23)
$GetDBButton.Text = "List databases"
$GetDBButton.Add_Click({
$script:x=$objTextBox.Text
if ($script:x -ne '') {Get-DBlist($script:x)} else
{[System.Windows.Forms.MessageBox]::Show("Please enter <servername>\<instance> in the server field.")}
})
$objForm.Controls.Add($GetDBButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(165,220)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
#############
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Server"
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objLabel2 = New-Object System.Windows.Forms.Label
$objLabel2.Location = New-Object System.Drawing.Size(10,65)
$objLabel2.Size = New-Object System.Drawing.Size(280,20)
$objLabel2.Text = "Database"
$objForm.Controls.Add($objLabel2)
$script:comboBox1 = New-Object System.Windows.Forms.ComboBox
$comboBox1.Location = New-Object System.Drawing.Size(10,85)
$comboBox1.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($comboBox1)
$objLabel3 = New-Object System.Windows.Forms.Label
$objLabel3.Location = New-Object System.Drawing.Size(10,105)
$objLabel3.Size = New-Object System.Drawing.Size(280,20)
$objLabel3.Text = "Object Filter"
$objForm.Controls.Add($objLabel3)
$objTextBox3 = New-Object System.Windows.Forms.TextBox
$objTextBox3.Location = New-Object System.Drawing.Size(10,125)
$objTextBox3.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox3)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
#Write-host "$x $x2 $x3"
if (($x -ne '') -and ($x2 -ne '') -and ($x3 -eq ''))
{GenerateSymbolsForDatabase -Server $x -Database $x2}
elseif (($x -ne '') -and ($x2 -ne '') -and ($x3 -ne ''))
{GenerateSymbolsForDatabase -Server $x -Database $x2 -ObjectFilter $x3}
else
{
[System.Windows.Forms.MessageBox]::Show("Please enter server and database. Object Filter is an option.")
Write-Error 'Please enter server and database. Object Filter is an option.'
}
}
GenerateSymbolsSQLMgt
26. Februar 2019 11:55