System Center Service Manager 2010 Custom Portal Development

23
System Center Service Manager 2010 SP1 Custom Portal Development 1. Contents of Portal Source Code Release The Portal Source Code Release contains the following items: A .zip file with the portal source code Visual Studio solution in its “original” form. Building this solution and deploying it will result in a portal that looks just like the portal as shipped in the product itself (version: SP1). A .zip file with all the files required to deploy a new version of the portal with a customized user experience – new style, new features, and bug fixes. A .zip file with the portal source code Visual Studio solution in the modified form that was used to build the new version of the portal described above. 2. Modifications to the Portal The new version of the portal has the following modifications: o Updated look and feel which is consistent with the default theme of SharePoint 2010. o Modified display strings to fix some of the inconsistencies in capitalization. o Modified display strings to make some things more clear in the portal. o SCSM logo removed from the lower right corner. o SCSM logo replaced with a generic Contoso IT company logo which is better for demo purposes. It can be easily replaced. o Bug fix so that when the user clicks into the Knowledge Search textbox the textbox hint text disappears

Transcript of System Center Service Manager 2010 Custom Portal Development

Page 1: System Center Service Manager 2010 Custom Portal Development

System Center Service Manager 2010 SP1 Custom Portal Development

1. Contents of Portal Source Code ReleaseThe Portal Source Code Release contains the following items:

A .zip file with the portal source code Visual Studio solution in its “original” form. Building this solution and deploying it will result in a portal that looks just like the portal as shipped in the product itself (version: SP1).

A .zip file with all the files required to deploy a new version of the portal with a customized user experience – new style, new features, and bug fixes.

A .zip file with the portal source code Visual Studio solution in the modified form that was used to build the new version of the portal described above.

2. Modifications to the PortalThe new version of the portal has the following modifications:

o Updated look and feel which is consistent with the default theme of SharePoint 2010.o Modified display strings to fix some of the inconsistencies in capitalization.o Modified display strings to make some things more clear in the portal.o SCSM logo removed from the lower right corner.o SCSM logo replaced with a generic Contoso IT company logo which is better for demo

purposes. It can be easily replaced.o Bug fix so that when the user clicks into the Knowledge Search textbox the textbox hint

text disappears automatically instead of requiring the user to manually delete it first before entering the search term.

o Bug “fix” for the issue where the steps do not progress in the request wizard. The “fix” in this case is just to not show progress at all. It’s a three step wizard and doesn’t really require that anyway.

o Added functionality to update an incident action log via the portal on the incident details page.

o Added a new request type – provision new user – with supporting management pack as an example of how to extend the portal to handle different types of requests with custom user interfaces.

These modifications were accomplished by making the following different types of changes. These changes (unless they were very extensive) are marked in comments in the code that are prefaced by the

Page 2: System Center Service Manager 2010 Custom Portal Development

phrase “PORTALMOD”. You can search through the modified code base for “PORTALMOD “and see many of the modifications that were made.

CSS File Modifications CSS was modified to change the look of the portal. Much of the style for the portal is contained in the CSS files but not all. There are two .css files –one of the analyst web portal and one for the end user portal. They are contained in the .\AnalystWeb\ and .\End User Portal\MasterPages directories respectively. There is an additional ie.css file that was added to the modified portal Visual Studio solution to handle some CSS specific to Internet Explorer.

Master File Modifications Master files are used to control the layout of the .aspx pages which reference them. There are three master files for the End User Portal. They are found in .\End User Portal\MasterPages. They are named:

ServiceManagerPortal.Master – the main Master page used for nearly all portal pages on the End User Portal.

ServiceManagerCommandMaster.Master – used for the RequestDetails.aspx page. KnowledgeArticle.Master – used for the KnowledgeSearchResults.aspx and

KnowledgeArticleDetails.aspx page.

The Analyst web portal only has a single master page - .\AnalystWeb\MasterPage.master.

You can modify the HTML and ASP in these pages to modify the layout of the pages – in particular the header area of the pages. The style is generally contained in the CSS files.

ASPX File ModificationsThere were just a few minor changes to the .aspx pages. Most of the modifications to the pages were done in the .master files. The .aspx pages generally just contain containers for the web parts.

These are the purpose of the main .aspx pages in the portal:

