Export (0) Print
Expand All

Project Initiation with Windows Forms

Office 2003
 

Grant Bolitho
Microsoft Consulting Services
Microsoft New Zealand

Jim Corbin
Microsoft Corporation

April 2005

Applies to:
    Microsoft Office Project Server 2003
    Microsoft Office Project Professional 2003
    Microsoft Visual Studio .NET 2003
    Microsoft SQL Server 2000, with Service Pack 3a

Summary:  Examine a sample application that enables a Microsoft Office Project Server 2003 user to initiate projects without installing Microsoft Office Project Professional 2003. Later, a project manager can review the project initiation details and create the project on Project Server. (23 pages)

Download pj11ProjectInitiationWinForms.exe.


Contents

Introduction
Implementation of the Windows Forms Sample
Creating Projects
Installing the Project Initiation Sample
Design of the Project Initiation Sample
Conclusion
Additional Resources
Files in the Download

Introduction

This article and the associated download (pj11ProjectInitiationWinForms.exe) provide a sample application that enables a Microsoft Office Project Server 2003 user to initiate new projects without installing Microsoft Office Project Professional 2003 on the user's desktop. The project details are stored in a Microsoft SQL Server table that you add to the Project Server database.

Note   The download includes all of the source code for the Project Initiation with Windows Forms solution for the client and server components, including: (1) the PDS extension; (2) the client application; (3) a utility for registering the PDS extension; and (4) scripts to create the necessary Microsoft SQL Server table and stored procedures. (435 KB)

At a later time in the project initiation workflow, a project manager can use the previously prepared project details to create the project in Project Server. Figure 1 shows the architecture of the Project Initiation sample. The sample demonstrates how to create and use a PDS extension that uses database tables and stored procedures other than those installed with Project Server.

Image showing Project Initiation architecture

Figure 1. Project Initiation architecture

The basic idea of the Project Initiation sample is similar to the Project Initiation sample for Microsoft Office InfoPath 2003 (for more information, see Overview: The Project Initiation Sample). Project Initiation with Windows Forms is an example for situations where InfoPath is not available.

When you use an independent project initiation application, you can:

  • Aid in the collaboration between project managers and others in the organization for project proposals.
  • Help restrict access to Project Server to only those who need it, for improved security.
  • Provide a customizable multi-tier application to implement validation, business rules, and manage workflow before projects are created.

Implementation of the Windows Forms Sample

The Project Initiation sample implements the client as a standard Microsoft Windows Forms application using Microsoft Visual C#. Use of the Windows Forms library enables easy client deployment.

The server side uses a standard Project Server 2003 installation. The PDS extension provides a mechanism that saves project initiation details until a project manager creates the real project. You need to add one additional table (ProjectInitiation) and the related stored procedures to the Project Server database. You make no other changes to the Project Server installation.

Note   A script installs the ProjectInitiation table and its stored procedures. Before implementing the Windows Forms sample, you must install the Microsoft .NET Framework version 1.1 on each client and server computer that will run it.

Project Initiation Form

One or more Project Server users can prepare new projects with the Project Initiation form shown in Figure 2.

Image showing Project Initiation application form

Figure 2. Project Initiation application form

During the project initiation phase, the user can add and maintain the following information about a proposed project:

  • Project name.
  • Project manager.
  • Project description information for the project initiation phase. The description is not used to create a project.
  • Project start date.
  • Project template to use (optional). The drop-down list contains all of the enterprise project templates available in the Project Server database.
  • Tasks specified by name, duration and time unit, and milestone flag. Task specification is not available when a project template is used.
  • Resources specified by resource names. Resource specification is not available when a project template is used.
  • Enterprise project outline codes specified by the name and full value.

Creating Projects

There are three steps to creating projects with the Project Initiation application.

  1. Check user groups and permissions.
  2. Specify a new project.
  3. Create the project on Project Server.

Checking User Groups and Permissions

A user who specifies and maintains projects using the Project Initiation client must be able to log on to Project Server, and can be in any one of the Project Server groups such as Team Members. Project Server administrators or project managers with the correct permission can modify the Team Members group. In Project Web Access, click Admin; on the Administration overview page, click Manage users and groups, and then click Groups in the actions pane.

