4 Replies Latest reply: Sep 14, 2013 3:50 AM by xavied edi RSS

    how to update primavera p6 API Using .net c#

    971312
      how to update primavera p6 API Using .net c#
        • 1. Re: how to update primavera p6 API Using .net c#
          gCubed
          If you have access to P6v7 or P6.2 software, you can find a .Net source code example of using the P6 web services. The C# source code was located in the P6 webservices file structure under a folder labeled demo.

          I looked around my system for a simple example but I have wrapped the P6ws servcies that I used to make it more .Net friendly.

          Gene

          I found the old sample code. Here are a few of the methods to give you an idea how it works.

          public void Login(String userName, String password, String hostName, String port)
          {
          AuthenticationService authService = new AuthenticationService();
          authService.CookieContainer = new System.Net.CookieContainer();

          authService.Url = "http://" + hostName + ":" + port + P6WS_SERVICES_AUTHENTICATION_SERVICE;

          Login loginObj = new Login();
          loginObj.UserName = userName;
          loginObj.Password = password;
          loginObj.DatabaseInstanceId = 1;
          loginObj.DatabaseInstanceIdSpecified = true;
          loginObj.VerboseFaults = true;
          loginObj.VerboseFaultsSpecified = true;
          LoginResponse loginReturn = authService.Login(loginObj);
          cookieContainer = authService.CookieContainer;
          }

          public void Logout(String host, String port)
          {
          AuthenticationService authService = new AuthenticationService();
          authService.CookieContainer = cookieContainer;

          authService.Url = "http://" + host + ":" + port + "/p6ws/services/AuthenticationService";
          LogoutResponse logoutReturn = authService.Logout(""); ;
          }

          public int ReadProject(String hostName, String portNumber, String projectId)
          {
          ProjectPortBinding apb = new ProjectPortBinding();

          apb.CookieContainer = cookieContainer;
          apb.Url = HTTP + hostName + ":" + portNumber + P6WS_SERVICES_PROJECT_SERVICE;

          ReadProjects rp = new ReadProjects();
          Primavera.Ws.P6.Project.ProjectFieldType[] projectFields = new Primavera.Ws.P6.Project.ProjectFieldType[1];
          projectFields[0] = Primavera.Ws.P6.Project.ProjectFieldType.ObjectId;
          rp.Filter = "Id='" + projectId + "'";
          rp.Field = projectFields;

          Primavera.Ws.P6.Project.Project[] projects = apb.ReadProjects(rp);

          if (projects != null && projects.Length > 0)
          {
          return (int)projects[0].ObjectId;
          }

          return 0;
          }

          public int[] CreateActivities(String hostName, String port, int projectObjectId)
          {
          ActivityPortBinding apb = new ActivityPortBinding();

          apb.CookieContainer = cookieContainer;
          apb.Url = HTTP + hostName + ":" + port + P6WS_SERVICES_ACTIVITY_SERVICE;

          Primavera.Ws.P6.Activity.Activity[] acts;
          acts = new Primavera.Ws.P6.Activity.Activity[3];

          Primavera.Ws.P6.Activity.Activity activity = null;
          for (int i = 0; i < 3; i++)
          {
          activity = new Primavera.Ws.P6.Activity.Activity();
          activity.ProjectObjectId = projectObjectId;
          activity.ProjectObjectIdSpecified = true;
          activity.Id = "TestAct"+(i+1);
          activity.Name = "TestAct"+(i+1);
          acts[i] = activity;
          }

          return apb.CreateActivities(acts);
          }
          • 2. Re: how to update primavera p6 API Using .net c#
            1009914
            gCubed, is there anyway you could upload (zipped) the .net demo directory? I have just been handed the task of writing an integration application using the P6 Web Services in .Net. There seems to be zero resources or examples for doing this. Any help would be appreciated.
            • 3. Re: how to update primavera p6 API Using .net c#
              gCubed
              I think in 8.1 or 8.2, Oracle dropped the .Net Demo. I have a P6.7 version (will look for it tonight). It is very basic and follows the Java demo flow.

              On P6 8.2, the p6wsstubs.dll in no longer included or at least I couldn't find it. It is easy to create one using wsdl.exe.

              If you use wsdl.exe with a parameter file, make sure you leave out the export service and enable sharetypes.

              I have a parameter file -- download it here: https://ggreiff.exavault.com/share/view/15i5-cslgi3ap


              Found a P6V7 .net demo files on an old VM. Same share named P6V7WsDemoNet.zip


              The hardest thing to get right is the Authentication if you aren't using cookies. I have played around with Username Token Profile but I was never able to get Require Nonce to work.


              Gene

              Edited by: gCubed on May 20, 2013 1:50 PM
              • 4. Re: how to update primavera p6 API Using .net c#
                xavied edi

                Hello

                I need create a integration with P6 r8.2

                Can you send a sample for .net

                Can you send me the parameter file for the wsdl.exe

                 

                 

                I prefer .net

                 

                if is not posible i write the program with the java api

                 

                Thanks in advance