Tải bản đầy đủ - 0 (trang)
Chapter 26. Writing Custom Reporting Services Extensions

Chapter 26. Writing Custom Reporting Services Extensions

Tải bản đầy đủ - 0trang

Chapter26.WritingCustomReporting

ServicesExtensions

InThisChapter

CommonConsiderationsforCustomReportingServices

Extensions:Implementation,Deployment,andSecurity

DeliveryExtension

InteractionsBetweenUser,SSRS,andaDeliveryExtension

SSRSisdesignedforextensibility.Inthepreviouschapters,you

learnedhowtoextendSSRS'reportingcapabilitiesbywritinga

customcodethatcanbecalledfromareport.Extensions,on

anotherhand,arecalledbySSRS.Extensionsarecomposedof

fourkeycategories:security,delivery,dataprocessing,and

rendering(seeChapter3,"ReportingServicesArchitecture,"

Figure3.1).

TypicalextensionsinstalledwithSSRSareasfollows:

DataprocessingMicrosoftSQLServer,OLEDB(including

OLEDBMDforMicrosoftSQLServerAnalysisServices),

Oracle,ODBC,andXML.XMLwasoneofthemostfrequent

requestsfordataextensionsinSSRS2000.Many

developersarehappytoseeXMLdatasourcesinSSRS

2005.Additionalextensionsthatcanbedeployedinthis

categoryareSQLServerIntegrationServices(SSIS)and

SAPdata-processingextensions.



DeliveryFileshare,eMail,NULL.

RenderExcel,MHTML,HTML3.2,HTML4.0(Microsoft

InternetExplorer5.0orlater),PDF,IMAGE(graphicalimage

output,suchasTIF,GIF,JPG),CSV,XML,NULL(usedto

placereportsincacheandinconjunctionwithscheduled

executionanddelivery).

OtherSemanticQueryandModelGenerationtoextendReport

Builder'sfunctionality.EventProcessingtoactontheevents

generatedbyReportServer.

Securityextensionsarenottypicallyinstalled.Bydefault,SSRS

usesWindowsintegratedauthentication.Acompletelistof

extensionsinstalledonaparticularinstanceofSSRScanbe

retrievedbycalling

ReportingService2005.ListExtensions(ExtensionTypeEnum.All)orby

examiningthersreportserver.configfile.

Renderingis,perhaps,themostdevelopedcategoryof

extensions.Withawiderangeofrenderingextensionsanda

multitudeofapplications(includingMicrosoftOffice)that

"understand"HTML,itishardtothinkofanewrendering

extensionthatwouldbeimmediatelyuseful.

SomeoftheSSRScapabilitiesthatcustomersarefrequently

lookingforandthatarecurrentlynotavailable"outofthebox"

areasfollows:

Printer(fax)deliveryTheabilitytoprint(fax)batchesof

reportswithouthumaninteractions

.NETdatasetaccessAnabilitytoaccessadatasetthat

wascreatedinsideofanapplication



CustomauthenticationAnabilitytoauthenticatenonWindowsclients

Itispossibletoworkaroundtheneedtohavecertain

functionality.Forexample,insteadofdeliverytoaprinter

directlyfromSSRS,anadministratorcanconfiguredeliveryofa

reporttoafileshareandhaveaseparateprocessmonitoring

andprintingfromsuchafilesharebyusingtheWindowsPRINT

command,suchasPRINT/D:\\\
print>.

Itisalsopossibletoworkaroundthescenarioinwhichusers

cannotuseWindowsauthentication.Anadministratorcan

createaWindowsaccountforauser,configureIIStoaccept

Basicauthentication(mustenableSSLforbettersecurity),and

asktheusertoenterWindowscredentialstoaccessareport.

Althoughitispossibletoworkaroundsomeofthelimitations,

customextensionscanofferelegantsolutionstosupplement

missingfunctionality.

Acustomextensionisaprivateorshared.NETassemblywitha

uniquenamespace(theexactnameisnotimportant,butit

mustbeunique),andaclassthatimplementstheIExtension

