Freigeben über


Project.UpdateProjectWorkspaceAddress-Methode

Aktualisiert die Projektwebsite-URL und des Namens in einer SharePoint-Website.

Namespace:  WebSvcProject
Assembly:  ProjectServerServices (in ProjectServerServices.dll)

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/UpdateProjectWorkspaceAddress", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Project/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Project/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub UpdateProjectWorkspaceAddress ( _
    projectUid As Guid, _
    newWebName As String, _
    newWSSServerUID As Guid _
)
'Usage
Dim instance As Project
Dim projectUid As Guid
Dim newWebName As String
Dim newWSSServerUID As Guid

instance.UpdateProjectWorkspaceAddress(projectUid, _
    newWebName, newWSSServerUID)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/UpdateProjectWorkspaceAddress", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Project/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Project/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void UpdateProjectWorkspaceAddress(
    Guid projectUid,
    string newWebName,
    Guid newWSSServerUID
)

Parameter

  • newWebName
    Typ: System.String

    Der neue Name des der Projektwebsite.

  • newWSSServerUID
    Typ: System.Guid

    Die GUID der neuen SharePoint-Server.

Hinweise

Das Ziel Projektwebsite muss vorhanden sein, oder ein WSSWebDoesNotExist Fehler ausgelöst wird. CreateWssSite wird eine neue Website für ein bestimmtes Projekt erstellen.

Wenn die neue Projektwebsite bereits verwendet wird, wird ein WSSSpWebAlreadyLinkedToProject Fehler ausgelöst.

Das angegebene Projekt muss in der Datenbank Published vorhanden sein.

Project Server-Berechtigungen

Berechtigung

Beschreibung

ManageWindowsSharePointServices

Ermöglicht einem Benutzer das Verwalten von SharePoint-Websites für Project Server. Die globale Berechtigung.

Beispiele

Im folgenden Beispiel wird ein neues Projekt erstellt, veröffentlicht wird und ändert anschließend die Projektwebsite Zuordnung zu einer entsprechen, die Sie erstellt haben.

Wichtige Informationen zum Ausführen dieses Codebeispiel finden Sie unter Prerequisites for Reference Code Samples.

