C# ArasPLM 登录的实现

来源:互联网 发布:如何编程写代码 编辑:程序博客网 时间:2024/05/16 05:18

Aras PLM是国外的一款免费的PLM软件,其开源性使的我们能够进行二次开发以满足不同用户的需求。这次实现的功能是登录PLM,获取用户列表。界面如下。

后台代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Aras.IOM;
using Aras.Client.Controls;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() != "" && textBox3.Text.Trim()!="" && textBox4.Text.Trim()!="")
            {
                string loginUser = textBox1.Text.Trim();
                string password = textBox2.Text.Trim();
                string serverUrl = textBox3.Text.Trim();
                string dbName = textBox4.Text.Trim();
                HttpServerConnection myArasServerConnection = IomFactory.CreateHttpServerConnection(serverUrl, dbName, loginUser, password);
                Item myArasLoginItem = myArasServerConnection.Login();
                Innovator myArasInnovator = myArasLoginItem.getInnovator();
               
                Item MyItem = myArasInnovator.newItem("User","get");
                MyItem.setAttribute("select","first_name,last_name");
                Item MyResult = MyItem.apply();
                if (MyResult.isError())
                {
                    msgBox.AppendText("\n\nQuery Error: " + MyResult.getErrorDetail());
                    return;
                }
                MyItem = MyResult.getItemsByXPath("//Item[@type='User']");
                msgBox.AppendText("\nQuery Found " + MyItem.getItemCount() + " User Items\n");
                for (int i=0; i <MyResult.getItemCount();i++)
                {
                    msgBox.AppendText("\n " + i + " " + MyItem.getItemByIndex(i).getProperty("first_name","na") + " " + MyItem.getItemByIndex(i).getProperty("last_name","na") );
                }

            }
           
        }
    }
}

 

运行结果:

原创粉丝点击