interfaceandoneormoreinterfacesshowninTable26.1.As

withany.NETimplementation,VisualStudioisthemost

frequentlyuseddevelopmenttoolfordevelopmentof

assembliesand,therefore,extensions.

Table26.1.TypicalSetofInterfacesUsedinCustomExtensions



Interface(s)



Appliedto

an

Extension

Category



IAuthenticationExtension



Security



Description



Implementationofthisinterfaceextends

theauthenticationfeatureofSSRS.This

interfaceisderivedfromIExtension.



IAuthorizationExtension



Security



Implementationofthisinterfaceextends

theauthorizationfeatureofSSRS.This

interfaceisnotCommonLanguage

Specification(CLS)-compliant.Thismeans

thatnotall.NETlanguagescancallor

implementthisinterface;alsoC#and

VB.NETcandealwiththisinterfacejust

fine.Thisinterfaceisderivedfrom

IExtension.



IDbConnection,

[IDbConnectionExtension],

IDbTransaction,

[IDbTransactionExtension],

IDbCommand,

[IDbCommandAnalysis],

[IDbCommandRewriter],

IDataParameter,

[IDataMultiValueParameter],

IDataParameterCollection,

IDataReader,

[IDataReaderExtension]



Data

processing



[Optional]andrequiredinterfacesofa

classthatimplementsadata-processing

extension.Thoseinterfacesaremodeled

after.NETdataproviderinterfacesand

definedinthe



IDeliveryExtension



Delivery



Implementationofthisinterfaceinteracts

withSSRStoshareandvalidatean

extension'ssettingsandtoexecute

delivery.Thisinterfaceisderivedfrom

IExtension.



IDeliveryReportServerInformation



Delivery



Implementationofthisinterfaceisusedin

conjunctionwithIDeliveryExtension.SSRS

suppliesinformationaboutitselfthrough

thisinterface.



IRenderStream



Rendering



Implementationofthisinterfaceprovides

supportformultiplestreamsrendering

fromarenderingextension.



IRenderingExtension



Rendering



Implementationofthisinterfaceis

requiredforarenderingextensionsothe

extensionisrecognizedbySSRS.This

interfaceisdefinedinthe



Microsoft.ReportingServices.DataProcessing



namespace.



Microsoft.ReportingServices.ReportingRendering



namespace.

[ISubscriptionBaseUIUserControl]



Delivery



Implementationofthisinterfaceprovides

asubscriptionUIfortheReportManager.

Thisinterfaceiswhatshowsdata-entry

fields.Forexample,inthecaseofan

email,itdisplaysaninterfacetoenter

"TO:"emailaddress,andsoon.This



interfaceextendsIExtension.Thisinterface

isoptionalbecauseasubscriptioncanbe

createdusingSOAPAPImethods

CreateSubscriptionand

CreateDataDrivenSubscription.Theclassthat

inheritsfromthisinterfacemustalso

inheritfrom

System.Web.UI.WebControls.WebControl.







CommonConsiderationsforCustomReporting

ServicesExtensions:Implementation,

Deployment,andSecurity

Thereportinglibraryprovidesthreenamespacesthatsupply

interfacedefinitions,classes,andvaluetypesthatallow

extensionstointeractwithSSRS:

Microsoft.ReportingServices.DataProcessingUsedtoextendthe



dataprocessingcapabilityofSSRS.

Microsoft.ReportingServices.InterfacesUsedtobuilddelivery



andsecurityextensions.

Thisnamespacealsoallowsyoutomaintainacrossconnectionstate.AclassthatimplementstheIExtension

interfacefromthisnamespaceiskeptinmemoryforaslong

asSSRSisrunning.

Microsoft.ReportingServices.ReportRenderingUsedtoextendthe



renderingcapabilitiesofSSRS.Thisnamespaceisusedin

conjunctionwiththeMicrosoft.ReportingServices.Interfaces

namespace.

Beforeyoucansuccessfullycompileanextension,youmust