Note   A user who creates real projects from the Project Initiation specification must be a member of the Project Managers group in Project Server.

Security Context

The default configuration of the Project Initiation application connects with Project Server using the Windows identity of the currently logged-on user. If that user has the appropriate permissions in Project Server, then the connection with Project Server just works. There are no user names and passwords to set up. You can easily modify the configuration file so that the application shows a logon dialog box that allows the user to choose Project Server or Windows authentication.

To configure the Project Initiation logon method:

  1. Edit the ProjectInitiationClient.exe.config file in the Project Initiation client installation directory. Change the value of the Authentication key to ProjectServer. The default contents of the ProjectInitiationClient.exe.config file follow:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="ProjectServerUrl" value="http://servername/ProjectServer" />
        <!-- Possible values for Authentication are: 
               WindowsOnly
               ProjectServer
        -->
        <add key="Authentication" value="WindowsOnly" />
      </appSettings>
    </configuration>
    
    
  2. When the Authentication key value is ProjectServer, you see the Project Initiation Logon dialog box (Figure 3).

    Project Initiation Logon dialog box

    Figure 3. Project Initiation Logon dialog box

  3. When the Authentication key value is WindowsOnly, the application starts without the Project Initiation Logon dialog box; you see only the message box that shows the status of your logon and data retrieval from Project Server (Figure 4).

    Image showing logon status

    Figure 4. Logon status

Specifying a New Project

You can specify a new project with the Project Initiation client before a project manager creates it on Project Server.

To specify a new project:

  1. On the Project Initiation form, click New to see the New Project dialog box (Figure 5).

     New Project dialog box

    Figure 5. New Project dialog box

  2. Type a name for the project. The name becomes the project name when the project manager creates the real project in Project Server at a later time.
  3. If you want to base the new project on the existing project information shown in the Project Initiation form, then select Base this on the current project.

    The application copies all details including tasks, resources, and outline code values from the current project. This greatly speeds up the process of project initiation.

  4. Click OK to create the project.
  5. Click Save on the Project Initiation form to save the project data to the ProjectInitiation table.
    Note   You must save a project to the ProjectInitiation table before you can create a project based on it. Saving the project saves the XML data for the project details.

After you specify a new project, and before the project manager creates the real project on Project Server, you can change details such as title, start date, and tasks. Any Project Server user can access and maintain the project initiation details during the project initiation phase. The Project Initiation client application captures and displays the name of the user and date and time of the last update.

Creating Tasks, Resources, and Outline Codes

If you do not use a project template, on the Project Initiation form you can click the appropriate Add button to create tasks, resources, and outline codes (Figures 6, 7, and 8).

New Task dialog box

Figure 6. New Task dialog box

If you select Task is a milestone, the duration changes to 0 Days and the Duration fields are disabled. You can change a milestone to a summary task using Project Professional 2003 after you create the project.

New Resource dialog box

Figure 7. New Resource dialog box

The resource drop-down list in Figure 7 is filled from the enterprise resource pool of the Project Server sample database.

New Outline Code dialog box

Figure 8. New Outline Code dialog box

The outline code Name and Value drop-down lists in Figure 8 are filled from the list of enterprise outline codes in the Enterprise Global Template.

Creating the Project on Project Server

When it is time to create the real project on Project Server, a project manager can review and modify the project initiation details and then create the project using a simple single-step process.

Any user who belongs to the Project Server Project Managers group can create the project. The Project Initiation form does not display the Create button for project team members or other users who are not in the Project Managers group. Click Create to create the project in Project Server. The project creation process can take a minute or more; the Project Creation message box appears when the process completes successfully (Figure 9).

 Message box showing project creation is complete

Figure 9. Message box showing project creation is complete

When you open the new project in Project Professional 2003, you can rearrange the specified tasks. For example, moving a task to become a subtask of a milestone turns the milestone into a summary task (Figure 10).

 Image showing that changing a task to a subtask turns a milestone into a summary task

Figure 10. Changing a task to a subtask turns a milestone into a summary task

