You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
451 lines
20 KiB
451 lines
20 KiB
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using Autodesk.AutoCAD.DatabaseServices;
|
|
using Autodesk.AutoCAD.Runtime;
|
|
using Autodesk.AutoCAD.Geometry;
|
|
using Autodesk.AutoCAD.ApplicationServices;
|
|
using Autodesk.AutoCAD.EditorInput;
|
|
|
|
using Teamcenter.Hello;
|
|
using Teamcenter.Soa.Client;
|
|
using Teamcenter.ClientX;
|
|
using Teamcenter.Services.Strong.Core;
|
|
using Teamcenter.Soa.Client.Model;
|
|
using Teamcenter.Soa.Exceptions;
|
|
using Teamcenter.Services.Strong.Query;
|
|
|
|
using Teamcenter.Services.Strong.Core._2007_06.DataManagement;
|
|
|
|
|
|
using User = Teamcenter.Soa.Client.Model.Strong.User;
|
|
using Folder = Teamcenter.Soa.Client.Model.Strong.Folder;
|
|
using WorkspaceObject = Teamcenter.Soa.Client.Model.Strong.WorkspaceObject;
|
|
using Item = Teamcenter.Soa.Client.Model.Strong.Item;
|
|
using ItemRevision = Teamcenter.Soa.Client.Model.Strong.ItemRevision;
|
|
using ImanQuery = Teamcenter.Soa.Client.Model.Strong.ImanQuery;
|
|
using DataSet = Teamcenter.Soa.Client.Model.Strong.Dataset;
|
|
|
|
using HelloTeamcenter.hello;
|
|
|
|
|
|
namespace HelloTeamcenter.form
|
|
{
|
|
public partial class SaveToTC : Form
|
|
{
|
|
public Document appdoc;
|
|
public User user;
|
|
public bool first = true;
|
|
public Folder home = null;
|
|
Editor ed;
|
|
|
|
public List<ALLOBJECT> folderlist = new List<ALLOBJECT>();
|
|
public List<ALLOBJECT> itemlist = new List<ALLOBJECT>();
|
|
public List<ALLOBJECT> itemvisionlist = new List<ALLOBJECT>();
|
|
public List<ALLOBJECT> datasetlist = new List<ALLOBJECT>();
|
|
|
|
public OriginBTL btlinfo;
|
|
public List<OriginMXL> bomlist;
|
|
public Hashtable itemtypetable;
|
|
|
|
public string xmlpath = "";
|
|
|
|
public SaveToTC()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void SaveToTC_Load(object sender, EventArgs e)
|
|
{
|
|
ed = appdoc.Editor;
|
|
treeView1.Nodes.Clear();
|
|
|
|
//读取Item类型.xml信息
|
|
OriginItemType originitemtype = new OriginItemType();
|
|
originitemtype.getType(this.xmlpath);
|
|
this.itemtypetable = originitemtype.Itemtypetable;
|
|
|
|
foreach (DictionaryEntry de in itemtypetable)
|
|
{
|
|
this.comboBox1.Items.Add(de.Key.ToString());
|
|
}
|
|
|
|
OriginReadXml originreadxml = new OriginReadXml();
|
|
OriginTypeRule origintyperule = originreadxml.OriginReadRuleXML(xmlpath);
|
|
OriginTool origintool = new OriginTool();
|
|
string itemtype = origintool.getItemType(btlinfo, origintyperule);
|
|
|
|
|
|
if (this.comboBox1.Items.Contains(itemtype))
|
|
this.comboBox1.SelectedText = itemtype;
|
|
else
|
|
{
|
|
this.comboBox1.Items.Add(itemtype);
|
|
this.comboBox1.SelectedText = itemtype;
|
|
}
|
|
|
|
TreeNode rootnode = new TreeNode("Home", 7, 7);
|
|
treeView1.Nodes.Add(rootnode);
|
|
|
|
WorkspaceObject[] contents = null;
|
|
DataManagementService dmService = DataManagementService.getService(Session.getConnection());
|
|
try
|
|
{
|
|
home = user.Home_folder;
|
|
}
|
|
catch (NotLoadedException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
ModelObject[] objects = { home };
|
|
String[] attributes = { "contents" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
contents = home.Contents;
|
|
}
|
|
catch (NotLoadedException ex) { MessageBox.Show(ex.Message); }
|
|
for (int i = 0; i < contents.Length; i++)
|
|
{
|
|
WorkspaceObject childobj = contents[i];
|
|
ModelObject[] objects = { childobj };
|
|
String[] attributes = { "object_string", "object_type" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
string name = childobj.Object_string;
|
|
string type = childobj.Object_type;
|
|
if (type == "Folder" || type == "Newstuff Folder" || type == "Mail Folder")
|
|
{
|
|
ALLOBJECT perobject = new ALLOBJECT();
|
|
perobject.workobject = childobj;
|
|
Folder fl = childobj as Folder;
|
|
if (type == "Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 1, 1);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
rootnode.Nodes.Add(childnode);
|
|
}
|
|
else if (type == "Newstuff Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 6, 6);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
rootnode.Nodes.Add(childnode);
|
|
}
|
|
else if (type == "Mail Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 5, 5);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
rootnode.Nodes.Add(childnode);
|
|
}
|
|
folderlist.Add(perobject);
|
|
}
|
|
else if (type == "Item" || this.itemtypetable.ContainsValue(type)) //需要替换类型
|
|
{
|
|
ALLOBJECT perobject = new ALLOBJECT();
|
|
perobject.workobject = childobj;
|
|
Item item = childobj as Item;
|
|
TreeNode childnode = new TreeNode(name, 3, 3);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
rootnode.Nodes.Add(childnode);
|
|
itemlist.Add(perobject);
|
|
}
|
|
}
|
|
foreach (TreeNode ch in rootnode.Nodes)
|
|
{
|
|
ch.EnsureVisible();
|
|
}
|
|
|
|
//这边是加载Item类型.xml文件的信息
|
|
////Tool tool = new Tool();
|
|
////BTLClass btlinfo = tool.getBTL("DFHM_BTL");
|
|
////string itemtype = tool.initItemType(btlinfo.Item_id, btlinfo.Materialgrade);
|
|
////this.comboBox1.SelectedText = itemtype;
|
|
}
|
|
|
|
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
|
|
{
|
|
TreeNode nownode = this.treeView1.SelectedNode;
|
|
|
|
getChild(nownode);
|
|
foreach (TreeNode ch in nownode.Nodes)
|
|
{
|
|
ch.EnsureVisible();
|
|
}
|
|
}
|
|
|
|
private void getChild(TreeNode nownode)
|
|
{
|
|
nownode.Nodes.Clear();
|
|
DataManagementService dmService = DataManagementService.getService(Session.getConnection());
|
|
WorkspaceObject[] contents = null;
|
|
string nodetext = nownode.Text;
|
|
int imageindex = nownode.SelectedImageIndex;
|
|
if (imageindex == 1)
|
|
{
|
|
foreach (ALLOBJECT perobject in folderlist)
|
|
{
|
|
if (perobject.treenode.Equals(nownode))
|
|
{
|
|
Folder fl = perobject.workobject as Folder;
|
|
ModelObject[] objects = { fl };
|
|
String[] attributes = { "contents" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
contents = fl.Contents;
|
|
for (int i = 0; i < contents.Length; i++)
|
|
{
|
|
WorkspaceObject childobj = contents[i];
|
|
ModelObject[] objects1 = { childobj };
|
|
String[] attributes1 = { "object_string", "object_type" };
|
|
dmService.RefreshObjects(objects1);
|
|
dmService.GetProperties(objects1, attributes1);
|
|
string name = childobj.Object_string;
|
|
string type = childobj.Object_type;
|
|
if (type == "Folder" || type == "Newstuff Folder" || type == "Mail Folder")
|
|
{
|
|
ALLOBJECT inperobject = new ALLOBJECT();
|
|
inperobject.workobject = childobj;
|
|
Folder infl = childobj as Folder;
|
|
|
|
if (type == "Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 1, 1);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
}
|
|
else if (type == "Newstuff Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 6, 6);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
}
|
|
else if (type == "Mail Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 5, 5);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
}
|
|
folderlist.Add(inperobject);
|
|
}
|
|
else if (type == "Item" || this.itemtypetable.ContainsValue(type))//需要替换类型
|
|
{
|
|
ALLOBJECT inperobject = new ALLOBJECT();
|
|
inperobject.workobject = childobj;
|
|
Item item = childobj as Item;
|
|
TreeNode childnode = new TreeNode(name, 3, 3);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
itemlist.Add(inperobject);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
|
|
}
|
|
else if (imageindex == 3)
|
|
{
|
|
foreach (ALLOBJECT perobject in itemlist)
|
|
{
|
|
if (perobject.treenode.Equals(nownode))
|
|
{
|
|
Item item = perobject.workobject as Item;
|
|
ModelObject[] itemrevisionlist = null;
|
|
ModelObject[] objects = { item };
|
|
String[] attributes = { "revision_list" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
itemrevisionlist = item.Revision_list;
|
|
for (int i = 0; i < itemrevisionlist.Length; i++)
|
|
{
|
|
ItemRevision itemrevision = itemrevisionlist[i] as ItemRevision;
|
|
ModelObject[] objects1 = { itemrevision };
|
|
String[] attributes1 = { "object_string", "object_type" };
|
|
dmService.RefreshObjects(objects1);
|
|
dmService.GetProperties(objects1, attributes1);
|
|
string name = itemrevision.Object_string;
|
|
string type = itemrevision.Object_type;
|
|
|
|
ALLOBJECT inperobject = new ALLOBJECT();
|
|
inperobject.workobject = itemrevision;
|
|
TreeNode childnode = new TreeNode(name, 4, 4);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
itemvisionlist.Add(inperobject);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
else if (imageindex == 4)
|
|
{
|
|
foreach (ALLOBJECT perobject in itemvisionlist)
|
|
{
|
|
if (perobject.treenode.Equals(nownode))
|
|
{
|
|
ItemRevision itemrevision = perobject.workobject as ItemRevision;
|
|
ExpandGRMRelationsPref myPref = new ExpandGRMRelationsPref();
|
|
RelationAndTypesFilter2 myFilter = new RelationAndTypesFilter2();
|
|
myFilter.RelationName = "IMAN_specification";
|
|
String[] typeVec = { "D5DWG", "Folder" };
|
|
myFilter.ObjectTypeNames = typeVec;
|
|
myPref.ExpItemRev = false;
|
|
RelationAndTypesFilter2[] myfilter = { myFilter };
|
|
myPref.Info = myfilter;
|
|
ModelObject[] objects1 = { itemrevision };
|
|
|
|
ExpandGRMRelationsResponse myResp = dmService.ExpandGRMRelationsForPrimary(objects1, myPref);
|
|
ExpandGRMRelationsOutput[] myoutput = myResp.Output;
|
|
for (int i = 0; i < myoutput.Length; i++)
|
|
{
|
|
ExpandGRMRelationsOutput one_out = myoutput[i];
|
|
for (int j = 0; j < one_out.OtherSideObjData.Length; j++)
|
|
{
|
|
ExpandGRMRelationsData otherSideData = one_out.OtherSideObjData[j];
|
|
for (int k = 0; k < otherSideData.OtherSideObjects.Length; k++)
|
|
{
|
|
Type typeinfo = otherSideData.OtherSideObjects[k].GetType();
|
|
string typename = typeinfo.Name;
|
|
if (typename == "Folder")
|
|
{
|
|
Folder infold = otherSideData.OtherSideObjects[k] as Folder;
|
|
|
|
ModelObject[] objects = { infold };
|
|
String[] attributes = { "object_string", "object_type" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
string name = infold.Object_string;
|
|
string type = infold.Object_type;
|
|
|
|
ALLOBJECT inperobject = new ALLOBJECT();
|
|
inperobject.workobject = infold;
|
|
TreeNode childnode = new TreeNode(name, 1, 1);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
folderlist.Add(inperobject);
|
|
}
|
|
else
|
|
{
|
|
DataSet dateset = otherSideData.OtherSideObjects[k] as DataSet;
|
|
ModelObject[] objects = { dateset };
|
|
String[] attributes = { "object_string" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
string name = dateset.Object_string;
|
|
|
|
ALLOBJECT inperobject = new ALLOBJECT();
|
|
inperobject.workobject = dateset;
|
|
inperobject.name = name;
|
|
TreeNode childnode = new TreeNode(name, 0, 0);
|
|
inperobject.treenode = childnode;
|
|
nownode.Nodes.Add(childnode);
|
|
datasetlist.Add(inperobject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
else if (imageindex == 6)
|
|
{
|
|
|
|
}
|
|
else if (imageindex == 7)
|
|
{
|
|
folderlist.Clear();
|
|
itemlist.Clear();
|
|
itemvisionlist.Clear();
|
|
datasetlist.Clear();
|
|
try
|
|
{
|
|
ModelObject[] objects = { home };
|
|
String[] attributes = { "contents" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
contents = home.Contents;
|
|
}
|
|
catch (NotLoadedException ex) { MessageBox.Show(ex.Message); }
|
|
for (int i = 0; i < contents.Length; i++)
|
|
{
|
|
WorkspaceObject childobj = contents[i];
|
|
ModelObject[] objects = { childobj };
|
|
String[] attributes = { "object_string", "object_type" };
|
|
dmService.RefreshObjects(objects);
|
|
dmService.GetProperties(objects, attributes);
|
|
string name = childobj.Object_string;
|
|
string type = childobj.Object_type;
|
|
if (type == "Folder" || type == "Newstuff Folder" || type == "Mail Folder")
|
|
{
|
|
ALLOBJECT perobject = new ALLOBJECT();
|
|
perobject.workobject = childobj;
|
|
Folder fl = childobj as Folder;
|
|
if (type == "Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 1, 1);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
nownode.Nodes.Add(childnode);
|
|
}
|
|
else if (type == "Newstuff Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 6, 6);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
nownode.Nodes.Add(childnode);
|
|
}
|
|
else if (type == "Mail Folder")
|
|
{
|
|
TreeNode childnode = new TreeNode(name, 5, 5);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
nownode.Nodes.Add(childnode);
|
|
}
|
|
folderlist.Add(perobject);
|
|
}
|
|
else if (type == "Item" || this.itemtypetable.ContainsValue(type))
|
|
{
|
|
ALLOBJECT perobject = new ALLOBJECT();
|
|
perobject.workobject = childobj;
|
|
Item item = childobj as Item;
|
|
TreeNode childnode = new TreeNode(name, 3, 3);
|
|
perobject.treenode = childnode;
|
|
perobject.name = name;
|
|
perobject.uid = childobj.Uid;
|
|
nownode.Nodes.Add(childnode);
|
|
itemlist.Add(perobject);
|
|
}
|
|
}
|
|
foreach (TreeNode ch in nownode.Nodes)
|
|
{
|
|
ch.EnsureVisible();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|