# ------------------------------------------------------------ # Copyright (c) 2003-2020 # Q.W.Page Associates Inc. # www.qwpage.com # All rights reserved. # ------------------------------------------------------------ ::namespace eval ::qw::registrations {}; ::set ::qw::registrations::registration_list ""; ::proc ::qw::registrations::registration_list_get {} { /* { Note registration_list is actually a sargs but we can treat it like a list of name/value pairs. base64 on file size 673k base64 17ms decrypt 170ms base64 off file size 491k decrypt 167ms */ } ::set rwb1_debug 0; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.0";} ::if {[::sargs::size $::qw::registrations::registration_list]!=0} { ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.0.0";} ::return $::qw::registrations::registration_list; } ::if {![::file exists [::file join $::qw_program_path system registrations customer_support_registrations.qw_tcl]]} { ::qw::bug 314120200328144010 "[::qw::procname] - can't find file."; # 2.34.5 eliminated file name from error message } ::set Data [::qw::fileutil::file_read .path [::file join $::qw_program_path system registrations customer_support_registrations.qw_tcl] .translation binary]; ::if {$::qw::control(qw_tcl_is_base64)} { ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.1";} ::qw::profile::begin ::qw::odb::load_registrations-base64; ::set Data [::qw::base64::decode .data $Data]; ::qw::profile::end ::qw::odb::load_registrations-base64; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.2";} } ::if {$::qw::control(qw_tcl_is_encrypted)} { ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.3";} ::qw::profile::begin ::qw::odb::load_registrations-decrypt; ::set Data [::qw::aes::decrypt .key "qw_tcl_key_16180339" .cipher_text $Data]; ::qw::profile::end ::qw::odb::load_registrations-decrypt; if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.4";} } ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::odb::registrations::registration_list_get,1000.5";} ::set ::qw::registrations::registration_list $Data; ::return $Data; } ::set ::qw::registrations::record ""; ::proc ::qw::registrations::record_get {sargs} { /* { Gets the customer support registration record assoicated with a serial number. This is the record exported from the crm. Loads the customer support registrion list and finds the record in that list. If .serial is empty then the serial is taken from the current installation. Usage: ::set Registration [[::qw::system] customer_support_registration_record_get ?.serial $Serial?]; #2.34.5 5 moved this method from qw_system2.cpp 2.28.0 If .serial is empty then the serial is taken from the current installation. 2.28.0 Add _customer_support_registration_record to cache the record. Help about and auto_update need it so don;t want to have to read entire customer cupport file every time. This method is called when we boot the application or when we are installing. Its only job is to return the customer support registration record (a structure). The records are incorporated into the exe from the NewViews customer support database when the exe is built. The record to return is found using the serial number extracted from the installation and provided in the sargs. If the record is not found then empty is returned. At the time of this writing (206) a record should contain the following fields: .serial { .nv2 INTERNAL-BENN-1 } .nv2_upgrades_expiry_date 20050525 .registration_date 20050425 As at 2.28 (but introduced much earlier): .0 { .nv2_serial_number NV2-R00563-3 .nv2_upgrades_expiry_date 20130125 .customer_number 0006033 } .1 { .nv2_serial_number NV2-A01793-4 .nv2_upgrades_expiry_date 20041231 .customer_number 8000365 } ... */ } ::set rwb1_debug 0; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.0,sargs==\n$sargs";} ::if {[::sargs::size $::qw::registrations::record]!=0} { ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.1";} ::return $::qw::registrations::record; } ::set ProgramSerial [::string tolower [::sargs::get $sargs .serial]]; ::if {$ProgramSerial eq ""} { ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.2";} ::set ProgramSerial [[::qw::system] cpp_serial_get]; } ::set ProgramSerial [::string tolower $ProgramSerial]; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.3,ProgramSerial==$ProgramSerial";} ::set RecordList [::qw::registrations::registration_list_get]; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.4.0,length==[::llength $RecordList]";} ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.4.1,string length==[::string length $RecordList]";} ::foreach {Field Record} $RecordList { ::if {$ProgramSerial eq [::string tolower [::sargs::get $Record .nv2_serial_number]]} { ::set $::qw::registrations::record $Record; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.5,record==\n[::sargs::format $Record]";} ::return $Record; } } ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::registrations::record_get,1000.6";} ::return ""; }