From: <si...@us...> - 2006-05-29 23:16:39
|
Revision: 881 Author: sickpig Date: 2006-05-29 16:16:22 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=881&view=rev Log Message: ----------- * fix typo (dlg message) * indent on check_user_connection * better way to check "no clear end" session Modified Paths: -------------- trunk/yaacs/cati.tcl trunk/yacati.tcl Modified: trunk/yaacs/cati.tcl =================================================================== --- trunk/yaacs/cati.tcl 2006-05-29 13:57:56 UTC (rev 880) +++ trunk/yaacs/cati.tcl 2006-05-29 23:16:22 UTC (rev 881) @@ -66,21 +66,21 @@ #@param pj - project's id #@param uid - user id #@result - 1 on black out ,0 otherwise -proc ::cati::crapOnExit {db start pj uid} { +proc ::cati::crapOnExit {db pj uid} { + ::yalog::debug "Trying to understand if there were black out during this session..." - ::yalog::debug "Trying to understand if there were black out during this session..." - set start [lindex [::yadb::getTuple $db "select now()::date + '$start'::interval " 0] 0] - set tbound [::bbtools::whichTurn $db $start $pj] - if {$tbound==-1} { - ::yalog::error "Error on ::bbtools::whichTurn" + set mSession [::yadb::getTuple $db "select min(session) from log.activitylog where uid=$uid and proj=$pj \ + and (start_work::date = now()::date or end_work::date = now()::date)" 0] + if {$mSession eq ""} { + ::yalog::error "not able to retrive user session number while checking fo no clear ending session" return -1 } set numS [::yadb::getNumTuples $db "select session from log.activitylog where proj=$pj \ - and end_work is null and start_work is not null and rid is null \ - and cod_com is null and uid=$uid and ouid = 0 and start_work > '[lindex $tbound 0]' "] + and end_work is null and start_work is not null and rid is null \ + and cod_com is null and uid=$uid and ouid = 0 and session >= $mSession"] set numE [::yadb::getNumTuples $db "select session from log.activitylog where proj=$pj \ - and start_work is null and end_work is not null and rid is null \ - and cod_com is null and uid=$uid and ouid = 0 and end_work > '[lindex $tbound 0]' "] + and start_work is null and end_work is not null and rid is null \ + and cod_com is null and uid=$uid and ouid = 0 and session >= $mSession"] if {$numE!=$numS} { ::yalog::debug "Pay attention black out Detected! " @@ -101,46 +101,46 @@ # @param db handler of the connection to the database "intervistatori" # @return 0 if <user> has no connection left open to YaaCs, 1 otherwise proc ::cati::check_user_connection {user project db} { - set blank " " + set blank " " - set chk "Select max(start_work) from log.activitylog where uid=$user and proj=$project and end_work is null" - set last_start [yadb::getTuple $db $chk 0] - - set last_start_date [lindex $last_start 0] - set last_start_time [lindex $last_start 1] - - set last_start_chk $last_start_date$blank$last_start_time - - # If there is no start of work then surely - # there is no open connection ;) - - if { ("$last_start_chk" == " ") } { - return 0 - } + set chk "Select max(start_work) from log.activitylog where uid=$user and proj=$project and end_work is null" + set last_start [yadb::getTuple $db $chk 0] - set chk_end "Select max(end_work) from log.activitylog where uid=$user and proj=$project and start_work is null" - set last_end [yadb::getTuple $db $chk_end 0] - - set last_end_date [lindex $last_end 0] - set last_end_time [lindex $last_end 1] - - set last_end_chk $last_end_date$blank$last_end_time - - # At this point we have at least a start! So if there - # are no end points there is an open connection. - - if { ("$last_end_chk" == " ") } { - return 1 - } - - set chk_last "select '$last_end_chk'::timestamp < '$last_start_chk'::timestamp" - set result [yadb::getTuple $db $chk_last 0] - - if {[lindex $result 0] == "t"} { - return 1 - } - - return 0 + set last_start_date [lindex $last_start 0] + set last_start_time [lindex $last_start 1] + + set last_start_chk $last_start_date$blank$last_start_time + + # If there is no start of work then surely + # there is no open connection ;) + + if { ("$last_start_chk" == " ") } { + return 0 + } + + set chk_end "Select max(end_work) from log.activitylog where uid=$user and proj=$project and start_work is null" + set last_end [yadb::getTuple $db $chk_end 0] + + set last_end_date [lindex $last_end 0] + set last_end_time [lindex $last_end 1] + + set last_end_chk $last_end_date$blank$last_end_time + + # At this point we have at least a start! So if there + # are no end points there is an open connection. + + if { ("$last_end_chk" == " ") } { + return 1 + } + + set chk_last "select '$last_end_chk'::timestamp < '$last_start_chk'::timestamp" + set result [yadb::getTuple $db $chk_last 0] + + if {[lindex $result 0] == "t"} { + return 1 + } + + return 0 } # Managing exit without saving scenario (sql side) Modified: trunk/yacati.tcl =================================================================== --- trunk/yacati.tcl 2006-05-29 13:57:56 UTC (rev 880) +++ trunk/yacati.tcl 2006-05-29 23:16:22 UTC (rev 881) @@ -1365,13 +1365,13 @@ if {[array size ::yacati::user]==0} {return [::yatk_dlg::error [mc "Your account is not present on the system, please contact the system administrator!"]]} if {[::bbtools::checkBlock $db $::yacati::survey(proj) $::yacati::user(uid)] > 0 && !$::yacati::recruit} { - ::yalog::error "Error, are they trying to avoid pause block?" + ::yalog::error "Error, are they trying to avoid pause block?" ::yatk_dlg::error [mc "Error, are you trying to avoid pause block?\n\nPlease call the administrator!!!"] return } if {[::cati::check_user_connection $yacati::user(uid) $yacati::survey(proj) $db] == 1 && !$yacati::recruit} { - set tmp [yatk_dlg::continue [mc "Warning, your account is aleady connected, please contact the system administrator."]] + set tmp [::yatk_dlg::continue [mc "Warning, your account is already connected, please contact the system administrator."]] if {$tmp == 1} { exit } @@ -1959,8 +1959,13 @@ variable ::yacati::seconds 0 set msgPause "No" - - if {[::cati::crapOnExit $db [lindex $reslist 1] $idpj $uid]} { + set crap [::cati::crapOnExit $db $idpj $uid] + if {$crap == -1} { + ::yacati::error "crapOnExit decide if the session is clear or not" + ::yatk_dlg::error "Unable to determine if this is a clear session or not, call the admin" + } + + if {$crap && $crap != -1} { ::yalog::debug "A non clear end session detected" set ::yacati::boMsg [mc "Something wrong happens during your session.Please write it down on your WORK FORM"] } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |