Programmatically creating the project site and synchronizing with project in project server 2010

Unanswered Programmatically creating the project site and synchronizing with project in project server 2010

  • Monday, April 30, 2012 12:45 PM
     
     

    Hi All,

    How to Programmatically create the project site and associating with project in project server 2010

    Thanks and regards,

    Swati Jain


    • Edited by MsSPJ Monday, April 30, 2012 1:38 PM
    •  

All Replies

  • Wednesday, May 02, 2012 5:34 AM
     
      Has Code

    Hello Swati--

    Project Server PSI - WssInterOp web services might be useful in that case.
    The [WssInterop Web service] namespace is an arbitrary name for a reference to the WssInterop.asmx web service (or the WssInterop.svc service) of the PSI in Microsoft Project Server 2010. Methods in the WssInterop class can create or delete a Microsoft SharePoint Server 2010 site for projects, get information about or update the SharePoint sites and settings in a farm, synchronize or update user memberships in SharePoint sites, and determine whether a SharePoint web exists.
    http://msdn.microsoft.com/en-us/library/websvcwssinterop_di_pj14mref.aspx

    [SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/WssInterop/CreateWssSite", RequestNamespace = "http://schemas.microsoft.com/office/project/server/webservices/WssInterop/", 
    	ResponseNamespace = "http://schemas.microsoft.com/office/project/server/webservices/WssInterop/", 
    	Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
    public void CreateWssSite(
    	Guid projectUID,
    	Guid wssServerUID,
    	string wssWebFullUrl,
    	int webTemplateLcid,
    	string webTemplateName
    )

    You can use CreateWssSite method of WssInterOp class where you can set the TemplateName, LCId etc but make sure to have a setting in PWA>Server settings> Project site provision settings - Allow users to manually create project sites option enabled. By this way once a  project is created, You can run the code which will create a project site with template you specify.

    Hope that helps.


    Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82

  • Thursday, May 03, 2012 1:02 PM
     
     

    Hi Amit ,

    Thanks for replying

    I am trying to create project site as stated above

    for that I need to get the guid of project

    I got the following sample from some blog

    private static WebSvcProject.Project project = new WebSvcProject.Project();

    private void createTask_InitApproval(object sender, EventArgs e)
    {
        [... insert your other required task attributes ...]
        taskProps.ExtendedProperties["Project Name"] = Proj_Name[0];
        taskProps.ExtendedProperties["Project Owner"] = Proj_Owner_Name[0];
        taskProps.ExtendedProperties["ProjectUid"] = GetProjectUidFromProjectName(Proj_Name[0]);
    }
    public static Guid GetProjectUidFromProjectName(string projectName)
    {
        Guid projectGUID;
        project.Credentials = CredentialCache.DefaultCredentials;
        WebSvcProject.ProjectDataSet readProjDs = new WebSvcProject.ProjectDataSet();
        readProjDs = project.ReadProjectStatus(
            Guid.Empty,
            WebSvcProject.DataStoreEnum.WorkingStore,
            projectName,
            0
            );
        if (readProjDs.Project.Rows.Count == 1)
        {
            projectGUID = new Guid(readProjDs.Project[0].PROJ_UID.ToString());
        }
        else
        {
            throw new Exception("No Project by the name: " + projectName + " Found");
        }
        return projectGUID;
    }

    Is above example works only for 2007 version?

    But In my case

    I am not getting the exact reference of class

    I have added the reference of Project.asmx but still following object is not created in my case

    private static WebSvcProject.Project project = new WebSvcProject.Project();

    following is my example .what could be wrong with it?

    private static ServiceReference2.ProjectSoap project = null;
                 public static Guid GetProjectUidFromProjectName(string projectName)
            {
                   Guid projectGUID;
              
                  
                     ProjectDataSet readProjDs = new ProjectDataSet();
                     readProjDs = project.ReadProjectStatus(
                         Guid.Empty,
                        DataStoreEnum.WorkingStore,
                         projectName,
                         0
                         );
                     if (readProjDs.Project.Rows.Count == 1)
                     {
                         projectGUID = new Guid(readProjDs.Project[0].PROJ_UID.ToString());
                     }
                     else
                     {
                         throw new Exception("No Project by the name: " + projectName + " Found");
                     }
                return projectGUID;
            }