123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500 |
- $PBExportHeader$w_system_plan_export.srw
- forward
- global type w_system_plan_export from w_publ_base
- end type
- type cb_export from uo_rpt_imflatbutton within w_system_plan_export
- end type
- type sle_filename from singlelineedit within w_system_plan_export
- end type
- type cb_2 from uo_rpt_imflatbutton within w_system_plan_export
- end type
- type gb_2 from groupbox within w_system_plan_export
- end type
- end forward
- global type w_system_plan_export from w_publ_base
- integer width = 2144
- integer height = 444
- string title = "系统解决方案导出"
- boolean minbox = false
- windowtype windowtype = response!
- cb_export cb_export
- sle_filename sle_filename
- cb_2 cb_2
- gb_2 gb_2
- end type
- global w_system_plan_export w_system_plan_export
- type variables
- int len_headinfo = 100
- string is_AllowVersion
- int ii_type = 0//0 导出; 1:导入
- string is_type = "导出"
- end variables
- forward prototypes
- public function integer wf_export (ref string arg_msg)
- public function integer wf_export_sysplan ()
- public function integer wf_import (ref string arg_msg)
- end prototypes
- public function integer wf_export (ref string arg_msg);Int rslt = 1
- String ls_exportbfilename
- String headinfo
- String trailinfo
- String r_headinfo
- Blob lb_r_headinfo, lb_ls_exportstr
- Blob lb_exportfilename
- String ls_pwrstr,ls_optionstr
- String ls_exportstr
- String ls_WinDwStr, ls_DwObjStr
- string ls_exportfilename
- datastore ds
- ds = Create datastore
- ls_exportbfilename = sle_filename.Text
- IF FileExists(ls_exportbfilename) THEN
- IF MessageBox("系统提示","指定文件已经存在,是否覆盖该文件?",question!,yesno!,2) = 2 THEN
- rslt = 1
- GOTO ext
- END IF
- END IF
- IF FileExists(ls_exportbfilename) THEN
- IF Not FileDelete(ls_exportbfilename) THEN
- rslt = 0
- arg_msg = "删除临时文件失败(" + ls_exportbfilename + "),请先手动清除!"
- GOTO ext
- END IF
- END IF
- //取解决方案所有窗口
- ds.DataObject = 'ds_system_plan_export'
- ds.SetTransObject(sqlca)
- ds.Retrieve()
- ls_WinDwStr = ds.Object.datawindow.Data
-
- //取解决方案所有字段
- ds.DataObject = 'ds_system_plan_dw_obj_export'
- ds.SetTransObject(sqlca)
- ds.Retrieve(is_AllowVersion)
- ls_DwObjStr = ds.Object.datawindow.Data
- string ls_tmpfile
- ls_tmpfile = sys_cur_path + "\tmppbsavefile.txt"
- IF FileExists(ls_tmpfile) THEN
- IF Not FileDelete(ls_tmpfile) THEN
- rslt = 0
- arg_msg = "删除临时文件失败(" + ls_tmpfile + "),请先手动清除!"
- GOTO ext
- END IF
- END IF
- ds.saveas(ls_tmpfile, Text! , true)
- blob lb_DwObjStr
- IF f_getblobfromfile(lb_DwObjStr,ls_tmpfile,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- //取权限, 系统选项
- SELECT sys_pwrstr,sys_optionstr
- INTO :ls_pwrstr,:ls_optionstr
- From sys_DB_version;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '查询系统解决方案失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- //文件内容
- ls_exportstr = ls_pwrstr + '/*1/'
- ls_exportstr += ls_optionstr + '/*2/'
- ls_exportstr += ls_WinDwStr + '/*3/'
- ls_exportstr += string(lb_DwObjStr) + '/*4/'
- //文件头
- headinfo = sys_system_id + ";" + is_AllowVersion +";"
- trailinfo = Fill("*",len_headinfo - Len(headinfo))
- r_headinfo = headinfo + trailinfo
- lb_exportfilename = blob(r_headinfo + ls_exportstr)
- IF f_saveblobtofile(lb_exportfilename,ls_exportbfilename,arg_msg) = 0 THEN
- rslt = 0
- END IF
- ext:
- Destroy ds
- RETURN rslt
- end function
- public function integer wf_export_sysplan ();////Export
- //wf_ExportTmpfile(arg_path, datastore)
- //wf_TmpfileToBlob(arg_path, arg_blob)
- //wf_DelTmpfile(arg_path)
- //wf_BlobToFile(arg_path, arg_blob)
- //arg_filename: win_dw_yyyymmdd.dbf, dw_obj_yyyymmdd.dbf
- //
- //一.
- //1.将win_dw导出,保存为临时文件;
- //2.读临时文件,得到win_dw_blob;
- //3.删除临时文件;
- //
- //二.
- //1.将dw_obj导出,保存为临时文件;
- //2.读临时文件,得到dw_obj_blob;
- //3.删除临时文件;
- //
- //三.
- //win_dw_blob + dw_obj_blob
- //
- //TolBlob = ls_pwrstr + '/*1/' + ls_optionstr + '/*2/' + win_dw_blob + '/*3/' + dw_obj_blob + '/*4/'
- //
- //四.
- //导出TolBlob作为解决方案文件
- /////////////////////////////////////////////////////////////////////////////////////////
- ////Inport
- //wf_FileToBlob(arg_path, arg_blob)
- //wf_BlobToTmpfile(arg_path, arg_blob)
- //wf_InportTmpfile(arg_path, arg_blob)
- //
- //一.
- //将解决方案文件导入,得到TolBlob;
- //
- //二.
- //将TolBlob 分解成ls_pwrstr + '/*1/' + ls_optionstr + '/*2/' + win_dw_blob + '/*3/' + dw_obj_blob + '/*4/'
- //
- //三处理win_dw
- //1.将win_dw_blob导出保存为win_dw_yyyymmdd.dbf
- //2.将win_dw_yyyymmdd.dbf 导入为datastore
- //3.保存win_dw数据;
- //
- //四.处理dw_obj
- //1.将dw_obj_blob导出保存为dw_obj_yyyymmdd.dbf
- //2.将dw_obj_yyyymmdd.dbf 导入为datastore
- //3.保存dw_obj数据;
- //string ls_data
- //
- //ls_data = ds.object.datawindow.data
- //if isnull(ls_data ) then
- // messagebox("数据", "data is null")
- //else
- // messagebox("数据", ls_data)
- //end if
- return 1
- end function
- public function integer wf_import (ref string arg_msg);Integer rslt = 1
- Blob lb_rsyntax
- String ls_importstr
- Blob lb_r_headinfo
- Blob lb_importfilename
- String bczh_headinfo
- String headinfo
- String ls_system_id, ls_AllowVersion
- Integer ls_k
- Integer ls_psc
- String ls_importfilename
- String ls_pwrstr,ls_optionstr
- String ls_WinDwStr, ls_DwObjStr
- datastore ds
- ds = Create datastore
- ls_importfilename = sle_filename.Text
- IF f_getblobfromfile(lb_importfilename,ls_importfilename,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_importstr = string(lb_importfilename)
- //文件头: system_id; AllowVersion;
- //bczh_headinfo = Left(String(lb_importfilename),len_headinfo * 3)
- //headinfo = f_psw_bczh(bczh_headinfo,1,sys_power_key)
- headinfo = Left(ls_importstr,len_headinfo)
- ls_importstr = mid(ls_importstr, len_headinfo + 1)
- ls_k = 0
- ls_psc = 0
- ls_psc = Pos(headinfo,";")
- ls_system_id = Left(headinfo,ls_psc - 1)
- IF ls_system_id <> sys_system_id THEN
- arg_msg = "导入的不是本系统的数据包,请检查"
- rslt = 0
- GOTO ext
- END IF
- headinfo = Mid(headinfo,ls_psc + 1)
- ls_psc = 0
- ls_psc = Pos(headinfo,";")
- ls_AllowVersion = Left(headinfo,ls_psc - 1)
- ls_psc = Pos(ls_importstr,"/*1/")
- ls_pwrstr = left(ls_importstr,ls_psc)
- ls_importstr = Mid(ls_importstr,ls_psc + 4)
- ls_psc = Pos(ls_importstr,"/*2/")
- ls_optionstr = left(ls_importstr,ls_psc)
- ls_importstr = Mid(ls_importstr,ls_psc + 4)
- ls_psc = Pos(ls_importstr,"/*3/")
- ls_WinDwStr = left(ls_importstr,ls_psc - 1)
- ls_importstr = Mid(ls_importstr,ls_psc + 4)
- ls_DwObjStr = left(ls_importstr,len(ls_importstr) - 4)
- ls_importstr = Mid(ls_importstr,ls_psc + 4)
- blob lb_DwObjStr
- lb_DwObjStr = blob(ls_importstr)
- string ls_tmpfile
- if right(sys_cur_path, 1) ="\" then
- ls_tmpfile = sys_cur_path + "tmppbsavefile.txt"
- else
- ls_tmpfile = sys_cur_path + "\tmppbsavefile.txt"
- end if
- IF FileExists(ls_tmpfile) THEN
- IF Not FileDelete(ls_tmpfile) THEN
- rslt = 0
- arg_msg = "删除临时文件失败(" + ls_tmpfile + "),请先手动清除!"
- GOTO ext
- END IF
- END IF
- IF f_saveblobtofile(lb_DwObjStr,ls_tmpfile,arg_msg) = 0 THEN
- rslt = 0
- END IF
- UPDATE sys_DB_version
- SET sys_pwrstr = :ls_pwrstr,
- sys_optionstr = :ls_optionstr;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '更新系统解决方案失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- delete from sys_win_dw;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '删除系统解决方案原数据1失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- delete from sys_dwnSyntax_sys;
- IF sqlca.SQLCode <> 0 THEN
- rslt = 0
- arg_msg = '删除系统解决方案原数据2失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- //取解决方案所有窗口
- ds.DataObject = 'ds_system_plan_export'
- ds.SetTransObject(sqlca)
- ds.ImportString(ls_WinDwStr)
- IF ds.Update() = -1 THEN
- rslt = 0
- arg_msg = '更新系统解决方案对应窗口数据失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- //取解决方案所有字段
- ds.DataObject = 'ds_system_plan_dw_obj_export'
- ds.SetTransObject(sqlca)
- ds.importfile(Text!, ls_tmpfile, 2)
- IF ds.Update() = -1 THEN
- rslt = 0
- arg_msg = '更新系统解决方案窗口对应字段数据失败,'+sqlca.SQLErrText
- GOTO ext
- END IF
- ext:
- IF rslt = 1 THEN
- COMMIT;
- ELSE
- ROLLBACK;
- END IF
- RETURN rslt
- end function
- on w_system_plan_export.create
- int iCurrent
- call super::create
- this.cb_export=create cb_export
- this.sle_filename=create sle_filename
- this.cb_2=create cb_2
- this.gb_2=create gb_2
- iCurrent=UpperBound(this.Control)
- this.Control[iCurrent+1]=this.cb_export
- this.Control[iCurrent+2]=this.sle_filename
- this.Control[iCurrent+3]=this.cb_2
- this.Control[iCurrent+4]=this.gb_2
- end on
- on w_system_plan_export.destroy
- call super::destroy
- destroy(this.cb_export)
- destroy(this.sle_filename)
- destroy(this.cb_2)
- destroy(this.gb_2)
- end on
- event open;call super::open;
- is_AllowVersion = message.stringparm
- //ii_type = Message.DoubleParm
- IF ii_type = 0 THEN
- is_type = "导出"
- ELSE
- is_type = "导入"
- END IF
- cb_export.text = is_type
- this.title = "系统解决方案"+is_type
- end event
- type cb_func from w_publ_base`cb_func within w_system_plan_export
- boolean visible = false
- end type
- type cb_exit from w_publ_base`cb_exit within w_system_plan_export
- integer x = 1801
- integer y = 252
- end type
- type cb_export from uo_rpt_imflatbutton within w_system_plan_export
- integer x = 1760
- integer y = 96
- integer width = 325
- integer height = 96
- integer taborder = 50
- boolean bringtotop = true
- string text = "导出"
- end type
- event clicked;call super::clicked;String arg_msg
- IF Not sys_power_issuper THEN
- MessageBox("系统提示","非管理员不可以操作")
- RETURN
- END IF
- IF Trim(sle_filename.Text) = "" THEN
- MessageBox("系统提示","请选择"+is_type+"文件")
- RETURN
- END IF
- IF ii_type = 0 THEN
-
- IF wf_export(arg_msg) = 0 THEN
- MessageBox("系统提示",arg_msg)
- ELSE
- MessageBox("系统提示",is_type+"成功")
- END IF
- ELSE
- IF wf_import(arg_msg) = 0 THEN
- MessageBox("系统提示",arg_msg)
- ELSE
- MessageBox("系统提示",is_type+"成功")
- END IF
- END IF
- RETURN
- end event
- type sle_filename from singlelineedit within w_system_plan_export
- integer x = 41
- integer y = 96
- integer width = 1591
- integer height = 92
- integer taborder = 60
- boolean bringtotop = true
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- borderstyle borderstyle = stylelowered!
- end type
- type cb_2 from uo_rpt_imflatbutton within w_system_plan_export
- integer x = 1646
- integer y = 96
- integer width = 114
- integer height = 96
- integer taborder = 60
- boolean bringtotop = true
- string text = "..."
- end type
- event clicked;call super::clicked;
- Integer i
- String Pathname
- String Filename
- i = GetFileSaveName("系统方案文件",Pathname,Filename,"ljsp","系统方案文件ljsp,*.ljsp")
- IF i = 1 AND Trim(Pathname) <> "" AND Trim(Filename) <> "" THEN
- sle_filename.Text = Pathname
- END IF
- RETURN
- end event
- type gb_2 from groupbox within w_system_plan_export
- integer x = 23
- integer y = 16
- integer width = 2094
- integer height = 228
- integer taborder = 30
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 134217739
- string text = "文件路径"
- end type
|