Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 50 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
50
Dung lượng
2,6 MB
Nội dung
ptg 331 Report Models and the Model Designer 18 Expressions should have a familiar ring to them. Expressions in a report model take one or more source fields, and manipulate them with functions, operators, and constants to derive a calculated value. These expressions are just like expressions in Report Designer. They are based on VB.NET, and automatically provide access to System.Math and System.Convert . Functions from the Microsoft.VisualBasic namespace and references to other assemblies or custom code can be used, too. A good example of what could be an expression is the combination of FirstName and LastName to create a new field called Name . Folders Folders allow you to group collections of entities. Folders can also contain other folders and perspectives. Folders allow you to add hierarchical information to the model. Folders can also be used to group items together regardless of hierarchical relationships. For example, because Report Builder users can navigate folders in a manner similar to Windows Explorer, you can move infrequently used items into a folder to hide them from the users. Perspectives Perspectives help to give us a narrower view or a view of a subset of the model. Perspectives can help limit users to see only information to which they have access. For example, a company might have a model that contains information about all the financial data items for that company. One of the things perspectives can help us do is to limit what budgetary information users can see to only information about their departments’ budgets. Perspectives are contained in the model, and the model designers and wizards don’t create them for you. They have to be manually created, and model items must be placed in them. Perspectives can contain other model objects, such as entities folders, roles, source fields, and expressions. Just placing items into a perspective does not exclude them from the rest of the models. Items can still be placed in other folders and perspectives. Creating a Model Project To create a model, you need to complete a few steps. The first is to create a report model project. Then you give the project a data source and a data source view. Finally, you can create the models. In the following steps, you create a model based on the Adventure Works catalog: 1. Create a new project. Open Visual Studio or BIDS. Click File, New Project. 2. In the dialog box that opens, if not selected by default, select Business Intelligence Projects under Project Types. 3. Under Templates in the right pane in the active dialog box, select Report Model Project. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 332 CHAPTER 18 Ad Hoc Reporting FIGURE 18.1 Creating new business intelligence projects. 4. Call the project First Model . Make sure Create Directory for Solution is checked (see Figure 18.1). Creating a Data Source Now that you have an empty project, the next thing to do is connect it to a data source. Remember the data source has to be SQLServer (or abstracted through linked servers or UDM). Unlike Report Designer, no other data sources are accepted directly: 1. Open Solution Explorer and right-click the Data Sources folder. Click Add New Data Source. This launches the New Data Source Wizard. 2. Skip the Welcome page by clicking Next. 3. On the next page, select Create a Data Source Based on an Existing or New Connection, and then click New. 4. Enter localhost as the name of the server to connect to. 5. Select Windows Authentication. 6. From the Select or Enter a Database Name list, select Adventure Works. 7. Click Test Connection; if you get an OK dialog box, click OK. If not, try to resolve the error using the debug information given, and then try again. 8. Click OK. At this point, you should have a screen that looks similar to Figure 18.2 (Data Source Wizard). 9. Click Next. 10. At this point, you could change the name of the data source. If it is not already, call the new data source Adventure Works . From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 333 Report Models and the Model Designer 18 FIGURE 18.2 Defining the connection. 11. Click Finish. A new data source called Adventure Works should appear in the Data Sources folder in Solution Explorer. Creating a Data Source View The next step in the creation of a model is the creation of the data source view. Recall, from earlier, that the data source view contains information about the physical layout of the database. To create a data source view, complete the following steps: 1. Open Solution Explorer and right-click the Data Source Views folder. Click Add New Data Source View. This launches the New Data Source View Wizard. 2. Select the Adventure Works data source and click Next. 3. The next screen asks you to select the tables and views that are going to be included in the semantic model. Click the >> button to move all the objects from the Available Objects list box to the Included Objects list box (see Figure 18.3). 4. Click Next. 5. Name the data source view Adventure Works DSV . 6. Click Finish. A new data source view called Adventure Works DSV should appear in the Data Source Views folder in Solution Explorer. The wizard is smart enough to detect whether the underlying data source has no foreign key constraints. In this case, the wizard gives you an extra screen before selecting which tables to include in the data source view. The screen gives you three types of matching logic so that it can infer relationships in the data store. If your DBMS does not follow any of these conventions, you will have to add the data source relationships yourself. Figure 18.4 shows the Name Matching screen. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 334 CHAPTER 18 Ad Hoc Reporting FIGURE 18.3 Selecting the tables and views. FIGURE 18.4 Name Matching screen of the Data Source View Wizard. After the wizard is complete, double-click the Adventure Works DSV.dsv file in Solution Explorer. This opens a document showing you the relationships that the wizard has just inferred (see Figure 18.5). To get the document to fit on one page, you might have to click the View menu, point to Zoom, and then click To Fit. Creating a Report Model Finally, you can create the actual model. To create the model, complete the following steps: 1. Open Solution Explorer and right-click the Report Models folder. Click Add New Report Model. This launches the New Report Model Wizard. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 335 Report Models and the Model Designer 18 FIGURE 18.5 Data source view. 2. Click Next on the Welcome screen. 3. The next screen is the screen to select data source views. At this point, only the Adventure Works DSV should show up. Select this, and then click Next. 4. The next screen is the Model Generation Rules screen, which is shown in Figure 18.6. From this screen, you can select from a predefined set of rules to ease the model-generation process. For our purposes, the defaults are fine. Click Next. FIGURE 18.6 Selecting report model generation rules. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 336 CHAPTER 18 Ad Hoc Reporting FIGURE 18.7 Collect Model Statistics screen of the Report Model Wizard. FIGURE 18.8 Completing the Wizard screen of the Report Model Wizard. 5. The next screen asks you to create statistics. Because Report Builder uses database statistics to aid it in the model-generation process, it is important to make sure your statistics are up-to-date. Otherwise, it might miscalculate some factors, such as drill down and aggregates. It is recommended to update statistics whenever the data source or data source views have changed. Click Update Model Statistics Before Generating, if necessary, on the Collect Model Statistics screen. Click Next (see Figure 18.7). 6. Name the model Adventure Works Model , and then click Run. Figure 18.8 shows the resulting screen. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 337 Report Models and the Model Designer 18 7. Click Finish. Figure 18.9 shows the completed model. Modifying Items in the Model The way entities show up in the Model Designer reflects how they will show up in Report Builder. To make things more meaningful for the end user, many of the properties or enti- ties can be customized. Working with the model involves some of the same basic concepts as working with Report Designer. The properties of any object can be modified from the Properties window. Things you can customize include sorting, instance selection, and inheritance. What this means is that attributes can be set to come from other entities or that users can see a filtered list of instances of an entity. Entities can also predefine formatting of their attrib- utes. For example, attributes that reflect currency can be formatted as currency depending on the user’s localized settings. The order in which things appear in the entity browser can also be customized. By default, entities appear sorted in alphabetic order, but you can move certain entities to the top if users are going to report off them frequently. To modify items in the model, it is just a matter of right-clicking in the tree view or list view. The Report Model menu in the Model Designer also gives the same menu options. To delete any item, just navigate to the item, right-click it, and choose Delete from the shortcut menu. To add an entity, folder, or perspective, do the following: 1. Navigate to the top of the tree view. FIGURE 18.9 Completed database model. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 338 CHAPTER 18 Ad Hoc Reporting 2. From the Report Model menu, select New Entity, New Perspective, or New Folder. From this point, each of these items has its own caveats. If you choose to add a new entity, the name given to the entity is simply NewEntity. You must navigate to NewEntity, right-click it, select Rename from the shortcut menu, and rename it to what you want. To be effective, the binding information has to be set, too. When adding folders, a similar process has to be followed. You must navigate to the entity or to the top entity in the tree, right-click it, and select New Folder. A new folder called New Folder is created. The location of the new folder is dependent on where you were when you right-clicked to add the new folder. You must right-click it and select Rename from the shortcut menu to rename it. To add a new role, attribute, or source field, click any detail item, and then select the option you need from the Report Model menu. When you add a new role, a pop-up appears with a list of entities. Select an entity, and then assign the bindings in the Properties window. Role bindings are nothing more than a list of relations defined in the data source view. When adding or modifying an expression, the Expression Editor is shown. From here, you can design the expression and name it. When adding a source field, select New Source Field from the Report Model menu. After adding the source field, you must rename it and set the bindings from the Properties window. Source field bind- ings refer to a list of columns from the data source view Model menu. When you are adding or modifying perspectives, a specialized dialog box opens that enables you to add/remove items from the perspective. When adding and removing perspectives, you might notice that adding one object seems to add others, and removing it removes other objects, too. This is because of the hierarchi- cal nature of the items. When a parent item, such as a folder or attribute, with variations gets added or removed, all of its children get added and removed, too. The same thing applies for roles and identifying attributes. When a role is selected, the corresponding role is selected along with the entity it leads to. The reverse is also true. When an identifying attribute is deselected, any other entities that use that identifying attribute get deselected, too. To reselect those entities, the identifying attribute must get reselected. Publishing the Model When you are done creating or updating the model, you can publish the model just as you would a report. In a published model, the data source and the SMDL file are placed in the Report Server. Because the information in the data source view is incorporated into the semantic model, the data source view does not get published. If the information in the data source view, or for that matter, anything in the semantic model, needs to be updated, just publish an updated model. After the model is published, it can be secured using Reporting Services role-based security. To use the model in Report Builder, a user must have access to it. When you are ready to deploy the semantic model, the deployment steps closely resemble the deployment steps in Report Designer: 1. Right-click the project file in Solution Explorer, and select Properties. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 339 Report Models and the Model Designer 18 2. Review the target folder’s properties. There is one target folder for the data sources, and there is another target folder for the semantic models. 3. Verify that the Overwrite Data Sources option is on the intended setting. This option is similar in name and function to the one in Report Designer. 4. Click OK. To deploy the model and data source, right-click the project file in Solution Explorer and select Deploy from the shortcut menu. To deploy just the model file, right-click the semantic model and click Deploy. Creating Models from Report Designer A second way to create a model is from Report Manager. Report Manager can take any SQLServer or Analysis Services data source and generate a model from it. You can complete the following steps to generate a model from Report Manager: 1. Go to the Report Manager web page. By default, it is located at http://localhost/Reports. 2. Click the New Data Source button. 3. Enter a name for this data source. Call this AdventureWorks DS . You can also enter a brief description. 4. Enter a connection type of MicrosoftSQLServer . 5. Make sure that the Enable This Data Source check box is checked. 6. Enter Data Source=localhost;Initial Catalog=AdventureWorks in the Connection String text box. 7. Select Windows Integrated Security. 8. Click OK. You should return to the Folder View screen. Click the data source you just created (AdventureWorks DS). 9. Click the Generate Model button. 10. Enter a name for this model. Call it Adventure Works DS Model. If you want to, you can change where the model is located and give it a description. For now, just leave these fields blank. 11. Click OK. Features of Report Builder Report Builder is the second part of the two-part solution for end-user reporting. As previ- ously mentioned, Report Builder is a click-once, client-side .NET application that can be launched from the Report Manager website. Report Builder uses Microsoft Office para- digms, so it should be easy for end users who use Microsoft Office to start using it, yet it still creates reports using standard Report Definition Language (RDL). Figure 18.10 shows how to access Report Builder. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. ptg 340 CHAPTER 18 Ad Hoc Reporting FIGURE 18.10 Starting Report Builder from the Report Manager web interface. Report Builder uses the models stored on the Report Server. Report Builder calls these models. Through Report Builder, the end user knows nothing of the actual data source used by the model. End users will most likely be referring to the model as the data source, as shown in Figure 18.11. Keep in mind that because the models are secured by the Report Server, users will not be able to access models to use as data sources for their report if the appropriate permissions have not been set. Report Builder has predefined templates available for matrix, table, and chart report layouts. Note that lists and rectangles are not supported. To use a template, the user just has to click a template in the left pane. Figure 18.12 shows the Report Builder interface. After selecting a template, the end user simply has to drag and drop fields from the Report Data Explorer onto the data region provided. Report Data Explorer is nothing more than the entity explorer. Attributes and expressions make up the fields that are usable from within the entity explorer. Some basic features are also available through Report Builder. Formatting can be done to any text box on the report layout. Data can be filtered, sorted, and grouped. A full range of export formats, such as PDF, TIFF, Excel, HTML, XML, CSV, and TIFF are also available to end users. Report Builder saves reports to the Report Server. After being published, the reports can be managed like any other reports. From the Library of STEPHEN EISEMAN Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... properties for the AdventureWorks project Now all you have to do is set the server name The server name and virtual directory have to be placed in the TargetServerURL property The format is http://{ServerName}/{VirtualDirectory} By default, if you have installed the server locally, its property is filled in as http://localhost/ReportServer Report Folder Location TargetReportFolder is another major property... Report Server An easy way to enable this access is to enable the My Reports option on the Report Server This gives users permissions to their own My Report folder After enabling My Reports, saving a report is a simple matter The menu options inside Report Builder are similar to the same commands in Microsoft Office The only difference is that you are saving to the Report Server and not a file server. .. From the Library of STEPHEN EISEMAN 366 CHAPTER 19 Managing Reports, Data Sources, and Models 4 In the Description field, enter Connects to the AdventureWorks database on the local SQL Server instance 5 Select Microsoft SQLServer for the connection type 6 Enter the following connection string: Data Source=localhost;Initial Catalog=AdventureWorks 7 Select Windows Integrated Security 8 Click OK Clicking... Now we have to pick the default target server This is the server where Report Builder will automatically try to save to, and Report Builder will also look to this server for Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark From the Library of STEPHEN EISEMAN 348 CHAPTER 18 Ad Hoc Reporting shared data sources Enter http://localhost/ReportServer (see Figure 18.17) Click Next... http://localhost/ReportServer (see Figure 18.17) Click Next FIGURE 18.17 Report Builder 2.0 Default Target Server screen 7 Click Install 8 Click Finish when install completes When the install is complete, you can launch Report Builder 2.0 by clicking the Report Builder 2.0 shortcut in the Start menu The program group is called Microsoft SQLServer 2008 Report Builder 2.0 Design Surface The design surface of Report Builder... models as a data source, and, in combination with user input, it generates standard RDL documents as reports Report Builder uses Microsoft Office paradigms, so end users who use Microsoft Office should find the product familiar The reports can then be saved to the Report Server for later use Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark From the Library of STEPHEN EISEMAN... right-click the project 2 Select Deploy After a quick permissions check with the chosen Report Server, Visual Studio should allow you to deploy the project At this point, you should see the folders created in Report Manager (see Figure 19.3) Deployment Through Report Manager 19 As covered in Chapter 1, “Introduction to SQL Server Reporting Services (SSRS),” the Report Manager web application is the main user... actually set it up to deploy reports every time you build your projects In addition, you can use Visual Studio to overwrite existing data sources on the server, hence setting the proper location for use in production Server Name First, you need to set the server name for deployment of your project You can do this by setting the project properties through the IDE This is actually much simpler than it sounds... end-user desktop The design of Report Builder 2.0 takes a different take on ad hoc reporting Report Builder 2.0 does not rely exclusively on report models for use as data sources You can use data from SQL Server, Analysis Services, other OLE DB data sources, ODBC, SAP, SAP BI, NetWeaver, Hyperion Essbase, and Oracle Connecting to a data source is a lot like when using BIDS You can use either a shared... Visual Studio Deployment Through Report Manager Changing Report Properties M anaging Report Server content on SSRS is fairly straightforward After developing reports, the first thing you need to do is to learn how to deploy them After reports are deployed, a number of options and properties can be set on the Report Server These options range from the fairly mundane, such as moving reports from one folder . in Microsoft Office. The only difference is that you are saving to the Report Server and not a file server. To save the existing report to the Report Server. You can also enter a brief description. 4. Enter a connection type of Microsoft SQL Server . 5. Make sure that the Enable This Data Source check box is checked.