UnregisterSite Thủ tục lưu trữ Thủ tục này là đối diện của thủ tục lưu trữ registerSite. Nó được gọi là khi các ứng dụng không còn nhu cầu để thu thập các tập tin đăng nhập cho một trang web nhất định. Các thủ tục lưu trữ được định nghĩa trong | Building the Web Log Analyzer 175 ELSE BEGIN COMMIT TRAN SET @SiteID @tmpID END Listing registersite stored procedure continued The unregisterSite Stored Procedure This procedure is the opposite of the registerSite stored procedure. It is called when the application no longer needs to collect the log files for a given site. The stored procedure is defined in Listing . CREATE PROCEDURE dbo . unregisterSite @SiteID uniqueidentifier AS BEGIN TRAN DECLARE @SQLStatement nvarchar 2000 DECLARE @MachineName nvarchar 15 DECLARE @SiteIndex smallint DECLARE @TableName nvarchar 25 -- First delete the entries from the child table so as -- not to cause any Foreign key constraint violations. DELETE FROM LogSource WHERE Site @SiteID -- Then select the machine name and site index from the -- log site table that corresponds to this registered -- site so we can build our SQL statement dynamically. SELECT @MachineName MachineName @SiteIndex SiteIndex FROM LogSite WHERE ID @SiteID -- Remove the site entry. DELETE FROM LogSite WHERE ID @SiteID SET @TableName @MachineName N W3SVC CONVERT nvarchar 5 @SiteIndex -- And finally drop the entries table for this site. IF EXISTS SELECT FROM WHERE ID OBJECT_ID @TableName AND OBJECTPROPERTY ID N IsUserTable 1 BEGIN SET @SQLStatement N DROP TABLE @TableName EXECUTE sp_executesql @SQLStatement Listing unregisterSite stored procedure 176 Project 4 SET @SQLStatement N DROP VIEW vw_ @TableName EXECUTE sp_executesql @SQLStatement END EXIT_BATCH IF @@ERROR 0 BEGIN ROLLBACK TRAN END ELSE BEGIN COMMIT TRAN END Listing unregisterSite stored procedure continued The getRegisteredSites Stored Procedure This procedure is used by the log collector service through our data-access component to retrieve the list of sites for which logs need to be collected. It is also used by the application to retrieve the list of available sites on a specific computer. The stored procedure is defined in Listing . CREATE PROCEDURE .