App File PurposeEnd User AllAnnouncements.aspx List of all current announcements.End User AllRequests List of all requests where the logged in user is the

affected user.End User AnnouncementDetails.aspx Details of a particular announcement.End User CreateRequest.aspx The Create Request “Wizard”End User Home.aspx The End User Portal Home PageEnd User KnowledgeArticleDetail.aspx The detail page for a knowledge article where the

user can click the link to open the knowledge article content.

End User KnowledgeSearchResults.aspx The list of knowledge articles returned by a search.End User RequestDetails.aspx The page that shows the details of a particular

incident or change request.End User RequestSoftware.aspx Request software wizard.Analyst AnalystHome.aspx The home page of the analyst portal.

Page 3: System Center Service Manager 2010 Custom Portal Development

Analyst ChangeRequests.aspx The list of change requests.Analyst ChangeRequestDetails.aspx The page that shows the details of a change

request.Analyst ChangeRequestsAssignedToMe.aspx The list of change requests assigned to the logged in

user.Analyst ChangeRequestsINeedToManual The list of active manual activities assigned to the

logged in user to complete.Analyst ChangeRequestsINeedToReview.asp

xThe list of active review activities the logged in user is a reviewer of.

Analyst ManualActivities.aspx The list of manual activities.Analyst ManualActivityDetails.aspx The page that shows the details of a manual

activity.Analyst ReviewActivities.aspx The list of Review Activities.Analyst ReviewActivityDetails.aspx The page that shows the details of a review activity.

RESX File Changes You can change the display strings by modifying the strings in the .resx files. The .resx files are:

App File Purpose Deployed ByEnd User .\End User Portal\

EndUserPortalResources.resxContains display strings for the end user portal (not including web parts)

Must be copied to .\EndUser\App_GlobalResources

Also compiled into theMS.EM.SM.Portal.dll assembly in .\End User Portal\bin that must be coped to .\EndUser\bin.

End User .\WebParts\WebPartsResources.resx Contains display strings for the end user web parts

Compiled into the MS.EM.SM.WebParts.dll assembly in .\End User Portal\bin that must be copied to .\EndUser\bin.

Common (Both End User and Analyst)

.\Common\CommonResources.aspx Contains display strings that are include in the Common web parts

Compiled into the MS.EM.SM.Portal.Common.dll assembly in .\End User Portal\bin that must be copied to .\EndUser\bin.

Analyst .\AnalystWeb\App_GlobalResources\AnalystPortalResources.resx

Contains display strings for the analyst portal (not including web parts)

Must be copied to .\Analyst\App_GlobalResources

Analyst .\AnalystWebParts\WebPartResources.resx

Contains the display strings for the analyst web

Compiled into the MS.EM.SM.AnalystWebParts.dll that must be copied

Page 4: System Center Service Manager 2010 Custom Portal Development

parts to .\Analyst\Bin

Web Part Changes

The web parts are compiled assemblies. Code modifications require a rebuild of the assembly projects. The Web Parts are:

App File PurposeEnd User Announcements.cs List of top 10 announcements on

home pageEnd User GlobalLinks.cs Nav bar in the upper left cornerEnd User HomePageTasks.cs List of tasks on the right sideEnd User KnowledgeArticleDetail.cs Details of a knowledge articleEnd User KnowledgeArticlePart.cs Knowledge articles sorted by

their star ratings in descending order as seen on the end user portal home page

End User RecentRequests.cs List of recent request seen on the right side of the portal home page

End User ViewAllAnnouncements.cs List of all announcementsEnd User ViewAllKnowledgeArticles.cs List of knowledge articles

returned by a searchEnd User ViewAllRequests View all active requests where

the logged in user is the affected user.

End User \Request\CreateRequest.cs Create request wizardEnd User \Request\RequestDetails.cs Details of a requestEnd User \SoftwareProvisioning\PortalSoftwareRequest.cs Software request wizardAnalyst Announcements.cs List of announcementsAnalyst ChangeRequestDetails.cs Detailed of a change requestAnalyst ChangeRequestOverview.cs Overview of a change requestAnalyst ChangeRequestAssignedToMe.cs List of change requests assigned

to the logged in userAnalyst ChangeRequestsNeedToManual.cs Change requests where there is

