inplace upadating
This commit is contained in:
parent
cefbb62994
commit
ded5dc3b8d
|
@ -258,15 +258,15 @@ proc rsvscan {} {
|
|||
|
||||
set ecrids [split $szEventToRecord "|"]
|
||||
set enum -1
|
||||
puts "Svcid Start End Evtid CRID"
|
||||
puts " Svcid Start End Evtid CRID"
|
||||
foreach aul $auls {
|
||||
lassign $aul service_id start end event_id
|
||||
incr enum
|
||||
set ecrid [lindex $ecrids $enum]
|
||||
puts "$service_id \
|
||||
puts "[format "%7d" $service_id] \
|
||||
$start [clock format $start -format "%d/%m/%Y %H:%M"] \
|
||||
$end [clock format $end -format "%d/%m/%Y %H:%M"] \
|
||||
$event_id \
|
||||
[format "%7d" $event_id] \
|
||||
$ecrid"
|
||||
}
|
||||
puts "========================================================"
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
source /mod/webif/lib/setup
|
||||
require rsv.class epg.class system.class
|
||||
|
||||
|
||||
proc log {msg {level 1}} {
|
||||
if {$level > $::loglevel} return
|
||||
puts $::logfd "[\
|
||||
|
@ -13,6 +14,10 @@ proc log {msg {level 1}} {
|
|||
flush $::logfd
|
||||
}
|
||||
|
||||
# let's mess with the internals - needs to be moved to rsv.class
|
||||
rsv method set {ivName val} {
|
||||
set $ivName $val
|
||||
}
|
||||
|
||||
# Parse command options and apply defaults
|
||||
proc checkopts {argv} {
|
||||
|
@ -195,7 +200,7 @@ proc rsvscan {} {
|
|||
set ended 0
|
||||
}
|
||||
|
||||
set dresv "$ds [clock format $d -format {%H:%M}] === $name === [$resv channel_name]"
|
||||
set dresv "$ds [clock format $d -format {%H:%M}] === slot [$resv get ulslot] === $name === [$resv channel_name]"
|
||||
|
||||
if {!$ended} {
|
||||
log "Reservation - $dresv" 2
|
||||
|
@ -220,7 +225,7 @@ proc rsvscan {} {
|
|||
epg dbfetch dump -service $svc -event $event_id -sort ""] 0]
|
||||
log "$service_id $start $end $svc $event_id $record $ecrid $epgcrid" 3
|
||||
if {$record==""} {
|
||||
set deps "[clock format $start -format {%a %d %b %Y %H:%M}] [clock format $dur -format {%H:%M}] === $name === [$resv channel_name]"
|
||||
set deps "[clock format $start -format {%a %d %b %Y %H:%M}] [clock format $dur -format {%H:%M}] === slot [$resv get ulslot] === $name === [$resv channel_name]"
|
||||
log "+++ No matching epg entry ++++ $deps" 0
|
||||
if {$::opts(nomissepg)} {
|
||||
log "-nomissepg - Not checking for alternate" 1
|
||||
|
@ -228,7 +233,7 @@ proc rsvscan {} {
|
|||
}
|
||||
# look for an alternate showing
|
||||
|
||||
set others [epg dbfetch dump -crid $epgcrid -nocase 1 -sort "start" debug 1]
|
||||
set others [epg dbfetch dump -crid $epgcrid -nocase 1 -sort "start" ]
|
||||
#param "collate nocase"
|
||||
log "$ecrid $epgcrid $ecrids $others" 3
|
||||
set other [findAlternate $resv $others $start $def 1]
|
||||
|
@ -240,6 +245,11 @@ proc rsvscan {} {
|
|||
set ocname [$other get channel_name]
|
||||
set dother "[clock format $ostart -format {%a %d %b %Y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
# attempt to schedule the alternate
|
||||
if {$::opts(inplace)} {
|
||||
update_event $resv $other $epsd $dother "Event Changed"
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
if {[schedule $other $dother "Event Changed"]} {
|
||||
if {![$resv isseries]} {
|
||||
# delete single recording
|
||||
|
@ -250,7 +260,7 @@ proc rsvscan {} {
|
|||
#refresh $resv $deps
|
||||
}
|
||||
conflict-list
|
||||
break
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +269,7 @@ proc rsvscan {} {
|
|||
|
||||
set epgname [$record get name]
|
||||
set def $svcdef([$record get channel_hsvc])
|
||||
set deps "[clock format $start -format {%a %d %b %Y %H:%M}] [clock format $dur -format {%H:%M}] === $epgname === [$record get channel_name]"
|
||||
set deps "[clock format $start -format {%a %d %b %Y %H:%M}] [clock format $dur -format {%H:%M}] === slot [$resv get ulslot] === $epgname === [$record get channel_name]"
|
||||
|
||||
log "Episode $deps" 2
|
||||
set ok 1
|
||||
|
@ -281,7 +291,8 @@ proc rsvscan {} {
|
|||
if {"[$resv get ulslot]$end" in $conflicts} {
|
||||
set ok 0
|
||||
log "+++ Confict exists +++ $deps" 1
|
||||
set others [$record othertimes]
|
||||
#set others [$record othertimes]
|
||||
set others [epg dbfetch dump -crid $epgcrid -nocase 1 -sort "start" debug 1]
|
||||
set other [findAlternate $resv $others $start $def 0]
|
||||
if {$other != ""} {
|
||||
set ostart [$other get start]
|
||||
|
@ -292,16 +303,21 @@ proc rsvscan {} {
|
|||
set dother "[clock format $ostart -format {%a %d %b %Y %H:%M}] [clock format $odur -format {%H:%M}] === $oname === $ocname"
|
||||
|
||||
# attempt to schedule the alternate
|
||||
if {$::opts(inplace)} {
|
||||
update_event $resv $other $epsd $dother "Confict resolution"
|
||||
conflict-list
|
||||
continue
|
||||
}
|
||||
if {[schedule $other $dother "Confict resolution"]} {
|
||||
if {![$resv isseries]} {
|
||||
# delete single recording
|
||||
cancel $resv $deps "Conflict resolution"
|
||||
} else {
|
||||
# skip conflicted epidode
|
||||
skip $resv $svc $resv_id $deps "Conflict resolution"
|
||||
skip $resv $svc $event_id $deps "Conflict resolution"
|
||||
}
|
||||
conflict-list
|
||||
break
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,6 +490,71 @@ proc replaceskip {resv skipcrid desc {reason ""}} {
|
|||
}
|
||||
}
|
||||
|
||||
# Update reservation with new event details
|
||||
proc update_event {resv other origaul desc {reason ""}} {
|
||||
if {$::opts(test)} {
|
||||
log "*** Test mode =Updated *** $desc === $reason" 0
|
||||
#return 1
|
||||
}
|
||||
set curauls [$resv aul]
|
||||
set ecrids [split [$resv get szEventToRecord] "|"]
|
||||
set hsvc [$other get channel_hsvc]
|
||||
set start [$other get start]
|
||||
set end [$other end]
|
||||
set evtid [$other get event_id]
|
||||
set othaul [list $hsvc $start $end $evtid]
|
||||
set othcrid [string toupper "1[$other get channel_crid][$other get event_crid]"]
|
||||
set newaul {}
|
||||
set newevnts ""
|
||||
puts "$origaul-- $othaul -- $curauls $ecrids "
|
||||
set insert 0
|
||||
|
||||
# rebuild aul and events list with new event in correct order
|
||||
lmap aul $curauls ecrid $ecrids {
|
||||
#puts "$aul $ecrid"
|
||||
if {$aul == $origaul} {continue; #remove current entry}
|
||||
if {$aul == ""} {continue; #null entry}
|
||||
if {!$insert && $start <= [lindex $aul 1]} {
|
||||
set insert 1
|
||||
lappend newaul $othaul
|
||||
append newevnts "$othcrid|"
|
||||
}
|
||||
lappend newaul $aul
|
||||
append newevnts "$ecrid|"
|
||||
}
|
||||
# add to end if not inserted
|
||||
if {!$insert} {
|
||||
set insert 1
|
||||
lappend newaul $othaul
|
||||
append newevnts "$othcrid|"
|
||||
}
|
||||
puts "$newevnts -- $newaul"
|
||||
|
||||
# update header with next event
|
||||
lassign [lindex $newaul 0] service_id start end event_id
|
||||
#$resv set hsvc $service_id
|
||||
$resv set nsttime $start
|
||||
$resv set nduration $($end-$start)
|
||||
$resv set usevtid $event_id
|
||||
$resv set ucVolume "$service_id:$event_id:$start"
|
||||
|
||||
if {[catch {
|
||||
$resv clear_ulslot
|
||||
$resv set action 5
|
||||
$resv setaul [$resv buildaul $newaul]
|
||||
$resv set szEventToRecord $newevnts
|
||||
$resv insert
|
||||
} msg]} {
|
||||
log "+++ Error encountered while updating: $msg ++++ $desc === $reason" 0
|
||||
return 0
|
||||
} else {
|
||||
log "*** Successfully Updated *** $desc === $reason" 0
|
||||
system restartpending
|
||||
#rsv commit
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------------------------------------
|
||||
# Start of mainline
|
||||
|
||||
|
|
Loading…
Reference in New Issue