Note   When you include resources from the enterprise resource pool, they are not yet assigned to tasks. Resource rates cannot be set with the PDS. When you first open the project with Project Professional 2003, you see a dialog box with the following message: "The currency for this project is different from the currency specified in the enterprise global. . . . Resource costs are always in the currency of the enterprise global. Do you want to overwrite this project's currency setting with that of the enterprise global? . . . "

You can click Yes or No. If you click No, the currency for resource cost fields is set correctly when you assign a resource to a task. When you save and reopen the project, the currency warning message does not appear.

If you assigned any enterprise project outline codes in the Project Initiation form, you can see they are set in the Project Information dialog box. Figure 11 shows the three outline codes specified for the project in Figure 2.

 Image showing enterprise project outline codes set by Project Initiation

Figure 11. Enterprise project outline codes set by Project Initiation

The Project Budget and Project Schedule enterprise project text fields in Figure 11 show an error, because the project manager has not yet set the budget and schedule in the new project.

The project manager can now use Project Professional 2003 and Project Web Access to manage the project in the normal manner. There is no further interaction between Project Server and the project specification in the Project Initiation application or database.

The Project Initiation application does not delete a project automatically after it is created on Project Server, because an initiation project can serve as the base for new initiation projects. If you try to create a project that has already been created, you receive a message that the project already exists.

Installing the Project Initiation Sample

The Project Initiation sample is provided in source code only, without compiled executable files, assemblies, or deployment packaging.

To install the Project Initiation application, you must compile the following three projects in the sample using Microsoft Visual Studio .NET:

  • ProjectInitiationClient
  • ProjectInitiationPDS
  • ProjectInitiationRegister

The sample Visual Studio solutions are configured to build debug versions. To build release versions, use either the Configuration Manager or the Batch Build dialog box to select the version you want.

You can optionally compile the ProjectInitiationClientSetup project to use the Microsoft Installer, or you can manually install the client.

After you compile the projects, you need to modify the installation script, install the necessary components on your Project Server computer, and then install the client on each computer where you will use the Project Initiation form.

Server Deployment

Server deployment involves four main steps, as described in the following procedure. Before you begin the following procedure, see Server Installation Warnings.

Important   For more information about code security, see Defend Your Code with Top Ten Security Tips Every Developer Must Know.

To deploy the server components:

  1. Copy the compiled ProjectInitiationPDS.dll assembly to the Project Server binary directory (most likely C:\Program Files\Microsoft Office Project Server 2003\BIN).
  2. Copy the InstallServer and Source\ProjectInitiationRegister directories to the Project Server computer. The InstallPDS.bat script calls the compiled ProjectInitiationRegister.exe utility using a relative path.
  3. Edit the InstallPDS.bat script in the InstallServer directory. Change each environment variable assignment as required for your system; for details, see InstallPDS Script Configuration. Change server names and passwords as required.
    Note   If you run the script in an existing Command Prompt window, close the window when the script completes. Otherwise, the temporary environment variables such as the Project Server administrator's password remain available in that cmd.exe process. Anyone who types the set command in the same window can see all of the variables.

    When you run the script on the Project Server computer, it does the following jobs:

    • Creates environment variables and sets them to the required values
    • Registers the .NET PDS extension with COM services and the Project Server PDS registration mechanism
    • Connects with SQL Server using the OSQL utility to create the ProjectInitiation table and its associated stored procedures
  4. Run InstallPDS.bat. Verify the script actions. When the InstallPDS.bat script completes execution, verify the following:
    • The script correctly created the ProjectInitiation table in the database for the specified Project Server instance.
    • The PDS extension is registered for the correct Project Server instance. For example, if your Project Server instance name is Sample, open the Registry Editor and click the following key:

      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\MS Project\WebClient Server\Sample

      If there are no previous PDS extensions registered for that Project Server instance, you should see the following string value:

      PDSExtension1 Microsoft.ProjectServer.ProjectInitiation.Initiation

      If there are other PDS extensions registered, the Project Initiation extension would be the next higher number n in PDSExtensionn.

      Note   If there is a prior PDS extension registered that causes an error in the PDS, the PDS logs the error to the event log and does not call the Project Initiation extension. For example, if a bad extension is registered as PDSExtension1 and the Project Initiation extension is PDSExtension2, the Project Initiation extension does not get called.

