home *** CD-ROM | disk | FTP | other *** search
/ gimli.bioss.sari.ac.uk / gimli.bioss.sari.ac.uk.zip / gimli.bioss.sari.ac.uk / pub / misc / McAfee8.7.Zip / ePOPolicyMigration.exe / CABFILE / 1 / 85To87_Task_Upgrade_Script.sql < prev    next >
Text File  |  2009-09-30  |  17KB  |  516 lines

  1. -------------------------------------------------------------------------------
  2.  
  3. -------------  V S E  8 . 5  T O  8 . 7  T A S K  U P G R A D E  --------------
  4.  
  5. -------------------------------------------------------------------------------
  6.  
  7. if exists (select * from tempdb..sysobjects where name like '#VseTmpUpgradeTask%')
  8. drop table #VseTmpUpgradeTask
  9. go
  10.  
  11. CREATE TABLE [dbo].[#VseTmpUpgradeTask] (
  12.     [AutoID] [int] IDENTITY (1, 1) NOT NULL ,
  13.     [ParentType] [tinyint] NOT NULL ,
  14.     [ParentID] [int] NOT NULL ,
  15.     [GlobalTaskID] [int] NOT NULL ,
  16.     [TaskStatus] [tinyint] NULL ,
  17.     [TheTimestamp] [binary] (8) NULL ,
  18.     [ProductCode] [nvarchar] (50) NULL ,
  19.     [DeleteTimestamp] [binary] (8) NULL ,
  20.     [TaskType] [nvarchar] (50) NULL ,
  21.     [TaskName] [nvarchar] (150) NULL ,
  22.     [PlatformsSupported] [nvarchar] (250) NULL ,
  23.     [JustPlaceHolder] [bit] NULL ,
  24.     [Priority] [int] NULL,
  25.     [VSE87AutoID] [int],        -- must link VSE 8.7 autoid
  26.     [VSE85AutoID] [int]            -- with VSE 8.5 autoid
  27. )
  28. go
  29.  
  30. -- Don't copy any tasks if 8.7 tasks already exist
  31. if not exists (select * from Task where ProductCode = 'VIRUSCAN8700' and ParentType = 7 and GlobalTaskID > 0)
  32. begin
  33.  
  34. -- Convert VSE8.5 tasks
  35. -- Copy over all task data and relink globaltaskid field
  36. -- Must copy over task and policies not just move them
  37. -- Copy all non global Task table 8.5 policies to 8.7 policies
  38. -- Copy over global root tasks, but only those with GlobalTaskID > 0
  39.  
  40. -- copy all VSE 8.5 tasks
  41. insert #VseTmpUpgradeTask
  42. (ParentType, ParentID, GlobalTaskID, TaskStatus, TheTimestamp, ProductCode, DeleteTimestamp,
  43.     TaskType, TaskName, PlatformsSupported, JustPlaceHolder, Priority, VSE87AutoID, VSE85AutoID)
  44. select 
  45. ParentType, ParentID, GlobalTaskID, TaskStatus, TheTimestamp, 'VIRUSCAN8700' as ProductCode, DeleteTimestamp,
  46.     TaskType, TaskName, PlatformsSupported, JustPlaceHolder, Priority, 0 as VSE87AutoID, autoid as VSE85AutoID
  47. from Task
  48. where
  49. Task.ProductCode = 'VIRUSCAN8600'
  50. and 
  51. (
  52. ParentType in (6,5,4,3,1)
  53. or
  54. (ParentType = 7 and GlobalTaskID > 0 )
  55. )
  56. and Task.TaskType = 'VSC700_Scan_Task'
  57. order by autoid
  58.  
  59. -- Find next task autoid value
  60. Declare @NextTaskid int
  61. Select @NextTaskid = IDENT_CURRENT('Task')
  62.  
  63. -- populate VSE87AutoID field in #VseTmpUpgradeTask
  64. Update #VseTmpUpgradeTask
  65. set VSE87AutoID = @NextTaskid + autoid
  66.  
  67. -- create VSE 8.7 tasks
  68. insert Task
  69. (ParentType, ParentID, GlobalTaskID, TaskStatus, TheTimestamp, ProductCode, DeleteTimestamp,
  70.     TaskType, TaskName, PlatformsSupported, JustPlaceHolder, Priority)
  71. select 
  72. ParentType, ParentID, GlobalTaskID, TaskStatus, TheTimestamp, 'VIRUSCAN8700' as ProductCode, DeleteTimestamp,
  73.     TaskType, TaskName + ' (VSE 8.7i)', PlatformsSupported, JustPlaceHolder, Priority
  74. from #VseTmpUpgradeTask
  75. order by autoid
  76.  
  77. -- Delete the old "(VSE 8.5i)" if it is an old upgraded 7.1 task
  78. update Task
  79. Set Task.TaskName = replace(Task.TaskName, ' (VSE 8.5i)', '')
  80. where
  81. patindex('% (VSE 8.5i)%', Task.TaskName) > 0
  82. and Task.ProductCode = 'VIRUSCAN8700'
  83. and 
  84. (
  85. Task.ParentType in (6,5,4,3,1)
  86. or
  87. (Task.ParentType = 7 and Task.GlobalTaskID > 0 )
  88. )
  89. and Task.TaskType = 'VSC700_Scan_Task'
  90.  
  91. -- Update GlobalTaskID field, link it to VSE 8.7 task instead of VSE 8.5 task
  92. update Task
  93. Set GlobalTaskID = VSE87AutoID
  94. From #VseTmpUpgradeTask
  95. where
  96. Task.GlobalTaskID = #VseTmpUpgradeTask.VSE85AutoID
  97. and Task.ProductCode = 'VIRUSCAN8700'
  98. and 
  99. (
  100. Task.ParentType in (6,5,4,3,1)
  101. or
  102. (Task.ParentType = 7 and Task.GlobalTaskID > 0 )
  103. )
  104. and Task.TaskType = 'VSC700_Scan_Task'
  105.  
  106. -- Update the GlobalTaskID for global root tasks, 
  107. -- (but only for those with with GlobalTaskID > 0)
  108. Declare @Root85Taskid int
  109. Select @Root85Taskid = AutoId
  110. From Task
  111. where ParentType = 7
  112. and GlobalTaskID = 0
  113. and ProductCode = 'VIRUSCAN8600'
  114. and TaskType = 'VSC700_Scan_Task'
  115.  
  116. Declare @Root87Taskid int
  117. Select @Root87Taskid = AutoId
  118. From Task
  119. where ParentType = 7
  120. and GlobalTaskID = 0
  121. and ProductCode = 'VIRUSCAN8700'
  122. and TaskType = 'VSC700_Scan_Task'
  123.  
  124. update Task
  125. Set GlobalTaskID = @Root87Taskid
  126. where
  127. Task.ProductCode = 'VIRUSCAN8700'
  128. and GlobalTaskID = @Root85Taskid
  129. and 
  130. (
  131. ParentType in (6,5,4,3,1)
  132. or
  133. (ParentType = 7 and GlobalTaskID > 0 )
  134. )
  135. and TaskType = 'VSC700_Scan_Task'
  136.  
  137. -- copy VSE 8.5 tasksettings to VSE 8.7 task settings
  138. -- Copy all non global TaskSetting from 8.5 Task settings to 8.7 Task settings
  139. -- copy only settings where GlobalTaskID > 0
  140. -- Change parentid to point to the VSE 8.7 task
  141. insert TaskSettings
  142. (ParentID, SectionName, SettingName, Value, TheTimestamp)
  143. select VSE87AutoID, SectionName, SettingName, Value, TaskSettings.TheTimestamp
  144. from TaskSettings, #VseTmpUpgradeTask
  145. where
  146. TaskSettings.ParentID = #VseTmpUpgradeTask.VSE85AutoID
  147.  
  148. /* ----------------------------------------------------------------------------
  149.  Change the SectionName and/or the SettingName of the policies that have moved.
  150.  A "-" sign indicates that the value is no longer used and is to be deleted only.
  151.  
  152. OLD VALUE:                                                        NEW VALUE:
  153. [Actions]                                                        [Actions]
  154. uAction                                        = 3    (Move)        =>  = 4 (Delete)
  155. uSecAction                                                    =>  = 1 (Continue)
  156.  
  157. [Actions]                                                        [Actions]
  158. uAction                                        = 5    (Clean)
  159. uSecAction                                    = 3    (Move)        =>  = 4 (Delete)
  160.  
  161. [Actions]                                                        [Actions]
  162. uAction                                        = 4    (Delete)
  163. uSecAction                                    = 3    (Move)        =>  = 1 (Continue)
  164.  
  165. [Spyware]                                                        [Spyware]
  166. uAction_Program                                = 3    (Move)        =>  = 4 (Delete)
  167. uSecAction_Program                                            =>  = 1 (Continue)
  168.  
  169. [Spyware]                                                        [Spyware]
  170. uAction_Program                                = 5    (Clean)
  171. uSecAction_Program                            = 3    (Move)        =>  = 4 (Delete)
  172.  
  173. [Spyware]                                                        [Spyware]
  174. uAction_Program                                = 4    (Delete)
  175. uSecAction_Program                            = 3    (Move)        =>  = 1 (Continue)
  176.  
  177. [Actions]                                                        
  178. -szMoveToFolder
  179. -szSecMoveToFolder
  180.  
  181. [Reports]                                                
  182. -bLogUsername
  183.  
  184. [Advanced]                                                
  185. bDeferScanOnBattery=0
  186.  
  187. [Advanced]                                                
  188. bDeferScanInFullScreen=0
  189.  
  190. [Advanced]                                                
  191. uDeferTime=1
  192. ----------------------------------------------------------------------------- */
  193.  
  194. /* ----------------------------------------------------------------------------
  195. [Actions]                                                        [Actions]
  196. uAction                                        = 3    (Move)        =>  = 4 (Delete)
  197. uSecAction                                                    =>  = 1 (Continue)
  198. ---------------------------------------------------------------------------- */
  199. update TaskSettings
  200. set Value = '1'
  201. where
  202. SectionName = 'Actions'
  203. and SettingName = 'uSecAction'
  204. and TaskSettings.parentid in 
  205.     (select b.parentid
  206.     from #VseTmpUpgradeTask, TaskSettings b
  207.     where
  208.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  209.     and b.SectionName = 'Actions'
  210.     and b.SettingName = 'uAction'
  211.     and b.Value = '3'
  212.     )
  213.  
  214. update TaskSettings
  215. set Value = '4'
  216. where
  217. SectionName = 'Actions'
  218. and SettingName = 'uAction'
  219. and TaskSettings.parentid in 
  220.     (select b.parentid
  221.     from #VseTmpUpgradeTask, TaskSettings b
  222.     where
  223.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  224.     and b.SectionName = 'Actions'
  225.     and b.SettingName = 'uAction'
  226.     and b.Value = '3'
  227.     )
  228.  
  229. /* ----------------------------------------------------------------------------
  230. [Actions]                                                        [Actions]
  231. uAction                                        = 5 (Clean)
  232. uSecAction                                    = 3    (Move)        =>  = 4 (Delete)
  233. ---------------------------------------------------------------------------- */
  234. update TaskSettings
  235. set Value = '4'
  236. where
  237. SectionName = 'Actions'
  238. and SettingName = 'uSecAction'
  239. and TaskSettings.parentid in 
  240.     (select b.parentid
  241.     from #VseTmpUpgradeTask, TaskSettings b, TaskSettings c
  242.     where
  243.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  244.     and b.SectionName = 'Actions'
  245.     and b.SettingName = 'uAction'
  246.     and b.Value = '5'
  247.     and b.ParentID = c.ParentID
  248.     and c.SectionName = 'Actions'
  249.     and c.SettingName = 'uSecAction'
  250.     and c.Value = '3'
  251.     )
  252.  
  253. /* ----------------------------------------------------------------------------
  254. [Actions]                                                        [Actions]
  255. uAction                                        = 4    (Delete)
  256. uSecAction                                    = 3    (Move)        =>  = 1 (Continue)
  257. ---------------------------------------------------------------------------- */
  258. update TaskSettings
  259. set Value = '1'
  260. where
  261. SectionName = 'Actions'
  262. and SettingName = 'uSecAction'
  263. and TaskSettings.parentid in 
  264.     (select b.parentid
  265.     from #VseTmpUpgradeTask, TaskSettings b, TaskSettings c
  266.     where
  267.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  268.     and b.SectionName = 'Actions'
  269.     and b.SettingName = 'uAction'
  270.     and b.Value = '4'
  271.     and b.ParentID = c.ParentID
  272.     and c.SectionName = 'Actions'
  273.     and c.SettingName = 'uSecAction'
  274.     and c.Value = '3'
  275.     )
  276.  
  277. /* ----------------------------------------------------------------------------
  278. [Spyware]                                                        [Spyware]
  279. uAction_Program                                = 3    (Move)        =>  = 4 (Delete)
  280. uSecAction_Program                                            =>  = 1 (Continue)
  281. ---------------------------------------------------------------------------- */
  282. update TaskSettings
  283. set Value = '1'
  284. where
  285. SectionName = 'Spyware'
  286. and SettingName = 'uSecAction_Program'
  287. and TaskSettings.parentid in 
  288.     (select b.parentid
  289.     from #VseTmpUpgradeTask, TaskSettings b
  290.     where
  291.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  292.     and b.SectionName = 'Spyware'
  293.     and b.SettingName = 'uAction_Program'
  294.     and b.Value = '3'
  295.     )
  296.  
  297. update TaskSettings
  298. set Value = '4'
  299. where
  300. SectionName = 'Spyware'
  301. and SettingName = 'uAction_Program'
  302. and TaskSettings.parentid in 
  303.     (select b.parentid
  304.     from #VseTmpUpgradeTask, TaskSettings b
  305.     where
  306.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  307.     and b.SectionName = 'Spyware'
  308.     and b.SettingName = 'uAction_Program'
  309.     and b.Value = '3'
  310.     )
  311.  
  312. /* ----------------------------------------------------------------------------
  313. [Spyware]                                                        [Spyware]
  314. uAction_Program                                = 5    (Clean)
  315. uSecAction_Program                            = 3    (Move)        =>  = 4 (Delete)
  316. ---------------------------------------------------------------------------- */
  317. update TaskSettings
  318. set Value = '4'
  319. where
  320. SectionName = 'Spyware'
  321. and SettingName = 'uSecAction_Program'
  322. and TaskSettings.parentid in 
  323.     (select b.parentid
  324.     from #VseTmpUpgradeTask, TaskSettings b, TaskSettings c
  325.     where
  326.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  327.     and b.SectionName = 'Spyware'
  328.     and b.SettingName = 'uAction_Program'
  329.     and b.Value = '5'
  330.     and b.ParentID = c.ParentID
  331.     and c.SectionName = 'Spyware'
  332.     and c.SettingName = 'uSecAction_Program'
  333.     and c.Value = '3'
  334.     )
  335.  
  336. /* ----------------------------------------------------------------------------
  337. [Spyware]                                                        [Spyware]
  338. uAction_Program                                = 4    (Delete)
  339. uSecAction_Program                            = 3    (Move)        =>  = 1 (Continue)
  340. ---------------------------------------------------------------------------- */
  341. update TaskSettings
  342. set Value = '1'
  343. where
  344. SectionName = 'Spyware'
  345. and SettingName = 'uSecAction_Program'
  346. and TaskSettings.parentid in 
  347.     (select b.parentid
  348.     from #VseTmpUpgradeTask, TaskSettings b, TaskSettings c
  349.     where
  350.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  351.     and b.SectionName = 'Spyware'
  352.     and b.SettingName = 'uAction_Program'
  353.     and b.Value = '4'
  354.     and b.ParentID = c.ParentID
  355.     and c.SectionName = 'Spyware'
  356.     and c.SettingName = 'uSecAction_Program'
  357.     and c.Value = '3'
  358.     )
  359.  
  360. /* ----------------------------------------------------------------------------
  361. [Actions]                                                        
  362. -szMoveToFolder
  363. -szSecMoveToFolder
  364. ---------------------------------------------------------------------------- */
  365. delete TaskSettings 
  366. where 
  367. TaskSettings.SectionName = 'Actions'
  368. and TaskSettings.SettingName = 'szMoveToFolder'
  369. and TaskSettings.parentid in 
  370.     (select b.parentid
  371.     from #VseTmpUpgradeTask, TaskSettings b
  372.     where
  373.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  374.     )
  375.  
  376. delete TaskSettings 
  377. where 
  378. TaskSettings.SectionName = 'Actions'
  379. and TaskSettings.SettingName = 'szSecMoveToFolder'
  380. and TaskSettings.parentid in 
  381.     (select b.parentid
  382.     from #VseTmpUpgradeTask, TaskSettings b
  383.     where
  384.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  385.     )
  386.  
  387. /* ----------------------------------------------------------------------------
  388. [Reports]                                                
  389. -bLogUsername
  390. ---------------------------------------------------------------------------- */
  391. delete TaskSettings 
  392. where 
  393. TaskSettings.SectionName = 'Reports'
  394. and TaskSettings.SettingName = 'bLogUsername'
  395. and TaskSettings.parentid in 
  396.     (select b.parentid
  397.     from #VseTmpUpgradeTask, TaskSettings b
  398.     where
  399.     b.ParentID = #VseTmpUpgradeTask.VSE87AutoID
  400.     )
  401.     
  402. /* ----------------------------------------------------------------------------
  403. [Advanced]                                                
  404. bDeferScanOnBattery=0
  405. ---------------------------------------------------------------------------- */
  406. insert into TaskSettings
  407. (ParentID, SectionName, SettingName, Value)
  408. select TaskSettings.parentid, 'Advanced', 'bDeferScanOnBattery', 0
  409. from TaskSettings, #VseTmpUpgradeTask
  410. where
  411. TaskSettings.SectionName = 'Advanced'
  412. and TaskSettings.SettingName = 'bDoHsm'
  413. and TaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  414.  
  415. /* ----------------------------------------------------------------------------
  416. [Advanced]                                                
  417. bDeferScanInFullScreen=0
  418. ---------------------------------------------------------------------------- */
  419. insert into TaskSettings
  420. (ParentID, SectionName, SettingName, Value)
  421. select TaskSettings.parentid, 'Advanced', 'bDeferScanInFullScreen', 0
  422. from TaskSettings, #VseTmpUpgradeTask
  423. where
  424. TaskSettings.SectionName = 'Advanced'
  425. and TaskSettings.SettingName = 'bDoHsm'
  426. and TaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  427.  
  428. /* ----------------------------------------------------------------------------
  429. [Advanced]                                                
  430. uDeferTime=1
  431. ---------------------------------------------------------------------------- */
  432. insert into TaskSettings
  433. (ParentID, SectionName, SettingName, Value)
  434. select TaskSettings.parentid, 'Advanced', 'uDeferTime', 1
  435. from TaskSettings, #VseTmpUpgradeTask
  436. where
  437. TaskSettings.SectionName = 'Advanced'
  438. and TaskSettings.SettingName = 'bDoHsm'
  439. and TaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  440.  
  441. /* ----------------------------------------------------------------------------
  442. [Reports]                                                
  443. Alert_ExcludeCookies=1
  444. ---------------------------------------------------------------------------- */
  445. insert into TaskSettings
  446. (ParentID, SectionName, SettingName, Value)
  447. select TaskSettings.parentid, 'Reports', 'Alert_ExcludeCookies', 1
  448. from TaskSettings, #VseTmpUpgradeTask
  449. where
  450. TaskSettings.SectionName = 'Reports'
  451. and TaskSettings.SettingName = 'bLogToFile'
  452. and TaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  453.  
  454. /* ----------------------------------------------------------------------------
  455. [Advanced]                                                
  456. dwHeuristicNetCheckSensitivity=0
  457. ---------------------------------------------------------------------------- */
  458. insert into TaskSettings
  459. (ParentID, SectionName, SettingName, Value)
  460. select TaskSettings.parentid, 'Advanced', 'dwHeuristicNetCheckSensitivity', 0
  461. from TaskSettings, #VseTmpUpgradeTask
  462. where
  463. TaskSettings.SectionName = 'Advanced'
  464. and TaskSettings.SettingName = 'bDoHsm'
  465. and TaskSettings.parentid = #VseTmpUpgradeTask.VSE87AutoID
  466. end
  467. go
  468.  
  469. if exists (select * from tempdb..sysobjects where name like '#VseTmpUpgradeTask%')
  470. drop table #VseTmpUpgradeTask
  471. go
  472.  
  473. /* ----------------------------------------------------------------------------
  474. Update the task timestamps
  475. ---------------------------------------------------------------------------- */
  476. if exists (select * from tempdb..sysobjects where name like '#vsetasktime%')
  477. drop table #vsetasktime
  478. go
  479.  
  480. begin
  481. -- Update the timestamps so that the agents know there are new tasks
  482. declare @Currenttime int
  483. select @Currenttime = @@dbts
  484.  
  485. update task set TheTimestamp = @Currenttime
  486. where ProductCode = 'VIRUSCAN8700'
  487.  
  488. select parentid as autoid, parenttype, max(thetimestamp)as maxtime
  489. into #vsetasktime
  490. from task
  491. where ProductCode = 'VIRUSCAN8700'
  492. group by parentid, parenttype
  493.  
  494. update leafnode
  495. set tasktimestamp = #vsetasktime.maxtime + 1
  496. from #vsetasktime
  497. where leafnode.autoid = #vsetasktime.autoid
  498. and #vsetasktime.parenttype = leafnode.type
  499.  
  500. update branchnode
  501. set tasktimestamp = #vsetasktime.maxtime + 1
  502. from #vsetasktime
  503. where branchnode.autoid = #vsetasktime.autoid
  504. and #vsetasktime.parenttype = branchnode.type
  505.  
  506. update tasksettings set TheTimestamp = @Currenttime
  507. from task
  508. where tasksettings.parentid = task.autoid
  509. and task.ProductCode = 'VIRUSCAN8700'
  510.  
  511. end
  512. go
  513.  
  514. if exists (select * from tempdb..sysobjects where name like '#vsetasktime%')
  515. drop table #vsetasktime
  516. go