w_system_plan_import.srw 12 KB

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