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 / 80To87_Task_Upgrade_Script.sql < prev    next >
Text File  |  2009-09-30  |  17KB  |  537 lines

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