supplythereferencetooneormoreMicrosoft.ReportingServices

namespacesasfollows:

usingMicrosoft.ReportingServices.Interfaces;



Anamespacecanhaveoptionalinterfaces,suchas

IDbConnectionExtensioninMicrosoft.ReportingServices.DataProcessing,



andrequiredinterfaces,suchasIDbConnectioninthesame

extension'snamespace.Whenaninterfaceisrequiredanda

developerchoosesnottoimplementaparticularpropertyor

methodoftheinterface,itisabestpracticetothrowa

NotSupportedException.NotSupportedExceptionismostappropriatefor

thispurposeasitindicatesmethods(andproperties)thatdid

notprovideimplementationformethodsdescribedinthebase

classes(interfaces).Thenextbestalternativeis

NotImplementedException.Notethatoptionalinterfacesdonot

requireimplementationatall.

AnyCommonLanguageRuntime(CLR)applicationinteracts

withtheCLRsecuritysystem.Thisbookbrieflycoveredthe

basicsof.NETsecurityinChapter23,"HowtoCreateandCalla

CustomAssemblyfromaReport,"specificallyinthesection

".NETSecurityPrimerforaSSRSAdministrator."Thesame

principlesapplytoextensions.LocalsecuritysettingsandSSRS

configurationfilesdefinethecodepermissionsthatan

extension'sassemblyreceives.SSRSextensionsmustbeapart

ofacodegroupthathastheFullTrustpermissionset.

Todeployanassembly,aSSRSadministratormusthave

appropriatepermissionstowritetotheReportServerdirectory,

ReportDesignerdirectory,andconfigurationfiles.

WhenaReportServerfirstloadsanextensioninmemory,the

ReportServeraccessesanassemblyusingserviceaccount

credentials.Serviceaccountcredentialsareneededsoan

extensioncanreadconfigurationfiles,accesssystemresources,

andloaddependentassemblies(ifneeded).Afteraninitialload,

theReportServerrunsanassemblyusingcredentialsofthe

userwhoiscurrentlyloggedin.

AnextensioncanbedeployedforusebytheReportServer,

ReportManager,ReportDesigner,oralloftheabove.Thisis

providedthattheextensioncanbeusedbyatool.Forexample,

ReportManageronlyusesdeliveryextensions.



ThedeploymentprocedureforanextensionusedbytheReport

Server,ReportManager,orReportDesignerisbasicallythe

same,theonlydifferenceisthedeploymentdirectoryand

configurationfilesthatneedtobemodified.Tosimplifyfurther

discussion,thisbookusesthefollowingabbreviations:

{AssmDir}Toabbreviateassemblydeploymentdirectories.



ThedefaultReportServerbinarydirectoryisC:\Program

Files\MicrosoftSQLServer\MSSQL.3\Reporting

Services\ReportServer\bin.ThedefaultReportDesignerbinary



directoryisC:\ProgramFiles\MicrosoftVisualStudio

8\Common7\IDE\PrivateAssemblies.ThedefaultReportManager

binarydirectoryisC:\ProgramFiles\MicrosoftSQL

Server\MSSQL.3\ReportingServices\ReportManager\bin.

{ConfigFile}Toabbreviateconfigurationfiles(notethe



defaultfilepath).ThedefaultlocationfortheReportServer

configurationfileisC:\ProgramFiles\MicrosoftSQL

Server\MSSQL.3\Reporting

Services\ReportServer\RSReportServer.config.Thedefaultlocation



fortheReportDesignerconfigurationfileisC:\Program

Files\MicrosoftVisualStudio

8\Common7\IDE\PrivateAssemblies\RSReportDesigner.config.The



defaultlocationfortheReportManagerconfigurationfileis

C:\ProgramFiles\MicrosoftSQLServer\MSSQL.3\Reporting

Services\ReportManager\RSWebApplication.config.

{SecConfig}Toabbreviatesecurityconfigurationfiles.The



defaultlocationfortheReportServersecurityconfiguration