Server Installation Warnings

Before you start installation on the Project Server computer, be aware of the following:

  • Running the InstallPDS.bat script on a Project Server instance that already contains a live version of the Project Initiation solution causes a loss of all data associated with the Project Initiation installation. No other Project Server data is affected.
  • Running the InstallPDS.bat script resets Microsoft Internet Information Services (IIS). This causes a short-term disruption or potential data loss for other applications also using IIS. On a production server, apply for a maintenance outage before proceeding.

InstallPDS Script Configuration

The InstallPDS.bat script contains a number of environment variables that you need to set correctly before you execute the script. You should modify the script in the order of the commands.

  1. PROJECTINSTANCE defines the name of the Project Server instance. This is normally projectserver. A typical value follows:
    SET PROJECTINSTANCE=projectserver
    
    
  2. PROJECTURL defines the URL of the Project Server instance. Use the environment variable %PROJECTINSTANCE% for the previous project instance name.
    Note   Except for any environment variable names, the PROJECTURL value must be lowercase. For example: SET PROJECTURL=http://servername/%PROJECTINSTANCE%/
  3. PROJECTACCOUNT defines the administration account name for the project server Web site. A typical value follows:
    SET PROJECTACCOUNT=Administrator
    
    
  4. PROJECTPASSWORD defines the administration account password for the project server Web site. For example:
    SET PROJECTPASSWORD=pass@word1 
    
    
  5. PROJECTPROGRAM defines the Project Server program directory. A typical value follows:
    SET PROJECTPROGRAM=C:\Program Files\Microsoft Office Project Server 2003\ 
    
    
    Note   Use a trailing backslash.
  6. SQLSERVER defines the SQL Server name. For example:
    SET SQLSERVER=SERVERNAME
    
    
  7. SQLUSER defines a Microsoft SQL Server user name with database owner (dbo) permission on the Project Server database. We recommend that you use a trusted connection instead of the SA user.

    Uncomment this value and use it only if you do not use a trusted connection to SQL Server. For example:

    SET SQLUSER=SA
    
    
  8. SQLPASSWORD defines the SQL Server administration account password. Uncomment and use this value only if you do not use a trusted connection to SQL Server. For example:
    SET SQLPASSWORD=pass@word1
    
    
  9. SQLDATABASE defines the SQL Server database name for Project Server. A typical value follows:
    SET SQLDATABASE=ProjectServer
    
    
  10. OSQL defines the fully qualified path and name to the SQL Server OSQL.EXE utility. A typical value follows:
    SET OSQL="C:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql.exe"
    
    
  11. The batch script sets the OSQL variable, and then uses the previous variables with the SQL script command. If you can, use the –E option for a trusted connection with Windows authentication. For example:
    %OSQL% -S %SQLSERVER% -d %SQLDATABASE% -i ProjectInitiation.sql 
          -E -n –b
    
    

    If you cannot use a trusted connection, comment out the previous command and uncomment the following command:

    %OSQL% -S %SQLSERVER% -d %SQLDATABASE% -i ProjectInitiation.sql 
          -U %SQLUSER% -P %SQLPASSWORD% -n –b
    
    
    Important   If the script contains any passwords, be sure to remove the passwords or protect the InstallPDS.bat file by setting the appropriate file access control list (ACL) after the PDS extension is successfully installed.

Client Deployment

You need to deploy the Project Initiation client application to each computer where it will be used. You can manually deploy the client, or compile and use the ProjectInitiationClientSetup project. Some advantages of using the setup project are that the Windows Installer checks for the correct version of the .NET Framework, configures the application shortcut in the same way on every computer, and adds the application to Add or Remove Programs in Control Panel.

For either manual or Windows Installer deployment, do the following:

  1. In Visual Studio .NET, open ProjectInitiationClient.sln. In the ProjectInitiationClient project, edit App.config to set the value of the ProjectServerUrl key that you normally will use. For example, if your Project Server instance name is sample, set the key as follows:
    <add key="ProjectServerUrl" value="http://servername/sample" />
    
    

    You can also change the key value after you compile the solution, in the ProjectInitiationClient.exe.config file.

  2. Compile the ProjectInitiationClient project.

