Changeset 243
- Timestamp:
- 12/15/06 15:02:38 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/message-handling-refactor-branch/bin/run-command-center.rb
r231 r243 98 98 end 99 99 100 def directive_dynamic_menu cpas_command, previous = nil, output = nil, number_directives = 1100 def directive_dynamic_menu party_name, cpas_command, previous = nil, output = nil, number_directives = 1 101 101 puts " HefeWeizen Main Directive Dynamic Menu" 102 102 puts "-------------------------------------------------------------------------------" 103 103 puts "D - Directive Menu S - Show Statistics T - Top program Q - Quit" 104 puts " PARTY :: #{party_name}" 104 105 puts "" 105 106 puts "N - set number of directives to copy. currently: #{number_directives}" … … 108 109 cpas_command.sort.each{ | entry | 109 110 command = entry[1] 110 # } ||| #{short_info_structure command[1]}"111 # } ||| #{short_info_structure command[1]}" 111 112 puts sprintf( "%1$*2$s %3$s", command[0], -40, short_info_structure(command[1])) 112 113 } … … 142 143 end 143 144 144 def work_directive_dynamic_menu cpas_info, number_directives145 def work_directive_dynamic_menu party_name, cpas_info, number_directives 145 146 cpas_command = get_cpas_command cpas_info 146 147 number_directives = number_directives 147 directive_dynamic_menu cpas_command, nil, nil, number_directives148 directive_dynamic_menu party_name, cpas_command, nil, nil, number_directives 148 149 while true do 149 150 output = nil … … 188 189 file << directive 189 190 file.close 190 command = "mv #{file_name} /var/spool/hefeweizen/ coronation/outgoing/directives"191 command = "mv #{file_name} /var/spool/hefeweizen/#{party_name.downcase}/outgoing/directives" 191 192 system command 192 193 output = command … … 195 196 196 197 system "clear" 197 directive_dynamic_menu cpas_command, input, output, number_directives198 directive_dynamic_menu party_name, cpas_command, input, output, number_directives 198 199 end 199 200 end … … 235 236 return 236 237 when "D" 238 239 party_name, cpa_path = get_party_and_cpa 237 240 system "clear" 238 241 239 cpas = Hash.new 240 cpa_filename = "#{@config['CONFIG_DIR']}/#{@config['SYSTEMS_DIR']}/Coronation/trading_agreements/cpa_test.xml" 241 242 # require "#{@config['LIB_DIR']}/hefeweizen_library_cpa" 242 cpa_filename = cpa_path 243 244 # require "#{@config['LIB_DIR']}/hefeweizen_library_cpa" 243 245 require "../src/hefeweizen_library_cpa" 244 246 cpa = HefeWeizen::HefeWeizenLibrary::CPA.create(cpa_filename, @config) 245 party_name = "Coronation" 246 party_identities = [ { :type => "string", :id => "coronation" }, 247 { :type => "urn:li.coronation.b2b", :id => "coronation_test_system"} ] 247 248 party_identities = nil 249 if party_name == "Coronation" then 250 party_identities = [ { :type => "string", :id => "coronation" }, 251 { :type => "urn:li.coronation.b2b", :id => "coronation_test_system"} ] 252 else 253 party_identities = [ { :type => "string", :id => "gnaraloo" }, 254 { :type => "urn:li.gnaraloo.b2b", :id => "gnaraloo_test_system"} ] 255 end 248 256 249 257 cpas_info = [cpa.setup_all_ebMS_header_infos( cpa.id, party_name, party_identities )] 250 number_directives = work_directive_dynamic_menu cpas_info, number_directives258 number_directives = work_directive_dynamic_menu party_name, cpas_info, number_directives 251 259 when "S" 252 260 output = %x(sh ./run-statistics.sh) … … 294 302 end 295 303 304 305 def get_party_and_cpa 306 puts "Getting the cpa and selecting the party." 307 puts "Select organisation:" 308 parties = Dir.glob "#{@config['CONFIG_DIR']}/#{@config['SYSTEMS_DIR']}/*" 309 party_selection = Hash.new 310 counter = 1 311 parties.each{ | party | 312 party_selection[counter] = party 313 puts "#{counter.to_s}. #{File.basename party}" 314 counter += 1 315 } 316 selected = false 317 party_path = nil 318 while selected == false do 319 puts "Your selection: " 320 selected_organisation = gets 321 if party_selection.has_key? selected_organisation.to_i then 322 selected = true 323 party_path = party_selection[selected_organisation.to_i] 324 else 325 puts "#{selected_organisation} is an invalid entry. Please select again." 326 end 327 end 328 329 party_name = File.basename party_path 330 331 puts "Select CPA:" 332 cpas = Hash.new 333 cpa_path = nil 334 counter = 1 335 available_cpas = Dir.glob "#{party_path}/trading_agreements/*" 336 available_cpas.each{ | cpa | 337 cpas[counter] = cpa 338 puts "#{counter.to_s}. #{File.basename cpa}" 339 counter += 1 340 } 341 selected = false 342 while selected == false do 343 puts "Your selection: " 344 selected_cpa = gets 345 if cpas.has_key? selected_cpa.to_i then 346 selected = true 347 cpa_path = cpas[selected_cpa.to_i] 348 else 349 puts "#{selected_cpa} is invalid. Please select again." 350 end 351 end 352 353 return party_name, cpa_path 354 end 296 355 297 356 def main_menu previous = nil, output = nil
