|
|
//==================================================
|
|
|
//
|
|
|
// @<COPYRIGHT>@
|
|
|
//
|
|
|
//==================================================
|
|
|
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using Teamcenter.ClientX;
|
|
|
using Autodesk.AutoCAD.DatabaseServices;
|
|
|
using Autodesk.AutoCAD.Runtime;
|
|
|
using Autodesk.AutoCAD.Geometry;
|
|
|
using Autodesk.AutoCAD.ApplicationServices;
|
|
|
using Autodesk.AutoCAD.EditorInput;
|
|
|
using Autodesk.AutoCAD.Windows;
|
|
|
using HelloTeamcenter.hello;
|
|
|
using HelloTeamcenter.form;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using System.IO;
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Teamcenter.Services.Strong.Core;
|
|
|
using Teamcenter.Soa.Client.Model;
|
|
|
using Teamcenter.Services.Strong.Core._2006_03.Reservation;
|
|
|
using Teamcenter.Services.Strong.Core._2006_03.FileManagement;
|
|
|
using Teamcenter.Services.Strong.Core._2006_03.DataManagement;
|
|
|
using Teamcenter.Services.Strong.Core._2007_01.DataManagement;
|
|
|
using Teamcenter.Services.Strong.Core._2007_06.DataManagement;
|
|
|
|
|
|
using Teamcenter.Soa.Internal.Client.Model;
|
|
|
using Teamcenter.Soa.Internal.Client;
|
|
|
using Teamcenter.Soa.Client;
|
|
|
using Teamcenter.Services.Strong.Query;
|
|
|
//using Teamcenter.FMS.FCCProxy.ClientCache;
|
|
|
using Teamcenter.Schemas.Soa._2006_03.Exceptions;
|
|
|
using Teamcenter.Soa.Exceptions;
|
|
|
|
|
|
|
|
|
using User = Teamcenter.Soa.Client.Model.Strong.User;
|
|
|
using DataSet = Teamcenter.Soa.Client.Model.Strong.Dataset;
|
|
|
using ImanFile = Teamcenter.Soa.Client.Model.Strong.ImanFile;
|
|
|
using SavedQueryResults = Teamcenter.Services.Strong.Query._2007_06.SavedQuery.SavedQueryResults;
|
|
|
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 ReleaseStatus = Teamcenter.Soa.Client.Model.Strong.ReleaseStatus;
|
|
|
using Form = Teamcenter.Soa.Client.Model.Strong.Form;
|
|
|
using Dataset = Teamcenter.Soa.Client.Model.Strong.Dataset;
|
|
|
using Folder = Teamcenter.Soa.Client.Model.Strong.Folder;
|
|
|
using WorkspaceObject = Teamcenter.Soa.Client.Model.Strong.WorkspaceObject;
|
|
|
|
|
|
[assembly: ExtensionApplication(typeof(Teamcenter.Hello.Hello))]
|
|
|
[assembly: CommandClass(typeof(Teamcenter.Hello.Hello))]
|
|
|
|
|
|
namespace Teamcenter.Hello
|
|
|
{
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
public class Hello : Autodesk.AutoCAD.Runtime.IExtensionApplication
|
|
|
{
|
|
|
static User loginuser;
|
|
|
Login loginfrom;
|
|
|
OpenFromTC openfrom;
|
|
|
Search searchfrom;
|
|
|
SaveToTC savefrom;
|
|
|
static Autodesk.AutoCAD.EditorInput.Editor ed;
|
|
|
static Autodesk.AutoCAD.ApplicationServices.Document appodc;
|
|
|
static DocumentCollection acdocmgr;
|
|
|
static Teamcenter.ClientX.Session session;
|
|
|
//
|
|
|
bool islogin = false;
|
|
|
bool hasRight = true;
|
|
|
string serveraddress;
|
|
|
string username;
|
|
|
string password;
|
|
|
string usergroup;
|
|
|
string userrole;
|
|
|
//
|
|
|
|
|
|
public void Initialize()
|
|
|
{
|
|
|
//addComtextMenu();
|
|
|
}
|
|
|
public void Terminate()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
[CommandMethod("LOGIN")]
|
|
|
public void login()
|
|
|
{
|
|
|
appodc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
|
|
|
acdocmgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
|
|
|
//acdocmgr.DocumentToBeDestroyed+=new DocumentCollectionEventHandler(acdocmgr_DocumentToBeDestroyed);
|
|
|
|
|
|
ed = appodc.Editor;
|
|
|
ed.WriteMessage("==========login==========\n");
|
|
|
loginfrom = new Login();
|
|
|
loginfrom.appodc = appodc;
|
|
|
loginfrom.button1.Click += new System.EventHandler(this.loginbutton1_Click);
|
|
|
loginfrom.button2.Click += new System.EventHandler(this.loginbutton2_Click);
|
|
|
loginfrom.Activate();
|
|
|
loginfrom.Show();
|
|
|
//ed.WriteMessage("==========here===========\n");
|
|
|
|
|
|
|
|
|
}
|
|
|
//<2F><>½
|
|
|
private void loginbutton1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
loginfrom.m_WebAddress = loginfrom.textBox1.Text.ToString();
|
|
|
loginfrom.username = loginfrom.textBox2.Text.ToString();
|
|
|
loginfrom.password = loginfrom.textBox3.Text.ToString();
|
|
|
loginfrom.usergroup = loginfrom.textBox4.Text.ToString();
|
|
|
loginfrom.userrole = loginfrom.textBox5.Text.ToString();
|
|
|
session = new Teamcenter.ClientX.Session(loginfrom.m_WebAddress);
|
|
|
loginuser = session.mylogin(loginfrom.username, loginfrom.password, loginfrom.usergroup, loginfrom.userrole);
|
|
|
if (loginuser != null)
|
|
|
{
|
|
|
serveraddress = loginfrom.m_WebAddress;
|
|
|
username = loginfrom.username;
|
|
|
password = loginfrom.password;
|
|
|
usergroup = loginfrom.usergroup;
|
|
|
userrole = loginfrom.userrole;
|
|
|
Tool.Loginuser = loginuser;
|
|
|
islogin = true;
|
|
|
string tempdir = System.Environment.GetEnvironmentVariable("TEMP").ToString();
|
|
|
string loginfile = tempdir + "\\login.ini";
|
|
|
loginfrom.Hide();
|
|
|
//loginfrom.Dispose();
|
|
|
if (File.Exists(loginfile))
|
|
|
{
|
|
|
StreamWriter sw = new StreamWriter(loginfile, false);
|
|
|
sw.WriteLine(loginfrom.m_WebAddress + "|" + loginfrom.username + "|" + loginfrom.password
|
|
|
+ "|" + loginfrom.usergroup + "|" + loginfrom.userrole + "||");
|
|
|
sw.Close();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
FileStream fs = new FileStream(loginfile, FileMode.Create, FileAccess.Write);
|
|
|
StreamWriter sw = new StreamWriter(fs);
|
|
|
sw.WriteLine(loginfrom.m_WebAddress + "|" + loginfrom.username + "|" + loginfrom.password
|
|
|
+ "|" + loginfrom.usergroup + "|" + loginfrom.userrole + "||");
|
|
|
sw.Close();
|
|
|
fs.Close();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("<22>Բ<EFBFBD><D4B2>𣬵<EFBFBD>¼ʧ<C2BC>ܣ<EFBFBD><DCA3><EFBFBD>ȷ<EFBFBD><C8B7>");
|
|
|
//*************** Modified by Samsara May/03/2012 ***************
|
|
|
//loginfrom.Dispose();
|
|
|
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD>ౣ<EFBFBD><E0B1A3>
|
|
|
loginfrom.textBox3.Text = "";
|
|
|
}
|
|
|
ed.WriteMessage("\n");
|
|
|
}
|
|
|
//ȡ<><C8A1>
|
|
|
private void loginbutton2_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
loginfrom.Hide();
|
|
|
loginfrom.Dispose();
|
|
|
}
|
|
|
bool hadlogin = false;
|
|
|
|
|
|
[CommandMethod("OPEN_FROM_TC")]
|
|
|
public void openformtc()
|
|
|
{
|
|
|
if (loginuser != null)
|
|
|
hadlogin = true;
|
|
|
else
|
|
|
login();
|
|
|
|
|
|
if (hadlogin == true)
|
|
|
{
|
|
|
openfrom = new OpenFromTC();
|
|
|
openfrom.appodc = appodc;
|
|
|
openfrom.user = loginuser;
|
|
|
openfrom.button1.Click += new System.EventHandler(this.openbutton1_Click);
|
|
|
openfrom.button2.Click += new System.EventHandler(this.openbutton2_Click);
|
|
|
openfrom.Activate();
|
|
|
openfrom.Show();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void openbutton1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
DataManagementService dmService = DataManagementService.getService(Session.getConnection());
|
|
|
Reservation res = ReservationService.getService(Session.getConnection());
|
|
|
Editor ed1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
|
|
|
TreeNode nownode = this.openfrom.treeView1.SelectedNode;
|
|
|
if (nownode.SelectedImageIndex == 0)
|
|
|
{
|
|
|
List<ALLOBJECT> datasetlist = this.openfrom.datasetlist;
|
|
|
foreach (ALLOBJECT perobject in datasetlist)
|
|
|
{
|
|
|
if (perobject.treenode.Equals(nownode))
|
|
|
{
|
|
|
this.openfrom.textBox1.Text = perobject.name;
|
|
|
DialogResult isopen = MessageBox.Show("<22><><EFBFBD>Ƿ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>ͼֽ<CDBC><D6BD>", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (isopen == DialogResult.None || isopen == DialogResult.No)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
DataSet mydateset = perobject.workobject as DataSet;
|
|
|
ModelObject[] objects = { mydateset };
|
|
|
String[] attributes = { "is_modifiable", "checked_out", "ref_list" };
|
|
|
dmService.RefreshObjects(objects);
|
|
|
dmService.GetProperties(objects, attributes);
|
|
|
if (mydateset.Is_modifiable == false || (mydateset.Checked_out == "Y"))
|
|
|
{
|
|
|
DialogResult moresult = MessageBox.Show("<22><>û<EFBFBD><C3BB><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><DEBB>ļ<EFBFBD><C4BC>Ѿ<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (moresult == DialogResult.Yes)
|
|
|
{
|
|
|
hasRight = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else if (mydateset.Is_modifiable)
|
|
|
{
|
|
|
DialogResult moresult = MessageBox.Show("<22>Ƿ<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (moresult == DialogResult.Yes)
|
|
|
{
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>,ͬ<><CDAC>
|
|
|
ModelObject[] dataobj = { mydateset };
|
|
|
res.Checkout(dataobj, "", "");
|
|
|
ed1.WriteMessage("<22>ļ<EFBFBD><C4BC><EFBFBD>ǩ<EFBFBD><C7A9>\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ModelObject[] dsfilevec = mydateset.Ref_list;
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>
|
|
|
if ((dsfilevec == null) || (dsfilevec.Length == 0))
|
|
|
{
|
|
|
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ȷ<EFBFBD>ϣ<EFBFBD>", "<22><><EFBFBD><EFBFBD>ͼֽ", MessageBoxButtons.OK);
|
|
|
return;
|
|
|
}
|
|
|
ed1.WriteMessage("<22><><EFBFBD><EFBFBD>:" + dsfilevec.Length);
|
|
|
ed1.WriteMessage(dsfilevec[0].GetType().ToString());
|
|
|
ImanFile dsfile = dsfilevec[0] as ImanFile;
|
|
|
|
|
|
ModelObject[] objects1 = { dsfile };
|
|
|
String[] attributes1 = { "relative_directory_path", "original_file_name" };
|
|
|
dmService.RefreshObjects(objects1);
|
|
|
dmService.GetProperties(objects1, attributes1);
|
|
|
|
|
|
ed1.WriteMessage("·<><C2B7>:" + dsfile.Relative_directory_path + "\n");
|
|
|
ed1.WriteMessage("<22>ļ<EFBFBD><C4BC><EFBFBD>:" + dsfile.Original_file_name + "\n");
|
|
|
string newfilename = dsfile.Original_file_name;
|
|
|
ed1.WriteMessage("Original_file_name : "+newfilename+"\n");
|
|
|
string tempdir = System.Environment.GetEnvironmentVariable("TEMP").ToString();
|
|
|
ed1.WriteMessage("TEMP:" + tempdir.ToString() + "\n");
|
|
|
|
|
|
FileManagementService fmService = FileManagementService.getService(Teamcenter.ClientX.Session.getConnection());
|
|
|
ImanFile[] objects2 = { dsfile };
|
|
|
FileTicketsResponse tickets = fmService.GetFileReadTickets(objects2);
|
|
|
ed1.WriteMessage("tickets : " + tickets.Tickets.Count + "\n");
|
|
|
|
|
|
foreach (System.Collections.DictionaryEntry ticket in tickets.Tickets)
|
|
|
{
|
|
|
ed1.WriteMessage("<22><><EFBFBD><EFBFBD>" + ticket.Key + "\n" + "ֵ<><D6B5>" + ticket.Value + "\n");
|
|
|
}
|
|
|
Teamcenter.Soa.Client.FileManagementUtility fmu = new Teamcenter.Soa.Client.FileManagementUtility(Teamcenter.ClientX.Session.getConnection());
|
|
|
Teamcenter.Soa.Client.GetFileResponse getFileResponse = fmu.GetFiles(dsfilevec);
|
|
|
FileInfo[] fileinfovec = getFileResponse.GetFiles();
|
|
|
|
|
|
ed1.WriteMessage("<22>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + fileinfovec.Length + "\n");
|
|
|
FileInfo file = fileinfovec[0];
|
|
|
//ed.WriteMessage("file.DirectoryName:" + file.DirectoryName + "\n");
|
|
|
//ed.WriteMessage("file.FullName" + file.FullName + "\n");
|
|
|
//string datestring = "";
|
|
|
//datestring = DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");//19
|
|
|
string newtempfile = tempdir + "\\" + newfilename;
|
|
|
ed1.WriteMessage("<22><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>" + newtempfile + "\n");
|
|
|
|
|
|
System.IO.File.Copy(file.FullName, newtempfile, true);
|
|
|
System.IO.File.SetAttributes(newtempfile, FileAttributes.Normal);
|
|
|
this.openfrom.Hide();
|
|
|
this.openfrom.Dispose();
|
|
|
if (File.Exists(newtempfile))
|
|
|
{
|
|
|
DocumentCollection acdocmgr1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
|
|
|
acdocmgr1.Open(newtempfile, false);
|
|
|
//Object pdata = newtempfile;
|
|
|
//acdocmgr.ExecuteInApplicationContext(c_back,pdata);
|
|
|
//Teamcenter.ClientX.Session session = new Teamcenter.ClientX.Session(serveraddress);
|
|
|
//loginuser = session.mylogin(username, password, usergroup, userrole);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ed1.WriteMessage("<22>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʱĿ¼<C4BF>²<EFBFBD><C2B2><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4>ļ<EFBFBD>\n");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ed1.WriteMessage("<22><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
MessageBox.Show("<22><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void openbutton2_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
string[] enableTypes = this.openfrom.enableTypes;
|
|
|
this.openfrom.Hide();
|
|
|
this.searchfrom = new Search();
|
|
|
this.searchfrom.appdoc = appodc;
|
|
|
this.searchfrom.user = loginuser;
|
|
|
this.searchfrom.enableTypes = enableTypes;
|
|
|
this.searchfrom.Activate();
|
|
|
this.searchfrom.Show();
|
|
|
this.openfrom.Dispose();
|
|
|
}
|
|
|
|
|
|
private void c_back(Object data)
|
|
|
{
|
|
|
DocumentCollection acdocmgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
|
|
|
if (acdocmgr.IsApplicationContext)
|
|
|
{
|
|
|
acdocmgr.Open(Convert.ToString(data));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[CommandMethod("SAVE_AS")]
|
|
|
public void saveas()
|
|
|
{
|
|
|
savetotc();
|
|
|
}
|
|
|
|
|
|
|
|
|
[CommandMethod("SAVE_TO_TC")]
|
|
|
public void savetotc()
|
|
|
{
|
|
|
|
|
|
//Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute(string.Format("{0}", "QSAVE"), true, false, true);
|
|
|
|
|
|
if (loginuser != null)
|
|
|
{
|
|
|
hadlogin = true;
|
|
|
}
|
|
|
else
|
|
|
login();
|
|
|
if (hadlogin)
|
|
|
{
|
|
|
//<2F><>ȡͼֽ<CDBC><D6BD>Ϣ
|
|
|
string titleName = "DFHM_CHS";
|
|
|
string detailName = "DFHM_CHS";
|
|
|
string filename = "";
|
|
|
|
|
|
DataManagementService dmService = DataManagementService.getService(Session.getConnection());
|
|
|
Editor ed1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
|
|
|
|
|
|
Tool tool = new Tool();
|
|
|
|
|
|
//---------------------- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> --------------------
|
|
|
ed1.WriteMessage("\n<><6E>ʼ<EFBFBD><CABC>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ...\n");
|
|
|
Dictionary<string, string> titleInfo = new Dictionary<string, string>();
|
|
|
titleInfo =tool.getBTL(titleName);
|
|
|
showMap(titleInfo,ed1);
|
|
|
|
|
|
//<2F><>ȡxml<6D><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
string path = "c:\\title.xml";
|
|
|
string root = "titles";
|
|
|
string nodeName = "types";
|
|
|
Dictionary<string, string> formInfo = new Dictionary<string, string>();
|
|
|
ReaderCusXML xml = new ReaderCusXML(path, appodc);
|
|
|
// 2012-05-16 <20><>ʱȡ<CAB1><C8A1><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2>ԡ<EFBFBD>
|
|
|
//formInfo = xml.GetTitleInfo(root, titleName, titleInfo["<22><><EFBFBD><EFBFBD>"]);
|
|
|
formInfo = xml.GetTitleInfo(root, titleName, "Item");
|
|
|
xml.close();
|
|
|
showMap(formInfo,ed1);
|
|
|
|
|
|
//---------------------- <20><>ϸ<EFBFBD><CFB8> --------------------
|
|
|
|
|
|
ed1.WriteMessage("<22><>ʼ<EFBFBD><CABC>ȡ<EFBFBD><C8A1>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>Ϣ...\n");
|
|
|
List<Dictionary<string, string>> bomlist = new List<Dictionary<string, string>>();
|
|
|
bomlist = tool.getMXL(detailName);
|
|
|
ed1.WriteMessage("<22><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ:" + bomlist.Count);
|
|
|
showMap(bomlist[0], ed1);
|
|
|
|
|
|
// 2012-05-16 <20><>ʱȡ<CAB1><C8A1><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2>ԡ<EFBFBD>
|
|
|
//SavedQueryResults found = tool.getSearchItem(titleInfo["ͼ<><CDBC>"]);
|
|
|
SavedQueryResults found = tool.getSearchItem("000126");
|
|
|
if ((found == null) || (found.NumOfObjects == 0)) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
{
|
|
|
DialogResult upresult = MessageBox.Show("û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Item<65><6D><EFBFBD>Ƿ<C7B7><F1B4B4BD><EFBFBD>", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (upresult == DialogResult.No || upresult == DialogResult.None)
|
|
|
{
|
|
|
ed1.WriteMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
}
|
|
|
if (upresult == DialogResult.Yes)
|
|
|
{
|
|
|
ed1.WriteMessage("============== <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Item ===================\n");
|
|
|
this.savefrom = new SaveToTC();
|
|
|
this.savefrom.appdoc = appodc;
|
|
|
//this.savefrom.ed = ed1;
|
|
|
this.savefrom.user = loginuser;
|
|
|
this.savefrom.btlinfo = formInfo;
|
|
|
this.savefrom.bomlist = bomlist;
|
|
|
this.savefrom.button1.Click += new EventHandler(savebutton1_Click);
|
|
|
this.savefrom.Activate();
|
|
|
this.savefrom.Show();
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (found.NumOfObjects != 1)
|
|
|
{
|
|
|
ed.WriteMessage("Item<65><6D>Ψһ<CEA8><D2BB>\n");
|
|
|
}
|
|
|
DialogResult upresult = MessageBox.Show("<22>ҵ<EFBFBD><D2B5><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Item<65><6D><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>£<EFBFBD>", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (upresult == DialogResult.No || upresult == DialogResult.None)
|
|
|
{
|
|
|
ed1.WriteMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
}
|
|
|
if (upresult == DialogResult.Yes)
|
|
|
{
|
|
|
for (int i = 0; i < found.NumOfObjects; i++)
|
|
|
{
|
|
|
Item item = found.Objects[i] as Item;
|
|
|
ModelObject[] objects = { item };
|
|
|
String[] attributes = { "item_id", "object_name", "object_string" };
|
|
|
dmService.RefreshObjects(objects);
|
|
|
dmService.GetProperties(objects, attributes);
|
|
|
string item_id = item.Item_id;
|
|
|
string object_name = item.Object_name;
|
|
|
|
|
|
Dataset dataset = null;
|
|
|
GetItemFromIdInfo tempitem = new GetItemFromIdInfo();
|
|
|
tempitem.ItemId = item_id;
|
|
|
GetItemFromIdInfo[] infos = new GetItemFromIdInfo[1];
|
|
|
infos[0] = tempitem;
|
|
|
GetItemFromIdPref pref = new GetItemFromIdPref();
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>µķ<C2B5>ʽ
|
|
|
GetItemFromIdResponse infoResp = dmService.GetItemFromId(infos, 1, pref);
|
|
|
for (int j = 0; j < infoResp.Output.Length; j++)
|
|
|
{
|
|
|
|
|
|
//------------------------- ItemRevision -----------------------
|
|
|
|
|
|
ModelObject[] objects1 = { infoResp.Output[j].Item };
|
|
|
String[] attributes1 = { "revision_list", "is_modifiable" };
|
|
|
dmService.RefreshObjects(objects1);
|
|
|
dmService.GetProperties(objects1, attributes1);
|
|
|
ModelObject[] revlist = infoResp.Output[j].Item.Revision_list;
|
|
|
dmService.RefreshObjects(revlist);
|
|
|
ItemRevision itemRev = null;
|
|
|
string rev_id = "";
|
|
|
|
|
|
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD>°汾
|
|
|
itemRev = revlist[revlist.Length - 1] as ItemRevision;
|
|
|
{
|
|
|
ModelObject[] objects2 = { itemRev };
|
|
|
String[] attributes2 = { "item_revision_id", "is_modifiable" ,
|
|
|
"checked_out","item_id","release_status_list",
|
|
|
"IMAN_master_form_rev"};
|
|
|
dmService.RefreshObjects(objects2);
|
|
|
dmService.GetProperties(objects2, attributes2);
|
|
|
//ReleaseStatus[] status =itemRev.reRelease_status_list;
|
|
|
//if((status !=null)&&(status.Length>0))
|
|
|
//{
|
|
|
// MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD>ġ<DEB8>");
|
|
|
// return ;
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
rev_id = itemRev.Item_revision_id;
|
|
|
ReleaseStatus[] releaselist = itemRev.Release_status_list;
|
|
|
if (!itemRev.Is_modifiable)
|
|
|
{
|
|
|
MessageBox.Show("ItemRevisionΪֻ<CEAA><D6BB>,<2C><>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD>Ȩ<EFBFBD><C8A8>!");
|
|
|
return;
|
|
|
}
|
|
|
if (releaselist.Length > 0)
|
|
|
{
|
|
|
string message = "Item IDΪ" + itemRev.Item_id + "<22><><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
MessageBox.Show(message);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//------------------------- Form -----------------------
|
|
|
|
|
|
FormInfo forminfo = new FormInfo();
|
|
|
FormInfo[] forminfo_vec = new FormInfo[1];
|
|
|
ModelObject[] form_vec;
|
|
|
Form masterForm;
|
|
|
form_vec = itemRev.IMAN_master_form_rev;
|
|
|
masterForm = form_vec[0] as Form;
|
|
|
{
|
|
|
Hashtable formAttrs = new Hashtable();
|
|
|
|
|
|
formAttrs =updateFormProp(formInfo, titleInfo);
|
|
|
|
|
|
ed1.WriteMessage("formAttrs:" + formAttrs.Count + "\n");
|
|
|
|
|
|
foreach (DictionaryEntry hash in formAttrs)
|
|
|
{
|
|
|
ed1.WriteMessage(hash.Key + ":" + Convert.ToString(hash.Value) + "\n");
|
|
|
}
|
|
|
|
|
|
//forminfo.AttributesMap = formAttrs;
|
|
|
//forminfo.ClientId = "1";
|
|
|
//forminfo.Description = "";
|
|
|
//forminfo.FormObject = (Form)masterForm;
|
|
|
//forminfo.Name = item_id + "/" + rev_id;
|
|
|
//forminfo.ParentObject = null;
|
|
|
//forminfo.RelationName = "IMAN_master_form";
|
|
|
//forminfo.SaveDB = true;
|
|
|
//forminfo.FormType = "ItemRevision Master";
|
|
|
//forminfo_vec[0] = forminfo;
|
|
|
//try
|
|
|
//{
|
|
|
// ed1.WriteMessage("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>\n");
|
|
|
// Teamcenter.Services.Strong.Core._2007_01.DataManagement.CreateOrUpdateFormsResponse formResp =
|
|
|
// dmService.CreateOrUpdateForms(forminfo_vec);
|
|
|
// ModelObject[] respon = { formResp.ServiceData.GetUpdatedObject(0) };
|
|
|
// dmService.RefreshObjects(respon);
|
|
|
// ed1.WriteMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
// break;
|
|
|
//}
|
|
|
//catch (ServiceException ex)
|
|
|
//{
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
//-------------------- <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݼ<EFBFBD> -------------------------
|
|
|
|
|
|
//<2F><>ȡxml<6D><6C>Ϣ
|
|
|
|
|
|
bool findDateset = false;
|
|
|
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
|
|
string tempName = "ͼֽ";
|
|
|
string dsType = "Sun7ThCAD";
|
|
|
string dsRefName = "Sun7SunThCAD";
|
|
|
Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsPref
|
|
|
myPref = new Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsPref();
|
|
|
Teamcenter.Services.Strong.Core._2007_06.DataManagement.RelationAndTypesFilter2
|
|
|
myFilter = new Teamcenter.Services.Strong.Core._2007_06.DataManagement.RelationAndTypesFilter2();
|
|
|
myFilter.RelationName = "IMAN_specification";
|
|
|
string[] typeVec = new string[1];
|
|
|
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
|
|
typeVec[0] = dsType;
|
|
|
myFilter.ObjectTypeNames = typeVec;
|
|
|
myPref.ExpItemRev = false;
|
|
|
Teamcenter.Services.Strong.Core._2007_06.DataManagement.RelationAndTypesFilter2[] myFilterVec = { myFilter };
|
|
|
myPref.Info = myFilterVec;
|
|
|
//ed1.WriteMessage("=======&&<26><><EFBFBD>ݼ<EFBFBD>&&=========");
|
|
|
ModelObject[] primaryObjects = { itemRev };
|
|
|
Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsResponse
|
|
|
myResp = dmService.ExpandGRMRelationsForPrimary(primaryObjects, myPref);
|
|
|
if (myResp.Output.Length > 0)
|
|
|
{
|
|
|
for (int k = 0; k < myResp.Output.Length; k++)
|
|
|
{
|
|
|
Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsOutput
|
|
|
grmOutput = myResp.Output[k];
|
|
|
for (int l = 0; l < grmOutput.OtherSideObjData.Length; l++)
|
|
|
{
|
|
|
ExpandGRMRelationsData otherSideData = grmOutput.OtherSideObjData[l];
|
|
|
if (otherSideData.OtherSideObjects.Length > 0)
|
|
|
{
|
|
|
for (int m = 0; m < otherSideData.OtherSideObjects.Length; m++)
|
|
|
{
|
|
|
Dataset tempDataset;
|
|
|
//Teamcenter.Soa.Client.Model.ServiceData sData;
|
|
|
tempDataset = otherSideData.OtherSideObjects[m] as Dataset;
|
|
|
|
|
|
string ds_name = tempDataset.Object_string;
|
|
|
if (ds_name == tempName)
|
|
|
{
|
|
|
findDateset = true;
|
|
|
dataset = otherSideData.OtherSideObjects[m] as Dataset;
|
|
|
ed1.WriteMessage("<22>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ݼ<EFBFBD>!\n");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (findDateset) //<2F><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
{
|
|
|
bool ischeckout = false;
|
|
|
try
|
|
|
{
|
|
|
ModelObject[] objects2 = { dataset };
|
|
|
String[] attributes2 = { "is_modifiable", "checked_out", "checked_out_user" };
|
|
|
dmService.RefreshObjects(objects2);
|
|
|
dmService.GetProperties(objects2, attributes2);
|
|
|
if (!dataset.Is_modifiable)
|
|
|
{
|
|
|
MessageBox.Show("<22><><EFBFBD><EFBFBD>ͼֽ״̬Ϊֻ<CEAA><D6BB>,<2C><><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD>浽<EFBFBD><E6B5BD>ϵͳ!");
|
|
|
return;
|
|
|
}
|
|
|
User checkuserinfo = dataset.Checked_out_user as User;
|
|
|
if (checkuserinfo != null)
|
|
|
{
|
|
|
if (checkuserinfo.Uid != loginuser.Uid)
|
|
|
{
|
|
|
MessageBox.Show("<22><>ͼֽ<CDBC>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ǩ<EFBFBD><C7A9>,<2C><EFBFBD><DEB7><EFBFBD><EFBFBD>浽ϵͳ!");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (dataset.Checked_out == "Y")
|
|
|
ischeckout = true;
|
|
|
|
|
|
}
|
|
|
catch (NotLoadedException ex)
|
|
|
{
|
|
|
ed1.WriteMessage(ex.Message);
|
|
|
}
|
|
|
|
|
|
Reservation res = ReservationService.getService(Session.getConnection());
|
|
|
//string comment = "", changeId = "";
|
|
|
//ModelObject[] ds_object = new ModelObject[1];
|
|
|
//ds_object[0] = dataset;
|
|
|
ModelObject[] dsFileVec = null;
|
|
|
//ed1.WriteMessage("=======22<32><32><EFBFBD>ݼ<EFBFBD>22=========");
|
|
|
try
|
|
|
{
|
|
|
ModelObject[] objects2 = { dataset };
|
|
|
String[] attributes2 = { "ref_list" };
|
|
|
dmService.RefreshObjects(objects2);
|
|
|
dmService.GetProperties(objects2, attributes2);
|
|
|
dsFileVec = dataset.Ref_list;
|
|
|
}
|
|
|
catch (NotLoadedException ex)
|
|
|
{
|
|
|
ed1.WriteMessage(ex.Message);
|
|
|
}
|
|
|
ImanFile dsfile = dsFileVec[0] as ImanFile;
|
|
|
|
|
|
ModelObject[] objects3 = { dsfile };
|
|
|
String[] attributes3 = { "relative_directory_path", "original_file_name" };
|
|
|
dmService.RefreshObjects(objects3);
|
|
|
dmService.GetProperties(objects3, attributes3);
|
|
|
filename = dsfile.Original_file_name;
|
|
|
//ed1.WriteMessage("=======33<33><33><EFBFBD>ݼ<EFBFBD>33=========\n");
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo[] fileInfos = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo[1];
|
|
|
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo fileInfo = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo();
|
|
|
|
|
|
DocumentCollection inacdocmgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
|
|
|
ed1.WriteMessage("<22><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>" + inacdocmgr.MdiActiveDocument.Name + "\n");
|
|
|
|
|
|
Document acdoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
|
|
|
acdoc.Database.SaveAs(acdoc.Name, true, DwgVersion.Current, acdoc.Database.SecurityParameters);
|
|
|
|
|
|
string mdiactivefile = acdoc.Name;
|
|
|
fileInfo.FileName = mdiactivefile;
|
|
|
fileInfo.AllowReplace = true;
|
|
|
fileInfo.IsText = false;
|
|
|
fileInfo.NamedReferencedName = dsRefName;
|
|
|
fileInfos[0] = fileInfo;
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData inputData = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData();
|
|
|
inputData.Dataset = dataset;
|
|
|
inputData.CreateNewVersion = false;
|
|
|
inputData.DatasetFileInfos = fileInfos;
|
|
|
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[] inputs = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[1];
|
|
|
inputs[0] = inputData;
|
|
|
FileManagementUtility fMSFileManagement = new FileManagementUtility(Session.getConnection());
|
|
|
ServiceData response = fMSFileManagement.PutFiles(inputs);
|
|
|
if (response.sizeOfPartialErrors() > 0)
|
|
|
ed1.WriteMessage("FileManagementService upload returned partial errors:" + response.sizeOfPartialErrors());
|
|
|
ModelObject[] datasets = new ModelObject[1];
|
|
|
datasets[0] = dataset;
|
|
|
if (ischeckout)
|
|
|
res.Checkin(datasets);
|
|
|
dmService.RefreshObjects(datasets);
|
|
|
|
|
|
ed1.WriteMessage("DateSet check in successful\n");
|
|
|
|
|
|
}
|
|
|
else //<2F><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
{
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties
|
|
|
oneDatasetProp = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties();
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties[]
|
|
|
dataset_vec = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties[1];
|
|
|
oneDatasetProp.ClientId = "datasetWriteTixTestClientId";
|
|
|
oneDatasetProp.Type = dsType;
|
|
|
oneDatasetProp.Name = tempName;
|
|
|
oneDatasetProp.Description = "";
|
|
|
oneDatasetProp.Container = null;
|
|
|
dataset_vec[0] = oneDatasetProp;
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateDatasetsResponse
|
|
|
dsResp = dmService.CreateDatasets(dataset_vec);
|
|
|
Dataset createdataset = dsResp.Output[0].Dataset;
|
|
|
|
|
|
//create relationship
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship[]
|
|
|
rela_vec = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship[1];
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship
|
|
|
one_rela = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship();
|
|
|
one_rela.ClientId = "";
|
|
|
one_rela.PrimaryObject = itemRev;
|
|
|
one_rela.SecondaryObject = createdataset;
|
|
|
one_rela.RelationType = "IMAN_specification";
|
|
|
one_rela.UserData = null;
|
|
|
rela_vec[0] = one_rela;
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateRelationsResponse
|
|
|
reResp = dmService.CreateRelations(rela_vec);
|
|
|
ed1.WriteMessage("<22><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n");
|
|
|
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo[] fileInfos = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo[1];
|
|
|
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo fileInfo = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo();
|
|
|
|
|
|
DocumentCollection inacdocmgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
|
|
|
//inacdocmgr.MdiActiveDocument.Database.SaveAs(inacdocmgr.MdiActiveDocument.Name, DwgVersion.Current);
|
|
|
//inacdocmgr.MdiActiveDocument.SendStringToExecute("QSAVE", true, false, true);
|
|
|
|
|
|
ed1.WriteMessage("<22><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>" + inacdocmgr.MdiActiveDocument.Name + "\n");
|
|
|
|
|
|
Document acdoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
|
|
|
acdoc.Database.SaveAs(acdoc.Name, true, DwgVersion.Current, acdoc.Database.SecurityParameters);
|
|
|
|
|
|
string mdiactivefile = acdoc.Name;
|
|
|
fileInfo.FileName = mdiactivefile;
|
|
|
fileInfo.AllowReplace = true;
|
|
|
fileInfo.IsText = false;
|
|
|
fileInfo.NamedReferencedName = dsRefName;
|
|
|
fileInfos[0] = fileInfo;
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData inputData = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData();
|
|
|
inputData.Dataset = createdataset;
|
|
|
inputData.CreateNewVersion = false;
|
|
|
inputData.DatasetFileInfos = fileInfos;
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[] inputs = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[1];
|
|
|
inputs[0] = inputData;
|
|
|
FileManagementUtility fMSFileManagement = new FileManagementUtility(Session.getConnection());
|
|
|
ServiceData response = fMSFileManagement.PutFiles(inputs);
|
|
|
if (response.sizeOfPartialErrors() > 0)
|
|
|
ed1.WriteMessage("FileManagementService upload returned partial errors:" + response.sizeOfPartialErrors());
|
|
|
ed1.WriteMessage("DateSet check in successful\n");
|
|
|
ModelObject[] datasets = new ModelObject[1];
|
|
|
datasets[0] = createdataset;
|
|
|
dmService.RefreshObjects(datasets);
|
|
|
dataset = createdataset;
|
|
|
}
|
|
|
|
|
|
if (bomlist.Count > 0)
|
|
|
{
|
|
|
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
|
|
if (true)
|
|
|
{
|
|
|
DialogResult flushbomresult = MessageBox.Show("<22>Ƿ<EFBFBD>ˢ<EFBFBD><CBA2>BOM", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (flushbomresult == DialogResult.Yes)
|
|
|
{
|
|
|
Folder aimFolder = null;
|
|
|
WorkspaceObject[] object_vec = new WorkspaceObject[1];
|
|
|
object_vec[0] = item;
|
|
|
Teamcenter.Services.Strong.Core._2007_01.DataManagement.WhereReferencedResponse
|
|
|
refResp = dmService.WhereReferenced(object_vec, 1);
|
|
|
Teamcenter.Services.Strong.Core._2007_01.DataManagement.WhereReferencedOutput[]
|
|
|
refOutput = refResp.Output;
|
|
|
|
|
|
for (int u = 0; u < refOutput.Length; u++)
|
|
|
{
|
|
|
Teamcenter.Services.Strong.Core._2007_01.DataManagement.WhereReferencedInfo[]
|
|
|
info = refOutput[u].Info;
|
|
|
for (int p = 0; p < info.Length; p++)
|
|
|
{
|
|
|
Teamcenter.Services.Strong.Core._2007_01.DataManagement.WhereReferencedInfo
|
|
|
it_info = info[p];
|
|
|
string type = it_info.Referencer.Object_type;
|
|
|
if (type.Contains("Folder"))
|
|
|
{
|
|
|
aimFolder = it_info.Referencer as Folder;
|
|
|
ed1.WriteMessage("<22>ҵ<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>\n");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (aimFolder == null)
|
|
|
CreateBomStructure(itemRev, dataset, bomlist, null);
|
|
|
else
|
|
|
CreateBomStructure(itemRev, dataset, bomlist, aimFolder);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("<22><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void savebutton1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
DataManagementService dmService = DataManagementService.getService(Session.getConnection());
|
|
|
Reservation res = ReservationService.getService(Session.getConnection());
|
|
|
Editor ed1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
|
|
|
ed1.WriteMessage("==============\n");
|
|
|
Dictionary<string, string> btlinfo = this.savefrom.btlinfo;
|
|
|
List<Dictionary<string, string>> bomlist = this.savefrom.bomlist;
|
|
|
//ed1.WriteMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ITEMͼ<4D>ţ<EFBFBD>" + btlinfo.Item_id + "\n");
|
|
|
//ed1.WriteMessage("<22><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:" + bomlist.Count + "\n");
|
|
|
Tool tool = new Tool();
|
|
|
|
|
|
TreeNode nownode = this.savefrom.treeView1.SelectedNode;
|
|
|
if (nownode.SelectedImageIndex == 1)
|
|
|
{
|
|
|
foreach (ALLOBJECT perobject in this.savefrom.folderlist)
|
|
|
{
|
|
|
if (perobject.treenode.Equals(nownode))
|
|
|
{
|
|
|
|
|
|
Folder folder = perobject.workobject as Folder;
|
|
|
ModelObject[] objects = { folder };
|
|
|
String[] attributes = { "is_modifiable" };
|
|
|
dmService.RefreshObjects(objects);
|
|
|
dmService.GetProperties(objects, attributes);
|
|
|
if (!folder.Is_modifiable)
|
|
|
{
|
|
|
MessageBox.Show("<22><><EFBFBD><EFBFBD>Ŀ¼û<C2BC><C3BB>дȨ<D0B4>ޣ<EFBFBD><DEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
ItemProperties oneItemProp = new ItemProperties();
|
|
|
CreateItemsResponse itemResp = new CreateItemsResponse();
|
|
|
|
|
|
Teamcenter.Hello.DataManagement hellomanagement = new Teamcenter.Hello.DataManagement();
|
|
|
string itemtype = this.savefrom.comboBox1.Text;
|
|
|
ItemIdsAndInitialRevisionIds[] itemIds = hellomanagement.generateItemIds(1, itemtype);
|
|
|
GetItemCreationRelatedInfoResponse relatedResponse = dmService.GetItemCreationRelatedInfo(itemtype, null);
|
|
|
string[] formTypes = new string[relatedResponse.FormAttrs.Length];
|
|
|
for (int j = 0; j < relatedResponse.FormAttrs.Length; j++)
|
|
|
{
|
|
|
FormAttributesInfo attrInfo = relatedResponse.FormAttrs[j];
|
|
|
formTypes[j] = attrInfo.FormType;
|
|
|
}
|
|
|
ItemProperties[] itemProps = new ItemProperties[itemIds.Length];
|
|
|
ItemProperties itemProperty = new ItemProperties();
|
|
|
for (int j = 0; j < itemIds.Length; j++)
|
|
|
{
|
|
|
ed1.WriteMessage("start Create form in cache!\n");
|
|
|
ModelObject[] forms = hellomanagement.createForms(itemIds[j].NewItemId,
|
|
|
formTypes[0], itemIds[j].NewRevId, formTypes[1], null, false);
|
|
|
ed1.WriteMessage("Create form in cache sucessful!\n");
|
|
|
ed1.WriteMessage("set item properties!\n");
|
|
|
|
|
|
//itemProperty.ClientId = "AppX-Test";
|
|
|
//Ϊ<>˲<EFBFBD><CBB2><EFBFBD>
|
|
|
itemProperty.ItemId = "000099";
|
|
|
itemProperty.RevId = "A";
|
|
|
itemProperty.Name = "<22>ҽ<EFBFBD>SB";
|
|
|
itemProperty.Type = "Item";
|
|
|
itemProperty.Description = "";
|
|
|
//itemProperty.Uom = "EA";
|
|
|
|
|
|
itemProps[j] = itemProperty;
|
|
|
}
|
|
|
|
|
|
try
|
|
|
{
|
|
|
ed1.WriteMessage("start item create!\n");
|
|
|
|
|
|
itemResp = dmService.CreateItems(itemProps, folder, "");
|
|
|
|
|
|
ItemRevision rev = null;
|
|
|
Item newitem = null;
|
|
|
for (int j = 0; j < itemResp.Output.Length; j++)
|
|
|
{
|
|
|
rev = itemResp.Output[j].ItemRev;
|
|
|
newitem = itemResp.Output[j].Item;
|
|
|
}
|
|
|
|
|
|
////--------------------- New Item rev Form ----------------------
|
|
|
////дform<72><6D><EFBFBD><EFBFBD>
|
|
|
//FormInfo forminfo = new FormInfo();
|
|
|
//FormInfo[] forminfo_vec;
|
|
|
//ModelObject[] form_vec = null;
|
|
|
|
|
|
//ModelObject[] objects1 = { rev };
|
|
|
//String[] attributes1 = { "IMAN_master_form_rev",
|
|
|
// "is_modifiable","item_revision_id"};
|
|
|
//dmService.RefreshObjects(objects1);
|
|
|
//dmService.GetProperties(objects1, attributes1);
|
|
|
|
|
|
//try
|
|
|
//{
|
|
|
// form_vec = rev.IMAN_master_form_rev;
|
|
|
// ed1.WriteMessage("get_IMAN_master_form_rev sucessful!\n");
|
|
|
//}
|
|
|
//catch (NotLoadedException ex)
|
|
|
//{
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
//}
|
|
|
|
|
|
//forminfo_vec = new FormInfo[form_vec.Length];
|
|
|
//{
|
|
|
// Form form = form_vec[0] as Form;
|
|
|
|
|
|
// Hashtable formAttrs = new Hashtable();
|
|
|
|
|
|
// string[] formAttrValue8 = new string[1];
|
|
|
|
|
|
// forminfo.AttributesMap = formAttrs;
|
|
|
// //forminfo.ClientId = "1";
|
|
|
// forminfo.Description = "";
|
|
|
// forminfo.FormObject = form;
|
|
|
// forminfo.Name = btlinfo.Item_id + "/" + rev.Item_revision_id;
|
|
|
// forminfo.ParentObject = null;
|
|
|
// forminfo.RelationName = "IMAN_master_form";
|
|
|
// forminfo.SaveDB = true;
|
|
|
// forminfo.FormType = "ItemRevision Master";
|
|
|
|
|
|
// forminfo_vec[j] = forminfo;
|
|
|
|
|
|
// try
|
|
|
// {
|
|
|
// CreateOrUpdateFormsResponse formResp
|
|
|
// = dmService.CreateOrUpdateForms(forminfo_vec);
|
|
|
// ed1.WriteMessage("update form attributes sucessful!\n");
|
|
|
// }
|
|
|
// catch (ServiceException ex)
|
|
|
// {
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// }
|
|
|
//}
|
|
|
string ds_name;
|
|
|
string rev_id = rev.Item_revision_id;
|
|
|
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties
|
|
|
oneDatasetProp = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties();
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties[]
|
|
|
dataset_vec = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.DatasetProperties[1];
|
|
|
//oneDatasetProp.ClientId = "datasetWriteTixTestClientId";
|
|
|
//<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
|
|
oneDatasetProp.Type = "D5DWG";
|
|
|
oneDatasetProp.Name = "<22><>ͷ";
|
|
|
oneDatasetProp.Description = "";
|
|
|
oneDatasetProp.Container = null;
|
|
|
dataset_vec[0] = oneDatasetProp;
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateDatasetsResponse
|
|
|
dsResp = dmService.CreateDatasets(dataset_vec);
|
|
|
Dataset createdataset = dsResp.Output[0].Dataset;
|
|
|
|
|
|
//create relationship
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship[]
|
|
|
rela_vec = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship[1];
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship
|
|
|
one_rela = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.Relationship();
|
|
|
one_rela.ClientId = "AppX-myTest";
|
|
|
one_rela.PrimaryObject = rev;
|
|
|
one_rela.SecondaryObject = createdataset;
|
|
|
one_rela.RelationType = "IMAN_specification";
|
|
|
one_rela.UserData = null;
|
|
|
rela_vec[0] = one_rela;
|
|
|
Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateRelationsResponse
|
|
|
reResp = dmService.CreateRelations(rela_vec);
|
|
|
ed1.WriteMessage("<22><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n");
|
|
|
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo[] fileInfos = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo[1];
|
|
|
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo fileInfo = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.DatasetFileInfo();
|
|
|
|
|
|
DocumentCollection inacdocmgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
|
|
|
ed1.WriteMessage("<22><>ǰ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>" + inacdocmgr.MdiActiveDocument.Name + "\n");
|
|
|
|
|
|
Document acdoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
|
|
|
acdoc.Database.SaveAs(acdoc.Name, true, DwgVersion.Current, acdoc.Database.SecurityParameters);
|
|
|
|
|
|
|
|
|
string mdiactivefile = acdoc.Name;
|
|
|
fileInfo.FileName = mdiactivefile;
|
|
|
fileInfo.AllowReplace = true;
|
|
|
fileInfo.IsText = false;
|
|
|
fileInfo.NamedReferencedName = "Sun7SunThCAD";
|
|
|
fileInfos[0] = fileInfo;
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData inputData = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData();
|
|
|
inputData.Dataset = createdataset;
|
|
|
inputData.CreateNewVersion = false;
|
|
|
inputData.DatasetFileInfos = fileInfos;
|
|
|
Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[] inputs = new Teamcenter.Services.Loose.Core._2006_03.FileManagement.GetDatasetWriteTicketsInputData[1];
|
|
|
inputs[0] = inputData;
|
|
|
FileManagementUtility fMSFileManagement = new FileManagementUtility(Session.getConnection());
|
|
|
ServiceData response = fMSFileManagement.PutFiles(inputs);
|
|
|
if (response.sizeOfPartialErrors() > 0)
|
|
|
ed1.WriteMessage("FileManagementService upload returned partial errors:" + response.sizeOfPartialErrors());
|
|
|
ed1.WriteMessage("DateSet check in successful\n");
|
|
|
ModelObject[] datasets = new ModelObject[1];
|
|
|
datasets[0] = createdataset;
|
|
|
dmService.RefreshObjects(datasets);
|
|
|
|
|
|
//BOMˢ<4D><CBA2>
|
|
|
{
|
|
|
DialogResult updateresult = MessageBox.Show("<22>Ƿ<EFBFBD>ˢ<EFBFBD><CBA2>BOM", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (updateresult == DialogResult.No || updateresult == DialogResult.None)
|
|
|
{
|
|
|
ed1.WriteMessage("<22><><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>BOM\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CreateBomStructure(rev, createdataset, bomlist, folder);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.savefrom.Hide();
|
|
|
this.savefrom.Dispose();
|
|
|
}
|
|
|
catch (ServiceException ex)
|
|
|
{
|
|
|
ed1.WriteMessage(ex.Message);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
MessageBox.Show("<22><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[CommandMethod("LOGOUT")]
|
|
|
public void layout()
|
|
|
{
|
|
|
if (!hadlogin)
|
|
|
return;
|
|
|
DialogResult updateresult = MessageBox.Show("<22><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>棡<EFBFBD><E6A3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD>Ƿ棿", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
if (updateresult == DialogResult.Yes)
|
|
|
{
|
|
|
savetotc();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
loginuser = null;
|
|
|
hadlogin = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool CreateBomStructure(ItemRevision parentRev, Dataset parent_ds, List<Dictionary<string, string>> bom_Vec, Folder folder)
|
|
|
{
|
|
|
|
|
|
//DataManagementService dmService = DataManagementService.getService(Session.getConnection());
|
|
|
//Reservation res = ReservationService.getService(Session.getConnection());
|
|
|
//Editor ed1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
|
|
|
//ed1.WriteMessage("bom_Vec size:" + bom_Vec.Count.ToString() + "\n");
|
|
|
//ItemRevision[] revVec = new ItemRevision[bom_Vec.Count];
|
|
|
//ed1.WriteMessage("revVec size:" + revVec.Length.ToString() + "\n");
|
|
|
//for (int i = 0; i < bom_Vec.Count; i++)
|
|
|
//{
|
|
|
// MXLClass it_bom = bom_Vec[i];
|
|
|
// Tool tool = new Tool();
|
|
|
// string item_id = it_bom.Item_id;
|
|
|
// SavedQueryResults found = tool.getSearchItem(it_bom.Item_id);
|
|
|
// if (found.NumOfObjects == 0)
|
|
|
// {
|
|
|
// //ItemProperties[] item_vec;
|
|
|
// //DatasetProperties[] dataset_vec;
|
|
|
// ItemProperties oneItemProp = new ItemProperties();
|
|
|
// CreateItemsResponse itemResp = new CreateItemsResponse();
|
|
|
|
|
|
// Teamcenter.Hello.DataManagement hellomanagement = new Teamcenter.Hello.DataManagement();
|
|
|
|
|
|
// ItemIdsAndInitialRevisionIds[] itemIds = hellomanagement.generateItemIds(1,it_bom.Itemtype);
|
|
|
// GetItemCreationRelatedInfoResponse relatedResponse = dmService.GetItemCreationRelatedInfo(it_bom.Itemtype, null);
|
|
|
// string[] formTypes = new string[relatedResponse.FormAttrs.Length];
|
|
|
|
|
|
// for (int j = 0; j < relatedResponse.FormAttrs.Length; j++)
|
|
|
// {
|
|
|
// FormAttributesInfo attrInfo = relatedResponse.FormAttrs[j];
|
|
|
// formTypes[j] = attrInfo.FormType;
|
|
|
// }
|
|
|
// ItemProperties[] itemProps = new ItemProperties[itemIds.Length];
|
|
|
// ItemProperties itemProperty = new ItemProperties();
|
|
|
// for (int j = 0; j < itemIds.Length; j++)
|
|
|
// {
|
|
|
// ed1.WriteMessage("start Create form in cache!\n");
|
|
|
// ModelObject[] forms = hellomanagement.createForms(itemIds[j].NewItemId,
|
|
|
// formTypes[0], itemIds[j].NewRevId, formTypes[1],null,false);
|
|
|
// ed1.WriteMessage("Create form in cache sucessful!\n");
|
|
|
// ed1.WriteMessage("set item properties!\n");
|
|
|
|
|
|
// itemProperty.ClientId = "";
|
|
|
// itemProperty.ItemId = it_bom.Item_id;
|
|
|
// itemProperty.RevId = "A";
|
|
|
// itemProperty.Name = it_bom.Name;
|
|
|
// itemProperty.Type = it_bom.Itemtype;
|
|
|
// itemProperty.Description = "";
|
|
|
// itemProperty.Uom = "EA";
|
|
|
|
|
|
// itemProps[j] = itemProperty;
|
|
|
// }
|
|
|
// try
|
|
|
// {
|
|
|
// ed1.WriteMessage("start item create!\n");
|
|
|
// if (folder == null)
|
|
|
// itemResp = dmService.CreateItems(itemProps, null, "");
|
|
|
// else
|
|
|
// itemResp = dmService.CreateItems(itemProps, folder, "");
|
|
|
// ed1.WriteMessage("create Items: " + it_bom.Item_id + "sucessful!\n");
|
|
|
// ItemRevision rev = null;
|
|
|
// Item newitem = null;
|
|
|
// for (int j = 0; j < itemResp.Output.Length;j++ )
|
|
|
// {
|
|
|
// rev = itemResp.Output[j].ItemRev;
|
|
|
// newitem = itemResp.Output[j].Item;
|
|
|
// }
|
|
|
// revVec[i] = rev;
|
|
|
|
|
|
// //дform<72><6D><EFBFBD><EFBFBD>
|
|
|
// FormInfo forminfo = new FormInfo();
|
|
|
// FormInfo[] forminfo_vec;
|
|
|
// ModelObject[] form_vec = null;
|
|
|
|
|
|
// ModelObject[] objects = { rev };
|
|
|
// String[] attributes = { "IMAN_master_form_rev",
|
|
|
// "is_modifiable","item_revision_id"};
|
|
|
// dmService.RefreshObjects(objects);
|
|
|
// dmService.GetProperties(objects, attributes);
|
|
|
// if (rev.Is_modifiable)
|
|
|
// {
|
|
|
// try
|
|
|
// {
|
|
|
// form_vec = rev.IMAN_master_form_rev;
|
|
|
// ed1.WriteMessage("get_IMAN_master_form_rev sucessful!\n");
|
|
|
// }
|
|
|
// catch (NotLoadedException ex)
|
|
|
// {
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// }
|
|
|
// forminfo_vec = new FormInfo[form_vec.Length];
|
|
|
// for (int j = 0; j < form_vec.Length; j++)
|
|
|
// {
|
|
|
// Form form = form_vec[j] as Form;
|
|
|
|
|
|
// Hashtable formAttrs = new Hashtable();
|
|
|
// string[] formAttrValue1 = new string[1];
|
|
|
// formAttrValue1[0] = "";
|
|
|
// formAttrValue1[0] = it_bom.Material;
|
|
|
// formAttrs.Add("d5MaterialGrade", formAttrValue1);
|
|
|
|
|
|
// string[] formAttrValue2 = new string[1];
|
|
|
// formAttrValue2[0] = "";
|
|
|
// formAttrValue2[0] = it_bom.Perweight;
|
|
|
// formAttrs.Add("d5SingleWeight", formAttrValue2);
|
|
|
|
|
|
// string[] formAttrValue3 = new string[1];
|
|
|
// formAttrValue3[0] = "";
|
|
|
// formAttrValue3[0] = it_bom.Partnumber;
|
|
|
// formAttrs.Add("d5PartNumber", formAttrValue3);
|
|
|
|
|
|
// string[] formAttrValue4 = new string[1];
|
|
|
// formAttrValue4[0] = "";
|
|
|
// formAttrValue4[0] = it_bom.Producttype;
|
|
|
// formAttrs.Add("d5ProductType", formAttrValue4);
|
|
|
|
|
|
// forminfo.AttributesMap = formAttrs;
|
|
|
// forminfo.ClientId = "1";
|
|
|
// forminfo.Description = "";
|
|
|
// forminfo.FormObject = form;
|
|
|
// forminfo.Name = item_id + "/" +rev.Item_revision_id;
|
|
|
// forminfo.ParentObject = null;
|
|
|
// forminfo.RelationName = "IMAN_master_form";
|
|
|
// forminfo.SaveDB = true;
|
|
|
// forminfo.FormType = "ItemRevision Master";
|
|
|
|
|
|
// forminfo_vec[j] = forminfo;
|
|
|
|
|
|
// try
|
|
|
// {
|
|
|
// CreateOrUpdateFormsResponse formResp
|
|
|
// =dmService.CreateOrUpdateForms(forminfo_vec);
|
|
|
// ed1.WriteMessage("update form attributes sucessful!\n");
|
|
|
// }
|
|
|
// catch (ServiceException ex)
|
|
|
// {
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// if (it_bom.Memo == "<22><>ͼ")
|
|
|
// {
|
|
|
// if (parent_ds != null)
|
|
|
// {
|
|
|
// ExpandGRMRelationsPref myPref = new ExpandGRMRelationsPref();
|
|
|
// RelationAndTypesFilter2 myFilter = new RelationAndTypesFilter2();
|
|
|
// myFilter.RelationName = "IMAN_reference";
|
|
|
// string[] typeVec = new string[1];
|
|
|
// typeVec[0] = "D5DWG";
|
|
|
// myFilter.ObjectTypeNames = typeVec;
|
|
|
// myPref.ExpItemRev = false;
|
|
|
// RelationAndTypesFilter2[] myFilterVec = { myFilter };
|
|
|
// myPref.Info = myFilterVec;
|
|
|
|
|
|
|
|
|
// ModelObject[] primaryObjects = { rev };
|
|
|
// Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsResponse
|
|
|
// myResp = dmService.ExpandGRMRelationsForPrimary(primaryObjects, myPref);
|
|
|
// if (myResp.Output.Length > 0)
|
|
|
// {
|
|
|
// for (int k = 0; k < myResp.Output.Length; k++)
|
|
|
// {
|
|
|
// Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsOutput
|
|
|
// grmOutput = myResp.Output[k];
|
|
|
// for (int l = 0; l < grmOutput.OtherSideObjData.Length; l++)
|
|
|
// {
|
|
|
// ExpandGRMRelationsData otherSideData = grmOutput.OtherSideObjData[l];
|
|
|
// if (otherSideData.OtherSideObjects.Length == 0)
|
|
|
// {
|
|
|
// Relationship[] rela_vec = new Relationship[1];
|
|
|
// Relationship one_rela = new Relationship();
|
|
|
// one_rela.ClientId = "";
|
|
|
// one_rela.PrimaryObject = rev;
|
|
|
// one_rela.SecondaryObject = parent_ds;
|
|
|
// one_rela.RelationType = "IMAN_reference";
|
|
|
// one_rela.UserData = null;
|
|
|
// rela_vec[0] = one_rela;
|
|
|
// CreateRelationsResponse reResp =
|
|
|
// dmService.CreateRelations(rela_vec);
|
|
|
// ed1.WriteMessage("create IMAN_reference sucessful!\n");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// catch (ServiceException ex)
|
|
|
// {
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// }
|
|
|
// }
|
|
|
// else//found
|
|
|
// {
|
|
|
// ItemRevision itemRev = null;
|
|
|
// for (int j = 0; j < found.NumOfObjects; j++)
|
|
|
// {
|
|
|
// GetItemFromIdInfo[] infos = new GetItemFromIdInfo[1];
|
|
|
// GetItemFromIdInfo oneItem = new GetItemFromIdInfo();
|
|
|
// oneItem.ItemId = item_id;
|
|
|
// infos[0] = oneItem;
|
|
|
// GetItemFromIdPref pref = new GetItemFromIdPref();
|
|
|
// GetItemFromIdResponse infoResp =
|
|
|
// dmService.GetItemFromId(infos, 1, pref);
|
|
|
// for (int n = 0; n < infoResp.Output.Length; n++)
|
|
|
// {
|
|
|
// ModelObject[] objects = { infoResp.Output[n].Item };
|
|
|
// String[] attributes = { "revision_list",
|
|
|
// "object_name","item_revision"};
|
|
|
// dmService.RefreshObjects(objects);
|
|
|
// dmService.GetProperties(objects, attributes);
|
|
|
// ModelObject[] revList = infoResp.Output[n].Item.Revision_list;
|
|
|
// dmService.RefreshObjects(revList);
|
|
|
// for (int l = 0; l < revList.Length; l++)
|
|
|
// {
|
|
|
// itemRev = revList[l] as ItemRevision;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// revVec[i] = itemRev;
|
|
|
// //дform<72><6D><EFBFBD><EFBFBD>
|
|
|
// FormInfo forminfo = new FormInfo();
|
|
|
// FormInfo[] forminfo_vec = new FormInfo[1];
|
|
|
// ModelObject[] form_vec;
|
|
|
// ModelObject[] objects1 = {itemRev };
|
|
|
// String[] attributes1 = { "IMAN_master_form_rev",
|
|
|
// "is_modifiable","item_revision_id",
|
|
|
// "date_released","item_id",
|
|
|
// "release_status_list"};
|
|
|
// dmService.RefreshObjects(objects1);
|
|
|
// dmService.GetProperties(objects1, attributes1);
|
|
|
|
|
|
// ReleaseStatus[] releaselist = itemRev.Release_status_list;
|
|
|
// if (releaselist.Length > 0)
|
|
|
// {
|
|
|
// MessageBox.Show("Item IDΪ" + itemRev.Item_id + "<22><><EFBFBD><EFBFBD><EFBFBD>°汾<C2B0>ѷ<EFBFBD><D1B7><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
// continue;
|
|
|
// }
|
|
|
// if (!itemRev.Is_modifiable)
|
|
|
// {
|
|
|
// MessageBox.Show("<22><>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Item IDΪ" + itemRev.Item_id + "<22><>Ȩ<EFBFBD>Ļ<DEB8><C4BB><EFBFBD>Item<65><6D><EFBFBD>°汾<C2B0>ѷ<EFBFBD><D1B7><EFBFBD>");
|
|
|
// continue;
|
|
|
// }
|
|
|
// else if (itemRev.Is_modifiable)
|
|
|
// {
|
|
|
// ed1.WriteMessage("is_modifiable!\n");
|
|
|
|
|
|
// form_vec = itemRev.IMAN_master_form_rev;
|
|
|
// ed1.WriteMessage("get_IMAN_master_form_rev sucessful!\n");
|
|
|
|
|
|
// for (int j = 0; j < form_vec.Length; j++)
|
|
|
// {
|
|
|
// Form form = form_vec[j] as Form;
|
|
|
// bool m_frash = false, w_frash = false, part_frash = false;
|
|
|
// string[] props = new string[1];
|
|
|
// string revId = itemRev.Object_string;
|
|
|
// Hashtable formAttrs = new Hashtable();
|
|
|
// //<2F><><EFBFBD><EFBFBD>
|
|
|
// ed1.WriteMessage("ȡd5MaterialGrade\n");
|
|
|
// props[0] = "d5MaterialGrade";
|
|
|
// ServiceData serviceData = dmService.GetProperties(form_vec, props);
|
|
|
// if (serviceData.sizeOfPartialErrors() > 0)
|
|
|
// {
|
|
|
// continue;
|
|
|
// }
|
|
|
// Property m_prop = form_vec[j].GetProperty("d5MaterialGrade");
|
|
|
// if (it_bom.Material != m_prop.StringValue)
|
|
|
// {
|
|
|
// if (m_prop.StringValue == "")
|
|
|
// m_frash = true;
|
|
|
// else
|
|
|
// {
|
|
|
// string message = "<22><>ǰ<EFBFBD><C7B0>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>" + revId + "<22>IJ<EFBFBD><C4B2><EFBFBD>" + it_bom.Material + "<22><>ϵͳ<CFB5>ڲ<EFBFBD><DAB2><EFBFBD>" + m_prop.StringValue + "<22><>һ<EFBFBD><D2BB>,<2C>Ƿ<C7B7>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?";
|
|
|
// DialogResult updateresult = MessageBox.Show(message, "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
// if (updateresult == DialogResult.Yes)
|
|
|
// {
|
|
|
// m_frash = true;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// string[] formAttrValue = new string[1];
|
|
|
// formAttrValue[0] = "";
|
|
|
// if (m_frash)
|
|
|
// formAttrValue[0] = it_bom.Material;
|
|
|
// else
|
|
|
// formAttrValue[0] = m_prop.StringValue;
|
|
|
// ed1.WriteMessage("d5MaterialGrade:" + formAttrValue[0] + "\n");
|
|
|
// formAttrs.Add("d5MaterialGrade", formAttrValue);
|
|
|
// props[0] = "";
|
|
|
|
|
|
// //<2F><><EFBFBD><EFBFBD>
|
|
|
// ed1.WriteMessage("ȡd5PartNumber\n");
|
|
|
// props[0] = "d5PartNumber";
|
|
|
// serviceData = dmService.GetProperties(form_vec, props);
|
|
|
// if (serviceData.sizeOfPartialErrors() > 0)
|
|
|
// {
|
|
|
// continue;
|
|
|
// }
|
|
|
// Property part_prop = form_vec[j].GetProperty("d5PartNumber");
|
|
|
// if (it_bom.Partnumber != part_prop.StringValue)
|
|
|
// {
|
|
|
// if (part_prop.StringValue == "")
|
|
|
// part_frash = true;
|
|
|
// else
|
|
|
// {
|
|
|
// string message = "<22><>ǰ<EFBFBD><C7B0>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>" + revId + "<22>Ĵ<EFBFBD><C4B4><EFBFBD>" + it_bom.Partnumber + "<22><>ϵͳ<CFB5>ڴ<EFBFBD><DAB4><EFBFBD>" + part_prop.StringValue + "<22><>һ<EFBFBD><D2BB>,<2C>Ƿ<C7B7>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?";
|
|
|
// DialogResult updateresult = MessageBox.Show(message, "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
// if (updateresult == DialogResult.Yes)
|
|
|
// {
|
|
|
// part_frash = true;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// string[] formAttrValue1 = new string[1];
|
|
|
// formAttrValue1[0] = "";
|
|
|
// if (part_frash)
|
|
|
// formAttrValue1[0] = it_bom.Partnumber;
|
|
|
// else
|
|
|
// formAttrValue1[0] = part_prop.StringValue;
|
|
|
// ed1.WriteMessage("d5PartNumber:" + formAttrValue1[0] + "\n");
|
|
|
// formAttrs.Add("d5PartNumber", formAttrValue1);
|
|
|
// props[0] = "";
|
|
|
// //<2F><><EFBFBD><EFBFBD>
|
|
|
// ed1.WriteMessage("ȡd5SingleWeight\n");
|
|
|
// props[0] = "d5SingleWeight";
|
|
|
// serviceData = dmService.GetProperties(form_vec, props);
|
|
|
// if (serviceData.sizeOfPartialErrors() > 0)
|
|
|
// {
|
|
|
// continue;
|
|
|
// }
|
|
|
// Property w_prop = form_vec[j].GetProperty("d5SingleWeight");
|
|
|
// if (it_bom.Perweight != w_prop.StringValue)
|
|
|
// {
|
|
|
// if (w_prop.StringValue == "")
|
|
|
// w_frash = true;
|
|
|
// else
|
|
|
// {
|
|
|
// string message = "<22><>ǰ<EFBFBD><C7B0>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>" + revId + "<22>ĵ<EFBFBD><C4B5><EFBFBD>" + it_bom.Perweight + "<22><>ϵͳ<CFB5>ڵ<EFBFBD><DAB5><EFBFBD>" + w_prop.StringValue + "<22><>һ<EFBFBD><D2BB>,<2C>Ƿ<C7B7>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?";
|
|
|
// DialogResult updateresult = MessageBox.Show(message, "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
// if (updateresult == DialogResult.Yes)
|
|
|
// {
|
|
|
// w_frash = true;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// string[] formAttrValue2 = new string[1];
|
|
|
// formAttrValue2[0] = "";
|
|
|
// if (w_frash)
|
|
|
// formAttrValue2[0] = it_bom.Perweight;
|
|
|
// else
|
|
|
// formAttrValue2[0] = w_prop.StringValue;
|
|
|
// ed1.WriteMessage("d5SingleWeight:" + formAttrValue2[0] + "\n");
|
|
|
// formAttrs.Add("d5SingleWeight", formAttrValue2);
|
|
|
|
|
|
// forminfo.AttributesMap = formAttrs;
|
|
|
// forminfo.ClientId = "";
|
|
|
// forminfo.Description = "";
|
|
|
// forminfo.FormObject = form;
|
|
|
// forminfo.Name = item_id + "/" + itemRev.Item_revision_id;
|
|
|
// forminfo.ParentObject = null;
|
|
|
// forminfo.RelationName = "IMAN_master_form";
|
|
|
// forminfo.SaveDB = true;
|
|
|
// forminfo.FormType = "ItemRevision Master";
|
|
|
|
|
|
// forminfo_vec[0] = forminfo;
|
|
|
// try
|
|
|
// {
|
|
|
// CreateOrUpdateFormsResponse formResp
|
|
|
// = dmService.CreateOrUpdateForms(forminfo_vec);
|
|
|
// }
|
|
|
// catch (SoaException ex)
|
|
|
// {
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// if (it_bom.Memo == "<22><>ͼ")
|
|
|
// {
|
|
|
// if (parent_ds != null)
|
|
|
// {
|
|
|
// ExpandGRMRelationsPref myPref = new ExpandGRMRelationsPref();
|
|
|
// RelationAndTypesFilter2 myFilter = new RelationAndTypesFilter2();
|
|
|
// myFilter.RelationName = "IMAN_reference";
|
|
|
// string[] typeVec = new string[1];
|
|
|
// typeVec[0] = "D5DWG";
|
|
|
// myFilter.ObjectTypeNames = typeVec;
|
|
|
// myPref.ExpItemRev = false;
|
|
|
// RelationAndTypesFilter2[] myFilterVec = { myFilter };
|
|
|
// myPref.Info = myFilterVec;
|
|
|
|
|
|
|
|
|
// ModelObject[] primaryObjects = { itemRev };
|
|
|
// Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsResponse
|
|
|
// myResp = dmService.ExpandGRMRelationsForPrimary(primaryObjects, myPref);
|
|
|
// if (myResp.Output.Length > 0)
|
|
|
// {
|
|
|
// for (int k = 0; k < myResp.Output.Length; k++)
|
|
|
// {
|
|
|
// Teamcenter.Services.Strong.Core._2007_06.DataManagement.ExpandGRMRelationsOutput
|
|
|
// grmOutput = myResp.Output[k];
|
|
|
// for (int l = 0; l < grmOutput.OtherSideObjData.Length; l++)
|
|
|
// {
|
|
|
// ExpandGRMRelationsData otherSideData = grmOutput.OtherSideObjData[l];
|
|
|
// if (otherSideData.OtherSideObjects.Length == 0)
|
|
|
// {
|
|
|
// Relationship[] rela_vec = new Relationship[1];
|
|
|
// Relationship one_rela = new Relationship();
|
|
|
// one_rela.ClientId = "";
|
|
|
// one_rela.PrimaryObject = itemRev;
|
|
|
// one_rela.SecondaryObject = parent_ds;
|
|
|
// one_rela.RelationType = "IMAN_reference";
|
|
|
// one_rela.UserData = null;
|
|
|
// rela_vec[0] = one_rela;
|
|
|
// CreateRelationsResponse reResp =
|
|
|
// dmService.CreateRelations(rela_vec);
|
|
|
// ed1.WriteMessage("create IMAN_reference sucessful!\n");
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
//}//for
|
|
|
////<2F><><EFBFBD><EFBFBD>BOM
|
|
|
//Teamcenter.Services.Strong.Cad.StructureManagementService ssService =
|
|
|
// Teamcenter.Services.Strong.Cad.StructureManagementService.getService(Session.getConnection());
|
|
|
//Teamcenter.Services.Strong.Cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructureInfo2
|
|
|
// structInfo = new Teamcenter.Services.Strong.Cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructureInfo2();
|
|
|
|
|
|
//Teamcenter.Services.Strong.Cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructureInfo2[]
|
|
|
// structInfoVec = new Teamcenter.Services.Strong.Cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructureInfo2[1];
|
|
|
|
|
|
////Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelativeStructureChildInfo
|
|
|
//// childInfo = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelativeStructureChildInfo();
|
|
|
|
|
|
//Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelativeStructureChildInfo[]
|
|
|
// childInfoVec;
|
|
|
|
|
|
////Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelOccInfo
|
|
|
//// occInfo = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelOccInfo();
|
|
|
|
|
|
////Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo
|
|
|
//// attrsInfo = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo();
|
|
|
|
|
|
|
|
|
//Teamcenter.Services.Strong.Cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructurePref2
|
|
|
// sPref = new Teamcenter.Services.Strong.Cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructurePref2();
|
|
|
|
|
|
////ItemRevision childRev;
|
|
|
//ed1.WriteMessage("<22><>ʼ<CABC><D7BC>pse<73><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
//childInfoVec = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelativeStructureChildInfo[revVec.Length];
|
|
|
//ed1.WriteMessage("childInfoVec size:"+childInfoVec.Length+"\n");
|
|
|
//Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo[]
|
|
|
// attrsToSet = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo[4];
|
|
|
//for (int i = 0; i < revVec.Length; i++)
|
|
|
//{
|
|
|
// MXLClass bomv = bom_Vec[i];
|
|
|
// ed1.WriteMessage("<22><><EFBFBD><EFBFBD>"+bomv.Item_id+"...\n");
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelativeStructureChildInfo
|
|
|
// childInfo = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelativeStructureChildInfo();
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelOccInfo
|
|
|
// occInfo = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.RelOccInfo();
|
|
|
// attrsToSet = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo[4];
|
|
|
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo
|
|
|
// attrsInfo = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo();
|
|
|
// attrsInfo.Name = "bl_quantity";
|
|
|
// attrsInfo.Value = bomv.Count;
|
|
|
// attrsToSet[0] = attrsInfo;
|
|
|
|
|
|
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo
|
|
|
// attrsInfo1 = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo();
|
|
|
// attrsInfo1.Name = "bl_sequence_no";
|
|
|
// attrsInfo1.Value = (Convert.ToInt32(bomv.Index) * 10).ToString();
|
|
|
// attrsToSet[1] = attrsInfo1;
|
|
|
|
|
|
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo
|
|
|
// attrsInfo2 = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo();
|
|
|
// attrsInfo2.Name = "D5DesignNote_bl";
|
|
|
// attrsInfo2.Value = bomv.Memo;
|
|
|
// attrsToSet[2] = attrsInfo2;
|
|
|
|
|
|
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo
|
|
|
// attrsInfo3 = new Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.AttributesInfo();
|
|
|
// attrsInfo3.Name = "D5TotalWeight";
|
|
|
// attrsInfo3.Value = bomv.Tolweight;
|
|
|
// attrsToSet[3] = attrsInfo3;
|
|
|
|
|
|
// occInfo.AttrsToSet = attrsToSet;
|
|
|
|
|
|
// childInfo.Child = revVec[i];
|
|
|
// childInfo.OccInfo = occInfo;
|
|
|
|
|
|
// childInfoVec[i] = childInfo;
|
|
|
|
|
|
//}
|
|
|
//for (int j = 0; j < childInfoVec.Length; j++)
|
|
|
//{
|
|
|
// for(int k=0;k<childInfoVec[j].OccInfo.AttrsToSet.Length;k++)
|
|
|
// {
|
|
|
// ed1.WriteMessage("====" + childInfoVec[j].OccInfo.AttrsToSet[k].Name + ":" + childInfoVec[j].OccInfo.AttrsToSet[k].Value + "====\n");
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
//structInfo.ChildInfo = childInfoVec;
|
|
|
//structInfo.Parent = parentRev;
|
|
|
//structInfo.Precise = false;
|
|
|
//structInfoVec[0] = structInfo;
|
|
|
|
|
|
//ServiceData sData;
|
|
|
|
|
|
//ModelObject[] objects2 = { parentRev };
|
|
|
//String[] attributes2 = { "structure_revisions"};
|
|
|
//dmService.RefreshObjects(objects2);
|
|
|
//sData = dmService.GetProperties(objects2, attributes2);
|
|
|
|
|
|
//Teamcenter.Soa.Client.Model.Strong.PSBOMViewRevision bvr = null;
|
|
|
//Teamcenter.Soa.Client.Model.Strong.PSBOMView bv = null;
|
|
|
//try
|
|
|
//{
|
|
|
// for (int i = 0; i < parentRev.Structure_revisions.Length; i++)
|
|
|
// {
|
|
|
// ed1.WriteMessage("<22><>ʼǩ<CABC><C7A9>Bomview revision\n");
|
|
|
// bvr = parentRev.Structure_revisions[i];
|
|
|
|
|
|
// ModelObject[] objects3 = { bvr };
|
|
|
// String[] attributes3 = { "is_modifiable",
|
|
|
// "object_string","checkde_out"};
|
|
|
// dmService.RefreshObjects(objects3);
|
|
|
// dmService.GetProperties(objects3, attributes3);
|
|
|
// if (!bvr.Is_modifiable)
|
|
|
// {
|
|
|
// MessageBox.Show("<22><>Ȩ<EFBFBD><EFBFBD>BOM<4F><4D>");
|
|
|
// return false;
|
|
|
// }
|
|
|
// if (bvr.Checked_out == "Y")
|
|
|
// {
|
|
|
// MessageBox.Show("BOM<4F>Ѿ<EFBFBD>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
// return false;
|
|
|
// }
|
|
|
// string bvr_name = bvr.Object_string;
|
|
|
// ed1.WriteMessage("bvr_name="+bvr_name+"\n");
|
|
|
|
|
|
// ModelObject[] bvr_vec = new ModelObject[1];
|
|
|
// bvr_vec[0] = bvr;
|
|
|
// sData = res.Checkout(bvr_vec, "", "");
|
|
|
// if (sData.sizeOfPartialErrors() > 0)
|
|
|
// {
|
|
|
// ed1.WriteMessage("checkout bom returned a partial error.");
|
|
|
// return false;
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
//catch (ServiceException ex)
|
|
|
//{
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
//}
|
|
|
|
|
|
//ed1.WriteMessage("<22><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Bom\n");
|
|
|
//try
|
|
|
//{
|
|
|
// Teamcenter.Services.Strong.Cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureResponse
|
|
|
// cursResp = ssService.CreateOrUpdateRelativeStructure(structInfoVec, "view", true, sPref);
|
|
|
// ed1.WriteMessage("Bom<6F><6D><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>\n");
|
|
|
//}
|
|
|
//catch (System.Exception ex)
|
|
|
//{
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// return false;
|
|
|
//}
|
|
|
|
|
|
//if (bvr != null)
|
|
|
//{
|
|
|
// ModelObject[] checkIn_vec = new ModelObject[1];
|
|
|
// checkIn_vec[0] = bvr;
|
|
|
// try
|
|
|
// {
|
|
|
// res.Checkin(checkIn_vec);
|
|
|
// ed1.WriteMessage("Bomview ǩ<><C7A9><EFBFBD>ɹ<EFBFBD>!\n");
|
|
|
// }
|
|
|
// catch (ServiceException ex)
|
|
|
// {
|
|
|
// ed1.WriteMessage(ex.Message);
|
|
|
// }
|
|
|
//}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private void loginbuttonclick(object Sender,EventArgs e)
|
|
|
{
|
|
|
login();
|
|
|
}
|
|
|
|
|
|
private void openbuttonclick(object Sender, EventArgs e)
|
|
|
{
|
|
|
openformtc();
|
|
|
}
|
|
|
|
|
|
private void savebuttonclick(object Sender, EventArgs e)
|
|
|
{
|
|
|
savetotc();
|
|
|
}
|
|
|
|
|
|
private void logoutbuttonclick(object Sender, EventArgs e)
|
|
|
{
|
|
|
layout();
|
|
|
}
|
|
|
|
|
|
private void showMap(Dictionary<string, string> formAttrs,Editor ed)
|
|
|
{
|
|
|
foreach (KeyValuePair<string, string> hash in formAttrs)
|
|
|
{
|
|
|
ed.WriteMessage(hash.Key + ":" + Convert.ToString(hash.Value) + "\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private Hashtable updateFormProp(Dictionary<string, string> formAttrs, Dictionary<string, string> formValues)
|
|
|
{
|
|
|
Hashtable table = new Hashtable();
|
|
|
foreach (KeyValuePair<string, string> hash in formAttrs)
|
|
|
{
|
|
|
string cadName = hash.Key;
|
|
|
string propName = hash.Value;
|
|
|
string propValue =formValues[cadName];
|
|
|
table.Add(propName,propValue);
|
|
|
}
|
|
|
return table;
|
|
|
}
|
|
|
|
|
|
//private void addComtextMenu()
|
|
|
//{
|
|
|
// ContextMenuExtension m_contextmenu = new ContextMenuExtension();
|
|
|
// m_contextmenu.Title = "MyTeamCenter";
|
|
|
// Autodesk.AutoCAD.Windows.MenuItem mi = new Autodesk.AutoCAD.Windows.MenuItem("<22><>¼");
|
|
|
// Autodesk.AutoCAD.Windows.MenuItem mi1 = new Autodesk.AutoCAD.Windows.MenuItem("<22><><EFBFBD><EFBFBD>");
|
|
|
// Autodesk.AutoCAD.Windows.MenuItem mi2 = new Autodesk.AutoCAD.Windows.MenuItem("<22><><EFBFBD><EFBFBD>");
|
|
|
// Autodesk.AutoCAD.Windows.MenuItem mi3 = new Autodesk.AutoCAD.Windows.MenuItem("<22>˳<EFBFBD>");
|
|
|
|
|
|
// mi.Click += new EventHandler (loginbuttonclick);
|
|
|
// mi1.Click += new EventHandler(openbuttonclick);
|
|
|
// mi2.Click += new EventHandler(savebuttonclick);
|
|
|
// mi3.Click += new EventHandler(logoutbuttonclick);
|
|
|
|
|
|
|
|
|
// m_contextmenu.MenuItems.Add(mi);
|
|
|
// m_contextmenu.MenuItems.Add(mi1);
|
|
|
// m_contextmenu.MenuItems.Add(mi2);
|
|
|
// m_contextmenu.MenuItems.Add(mi3);
|
|
|
|
|
|
// Autodesk.AutoCAD.ApplicationServices.Application.AddDefaultContextMenuExtension(m_contextmenu);
|
|
|
//}
|
|
|
|
|
|
////<2F>˳<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
//public void acdocmgr_DocumentToBeDestroyed(object sender, DocumentCollectionEventArgs e)
|
|
|
//{
|
|
|
// DialogResult updateresult = MessageBox.Show("<22><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>棡<EFBFBD><E6A3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD>Ƿ棿", "<22><>ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
// if (updateresult == DialogResult.Yes)
|
|
|
// {
|
|
|
// savetotc();
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// loginuser = null;
|
|
|
// hadlogin = false;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
} |