a manual activity assigned to the logged in user

Analyst ChangeRequestsNeedToReview.cs Change requests where there is a review activity where the logged in user is a reviewer

Analyst ChangeRequestsSubmitted.cs A list of change requests submitted by the user

Analyst ManualActivities.cs A list of manual activitiesAnalyst ManualActivity.cs Details of a manual activityAnalyst ReviewActivities.cs A list of review activitiesAnalyst ReviewActivity.cs Details of a review activity

Page 5: System Center Service Manager 2010 Custom Portal Development

3. Portal SetupRun the Portal setup on the web server where you want host your customized portal. Portal setup provisions the SDK so that it can use the ServiceManager database and sets up the performance counters required to initialize and use the in-process SDK. The portal is designed to host the SDK in the same process as w3p.exe.

4. Creating a Custom Portal ASP.Net ApplicationYou can create a new ASP.Net application for the End User and another one for the Analyst portal that run side-by-side with the out of the box portal. This way you can continue to use the out of the box portal while working on creating a customized portal.

1. Create a new directory on the file system that is a peer of the original portal directory. For example:

2. Copy the folders (Analyst, EndUser, aspnet_client) contained in C:\Inetpub\wwwroot\System Center Service Manager Portal to the new directory.

3. Create a new EndUser2 (or any name you choose) application in IIS under the same website (SCSMPortal) installed by SM portal setup. Configure the physical path to point to the EndUser directory inside of new physical directory (Custom System Center Service Manager Portal) you created in step #2.

Page 6: System Center Service Manager 2010 Custom Portal Development

4. Create a new Analyst2 (or any name you choose) application in IIS under the same website (SCSMPortal) installed by SM portal setup. Configure the physical path to point to the Analyst directory inside of new physical directory (Custom System Center Service Manager Portal) you created in step #2.

Page 7: System Center Service Manager 2010 Custom Portal Development

5. For both applications configure the following:a. Optionally create a new application pool (you can use the SM_AppPool from the IIS

application pools as shown above). If you create a new application pool make sure it uses:

i. Integrated managed pipelineii. Load user profile is set to true

iii. Identity is set to SM data access service accountb. Make sure only Windows authentication is enabled for your application.

c. Since the System Center Data Access Service, portal helper functions, and utilities in Microsoft.EnterpriseManagement.ServiceManager.Portal.Common.dll don’t encrypt any data sent over the wire it is recommended that your web site use https binding along

Page 8: System Center Service Manager 2010 Custom Portal Development

with an SSL certificate. This is only necessary to consider if you are creating a new web site to host the applications instead of using the web site installed by portal set up.

The web sites should look like this when you are done:

5. Updating Assembly References in the Visual Studio ProjectIn order to build and deploy a customized portal the assembly references in the Visual Studio project provided must be updated.

1. Copy the reference binaries listed below from %systemDrive%\inetpub\wwwroot\System Center Service Manager Portal\EndUser\bin\ into the \Common folder in the Visual Studio solution. These assemblies can then be used to resolve the VS project assembly references. Microsoft.EnterpriseManagement.Config.dll Microsoft.EnterpriseManagement.UI.Foundation.dll Microsoft.EnterpriseManagement.UI.SdkDataAccess.dll Microsoft.Mom.BuildConstants.dll Microsoft.EnterpriseManagement.DataAccessService.Core.dll Microsoft.EnterpriseManagement.ServiceManager.dll Microsoft.EnterpriseManagement.ServiceManager.Portal.Common.dll

2. Open the Portal.sln file in Visual Studio.3. In the Solution explorer in Visual Studio expand the Resources folder for each Project and you will

see some broken assembly references indicated by the exclamation point like this:

Analyst Web Parts

Common

Author, 01/03/-1,
Do I need this?
Page 9: System Center Service Manager 2010 Custom Portal Development

End User Portal

Web Parts

4. For each of the missing references – first, remove the reference

and then add it again (Add Reference…) by browsing to the corresponding .dll in the \Common folder.

Page 10: System Center Service Manager 2010 Custom Portal Development

5. For the End User Web Parts project – create a reference to the Portal Common project:

Page 11: System Center Service Manager 2010 Custom Portal Development

6. Build and Deploy a Customized PortalTo build the SM portal just click Build >Build Solution in Visual Studio.