To manually deploy the Project Initiation client:

  1. Copy the compiled files from the ProjectInitiationClient\bin\Debug directory into a directory on the client computer. For example, in a Command Prompt window, type the following:
    cd [Project Initiation]\Source\ProjectInitiationClient\bin\Debug
    xcopy /I ProjectInitiationClient* "C:\Program Files\Project 
          Initiation Client" 
    
    
  2. Create a shortcut to the ProjectInitiationClient.exe application in the menu or on the desktop (optional).
  3. If you need to change the Project Server URL, set the ProjectServerUrl value in the ProjectInitiationClient.exe.config file to the Project Server instance you want.

To deploy the Project Initiation client with the setup application:

  1. Optional: In Visual Studio .NET, open the ProjectInitiationClientSetup project, and then add a shortcut in the User's Desktop folder or a folder and shortcut in the User's Programs Menu.
  2. Compile the ProjectInitiationClientSetup project.
  3. Run ProjectInitiationClientSetup.msi on each computer where you want to install the client.
  4. If you need to change the Project Server URL, set the ProjectServerUrl value in the installed ProjectInitiationClient.exe.config file to the Project Server instance you want.

Design of the Project Initiation Sample

There are two major components for the Project Initiation application. The following sections describe the overall application design and details of the client and server components.

Application Design

The Project Initiation application has components both on the Project Server computer and on each client computer. The Project Initiation client sends XML requests to the PDS on Project Server (Figure 12).

Image showing client components of Project Initiation application

Figure 12. Client components of the Project Initiation application

The PDS parses the requests and sends the Project Initiation requests to the Project Initiation PDS extension (Figure 13).

Image showing server components of Project Initiation application

Figure 13. Server components of the Project Initiation application

If the Project Initiation PDS extension is properly registered for the Project Server instance, the PDS sends XML requests from the Project Initiation client to the PDS extension.

Server-side Design

The Project Initiation server functionality relies on the PDS extension in the ProjectInitiationPDS project (Figure 13). The ProjectInitiation PDS extension and the Project Initiation stored procedures together provide a storage mechanism for all of the projects currently in an initiation phase.

Creating a Managed Code PDS Extension for Project Server 2003 explains the base Extender and ExceptionManager classes that provide an infrastructure for accessing the PDS and the Database class that simplifies the code required for data access. The download sample includes the base classes and the Initiation class that manages the ProjectInitiation table.

A single XML string in the Data column of the ProjectInitiation table stores data from all of the client user interface elements. You can add additional fields to the client application without adding extra columns to the ProjectInitiation table.

