w_system_plan_export.srw 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. $PBExportHeader$w_system_plan_export.srw
  2. forward
  3. global type w_system_plan_export from w_publ_base
  4. end type
  5. type cb_export from uo_rpt_imflatbutton within w_system_plan_export
  6. end type
  7. type sle_filename from singlelineedit within w_system_plan_export
  8. end type
  9. type cb_2 from uo_rpt_imflatbutton within w_system_plan_export
  10. end type
  11. type gb_2 from groupbox within w_system_plan_export
  12. end type
  13. end forward
  14. global type w_system_plan_export from w_publ_base
  15. integer width = 2144
  16. integer height = 444
  17. string title = "系统解决方案导出"
  18. boolean minbox = false
  19. windowtype windowtype = response!
  20. cb_export cb_export
  21. sle_filename sle_filename
  22. cb_2 cb_2
  23. gb_2 gb_2
  24. end type
  25. global w_system_plan_export w_system_plan_export
  26. type variables
  27. int len_headinfo = 100
  28. string is_AllowVersion
  29. int ii_type = 0//0 导出; 1:导入
  30. string is_type = "导出"
  31. end variables
  32. forward prototypes
  33. public function integer wf_export (ref string arg_msg)
  34. public function integer wf_export_sysplan ()
  35. public function integer wf_import (ref string arg_msg)
  36. end prototypes
  37. public function integer wf_export (ref string arg_msg);Int rslt = 1
  38. String ls_exportbfilename
  39. String headinfo
  40. String trailinfo
  41. String r_headinfo
  42. Blob lb_r_headinfo, lb_ls_exportstr
  43. Blob lb_exportfilename
  44. String ls_pwrstr,ls_optionstr
  45. String ls_exportstr
  46. String ls_WinDwStr, ls_DwObjStr
  47. string ls_exportfilename
  48. datastore ds
  49. ds = Create datastore
  50. ls_exportbfilename = sle_filename.Text
  51. IF FileExists(ls_exportbfilename) THEN
  52. IF MessageBox("系统提示","指定文件已经存在,是否覆盖该文件?",question!,yesno!,2) = 2 THEN
  53. rslt = 1
  54. GOTO ext
  55. END IF
  56. END IF
  57. IF FileExists(ls_exportbfilename) THEN
  58. IF Not FileDelete(ls_exportbfilename) THEN
  59. rslt = 0
  60. arg_msg = "删除临时文件失败(" + ls_exportbfilename + "),请先手动清除!"
  61. GOTO ext
  62. END IF
  63. END IF
  64. //取解决方案所有窗口
  65. ds.DataObject = 'ds_system_plan_export'
  66. ds.SetTransObject(sqlca)
  67. ds.Retrieve()
  68. ls_WinDwStr = ds.Object.datawindow.Data
  69. //取解决方案所有字段
  70. ds.DataObject = 'ds_system_plan_dw_obj_export'
  71. ds.SetTransObject(sqlca)
  72. ds.Retrieve(is_AllowVersion)
  73. ls_DwObjStr = ds.Object.datawindow.Data
  74. string ls_tmpfile
  75. ls_tmpfile = sys_cur_path + "\tmppbsavefile.txt"
  76. IF FileExists(ls_tmpfile) THEN
  77. IF Not FileDelete(ls_tmpfile) THEN
  78. rslt = 0
  79. arg_msg = "删除临时文件失败(" + ls_tmpfile + "),请先手动清除!"
  80. GOTO ext
  81. END IF
  82. END IF
  83. ds.saveas(ls_tmpfile, Text! , true)
  84. blob lb_DwObjStr
  85. IF f_getblobfromfile(lb_DwObjStr,ls_tmpfile,arg_msg) = 0 THEN
  86. rslt = 0
  87. GOTO ext
  88. END IF
  89. //取权限, 系统选项
  90. SELECT sys_pwrstr,sys_optionstr
  91. INTO :ls_pwrstr,:ls_optionstr
  92. From sys_DB_version;
  93. IF sqlca.SQLCode <> 0 THEN
  94. rslt = 0
  95. arg_msg = '查询系统解决方案失败,'+sqlca.SQLErrText
  96. GOTO ext
  97. END IF
  98. //文件内容
  99. ls_exportstr = ls_pwrstr + '/*1/'
  100. ls_exportstr += ls_optionstr + '/*2/'
  101. ls_exportstr += ls_WinDwStr + '/*3/'
  102. ls_exportstr += string(lb_DwObjStr) + '/*4/'
  103. //文件头
  104. headinfo = sys_system_id + ";" + is_AllowVersion +";"
  105. trailinfo = Fill("*",len_headinfo - Len(headinfo))
  106. r_headinfo = headinfo + trailinfo
  107. lb_exportfilename = blob(r_headinfo + ls_exportstr)
  108. IF f_saveblobtofile(lb_exportfilename,ls_exportbfilename,arg_msg) = 0 THEN
  109. rslt = 0
  110. END IF
  111. ext:
  112. Destroy ds
  113. RETURN rslt
  114. end function
  115. public function integer wf_export_sysplan ();////Export
  116. //wf_ExportTmpfile(arg_path, datastore)
  117. //wf_TmpfileToBlob(arg_path, arg_blob)
  118. //wf_DelTmpfile(arg_path)
  119. //wf_BlobToFile(arg_path, arg_blob)
  120. //arg_filename: win_dw_yyyymmdd.dbf, dw_obj_yyyymmdd.dbf
  121. //
  122. //一.
  123. //1.将win_dw导出,保存为临时文件;
  124. //2.读临时文件,得到win_dw_blob;
  125. //3.删除临时文件;
  126. //
  127. //二.
  128. //1.将dw_obj导出,保存为临时文件;
  129. //2.读临时文件,得到dw_obj_blob;
  130. //3.删除临时文件;
  131. //
  132. //三.
  133. //win_dw_blob + dw_obj_blob
  134. //
  135. //TolBlob = ls_pwrstr + '/*1/' + ls_optionstr + '/*2/' + win_dw_blob + '/*3/' + dw_obj_blob + '/*4/'
  136. //
  137. //四.
  138. //导出TolBlob作为解决方案文件
  139. /////////////////////////////////////////////////////////////////////////////////////////
  140. ////Inport
  141. //wf_FileToBlob(arg_path, arg_blob)
  142. //wf_BlobToTmpfile(arg_path, arg_blob)
  143. //wf_InportTmpfile(arg_path, arg_blob)
  144. //
  145. //一.
  146. //将解决方案文件导入,得到TolBlob;
  147. //
  148. //二.
  149. //将TolBlob 分解成ls_pwrstr + '/*1/' + ls_optionstr + '/*2/' + win_dw_blob + '/*3/' + dw_obj_blob + '/*4/'
  150. //
  151. //三处理win_dw
  152. //1.将win_dw_blob导出保存为win_dw_yyyymmdd.dbf
  153. //2.将win_dw_yyyymmdd.dbf 导入为datastore
  154. //3.保存win_dw数据;
  155. //
  156. //四.处理dw_obj
  157. //1.将dw_obj_blob导出保存为dw_obj_yyyymmdd.dbf
  158. //2.将dw_obj_yyyymmdd.dbf 导入为datastore
  159. //3.保存dw_obj数据;
  160. //string ls_data
  161. //
  162. //ls_data = ds.object.datawindow.data
  163. //if isnull(ls_data ) then
  164. // messagebox("数据", "data is null")
  165. //else
  166. // messagebox("数据", ls_data)
  167. //end if
  168. return 1
  169. end function
  170. public function integer wf_import (ref string arg_msg);Integer rslt = 1
  171. Blob lb_rsyntax
  172. String ls_importstr
  173. Blob lb_r_headinfo
  174. Blob lb_importfilename
  175. String bczh_headinfo
  176. String headinfo
  177. String ls_system_id, ls_AllowVersion
  178. Integer ls_k
  179. Integer ls_psc
  180. String ls_importfilename
  181. String ls_pwrstr,ls_optionstr
  182. String ls_WinDwStr, ls_DwObjStr
  183. datastore ds
  184. ds = Create datastore
  185. ls_importfilename = sle_filename.Text
  186. IF f_getblobfromfile(lb_importfilename,ls_importfilename,arg_msg) = 0 THEN
  187. rslt = 0
  188. GOTO ext
  189. END IF
  190. ls_importstr = string(lb_importfilename)
  191. //文件头: system_id; AllowVersion;
  192. //bczh_headinfo = Left(String(lb_importfilename),len_headinfo * 3)
  193. //headinfo = f_psw_bczh(bczh_headinfo,1,sys_power_key)
  194. headinfo = Left(ls_importstr,len_headinfo)
  195. ls_importstr = mid(ls_importstr, len_headinfo + 1)
  196. ls_k = 0
  197. ls_psc = 0
  198. ls_psc = Pos(headinfo,";")
  199. ls_system_id = Left(headinfo,ls_psc - 1)
  200. IF ls_system_id <> sys_system_id THEN
  201. arg_msg = "导入的不是本系统的数据包,请检查"
  202. rslt = 0
  203. GOTO ext
  204. END IF
  205. headinfo = Mid(headinfo,ls_psc + 1)
  206. ls_psc = 0
  207. ls_psc = Pos(headinfo,";")
  208. ls_AllowVersion = Left(headinfo,ls_psc - 1)
  209. ls_psc = Pos(ls_importstr,"/*1/")
  210. ls_pwrstr = left(ls_importstr,ls_psc)
  211. ls_importstr = Mid(ls_importstr,ls_psc + 4)
  212. ls_psc = Pos(ls_importstr,"/*2/")
  213. ls_optionstr = left(ls_importstr,ls_psc)
  214. ls_importstr = Mid(ls_importstr,ls_psc + 4)
  215. ls_psc = Pos(ls_importstr,"/*3/")
  216. ls_WinDwStr = left(ls_importstr,ls_psc - 1)
  217. ls_importstr = Mid(ls_importstr,ls_psc + 4)
  218. ls_DwObjStr = left(ls_importstr,len(ls_importstr) - 4)
  219. ls_importstr = Mid(ls_importstr,ls_psc + 4)
  220. blob lb_DwObjStr
  221. lb_DwObjStr = blob(ls_importstr)
  222. string ls_tmpfile
  223. if right(sys_cur_path, 1) ="\" then
  224. ls_tmpfile = sys_cur_path + "tmppbsavefile.txt"
  225. else
  226. ls_tmpfile = sys_cur_path + "\tmppbsavefile.txt"
  227. end if
  228. IF FileExists(ls_tmpfile) THEN
  229. IF Not FileDelete(ls_tmpfile) THEN
  230. rslt = 0
  231. arg_msg = "删除临时文件失败(" + ls_tmpfile + "),请先手动清除!"
  232. GOTO ext
  233. END IF
  234. END IF
  235. IF f_saveblobtofile(lb_DwObjStr,ls_tmpfile,arg_msg) = 0 THEN
  236. rslt = 0
  237. END IF
  238. UPDATE sys_DB_version
  239. SET sys_pwrstr = :ls_pwrstr,
  240. sys_optionstr = :ls_optionstr;
  241. IF sqlca.SQLCode <> 0 THEN
  242. rslt = 0
  243. arg_msg = '更新系统解决方案失败,'+sqlca.SQLErrText
  244. GOTO ext
  245. END IF
  246. delete from sys_win_dw;
  247. IF sqlca.SQLCode <> 0 THEN
  248. rslt = 0
  249. arg_msg = '删除系统解决方案原数据1失败,'+sqlca.SQLErrText
  250. GOTO ext
  251. END IF
  252. delete from sys_dwnSyntax_sys;
  253. IF sqlca.SQLCode <> 0 THEN
  254. rslt = 0
  255. arg_msg = '删除系统解决方案原数据2失败,'+sqlca.SQLErrText
  256. GOTO ext
  257. END IF
  258. //取解决方案所有窗口
  259. ds.DataObject = 'ds_system_plan_export'
  260. ds.SetTransObject(sqlca)
  261. ds.ImportString(ls_WinDwStr)
  262. IF ds.Update() = -1 THEN
  263. rslt = 0
  264. arg_msg = '更新系统解决方案对应窗口数据失败,'+sqlca.SQLErrText
  265. GOTO ext
  266. END IF
  267. //取解决方案所有字段
  268. ds.DataObject = 'ds_system_plan_dw_obj_export'
  269. ds.SetTransObject(sqlca)
  270. ds.importfile(Text!, ls_tmpfile, 2)
  271. IF ds.Update() = -1 THEN
  272. rslt = 0
  273. arg_msg = '更新系统解决方案窗口对应字段数据失败,'+sqlca.SQLErrText
  274. GOTO ext
  275. END IF
  276. ext:
  277. IF rslt = 1 THEN
  278. COMMIT;
  279. ELSE
  280. ROLLBACK;
  281. END IF
  282. RETURN rslt
  283. end function
  284. on w_system_plan_export.create
  285. int iCurrent
  286. call super::create
  287. this.cb_export=create cb_export
  288. this.sle_filename=create sle_filename
  289. this.cb_2=create cb_2
  290. this.gb_2=create gb_2
  291. iCurrent=UpperBound(this.Control)
  292. this.Control[iCurrent+1]=this.cb_export
  293. this.Control[iCurrent+2]=this.sle_filename
  294. this.Control[iCurrent+3]=this.cb_2
  295. this.Control[iCurrent+4]=this.gb_2
  296. end on
  297. on w_system_plan_export.destroy
  298. call super::destroy
  299. destroy(this.cb_export)
  300. destroy(this.sle_filename)
  301. destroy(this.cb_2)
  302. destroy(this.gb_2)
  303. end on
  304. event open;call super::open;
  305. is_AllowVersion = message.stringparm
  306. //ii_type = Message.DoubleParm
  307. IF ii_type = 0 THEN
  308. is_type = "导出"
  309. ELSE
  310. is_type = "导入"
  311. END IF
  312. cb_export.text = is_type
  313. this.title = "系统解决方案"+is_type
  314. end event
  315. type cb_func from w_publ_base`cb_func within w_system_plan_export
  316. boolean visible = false
  317. end type
  318. type cb_exit from w_publ_base`cb_exit within w_system_plan_export
  319. integer x = 1801
  320. integer y = 252
  321. end type
  322. type cb_export from uo_rpt_imflatbutton within w_system_plan_export
  323. integer x = 1760
  324. integer y = 96
  325. integer width = 325
  326. integer height = 96
  327. integer taborder = 50
  328. boolean bringtotop = true
  329. string text = "导出"
  330. end type
  331. event clicked;call super::clicked;String arg_msg
  332. IF Not sys_power_issuper THEN
  333. MessageBox("系统提示","非管理员不可以操作")
  334. RETURN
  335. END IF
  336. IF Trim(sle_filename.Text) = "" THEN
  337. MessageBox("系统提示","请选择"+is_type+"文件")
  338. RETURN
  339. END IF
  340. IF ii_type = 0 THEN
  341. IF wf_export(arg_msg) = 0 THEN
  342. MessageBox("系统提示",arg_msg)
  343. ELSE
  344. MessageBox("系统提示",is_type+"成功")
  345. END IF
  346. ELSE
  347. IF wf_import(arg_msg) = 0 THEN
  348. MessageBox("系统提示",arg_msg)
  349. ELSE
  350. MessageBox("系统提示",is_type+"成功")
  351. END IF
  352. END IF
  353. RETURN
  354. end event
  355. type sle_filename from singlelineedit within w_system_plan_export
  356. integer x = 41
  357. integer y = 96
  358. integer width = 1591
  359. integer height = 92
  360. integer taborder = 60
  361. boolean bringtotop = true
  362. integer textsize = -9
  363. integer weight = 400
  364. fontcharset fontcharset = gb2312charset!
  365. fontpitch fontpitch = variable!
  366. string facename = "宋体"
  367. long textcolor = 33554432
  368. borderstyle borderstyle = stylelowered!
  369. end type
  370. type cb_2 from uo_rpt_imflatbutton within w_system_plan_export
  371. integer x = 1646
  372. integer y = 96
  373. integer width = 114
  374. integer height = 96
  375. integer taborder = 60
  376. boolean bringtotop = true
  377. string text = "..."
  378. end type
  379. event clicked;call super::clicked;
  380. Integer i
  381. String Pathname
  382. String Filename
  383. i = GetFileSaveName("系统方案文件",Pathname,Filename,"ljsp","系统方案文件ljsp,*.ljsp")
  384. IF i = 1 AND Trim(Pathname) <> "" AND Trim(Filename) <> "" THEN
  385. sle_filename.Text = Pathname
  386. END IF
  387. RETURN
  388. end event
  389. type gb_2 from groupbox within w_system_plan_export
  390. integer x = 23
  391. integer y = 16
  392. integer width = 2094
  393. integer height = 228
  394. integer taborder = 30
  395. integer textsize = -9
  396. integer weight = 400
  397. fontcharset fontcharset = gb2312charset!
  398. fontpitch fontpitch = variable!
  399. string facename = "宋体"
  400. long textcolor = 33554432
  401. long backcolor = 134217739
  402. string text = "文件路径"
  403. end type