Sie benötigen zum Erstellen einer Project Server- Projektwebsite im Beispiel zu verwenden. Es dient als die neue Projektwebsite für dieses Projekt.

  1. Öffnen Sie die Website Project Web App (https://ServerName/ProjectServerName/.

  2. Klicken Sie auf der rechten oberen Ecke auf Websiteaktionen. Wählen Sie Erstellen.

  3. Klicken Sie unter Webseiten auf Websites und Arbeitsbereiche.

  4. Geben Sie einen Titel, Beschreibung, und URL-Name.

    Notieren Sie sich den URL-Namen, die Sie eingegeben haben. Sie benötigen sie für das folgende Beispiel:

  5. Wählen Sie die Microsoft Office Project-Arbeitsbereichs-Vorlage.

  6. Klicken Sie auf Erstellen.

  7. Legen Sie den Wert des NEW WORKSPACE im Beispiel entsprechend der URL-Name, die Sie zuvor eingegeben haben.

Wenn Sie das Beispiel in einer Zeile zweimal ausführen, erhalten Sie einen Fehler. Dies liegt daran die Website, die Sie zuvor vorgenommen dem Projekt zugeordnet wird, die Sie in der Stichprobe erstellen. Sie können entweder verwenden die Project Web App BereichServereinstellungen , um das Projekt zu löschen, die gerade (https://ServerName/ProjectServerName/admin/admin.aspxerstellt wurde), oder Sie können einen Anruf UpdateProjectWorkspaceAddress für die Projektwebsite des vorherigen Projekts festzulegen, string.Emptyhinzufügen.

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web.Services.Protocols;
using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.UpdateProjectWorkspaceAddress
{
   class Program
   {
      [STAThread]
      static void Main()
      {
         try
         {
            #region Setup
            // Replace the NEW_WORKSPACE value with the workspace name
            // that you created above.
            const string NEW_WORKSPACE = "NEW WORKSPACE";
            const string PROJECT_SERVER_URI = "https://ServerName/ProjectServerName/";
            const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx";
            const string QUEUESYSTEM_SERVICE_PATH = "_vti_bin/psi/queuesystem.asmx";
            const string WSSINTEROP_SERVICE_PATH = "_vti_bin/psi/wssinterop.asmx";
            const string SESSION_DESC = "Update Workspace Sample";

            Guid sessionId = Guid.NewGuid();
            Guid jobId;

            // Set up the web service objects.
            SvcProject.Project projectSvc = new SvcProject.Project();

            projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
            projectSvc.Credentials = CredentialCache.DefaultCredentials;

            SvcQueueSystem.QueueSystem q = new SvcQueueSystem.QueueSystem();
            q.Url = PROJECT_SERVER_URI + QUEUESYSTEM_SERVICE_PATH;
            q.Credentials = CredentialCache.DefaultCredentials;

            SvcWssInterop.WssInterop wssInterOpSvc = new SvcWssInterop.WssInterop();
            wssInterOpSvc.Url = PROJECT_SERVER_URI + WSSINTEROP_SERVICE_PATH;
            wssInterOpSvc.Credentials = CredentialCache.DefaultCredentials;

            // Create a sample project.
            Console.WriteLine("Creating the project");
            Guid projectId = CreateSampleProject(projectSvc, q);
            Console.WriteLine("\tProject UID: " + projectId);

            // Publish the project.
            Console.WriteLine("Publishing the project");
            jobId = Guid.NewGuid();
            projectSvc.QueuePublish(jobId, projectId, true, SESSION_DESC);
            WaitForQueue(q, jobId);
            #endregion
            #region Get workspace info
            // Get the admin settings that are necessary for site linking.
            Console.WriteLine("Getting the server info");
            SvcWssInterop.WssSettingsDataSet dsCurrentWssInfo = wssInterOpSvc.ReadWssSettings();
            SvcWssInterop.WssSettingsDataSet.WssAdminRow adminRow = dsCurrentWssInfo.WssAdmin[0];

            Guid wssWebAppUid = adminRow.WADMIN_CURRENT_STS_SERVER_UID;
            string siteCollection = string.Empty;
            if (!adminRow.IsWADMIN_DEFAULT_SITE_COLLECTIONNull())
            {
               siteCollection = adminRow.WADMIN_DEFAULT_SITE_COLLECTION;
            }
            #endregion
            #region Change Workspace Address
            Console.WriteLine("Changing the address");
            projectSvc.UpdateProjectWorkspaceAddress(projectId, siteCollection + "/"+ NEW_WORKSPACE , wssWebAppUid);
            #endregion
         }
         #region Exception Handling and Final
         catch (SoapException ex)
         {
            PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
            PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
            string errMess = "==============================\r\nError: \r\n";
            for (int i = 0; i < errors.Length; i++)
            {
               errMess += "\n" + ex.Message.ToString() + "\r\n";
               errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
               errMess += errors[i].ErrId.ToString() + "\n";

               for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
               {
                  errMess += "\r\n\t" + errors[i].ErrorAttributeNames()[j] + ": " + errors[i].ErrorAttributes[j];
               }
               errMess += "\r\n".PadRight(30, '=');
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(errMess);
         }
         catch (WebException ex)
         {
            string errMess = ex.Message.ToString() +
               "\n\nLog on, or check the Project Server Queuing Service";
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + errMess);
         }
         catch (Exception ex)
         {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + ex.Message);
         }
         finally
         {
            Console.ResetColor();
            Console.WriteLine("\r\n\r\nPress any key...");
            Console.ReadKey();
         }
         #endregion
      }

      #region Supporting Classes
      // Wait for the job to finish.
      // Outputs job status to the console.
      static private void WaitForQueue(SvcQueueSystem.QueueSystem q, Guid jobId)
      {
         SvcQueueSystem.JobState jobState;
         const int QUEUE_WAIT_TIME = 2; // two seconds
         bool jobDone = false;
         string xmlError = string.Empty;
         int wait = 0;

         // Wait for the project to get through the queue.
         // Get the estimated wait time in seconds.
         wait = q.GetJobWaitTime(jobId);

         // Wait for it.
         Thread.Sleep(wait * 1000);
         // Wait until it is finished.

         do
         {
            // Get the job state.
            jobState = q.GetJobCompletionState(jobId, out xmlError);

            if (jobState == SvcQueueSystem.JobState.Success)
            {
               jobDone = true;
            }
            else
            {
               if (jobState == SvcQueueSystem.JobState.Unknown
               || jobState == SvcQueueSystem.JobState.Failed
               || jobState == SvcQueueSystem.JobState.FailedNotBlocking
               || jobState == SvcQueueSystem.JobState.CorrelationBlocked
               || jobState == SvcQueueSystem.JobState.Canceled)
               {
                  // If the job failed, error out.
                  throw (new ApplicationException("Queue request " + jobState + " for Job ID " + jobId + ".\r\n" + xmlError));
               }
               else
               {
                  Console.WriteLine("Job State: " + jobState + " for Job ID: " + jobId);
                  Thread.Sleep(QUEUE_WAIT_TIME * 1000);
               }
            }
         }
         while (!jobDone);
      }
      static private Guid CreateSampleProject(SvcProject.Project projectSvc, SvcQueueSystem.QueueSystem q)
      {
         SvcProject.ProjectDataSet projectDs = new SvcProject.ProjectDataSet();
         Guid jobId;
         // Create the project.
         SvcProject.ProjectDataSet.ProjectRow projectRow = projectDs.Project.NewProjectRow();
         Guid projectId = Guid.NewGuid();
         projectRow.PROJ_UID = projectId;
         projectRow.PROJ_NAME = "Its a wonderful project at " + 
            DateTime.Now.ToShortDateString().Replace("/", "") + " " + 
            DateTime.Now.ToShortTimeString().Replace(":", "");
         projectRow.PROJ_TYPE = (int)PSLibrary.Project.ProjectType.Project;
         projectDs.Project.AddProjectRow(projectRow);

         // Add some tasks.
         SvcProject.ProjectDataSet.TaskRow taskOne = projectDs.Task.NewTaskRow();
         taskOne.PROJ_UID = projectId;
         taskOne.TASK_UID = Guid.NewGuid();
         // The Task Duration format must be specified.
         taskOne.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
         taskOne.TASK_DUR = 4800;  // 8 hours in duration units (minute/10)
         taskOne.TASK_NAME = "Task One";
         taskOne.TASK_START_DATE = System.DateTime.Now.AddDays(1);
         projectDs.Task.AddTaskRow(taskOne);

         SvcProject.ProjectDataSet.TaskRow taskTwo = projectDs.Task.NewTaskRow();
         taskTwo.PROJ_UID = projectId;
         taskTwo.TASK_UID = Guid.NewGuid();
         // The Task Duration format must be specified.
         taskTwo.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
         taskTwo.TASK_DUR = 4800;  // 8 hours in duration units (minute/10)
         taskTwo.TASK_NAME = "Task Two";
         projectDs.Task.AddTaskRow(taskTwo);

         // Make task two dependent on task one.
         SvcProject.ProjectDataSet.DependencyRow dependency = projectDs.Dependency.NewDependencyRow();
         dependency.LINK_UID = Guid.NewGuid();
         dependency.PROJ_UID = projectId;
         dependency.LINK_PRED_UID = taskOne.TASK_UID;
         dependency.LINK_SUCC_UID = taskTwo.TASK_UID;
         dependency.LINK_TYPE = 1;  //Finish to Start
         dependency.LINK_LAG_FMT = (int)PSLibrary.Task.DurationFormat.Hour;
         dependency.LINK_LAG = 0;
         projectDs.Dependency.AddDependencyRow(dependency);

         // Add a summary task.
         SvcProject.ProjectDataSet.TaskRow taskOthers = projectDs.Task.NewTaskRow();
         taskOthers.PROJ_UID = projectId;
         taskOthers.TASK_UID = Guid.NewGuid();
         taskOthers.TASK_NAME = "Other Tasks";
         projectDs.Task.AddTaskRow(taskOthers);

         // Add some subtasks.

         SvcProject.ProjectDataSet.TaskRow taskThree = projectDs.Task.NewTaskRow();
         taskThree.PROJ_UID = projectId;
         taskThree.TASK_UID = Guid.NewGuid();
         // The Task Duration format must be specified.
         taskThree.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
         taskThree.TASK_DUR = 4800;  // 8 hours in duration units (minute/10)
         taskThree.TASK_NAME = "Task Three";
         taskThree.TASK_PARENT_UID = taskOthers.TASK_UID;
         taskThree.TASK_OUTLINE_LEVEL = 2;
         projectDs.Task.AddTaskRow(taskThree);

         SvcProject.ProjectDataSet.TaskRow taskFour = projectDs.Task.NewTaskRow();
         taskFour.PROJ_UID = projectId;
         taskFour.TASK_UID = Guid.NewGuid();
         // The Task Duration format must be specified.
         taskFour.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
         taskFour.TASK_DUR = 4800;  // 8 hours in duration units (minute/10)
         taskFour.TASK_NAME = "Task Four";
         taskFour.TASK_PARENT_UID = taskOthers.TASK_UID;
         taskFour.TASK_OUTLINE_LEVEL = 2;
         projectDs.Task.AddTaskRow(taskFour);


         // Make task four dependent on task three.
         dependency = projectDs.Dependency.NewDependencyRow();
         dependency.LINK_UID = Guid.NewGuid();
         dependency.PROJ_UID = projectId;
         dependency.LINK_PRED_UID = taskThree.TASK_UID;
         dependency.LINK_SUCC_UID = taskFour.TASK_UID;
         dependency.LINK_TYPE = 1;  //Finish to Start
         dependency.LINK_LAG_FMT = (int)PSLibrary.Task.DurationFormat.Hour;
         dependency.LINK_LAG = 0;
         projectDs.Dependency.AddDependencyRow(dependency);

         // Make others task dependent on task two.
         dependency = projectDs.Dependency.NewDependencyRow();
         dependency.LINK_UID = Guid.NewGuid();
         dependency.PROJ_UID = projectId;
         dependency.LINK_PRED_UID = taskTwo.TASK_UID;
         dependency.LINK_SUCC_UID = taskOthers.TASK_UID;
         dependency.LINK_TYPE = 1;  //Finish to Start
         dependency.LINK_LAG_FMT = (int)PSLibrary.Task.DurationFormat.Hour;
         dependency.LINK_LAG = 0;
         projectDs.Dependency.AddDependencyRow(dependency);

         //Add some resources.
         SvcProject.ProjectDataSet.ProjectResourceRow resourceOne = projectDs.ProjectResource.NewProjectResourceRow();
         resourceOne.PROJ_UID = projectId;
         resourceOne.RES_UID = Guid.NewGuid();
         resourceOne.RES_NAME = "Brynja Sigrídur Blomsterberg";
         resourceOne.RES_INITIALS = "BSB";
         projectDs.ProjectResource.AddProjectResourceRow(resourceOne);
         CreateAssignment(projectDs, taskOne.TASK_UID, resourceOne.RES_UID);
         CreateAssignment(projectDs, taskTwo.TASK_UID, resourceOne.RES_UID);

         SvcProject.ProjectDataSet.ProjectResourceRow resourceTwo = projectDs.ProjectResource.NewProjectResourceRow();
         resourceTwo.PROJ_UID = projectId;
         resourceTwo.RES_UID = Guid.NewGuid();
         resourceTwo.RES_NAME = "Ioannis Xylaras";
         resourceTwo.RES_INITIALS = "IX";
         projectDs.ProjectResource.AddProjectResourceRow(resourceTwo);
         CreateAssignment(projectDs, taskOne.TASK_UID, resourceTwo.RES_UID);
         CreateAssignment(projectDs, taskTwo.TASK_UID, resourceTwo.RES_UID);
         CreateAssignment(projectDs, taskThree.TASK_UID, resourceTwo.RES_UID);
         CreateAssignment(projectDs, taskFour.TASK_UID, resourceTwo.RES_UID);

         // Save the project to the database.
         jobId = Guid.NewGuid();
         projectSvc.QueueCreateProject(jobId, projectDs, false);
         WaitForQueue(q, jobId);
         return projectRow.PROJ_UID;
      }
      // A helper function for CreateSampleProject.
      // Makes simple assignments.
      private static void CreateAssignment(SvcProject.ProjectDataSet projectDs, Guid taskGuid, Guid resourceGuid)
      {
         SvcProject.ProjectDataSet.AssignmentRow assnRow = projectDs.Assignment.NewAssignmentRow();
         assnRow.PROJ_UID = projectDs.Project[0].PROJ_UID;
         assnRow.ASSN_UID = Guid.NewGuid();
         assnRow.TASK_UID = taskGuid;
         assnRow.RES_UID = resourceGuid;
         projectDs.Assignment.AddAssignmentRow(assnRow);
      }
      #endregion
   }
}

Siehe auch

Referenz

Project Klasse

Project-Member

WebSvcProject-Namespace