The Initiation class inherits from the Extender base class and adds the PDS extension methods for the Project Initiation application. Each of the following PDS extension methods accesses the ProjectInitiation table by using stored procedures that you add to the Project Server database:

  • InitiationCreate calls the ProjectInitiationCreate stored procedure with the Name, Data, and Owner parameters. ProjectInitiationCreate adds a record to the table that also initializes the UpdateUser field with Owner, and returns the ID of the new record. Following are the XML request and reply for InitiationCreate, using the example in Figure 2.
    <Request>
       <InitiationCreate>
          <Name>MegaStore</Name>
          <Owner>Project User</Owner>
          <Data></Data>
       </InitiationCreate>
    </Request>
    <Reply>
       <HRESULT>0</HRESULT>
       <STATUS>0</STATUS>
       <InitiationCreate>
          <ProjectInitiationId>10</ProjectInitiationId>
       </InitiationCreate>
    </Reply>
    
    
  • InitiationUpdate calls the ProjectInitiationUpdate stored procedure with the Id, Name, Data, and Updateuser parameters. Following are the XML request and reply for InitiationUpdate using the same example.
    <Request>
       <InitiationUpdate>
          <Id>10</Id>
          <Name>MegaStore</Name>
          <UpdateUser>Project User</UpdateUser>
          <Data>
             <Manager>Eva Corets</Manager>
             <Title>Factory shelving</Title>
             <StartDate>4/20/2005 1:30:37 PM</StartDate>
             <Template>&lt;None Selected&gt;</Template>
             <Tasks>
                <Task Name="Planning" Duration="0" Unit="Days" 
                Milestone="Yes" />
                <Task Name="Foundations" Duration="2" Unit="Days" 
                Milestone="No" />
             </Tasks>
             <OutlineCodes>
                <OutlineCode Name="Project Status" Value="Opportunity" />
                <OutlineCode Name="Sponsor" 
                   Value="Manufacturing.Storage Products" />
                <OutlineCode Name="Location" Value="USA.West.Washington" />
             </OutlineCodes>
             <Resources>
                <Resource Name="Jo Brown" />
                <Resource Name="Kim Akers" />
                <Resource Name="Lawyer" />
             </Resources>
          </Data>
       </InitiationUpdate>
    </Request>
    <Reply>
       <HRESULT>0</HRESULT>
       <STATUS>0</STATUS>
       <InitiationUpdate />
    </Reply>
    
    
  • InitiationList calls the ProjectInitiationList stored procedure with no parameters. ProjectInitiationList returns the list of projects sorted by name.
  • InitiationRetrieve calls the ProjectInitiationRetrieve stored procedure with the Id parameter, to retrieve the Name, Owner, CreateDate, UpdateDate, and UpdateUser fields.
  • InitiationRetrieveData calls the ProjectInitiationRetrieveData stored procedure with the Id parameter, to retrieve the Data field.
  • InitiationDelete calls the ProjectInitiationDelete stored procedure with the Id parameter, to delete the specified record.

To see all of the PDS requests and replies, set breakpoints in the Request class of ProjectInitiationClient and run the application. The two methods that call the PDS are ExecuteRequestXml and ExecuteRequestId.

The Project Initiation client also calls the following standard PDS methods:

  • ProjectCreate creates a real project from the initiation project.
  • ProjectsStatus gets the list of existing projects, to check if the initiation project already exists.
  • ResourcesStatus gets the list of enterprise resources.
  • EnterpriseOutlineCodes gets the existing project enterprise outline codes.
  • PermissionCheck determines if the user has New project permission (permission ID 1004).
  • ProjectsCheckout checks out the new project after it is created, to apply the selected outline codes.
  • ProjectsCheckin checks in the project after the outline code update.
  • ProjectCodeValuesUpdate adds the selected outline codes to the new project.

The application calls ProjectCreate when you click Create in the Project Initiation form. Using the same example as in Figure 2, following are the PDS request and reply.

<Request>
   <ProjectCreate>
      <AutoPublish>1</AutoPublish>
      <Project>
         <ProjectName>MegaStore.Published</ProjectName>
         <StartDate>20050420</StartDate>
         <Manager>Eva Corets</Manager>
         <Tasks>
            <Task>
               <Name>Project Start</Name>
               <ID>1</ID>
               <Deadline>20050420</Deadline>
               <ConstraintDate>20050420</ConstraintDate>
               <ConstraintType>4</ConstraintType>
               <Duration>0</Duration>
               <Milestone>1</Milestone>
            </Task>
            <Task>
               <Name>Planning</Name>
               <ID>3</ID>
               <Duration>0</Duration>
               <Milestone>1</Milestone>
            </Task>
            <Task>
               <Name>Foundations</Name>
               <ID>2</ID>
               <Duration>960</Duration>
            </Task>
         </Tasks>
         <Resources>
            <Resource>
               <Name>Jo Brown</Name>
            </Resource>
            <Resource>
               <Name>Kim Akers</Name>
            </Resource>
            <Resource>
               <Name>Lawyer</Name>
            </Resource>
         </Resources>
      </Project>
   </ProjectCreate>
</Request>
<Reply>
   <HRESULT>0</HRESULT>
   <STATUS>0</STATUS>
   <UserName>Administrator</UserName>
   <ProjectCreate>
      <Project>
         <ProjectName>MegaStore.Published</ProjectName>
         <ProjectID>42</ProjectID>
      </Project>
   </ProjectCreate>
</Reply>