To deploy the customized portal copy the flies as follows (only if you modified them):

Source File Destination.\End User Portal\bin\ MS.EM.SM.WebParts.dll .\EndUser\Bin\.\End User Portal\bin\ MS.EM.SM.WebParts.pdb .\EndUser\Bin\.\End User Portal\bin\ MS.EM.SM.Portal.Common.dll .\EndUser\Bin\.\End User Portal\bin\ MS.EM.SM.Portal.Common.pdb .\EndUser\Bin\.\End User Portal\bin\ MS.EM.SM.Portal.dll .\EndUser\Bin\.\End User Portal\bin\ MS.EM.SM.Portal.pdb .\EndUser\Bin\.\End User Portal\ *.aspx .\EndUser\.\End User Portal\MasterPages\ *.Master .\EndUser\MasterPages\.\End User Portal\MasterPages\ *.css .\EndUser\MasterPages\.\End User Portal\ EndUserPortalResources.resx .\EndUser\App_GlobalResources\.\AnalystWeb\bin\ MS.EM.SM.Portal.Common.dll .\Analyst\Bin\.\AnalystWeb\bin\ MS.EM.SM.Portal.Commonpdb .\Analyst\Bin\.\AnalystWeb\bin\ MS.EM.SM.AnalystWebParts.dll .\Analyst\Bin\.\AnalystWeb\bin\ MS.EM.SM.AnalystWebParts.pdb .\Analyst\Bin\.\AnalystWeb\ *.aspx .\Analyst\.\AnalystWeb\MasterPages\ *.Master .\Analyst\MasterPages\

Page 12: System Center Service Manager 2010 Custom Portal Development

.\AnalystWeb\MasterPages\ *.css .\Analyst\MasterPages\

.\AnalystWeb\App_GlobalResources\ AnalystPortalResources.resx .\Analyst\App_GlobalResources\Note: the file names above are shortened – MS=Microsoft, EM=EnterpriseManagement, SM=ServiceManager.

Of course if you add any .aspx, .css, images, new projects that generate assemblies, etc. you will need to get those copied to the corresponding places.

Remember to use CTRL+F5 to refresh the page after making changes to make sure that the browser doesn’t use any cached content like images, .css files, etc and requests the entire page new from the server.

7. Making a New Web Part and Page on the Portal (New User Provisioning Example)

The modified portal contains a new page for requesting a new user. This is the process that was used to create this solution:

1) Create a new management pack in the SCSM Authoring Tool.2) Create a new activity work item class with some properties to capture the data inputs.3) Create a custom form for the new activity work item class (optional; you can just use the generic

form).4) Create a workflow to automate the implementation of the request5) Import the MP into SCSM.6) Copy the workflow .dll to C:\Program Files\Microsoft System Center\Service Manager 2010 on

the SCSM management server.7) Create a new Web Part (see RequestNewUser.cs in the modified source Visual Studio solution)8) Create a new .aspx page to host the web part (see RequestNewUser.aspx).9) Modify the HomePageTasks.cs web part to show an additional link to the new page (see

modified HomePageTasks.cs).10) Modify web.enduser.config to have a new appSetting (see modified web.enduser.config).

8. SM Web part internalsAll SM web parts are ASP.NET web part composite controls. They override CreateChildControls to compose the actual web part UI hierarchy consisting of ASP.NET/HTML web controls. The web part layout is defined using the ASP.NET Table web control.

Some webparts use complex ASP.NET controls like wizard controls (e.g. create request web part)

5.1 Data BindingThe portal uses a data model which wraps the complex or hierarchical SDK objects like EnterpriseManagementObjectProjection. These data model objects are used for easier consumption in the UI and for data binding to ASP.NET controls like GridView, DropDownList, etc. This data model is

Page 13: System Center Service Manager 2010 Custom Portal Development

shared between the portal and WPF rich console. The following binaries contain the implementation of this data model:Microsoft.EnterpriseManagement.UI.Foundation.dllMicrosoft.EnterpriseManagement.UI.SdkDataAccess.dll

5.2Common portal UI layerMicrosoft.EnterpriseManagement.ServiceManager.Portal.Common.dll contains most of this code.

