123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- $PBExportHeader$n_dw2xls_progress.sru
- forward
- global type n_dw2xls_progress from nonvisualobject
- end type
- end forward
- global type n_dw2xls_progress from nonvisualobject
- end type
- global n_dw2xls_progress n_dw2xls_progress
- type variables
- Boolean ib_Cancel
- Boolean ib_OpenExcelFile
- Boolean ib_WritePictures
- Boolean ib_WriteBKColor=TRUE
- Boolean ib_FreezeTitles=TRUE
- Boolean ib_ProcessSparse=TRUE
- Int ii_Result
- Long il_Progress_Max
- Long il_Progress_Total
- Long il_Progress, li_Step_Count
- Long il_PriorStep
- Int ii_BeginPosition
- DateTime idt_start
- DateTime idt_last
- Boolean ib_CalcRemainTimes =False
- PowerObject inv_Requestor
- n_dw2xls_Resource inv_Res
- w_dw2xls_Progress iw_progress
- HProgressBar iu_hpb
- end variables
- forward prototypes
- public subroutine of_stepit ()
- public subroutine of_close_progress ()
- public subroutine of_intial_progress (readonly long ai_progresstal, integer ai_remain)
- public subroutine of_progress (readonly long al_value)
- public function LONG of_secondsafter (datetime adtm_start, datetime adtm_end)
- public subroutine of_calcremaintimes ()
- public subroutine of_open_progress ()
- public subroutine of_disablecancel ()
- public subroutine of_setrequestor (powerobject anv_requestor, n_dw2xls_resource anv_resource)
- end prototypes
- public subroutine of_stepit ();
- IF Not IsValid(inv_Requestor) Then
- Return
- END IF
- IF Not IsValid(iu_hpb) Then
- Return
- END IF
- IF ib_CalcRemainTimes AND iu_hpb.Position <iu_hpb.MaxPosition Then
- OF_CalcRemainTimes()
- iu_hpb.StepIt()
- END IF
- end subroutine
- public subroutine of_close_progress ();IF IsValid(iw_progress) Then
- iu_hpb.Position = iu_hpb.MaxPosition //保证显示100%处理完毕
- Yield()
- Close(iw_progress)
- END IF
- end subroutine
- public subroutine of_intial_progress (readonly long ai_progresstal, integer ai_remain);
- il_Progress_Total =ai_progresstal
- il_Progress =0
- il_Progress_Max =100 - ai_remain -iu_hpb.Position
- IF il_Progress_Max<=0 THen Return
- IF il_Progress_Total<=100 Then
- iu_hpb.MaxPosition = il_Progress_Total+1
- il_Progress_Max =il_Progress_Total - ai_remain -iu_hpb.Position
- li_Step_Count =1
- ELSE
- li_Step_Count =Ceiling(il_Progress_Total/ il_Progress_Max)
- END IF
- ib_CalcRemainTimes =TRUE
- idt_start = datetime(today(),now())
- idt_last = idt_start
- ii_BeginPosition = iu_hpb.Position
- end subroutine
- public subroutine of_progress (readonly long al_value);Int li_Step,li_Secornds
- IF al_value<=0 Then
- Return
- END IF
- IF Not IsValid(iu_hpb) Then
- Return
- END IF
-
- IF li_Step_Count<=1 Then
- iu_hpb.Position = iu_hpb.Position + al_value
- ELSE
- il_Progress +=al_value
- IF il_Progress>=il_Progress_Total Then
- iu_hpb.Position = iu_hpb.Position + il_Progress_Max - il_PriorStep
- ELSE
- li_Step =il_Progress /li_Step_Count
- IF li_Step>il_PriorStep Then
- OF_CalcRemainTimes()
- iu_hpb.Position = iu_hpb.Position + li_Step - il_PriorStep
- il_PriorStep =li_Step
- END IF
- END IF
- END IF
- Yield()
- end subroutine
- public function LONG of_secondsafter (datetime adtm_start, datetime adtm_end);long ll_total_seconds
- long ll_day_adjust
- date ld_sdate
- date ld_edate
- time lt_stime
- time lt_etime
- long ll_null
- ld_sdate = date(adtm_start)
- ld_edate = date(adtm_end)
- lt_stime = time(adtm_start)
- lt_etime = time(adtm_end)
- if ld_sdate = ld_edate then
- ll_total_seconds = secondsafter(lt_stime,lt_etime)
- else
- if ld_sdate < ld_edate then
- ll_total_seconds = secondsafter(lt_stime,time("23:59:59"))
- ll_day_adjust = daysafter(ld_sdate,ld_edate) - 1
- if ll_day_adjust > 0 then
- ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjust
- end if
- ll_total_seconds = ll_total_seconds + secondsafter(time("00:00:00"),lt_etime) + 1
- else
- ll_total_seconds = secondsafter(lt_stime,time("00:00:00"))
- ll_day_adjust = daysafter(ld_sdate,ld_edate) + 1
- if ll_day_adjust < 0 then
- ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjust
- end if
- ll_total_seconds = ll_total_seconds + secondsafter(time("23:59:59"),lt_etime) - 1
- end if
- end if
- return ll_total_seconds
- end function
- public subroutine of_calcremaintimes ();long ll_cur_s, li_progress
- long ll_total_rem_s
- long ll_rem_s
- long ll_rem_m
- long ll_rem_h
- string ls_str
- datetime ldt_now
- ldt_now = datetime(today(),now())
- li_progress=iu_hpb.Position - ii_BeginPosition
- IF OF_SecondsAfter(idt_last,ldt_now) >5 Then
-
- IF Not iw_progress.cb_Cancel.Visible Then
- iw_progress.cb_Cancel.Visible=TRUE
- END IF
-
- idt_last = ldt_now
- ll_cur_s =OF_SecondsAfter(idt_start,ldt_now)
-
- IF ll_cur_s > 5 AND li_progress > 0 Then
- ll_total_rem_s = truncate(round((ll_cur_s * 100) / li_progress - ll_cur_s,0),0)
- ll_total_rem_s = round(ll_total_rem_s / 5,0) * 5
- ll_rem_s = mod(ll_total_rem_s,60)
- ll_total_rem_s = truncate(ll_total_rem_s / 60,0)
- ll_rem_m = mod(ll_total_rem_s,60)
- ll_rem_h = truncate(ll_total_rem_s / 60,0)
- ls_str = ""
-
- IF ll_rem_s=0 AND ll_rem_m =0 AND ll_rem_h=0 Then
- Return
- END IF
-
- IF ll_rem_h = 1 Then
- ls_str = ls_str + string(ll_rem_h) + " "+inv_Res.Hour+" "
- ELSEIF ll_rem_h>1 Then
- ls_str = ls_str + string(ll_rem_h) + " "+inv_Res.Hours+" "
- END IF
-
- IF ll_rem_m=1 Then
- ls_str = ls_str + string(ll_rem_m) + " "+inv_Res.Minute+" "
- ELSEIF ((ll_rem_m > 1) or (ll_rem_h > 0)) Then
- ls_str = ls_str + string(ll_rem_m) + " "+inv_Res.Minutes+" "
- END IF
-
- IF ll_rem_s=1 Then
- ls_str = ls_str + string(ll_rem_s) + " "+inv_Res.Second
- ELSE
- ls_str = ls_str + string(ll_rem_s) + " "+inv_Res.Seconds
- END IF
- IF ls_str <> "" Then
- ls_str =inv_Res.RemainTimes+" "+ ls_str
- iw_progress.st_remain.text = ls_str
- END IF
- END IF
- END IF
- end subroutine
- public subroutine of_open_progress ();IF Not IsValid(inv_Requestor) Then
- Return
- END IF
- IF Not IsValid(iw_progress) Then
- OpenWithParm(iw_progress, This, "w_dw2xls_progress" )
- END IF
- end subroutine
- public subroutine of_disablecancel ();IF IsValid(iw_progress) Then
- iw_progress.cb_Cancel.Enabled=False
- END IF
- end subroutine
- public subroutine of_setrequestor (powerobject anv_requestor, n_dw2xls_resource anv_resource);inv_Requestor = anv_Requestor
- inv_Res = anv_Resource
- end subroutine
- on n_dw2xls_progress.create
- call super::create
- TriggerEvent( this, "constructor" )
- end on
- on n_dw2xls_progress.destroy
- TriggerEvent( this, "destructor" )
- call super::destroy
- end on
- event destructor;IF IsValid(iw_progress) Then
- Close(iw_progress)
- END IF
- end event
|