Переделана одновременная работа с различными платформами 1С:Предприятия
Изменён формат файла конфигурации (старый формат также поддерживается). В связи с этим, изменены процедуры добавления, редактирования и удаления основного сервера.
This commit is contained in:
parent
cc4130f0a4
commit
55d82ca7e7
|
@ -30,12 +30,27 @@ proc TreePress {tree} {
|
|||
}
|
||||
|
||||
proc SetGlobalVarFromTreeItems {tree id} {
|
||||
global host server active_cluster infobase profile_name
|
||||
global host server active_cluster infobase profile_name dir rac_cmd_for_host rac_cmd
|
||||
set parent [$tree parent $id]
|
||||
set values [$tree item $id -values]
|
||||
set key [lindex [split $id "::"] 0]
|
||||
switch -- $key {
|
||||
server {set host $values}
|
||||
server {
|
||||
set host $values
|
||||
set orig_file [open [file join $dir(work) 1c_srv.cfg] "r"]
|
||||
while {[gets $orig_file line] >=0 } {
|
||||
if [string match "$host*" $line] {
|
||||
set path_to_rac [string trim [lindex [split $line ","] 1]]
|
||||
if {$path_to_rac eq ""} {
|
||||
set rac_cmd_for_host($host) "$rac_cmd"
|
||||
} else {
|
||||
set rac_cmd_for_host($host) $path_to_rac
|
||||
set rac_cmd $path_to_rac
|
||||
}
|
||||
}
|
||||
}
|
||||
close $orig_file
|
||||
}
|
||||
work_server {set server $values}
|
||||
cluster {set active_cluster $values}
|
||||
infobase {set infobase $values}
|
||||
|
@ -74,11 +89,6 @@ proc RunCommand {par} {
|
|||
global dir rac_cmd cluster work_list_row_count \
|
||||
agent_user agent_pwd cluster_user cluster_pwd server_platform
|
||||
set host [lindex [split $par " "] end]
|
||||
if [info exists server_platform($host)] {
|
||||
set rac_cmd $server_platform($host)
|
||||
puts "host - $host"
|
||||
}
|
||||
puts "$rac_cmd $par"
|
||||
set work_list_row_count 0
|
||||
|
||||
set pipe [open "|\"$rac_cmd\" $par" "r"]
|
||||
|
@ -285,7 +295,8 @@ proc SaveMainServer {host port path_to_rac} {
|
|||
set rac_cmd $path_to_rac
|
||||
}
|
||||
set file [open [file join $dir(work) 1c_srv.cfg] "a+"]
|
||||
puts $file "$host:$port $rac_cmd"
|
||||
puts "$host:$port $rac_cmd"
|
||||
puts $file "$host:$port,$rac_cmd"
|
||||
close $file
|
||||
return "$host:$port"
|
||||
}
|
||||
|
@ -332,7 +343,10 @@ namespace eval Run {} {}
|
|||
# Получение данных по кластерам
|
||||
|
||||
proc Run::server {tree host values} {
|
||||
|
||||
global rac_cmd_for_host rac_cmd
|
||||
if {[info exists rac_cmd_for_host($host)] == 1 && $rac_cmd_for_host($host) ne "" } {
|
||||
set rac_cmd $rac_cmd_for_host($host)
|
||||
}
|
||||
set lst [RunCommand "cluster list $host"]
|
||||
if {$lst eq ""} {return}
|
||||
set l [lindex $lst 0]
|
||||
|
@ -865,7 +879,7 @@ proc Add::admin {tree host value} {
|
|||
}
|
||||
|
||||
proc Add::server {} {
|
||||
global default
|
||||
global default rac_cmd_for_host
|
||||
set frm [AddToplevel [::msgcat::mc "Main server"] server_grey_64]
|
||||
|
||||
ttk::label $frm.lbl_host -text [::msgcat::mc "Address"]
|
||||
|
@ -886,6 +900,7 @@ proc Add::server {} {
|
|||
#set frm_btn [frame .add.frm_btn -border 0]
|
||||
.add.frm_btn.btn_ok configure -command {
|
||||
set host [SaveMainServer [.add.frm.ent_host get] [.add.frm.ent_port get] [.add.frm.ent_path_to_rac get]]
|
||||
set rac_cmd_for_host($host) [.add.frm.ent_path_to_rac get]
|
||||
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
|
||||
destroy .add
|
||||
return $host
|
||||
|
@ -1677,27 +1692,44 @@ proc Edit::managers {tree host values} {
|
|||
}
|
||||
|
||||
proc Edit::server {tree host value} {
|
||||
global dir prev_address
|
||||
global dir prev_address rac_cmd rac_cmd_for_host
|
||||
|
||||
set frm [Add::server]
|
||||
wm title .add [::msgcat::mc "Edit record"]
|
||||
set lst [split $value ":"]
|
||||
set prev_address $value
|
||||
set orig_file [open [file join $dir(work) 1c_srv.cfg] "r"]
|
||||
while {[gets $orig_file line] >=0 } {
|
||||
if [string match "$prev_address*" $line] {
|
||||
set path_to_rac [string trim [lindex [split $line ","] 1]]
|
||||
if {$path_to_rac eq ""} {
|
||||
set path_to_rac "$rac_cmd"
|
||||
}
|
||||
}
|
||||
}
|
||||
close $orig_file
|
||||
.add.frm.ent_host delete 0 end
|
||||
.add.frm.ent_port delete 0 end
|
||||
.add.frm.ent_path_to_rac delete 0 end
|
||||
.add.frm.ent_host insert end [lindex $lst 0]
|
||||
.add.frm.ent_port insert end [lindex $lst 1]
|
||||
.add.frm.ent_path_to_rac insert end $path_to_rac
|
||||
.add.frm_btn.btn_ok configure -command {
|
||||
set host "[.add.frm.ent_host get]:[.add.frm.ent_port get]"
|
||||
#set rac_cmd [.add.frm.ent_path_to_rac get]
|
||||
set rac_cmd_for_host($host) [.add.frm.ent_path_to_rac get]
|
||||
.frm_tree.tree delete "server::$prev_address"
|
||||
.frm_work.tree_work delete [ .frm_work.tree_work children {}]
|
||||
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
|
||||
if [file exists [file join $dir(work) 1c_srv.cfg.bak]] {
|
||||
file delete [file join $dir(work) 1c_srv.cfg.bak]
|
||||
}
|
||||
file copy [file join $dir(work) 1c_srv.cfg] [file join $dir(work) 1c_srv.cfg.bak]
|
||||
set orig_file [open [file join $dir(work) 1c_srv.cfg.bak] "r"]
|
||||
set file [open [file join $dir(work) 1c_srv.cfg] "w"]
|
||||
while {[gets $orig_file line] >=0 } {
|
||||
if { $line eq "$prev_address"} {
|
||||
puts $file $host
|
||||
if [string match "$prev_address*" $line] {
|
||||
puts $file "$host,$rac_cmd_for_host($host)"
|
||||
} else {
|
||||
puts $file $line
|
||||
}
|
||||
|
@ -1705,7 +1737,7 @@ proc Edit::server {tree host value} {
|
|||
close $file
|
||||
close $orig_file
|
||||
#return "$host:$port"
|
||||
file delete [file join $dir(work) rac_gui .cfg.bak]
|
||||
file delete [file join $dir(work) 1c_srv.cfg.bak]
|
||||
destroy .add
|
||||
return $host
|
||||
}
|
||||
|
@ -2288,7 +2320,7 @@ proc Del::server {tree host values} {
|
|||
set orig_file [open [file join $dir(work) 1c_srv.cfg.bak] "r"]
|
||||
set file [open [file join $dir(work) 1c_srv.cfg] "w"]
|
||||
while {[gets $orig_file line] >=0 } {
|
||||
if { $line ne "" && $line ne "$values"} {
|
||||
if { $line ne "" && [string match "$values*" $line] == 0} {
|
||||
puts $file $line
|
||||
}
|
||||
}
|
||||
|
@ -2392,3 +2424,4 @@ proc Del::inet {tree host profile_name} {
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
19
rac_gui.tcl
19
rac_gui.tcl
|
@ -78,12 +78,12 @@ source [file join $dir(work) rac_gui.cfg]
|
|||
if [file exists [file join $dir(work) 1c_srv.cfg]] {
|
||||
set f [open [file join $dir(work) 1c_srv.cfg] "RDONLY"]
|
||||
while {[gets $f line] >=0} {
|
||||
set l [split $line " "]
|
||||
set line [lindex $l 0]
|
||||
set l [split $line ","]
|
||||
set host [lindex $l 0]
|
||||
if {[lindex $l 1] ne ""} {
|
||||
set server_platform($line) [lindex $l 1]
|
||||
set rac_cmd_for_host($host) [lindex $l 1]
|
||||
}
|
||||
.frm_tree.tree insert {} end -id "server::$line" -text "$line" -values "$line"
|
||||
.frm_tree.tree insert {} end -id "server::$host" -text "$host" -values "$host"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,14 +106,3 @@ if [file exists [file join $dir(work) 1c_srv.cfg]] {
|
|||
# #option add *Frame.Background $editor(bg) interactive
|
||||
# option add *ScrollableFrame.Background $editor(bg) interactive
|
||||
# option add *ScrolledWindow.Background $editor(bg) interactive
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user