fileisC:\ProgramFiles\MicrosoftSQLServer\MSSQL.3\Reporting

Services\ReportServer\RsSrvPolicy.config.Thedefaultlocationfor

theReportDesignersecurityconfigurationfileisC:\Program

Files\MicrosoftVisualStudio

8\Common7\IDE\PrivateAssemblies\RSPreviewPolicy.config.The



defaultlocationfortheReportManagersecurity

configurationisC:\ProgramFiles\MicrosoftSQL

Server\MSSQL.3\ReportingServices\ReportServer\RsMgrPolicy.config.



Todeployanextension,areportadministratorcanusethe

followingsteps:



1. Copyanextensionassemblytothe{AssmDir}directory.Remembertosub

threedirectoriesthisshortcutabbreviation.Ifanassemblywiththesam

directory,stoptheReportServerservice,copyanassembly,andthenre

2. Locateanentryinthe{ConfigFile}underthetagtag(

correspondstoacategory({ExtCategory})ofanextension:

(Authorization),,or.

3. Addanentryforanewlycreatedextensiontoa{ConfigFile}.





...

<(ExtCategory}>


Name="{Uniqueextensionnameupto255characters

Type="{Fullyqualifiednameoftheclassimplemen

{AssemblyNamewithout.dll}"

Visible="{false|true;falseindicatesthatextens

>

{optionalconfigurationdata}





...





AnexampleofCustomFileShareProviderforrsreportserver.configisasfollows:








Name="ReportServerCustomFileShare"

Type="MyCorp.FileShareDeliveryProvider.CustomFileSha



CustomFileShareProviderAssembly"

>

3

900





\\myserver1\result

\\myserver2\result







...



WhenanextensionthatimplementstheIExtensioninterfaceisinvoked,S

IExtensioninterface:SetConfigurationandLocalizedName.SSRSpassesanXM

andtagsintheconfigurationfileasaparam

extensioncantakeadvantageoftheflexibilitythatconfigurationoffers.

userinterfaceimplementations(suchasReportManager)andshouldre

Thisway,anextensioncanbeusedaroundtheworldanddoesnothave

extensionisdeployedinanewlocale.



4. Finally,anadministratorcangrantFullTrustpermissionforanassembly




version="1"

PermissionSetName="FullTrust"

Name="MyExtensionCodeGroup"

>


version="1"

Url="C:\ProgramFiles\MicrosoftSQLServer\MSSQL\Repor

Services\ReportServer\bin\MyExtensionAssembly.dll"

/>





5. Anadministratorcanverifydeploymentofanextensionbyusingthe



Note

Additionaldetailsaboutsecurityarecoveredin

Chapter23,specificallyinthesection".NETSecurity

PrimerforaSSRSAdministrator."



Todebugadeployedextension,completethefollowingsteps:

1. Determinetheprocessesthataccesstheextension.For

example,foradeliveryextensionthatisaccessedbyReport

Manager(becauseReportManagerrunsinthecontentof

IIS),theprocessisaspnet_wp.exeorw3wp.exe.Similarly,the

subscriptionnotificationeventishandledbySSRS,and

SSRS(theprocessisReportingServicesService.exe)invokesa

deliveryextensiontoexecuteadelivery.Adata-processing

extensioncanbeaccessedbyReportManagerandfrom

withinaninstanceofVisualStudio(theprocessisdevenv.exe).

2. Setbreakpointsintheextension'scode.

3. AttachVisualStudiotothecallingprocessusing,for

example,theDebug,AttachtoProcessmenu.TheAttachto

Processdialogboxopens.YouneedtomakesurethatShow

ProcessesfromAllUserscheckboxisselected,afterwhich

youcanselectaprocesstoattachto,andclickAttach.

4. Astheextensionisinvoked,VisualStudiobreaksatset

breakpoints,andyoucanstepthroughthecode.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 26. Writing Custom Reporting Services Extensions

Tải bản đầy đủ ngay(0 tr)

×