Добавлена функция GetWorkTreeItems

This commit is contained in:
Sergey Kalinin 2018-06-25 08:41:32 +03:00
parent c8151f3b16
commit 234ad208fb

View File

@ -277,6 +277,26 @@ proc SaveMainServer {host port} {
return "$host:$port"
}
proc GetWorkTreeItems {par} {
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
#puts ">$work_tree_id >$work_tree_values"
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq $par } {
set item_id [lindex $work_tree_values $i]
set tree .frm_work.tree_work
}
incr i
}
return $item_id
}
namespace eval Run {} {}
# Получение данных по кластерам
@ -1319,20 +1339,7 @@ proc Edit::cluster {tree host values} {
}
}
proc Edit::infobases {tree host values} {
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "infobase" } {
set infobase [lindex $work_tree_values $i]
}
incr i
}
set infobase [GetWorkTreeItems "infobase"]
if {[info exists infobase] == 0 || $infobase eq ""} {
return
}
@ -1441,20 +1448,7 @@ proc Edit::infobase {tree host values} {
}
}
proc Edit::servers {tree host values} {
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "server" } {
set work_server [lindex $work_tree_values $i]
}
incr i
}
set work_server [GetWorkTreeItems "server"]
if {[info exists work_server] == 0 || $work_server eq ""} {
return
}
@ -1509,21 +1503,8 @@ proc Edit::rule {tree host values} {
} else {
set auth ""
}
set rule [GetWorkTreeItems "rule"]
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "rule" } {
set rule [lindex $work_tree_values $i]
}
incr i
}
if {[info exists rule] == 0 || $rule eq ""} {
return
}
@ -1602,24 +1583,7 @@ proc Del::admin {tree host values} {
}
}
proc Del::admins {tree host values} {
global active_cluster
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
#puts ">$work_tree_id >$work_tree_values"
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "name" } {
set admin_id [lindex $work_tree_values $i]
set tree .frm_work.tree_work
}
incr i
}
Del::admin $tree $host $admin_id
Del::admin $tree $host [GetWorkTreeItems "name"]
}
proc Del::agent_admin {tree host values} {
@ -1645,24 +1609,7 @@ proc Del::agent_admin {tree host values} {
}
proc Del::agent_admins {tree host values} {
global active_cluster
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
#puts ">$work_tree_id >$work_tree_values"
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "name" } {
set admin_id [lindex $work_tree_values $i]
set tree .frm_work.tree_work
}
incr i
}
Del::agent_admin $tree $host $admin_id
Del::agent_admin $tree $host [GetWorkTreeItems "name"]
}
@ -1673,7 +1620,6 @@ proc Del::work_server {tree host values} {
} else {
set auth ""
}
set answer [tk_messageBox -message "Удалить рабочий сервер $values?" \
-icon question -type yesno ]
switch -- $answer {
@ -1685,26 +1631,11 @@ proc Del::work_server {tree host values} {
no {return}
}
}
proc Del::servers {tree host values} {
global active_cluster
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
#puts ">$work_tree_id >$work_tree_values"
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "server" } {
set work_server_id [lindex $work_tree_values $i]
set tree .frm_work.tree_work
}
incr i
}
Del::work_server $tree $host $work_server_id
Del::work_server $tree $host [GetWorkTreeItems "server"]
}
proc Del::cluster {tree host values} {
global agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
@ -1712,7 +1643,6 @@ proc Del::cluster {tree host values} {
} else {
set auth ""
}
set answer [tk_messageBox -message "Удалить кластер $values?" \
-icon question -type yesno ]
switch -- $answer {
@ -1743,27 +1673,9 @@ proc Del::infobase {tree host values} {
}
}
proc Del::infobases {tree host values} {
global active_cluster
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
#puts ">$work_tree_id >$work_tree_values"
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "infobase" } {
set values [lindex $work_tree_values $i]
set tree .frm_work.tree_work
}
incr i
}
#puts "$tree $host $values"
Del::infobase $tree $host $values
Del::infobase $tree $host [GetWorkTreeItems "infobase"]
}
proc Del::connections {tree host values} {
global active_cluster agent_user agent_pwd cluster_user cluster_pwd auth
if {$cluster_user ne "" && $cluster_pwd ne ""} {
@ -1772,26 +1684,8 @@ proc Del::connections {tree host values} {
set auth ""
}
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
#puts ">$work_tree_id >$work_tree_values"
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "connection" } {
set connection_id [lindex $work_tree_values $i]
}
if {$l eq "process" } {
set process_id [lindex $work_tree_values $i]
}
incr i
}
#puts "$connection_id $process_id"
set connection_id [GetWorkTreeItems "connection"]
set process_id [GetWorkTreeItems "process"]
set answer [tk_messageBox -message "Удалить соединение $connection_id?" \
-icon question -type yesno ]
@ -1812,20 +1706,7 @@ proc Del::sessions {tree host values} {
} else {
set auth ""
}
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
set id [.frm_tree.tree selection]
set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "session" } {
set session_id [lindex $work_tree_values $i]
}
incr i
}
set session_id [GetWorkTreeItems "session"]
set answer [tk_messageBox -message "Прервать сессию $session_id?" \
-icon question -type yesno ]
@ -1847,21 +1728,8 @@ proc Del::rule {tree host values} {
} else {
set auth ""
}
set rule_id [GetWorkTreeItems "rule"]
set work_tree_id [.frm_work.tree_work selection]
set work_tree_values [.frm_work.tree_work item $work_tree_id -values]
set id [.frm_tree.tree selection]
#set values [.frm_tree.tree item $id -values]
set key [lindex [split $id "::"] 0]
set column_list [.frm_work.tree_work cget -columns]
set i 0
# проверка соответсвия колонки в таблице и ключа в дереве
foreach l $column_list {
if {$l eq "rule" } {
set rule_id [lindex $work_tree_values $i]
}
incr i
}
if {[info exists rule_id] == 0 || $rule_id eq ""} {
return
}