home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
moodle.waes.ac.uk
/
moodle.waes.ac.uk.zip
/
moodle.waes.ac.uk
/
TMG
/
SP1-TMG-KB981324-AMD64-ENU.msp
/
PCW_CAB_SHFx2
/
F2143_msfpcui.dll
/
BINARY
/
25542
< prev
next >
Wrap
Text File
|
2010-06-15
|
5KB
|
160 lines
CREATE PROCEDURE [dbo].[ISA_spUrlfMetadata]
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY -- we want to disable OA_procs on exit
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'Ole Automation Procedures', 1;
RECONFIGURE WITH OVERRIDE
DECLARE @Object int;
DECLARE @HR int;
DECLARE @Count int;
DECLARE @UrlfEnabled int;
DECLARE @Source nvarchar(255), @Desc nvarchar(255);
DECLARE @ArrayOrEnterprise int, @Array int;
DECLARE @ConfigurationMode int;
EXEC @HR = sp_OACreate N'FPC.Root', @Object OUT;
IF @HR <> 0
GOTO CLEANUP
EXEC @HR = sp_OAMethod @Object, N'ConnectToLocalStorage';
EXEC @HR = sp_OAGetProperty @Object, N'ConfigurationMode', @ConfigurationMode OUT;
IF @HR <> 0
GOTO CLEANUP
EXEC @HR = sp_OAMethod @Object, N'GetContainingArray', @Array OUT
IF @HR <> 0
GOTO CLEANUP
EXEC @HR = sp_OAGetProperty @Array, N'ArrayPolicy.WebProxy.UrlFilteringSettings.Enabled', @UrlfEnabled OUT;
IF @HR <> 0
GOTO CLEANUP
IF OBJECT_ID ('tblUrlfTelemtryConfig', 'u') IS NULL
BEGIN
CREATE TABLE [dbo].[tblUrlfTelemtryConfig]
(
[NthUrl] [int] NULL,
[TelemtryEnabled] [int] NULL
) ON [PRIMARY]
INSERT INTO [dbo].[tblUrlfTelemtryConfig] ([NthUrl], [TelemtryEnabled]) VALUES (1000, 0)
END
IF (@UrlfEnabled = 1)
BEGIN
UPDATE [dbo].[tblUrlfTelemtryConfig] SET [TelemtryEnabled] = 1
END
IF (@ConfigurationMode = 1)
BEGIN
EXEC @HR = sp_OAGetProperty @Object, N'Enterprise', @ArrayOrEnterprise OUT
END
ELSE
BEGIN
EXEC @HR = sp_OAMethod @Object, N'GetContainingArray', @ArrayOrEnterprise OUT
END
IF @HR <> 0
GOTO CLEANUP
EXEC @HR = sp_OAGetProperty @ArrayOrEnterprise, N'RuleElements.UrlCategories.Count', @Count OUT;
IF @HR <> 0
GOTO CLEANUP
IF OBJECT_ID ('tblUrlfMetadata', 'u') IS NOT NULL
DROP TABLE dbo.tblUrlfMetadata
CREATE TABLE [dbo].[tblUrlfMetadata](
[UrlCategoryName] [nvarchar](255) NULL,
[UrlCategoryId] [int] NULL
) ON [PRIMARY]
DECLARE @CategoryPath nvarchar(100);
DECLARE @CatNameProperty nvarchar(255);
DECLARE @CatIdProperty int;
DECLARE @i int
SET @i = 1
WHILE (@i <= @Count)
BEGIN
SET @CategoryPath = N'RuleElements.UrlCategories(' + CONVERT(nvarchar(5), @i) + N').Name'
EXEC @HR = sp_OAGetProperty @ArrayOrEnterprise, @CategoryPath , @CatNameProperty OUT;
IF @HR <> 0
GOTO CLEANUP
SET @CategoryPath = N'RuleElements.UrlCategories(' + CONVERT(nvarchar(5), @i) + N').CategoryId'
EXEC @HR = sp_OAGetProperty @ArrayOrEnterprise, @CategoryPath, @CatIdProperty OUT;
IF @HR <> 0
GOTO CLEANUP
PRINT 'Read From COM (URLCategory,ID) : ' + @CatNameProperty + ' , '
PRINT @CatIdProperty
INSERT INTO dbo.tblUrlfMetadata ([UrlCategoryName],[UrlCategoryId])
VALUES (@CatNameProperty, @CatIdProperty)
SET @i = @i + 1
END
CLEANUP:
-- Check whether an error occurred.
IF @HR <> 0
BEGIN
-- Report the error.
EXEC sp_OAGetErrorInfo @Object,
@Source OUT,
@Desc OUT;
PRINT 'Error: HR = '
PRINT convert(varbinary(4),@HR)
PRINT 'Error: Source = ' + @Source
PRINT 'Error: Description = ' + @Desc
END
EXEC @Count = sp_OADestroy @Object;
EXEC sp_configure 'Ole Automation Procedures', 0;
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0;
RECONFIGURE WITH OVERRIDE
END TRY
BEGIN CATCH
EXEC sp_configure 'Ole Automation Procedures', 0;
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'show advanced options', 0;
RECONFIGURE WITH OVERRIDE
PRINT ERROR_MESSAGE()
DECLARE
@ErrorMessage NVARCHAR(4000),
@ErrorNumber INT,
@ErrorSeverity INT,
@ErrorState INT,
@ErrorLine INT,
@ErrorProcedure NVARCHAR(200);
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorNumber = ERROR_NUMBER(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE(),
@ErrorLine = ERROR_LINE(),
@ErrorProcedure = ISNULL(ERROR_PROCEDURE(), '-');
RAISERROR (@ErrorMessage, @ErrorSeverity, 1, @ErrorNumber, @ErrorSeverity, @ErrorState, @ErrorProcedure, @ErrorLine);
END CATCH
IF @HR <> 0
BEGIN
SET @Desc = @Desc + ' , HR returned = ' + CONVERT(varchar(50),@HR)
RAISERROR (@Desc,10,1)
SET @HR = 1/0
END
END