The Project Initiation application sets the enterprise project outline codes after ProjectCreate completes. The application calls the EnterpriseOutlineCodes PDS method to get XML data for all of the outline codes, and then calls ProjectsCheckout with the ProjectID parameter from the ProjectCreate reply. The ComposeOutlineCodes method in MainFrame.cs iterates through each item in the list of outline codes. Following is the code that creates the Columns parameter of a ProjectCodeValuesUpdate XML request.

xmlWriter.WriteStartElement("Columns");

foreach (ListViewItem item in outlineList.Items)
{
   string[] lookup = OutlineCodesLookup(document, item.SubItems[0].Text, 
                                        item.SubItems[1].Text); 
   if (lookup != null)
   {
      xmlWriter.WriteStartElement("Column");
      xmlWriter.WriteElementString("UID", lookup[0]);
      xmlWriter.WriteElementString("ValueUID", lookup[1]);
      xmlWriter.WriteEndElement();
   }
}
xmlWriter.WriteEndElement();

The OutlineCodesLookup method matches the outline code name and then iterates through all of the values in that outline code to find a match for the specified value. In the following code, the document parameter contains the reply from EnterpriseOutlineCodes.

private string[] OutlineCodesLookup(
   XmlDocument document, 
   string codeName, 
   string codeValue)
{   
   string[] lookup = new string[2];   
   // Scan the codes for the required code name
   XmlNodeList outlineNodes = document.SelectNodes( 
                              "Reply/OutlineCodes/OutlineCode");
   foreach(XmlNode outlineNode in outlineNodes)
   {
      XmlNode codeUidNode = outlineNode.SelectSingleNode("UID");
      XmlNode codeNameNode = outlineNode.SelectSingleNode("Name");

      if (codeNameNode.InnerXml == codeName)
      {
         // Scan the values for the required value name
         XmlNodeList valuesNodes = 
            outlineNode.SelectNodes("Values/Value");
         foreach(XmlNode valueNode in valuesNodes)
         {
            XmlNode valueUidNode = valueNode.SelectSingleNode("UID");
            // The value is in the "ValueFull" node, not the "Value" node
            XmlNode valueFullNode = 
               valueNode.SelectSingleNode("ValueFull");
            if (valueFullNode.InnerXml == codeValue)
            {
               lookup[0] = codeUidNode.InnerXml;
               lookup[1] = valueUidNode.InnerXml;
               return lookup;
            }
         }
      }
   }
   return null;
}

The XML reply from the EnterpriseOutlineCodes PDS method includes the following (without the comment). The comment shows the specific enterprise project outline code (EPOC) referenced by that Field ID in the Project Server sample database.

<Reply>
   <HRESULT>0</HRESULT>
   <STATUS>0</STATUS>
   <UserName>Administrator</UserName>
   <OutlineCodes>
      <MaxUsedCodeUID>159</MaxUsedCodeUID>
      <OutlineCode>
         <UID>188744589</UID>  <!-- UID for 'Location' (EPOC 1) -->
         <Name>Location</Name>
         . . .
         <Values>
            . . .
            <Value>
               <UID>159</UID>
               <ParentUID>144</ParentUID>
               <Description></Description>
               <Value>Washington</Value>
               <ValueFull>USA.West.Washington</ValueFull>
            </Value>
         </Values>
         . . .
      </OutlineCode>
      . . .
   </OutlineCodes>
</Reply>

Using the ComposeOutlineCodes method, the Project Initiation application creates a ProjectCodeValuesUpdate PDS request. The AutoCheckin parameter is 1 to check in the project. Each UID parameter contains the Field ID value for a specific enterprise project outline code. Each ValueUID parameter in the following ProjectCodeValuesUpdate request matches the unique ID (UID) of the ValueFull element in the reply from EnterpriseOutlineCodes.

<Request>
   <ProjectCodeValuesUpdate>
      <ProjectID>45</ProjectID>
      <AutoCheckin>1</AutoCheckin>
      <Columns>
         <Column>
            <UID>188744592</UID>     <!-- 'Project Status' (EPOC 4)-->
            <ValueUID>22</ValueUID>  <!-- 'Opportunity'-->
            <UID>188744590</UID>     <!-- 'Sponsor' (EPOC 2) -->
            <ValueUID>18</ValueUID>  <!-- 'Manufacturing.Storage 
            Projects' -->
            <UID>188744589</UID>     <!-- 'Location' (EPOC 1) -->
            <ValueUID>159</ValueUID> <!-- 'USA.West.Washington' -->
         </Column>
      </Columns>
   </ProjectCodeValuesUpdate>
