如何使用C#通过P6 Web服务在P6DB中读写数据 [英] How to read and write data in P6DB via P6 Web service using C#

查看:53
本文介绍了如何使用C#通过P6 Web服务在P6DB中读写数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 P6 网络服务中使用基于 Cookie 的身份验证,我遵循以下两个链接

I want to use Cookie based authentication in P6 web service and I followed below two links

  1. http://docs.oracle.com/cd/E16281_01/Technical_Documentation/Web_Services/ProgrammersGuide/Logging_into_Primavera_Web_Services.htm#dotnetexample
  2. http://docs.oracle.com/cd/E16281_01/Technical_Documentation/Web_Services/ProgrammersGuide/whnjs.htm

现在我可以使用基于 cookie 的身份验证登录,但是当我尝试进行下一步时,我感到震惊.

Now I am able to Login with cookie based authentication but when I tries to proceed the next step I am strucked.

例如.我想在 P6 DB 中创建一个新活动,我按照以下步骤操作.

For eg. I want to create a new activity in P6 DB, I followed the below steps.

  1. 登录系统(创建 Cookie 容器):我为 AuthenticationService.wsdl 添加了服务引用

  1. Login to system (create a Cookie Container) : I added service reference for AuthenticationService.wsdl

System.Net.CookieContainer cookieContainer;
public void Login(String userName, String password)
{

    AuthenticationServiceWebRef.AuthenticationService authService = new  AuthenticationServiceWebRef.AuthenticationService();
    authService.CookieContainer = new System.Net.CookieContainer();

    authService.Url = ConfigurationManager.AppSettings["WSAuthenticationService"];
    AuthenticationServiceWebRef.Login loginObj = new AuthenticationServiceWebRef.Login();
    loginObj.UserName = userName;
    loginObj.Password = password;
    loginObj.DatabaseInstanceId = 1;
    loginObj.DatabaseInstanceIdSpecified = true;
    AuthenticationServiceWebRef.LoginResponse loginReturn = authService.Login(loginObj);
    cookieContainer = authService.CookieContainer;
}

  • 创建活动:我为 ActivityService?wsdl 添加服务引用

  • Create the Activity : I add service reference for ActivityService?wsdl

            Login(WSUsername, WSPassword);
            ActivityPortBinding apb = new ActivityPortBinding();
            apb.CookieContainer = cookieContainer;
            apb.Url = ConfigurationManager.AppSettings["WSGetDataByID"];
            Activity[] acts;
            acts = new Activity[1];
    
            Activity activity = null;
            for (int i = 0; i < 1; i++)
            {
                activity = new Activity();
                activity.ProjectObjectId = iProjectObjectID;
                activity.ProjectObjectIdSpecified = true;
                activity.Id = "P6 Test" + (i + 1);
                activity.Name = "P6 Test" + (i + 1);
                acts[i] = activity;
            }
            int [] arrayObjectIDs= apb.CreateActivities(acts);
            iRetActivityObjectID = arrayObjectIDs[0];
    

  • 问题出现在第二步,我无法创建 ActivityPortBinding 类.

    The issue is coming in second step, I am not able to create ActivityPortBinding class.

    错误:找不到类型或命名空间名称ActivityPortBinding"(您是否缺少 using 指令或程序集引用?)

    Error : The type or namespace name 'ActivityPortBinding' could not be found (are you missing a using directive or an assembly reference?)

    1. 你能帮我找出我在上面代码中出错的地方吗?
    2. 我在步骤 1 中调用了正确的 Login() 吗?
    3. 我应该对 Step2 中的 ActivityPortBinding 类使用哪个参考?

    提前致谢!

    推荐答案

    act1.ReadActivities(act)
    

    这行代码给出空值或数组长度为零.已经有数据加载 P6.P6端是否需要设置

    This line of code is giving null or array length zero. There is already data loaded P6. Whether there is any setting to be done on P6 side

    这篇关于如何使用C#通过P6 Web服务在P6DB中读写数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