SdkConnection: It provides a singleton management server connection ServiceManagementGroup. It uses ManagementGroupConnectionManager which maintains a cache of connections one for each language based on the incoming request’s default language setting in the browser.

ReadOnlyWebPart: abstract base web part from which almost all SM web parts derive. This web part disables actions like closing/editing a web part. It also provides a virtual method HandleException which can be used by derived web parts to handler exceptions as desired.

Page 14: System Center Service Manager 2010 Custom Portal Development

PoppableWebPart: it can be derived from to create a web part with modal dialog support. E.g.: Announcements web part.

Page 15: System Center Service Manager 2010 Custom Portal Development

IDataItem:

This is a UI wrapper of SDK objects (instance/projection instances/MP elements/templates) used by the portal and SM WPF console. It provides get/set operations on SDK object properties if it is supported by the wrapped SDK object.The oortal uses System.WorkItem.IncidentPortalProjectiontype projection for incidents.

I. Property “CreatedDate” on MP class System.WorkItem can be accessed from the above incident projection as dataItem[“CreatedDate”].

II. To get the resolved by user’s name you can use: String resolvedByUserName = (dataItem[“ResolvedByUser”] as IDataItem)[“DisplayName”].ToString();This will work provided incident was resolved and dataItem[“ResolvedByUser”] as IDataItem) is not null.

SdkQueryUtility: publicly exposes the typical type and instance space operations required to implement any business logic from the web parts.

Example:GetInstances can be used to query for all instances of a ManagementPackClass Id, matching a search criteria. /// <summary>

/// Gets the instances. /// </summary> /// <param name="classId">The class id.</param> /// <param name="criteria">The criteria.</param> /// <returns></returns>

public IList<IDataItem> GetInstances(Guid classId, string criteria)

Page 16: System Center Service Manager 2010 Custom Portal Development
Page 17: System Center Service Manager 2010 Custom Portal Development

Notes: Portal doesn’t use any kind of IOC container or such so you need to take a hard dependency on the binaries listed above if you want to customize any OOB SM v1 portal web parts/build custom web parts. The list of above binaries is applicable only for Service Manager V1 (RTM).

9. Web site folder layout\Enduser(vroot)

\bin(SDK server binary files)(End user webparts: Microsoft.EnterpriseManagement.ServiceManager.WebParts.dll)(Common portal UI layer: Microsoft.EnterpriseManagement.ServiceManager.Portal.Common.dll)\bin\language code(satellite resource binary files)

\Analyst(vroot)\bin(SDK server binary files)(Analyst webparts: Microsoft.EnterpriseManagement.ServiceManager.AnalystWebParts.dll)(Common portal UI layer: Microsoft.EnterpriseManagement.ServiceManager.Portal.Common.dll)\bin\language code(satellite resource binary files)

10. Dependency ReferenceThe portal depends on the following assemblies:

Binary DescriptionMicrosoft.EnterpriseManagement.ServiceManager.Portal.Common.dll Required if you want to customize any

portal end user or analyst web parts. Provides you with boiler plate code like connection to a management group.

Microsoft.EnterpriseManagement.Common.dllMicrosoft.EnterpriseManagement.Config.dllMicrosoft.EnterpriseManagement.Core.dllMicrosoft.EnterpriseManagement.DataAccessLayer.Common.dllMicrosoft.EnterpriseManagement.DataAccessLayer.dllMicrosoft.EnterpriseManagement.DataAccessLayer.QueryCache.dllMicrosoft.EnterpriseManagement.DataAccessService.Core.dllMicrosoft.EnterpriseManagement.HealthService.dllMicrosoft.EnterpriseManagement.Modules.DataTypes.dllMicrosoft.Mom.Common.dll

Required to initialize and use the SDK client and server

Page 18: System Center Service Manager 2010 Custom Portal Development

Microsoft.Mom.DiscoveryDatabaseAccess.dllMicrosoft.Mom.Sdk.Authorization.dllMicrosoft.EnterpriseManagement.UI.Foundation.dllMicrosoft.EnterpriseManagement.UI.SdkDataAccess.dllMicrosoft.EnterpriseManagement.ServiceManager.dllMicrosoft.Mom.BuildConstants.dll Contains references to Management

Pack elements. The portal code uses references from this binary to query for portal specific MP element references.