</Request>

For more information about the standard PDS methods, see the Project Data Service Reference for Microsoft Office Project Server 2003.

Client-side Design

The Project Initiation client is implemented as a Windows Forms application called ProjectInitiationClient. The client provides a data entry form and connection to the PDS and the ProjectInitiationPDS extension for projects being initiated.

The Client class provides an interface to the Project Server PDS for the Project Initiation form (MainFrame class). Client inherits from the Request class, which provides methods that assist in the process of wrapping and unwrapping the PDS XML data. The Proxy class provides the logical connection with the PDS Web service.

Table 1 describes the Client class methods that call PDS extensions and standard PDS methods.

Table 1. Methods in the Client class that call the PDS

Method Description
List Obtains a list of project records in the ProjectInitiation table, in XML format
Create Creates a new project initiation record
RetrieveData Obtains the XML data associated with a specific project initiation record; this data contains all information (tasks, resources, and so forth) displayed in the Project Initiation form
Retrieve Obtains the general data associated with a specific project initiation record
Update Saves the general and XML data associated with a specific project initiation record
Delete Deletes a specific project initiation record
TemplateList Obtains a list of project templates available in the Project Server database
ResourceList Obtains a list of resources available in the enterprise resource pool
PermissionCheck Checks that the user logged on to Project Server has permission ID 1004, to create a project
OutlineCodesList Obtains a list of available enterprise project outline codes
CreateProject Creates a new project in the Project Server database
CreateOutlineCodes Adds the specified outline codes and values to the newly created project
CheckoutProject Checks a project out from Project Server
CheckinProject Checks a project in to Project Server

Conclusion

Project Initiation with Windows Forms provides the basis for a simple and low-cost way for project users and managers to initiate projects. You can easily enhance the Project Initiation sample application to fit your business workflow processes or to provide additional features.

Additional Resources

For more information about the technologies that you can use when developing customizations for Project Server, visit the following Web sites.

Files in the Download

When you execute the pj11ProjectInitiationWinForms.exe download file, it installs the following files in the default path [Program Files]\Microsoft Office 2003 SDKs\Microsoft Office Project 2003 SDK\ProjectInitiationWinForms.

Table 2. Files in the pj11ProjectInitationWinForms.exe download

Subdirectory File Name Description
  Readme.rtf Reminder to modify the InstallPDS.bat script.
InstallServer InstallPDS.bat Script for installing the server components of the Project Initiation application.
     " ProjectInitiation.SQL T-SQL script that creates the ProjectInitiation table in the Project Server database, and the related stored procedures.
Source ProjectInitiationClient.sln Visual Studio .NET solution file; loads the ProjectInitiationClient and ProjectInitiationClientSetup projects.
Source

\ProjectInitiationClient

(25 files) Source files for the Project Initiation client application. The .exe files are not included in the download. When you compile the project, it builds the following files:
  • ProjectInitiationClient.exe
  • ProjectInitiationClient.exe.config
  • ProjectInitiationClient.pdb (in the Debug configuration)

Edit the .config file to set the Project Server URL and the logon option.

Source

\ProjectInitiationClientSetup

ProjectInitiationClientSetup.vdproj Source file for the setup project of the Project Initiation client. When you compile the project it builds the following files:
  • ProjectInitiationClientSetup.msi
  • Setup.exe
  • Setup.Ini
Source

\ProjectInitiationClientSetup

ProjectInitiationPDS.sln

(plus 9 files)

Solution and source files for the PDS extension project; when you compile the project, it builds ProjectInitiationPDS.dll.
Source

\ProjectInitiationRegister

ProjectInitiationRegister.sln

(plus 5 files)

Solution and source files for the utility that registers the PDS extension; when you compile the project, it builds ProjectInitiationRegister.exe.
Show:
© 2014 Microsoft