您的位置:网站首页 > Proe教程

ProE二次开发中的Windchill PDMLink 7.0数据整理及导入经验

时间:2011-02-24 09:39:32 来源:

  本文介绍了ProE二次开发中的Windchill PDMLink 7.0数据整理及导入经验。

  当批量导入用户时,我试图将Locale设为中文,测试过:zh_CN,CN,China等都不对,虽能正常导入,但导入后用户的Locale设置错误,更新用户时还是英文的。

  LoadUser.class中的程序:

  ...

  String s5 = LoadServerHelper.getValue("Locale", hashtable, hashtable1, 1);

  ...

  if(s5 == null)

  s5 = "English (United States)";

  if(s5.equals("US"))

  s5 = "English (United States)";

  Locale locale = new Locale(s5, s5);

  String s17 = locale.toString();

  Enumeration enumeration = (new Vector()).elements();

  for(Enumeration enumeration1 = OrganizationServicesHelper.manager.getUserLanguages(); enumeration1.hasMoreElements();)

  {

  Locale locale1 = (Locale)enumeration1.nextElement();

  String s20 = locale1.getDisplayName(locale);

  if(s20.equalsIgnoreCase(s5))

  s17 = locale1.toString();

  }

  s17 = s17.replace('_', '-');

  vector1.addElement(DirContext.getMapping(defaultAdapter, "user.preferredLanguage") + '=' + s17);

  ...

  根据程序并跟踪测试,得知Locale为中文时应该写:

  中文 (中国)

  (注意:中间必须有一个空格)

  如:User,,eric,eric,Eric Lin,中文 (中国),eric@abc.com,,,,,,,,,,x,1234

  同理, 繁体中文应设置为:

  中文 (台湾)

  ----------------------------------------------------

  How to Bulk-Load documents that are soft-types of some Out-of-the-Box provided type.

  Assuming that,

  1. A Library called 'MyLib' exists and contain a folder called 'Folder1'

  2. A soft-type of Out-of-the-box provided RefernceDocument, called SubOfRef was created that has two attributes. The name of this soft-type should be exactly as it is reported by Type Manager UI.

  a) MBool, a boolean

  b) MString, a String

  3. An Organization called MyOrg exists

  Then use ...

  windchill wt.load.LoadFromFile -d C:PathToMyFile.xml -u wcadmin -p wcadmin -CONT_PATH "/wt.inf.container.OrgContainer=MyOrg/wt.inf.library.WTLibrary=MyLib"

  ...to load the data below.

  Name of SoftType Load - 01

  Title of SoftType Load - 01

  NUM:SoftType-01

  Document

  description 1112-002

  DESIGN

  /Default/Folder1

  com.ptc.ReferenceDocument│com.ptc.SubOfRef

  MyAttrs/MBool

  false

  MyAttrs/MString

  Eleven

  ApplicationData

  EGadWork.xls

  DGadReq.doc

  DGadSpec.doc

  ----------------------------------------------------

  Windchill PDMLink 7.0数据库重新导入后,导致不能通过WGM和Proe Wildfire来创建EPMDocument,解决方法是:重新运行%WT_HOME%dbsqlwnc-wsp.sql,当然这要求当前Windchill系统必须正确安装MO10和M020的patch。

  ---------------------------------------------------

  导入Part和Doc的关联

  导入格式:

  #PartDocLink,*文档编号,docVersion,docIteration,*零部件编号,partVersion,partIteration

  PartDocLink,SJ0000001,,,100-10-12,,

  ...

  如上所示,如果partVersion为空,将可能导致系统创建关联到旧版本的Part上。

  建议把该栏位全部填上“A”即可创建关联到Part的最新版本上。

  在LoadPart.class中,根据编号、大版本、小版本获取Part的函数如下:

  private static WTPart getPart(String s, String s1, String s2)

  throws WTException

  {

  WTPart wtpart = getCachedPart(s, s1, s2);

  if(wtpart == null && s != null)

  {

  boolean flag = false;

  QuerySpec queryspec = new QuerySpec(wt.part.WTPart.class);

  queryspec.appendWhere(new SearchCondition(wt.part.WTPart.class, "master>number", "=", s.toUpperCase(), false));

  if(s1 != null)

  {

  queryspec.appendAnd();

  queryspec.appendWhere(new SearchCondition(wt.part.WTPart.class, "versionInfo.identifier.versionId", "=", s1, false));

  if(s2 != null)

  {

  queryspec.appendAnd();

  queryspec.appendWhere(new SearchCondition(wt.part.WTPart.class, "iterationInfo.identifier.iterationId", "=", s2, false));

  } else

  {

  queryspec.appendAnd();

  queryspec.appendWhere(new SearchCondition(wt.part.WTPart.class, "iterationInfo.latest", "TRUE"));

  }

  } else

  {

  flag = true;

  }

  QueryResult queryresult = PersistenceHelper.manager.find(queryspec);

  if(flag)

  {

  queryresult = (new OwnershipIndependentLatestConfigSpec()).process(queryresult);

  }

  if(queryresult.size() > 0)

  {

  wtpart = (WTPart)queryresult.nextElement();

  wtpart = cachePart(wtpart);

  }

  }

  return wtpart;

  }

  可见,但大版本为空时,没有获取到最新小版本;

  当大版本不为空,小版本为空时,可以正常获取到最新小版本。

  而在LoadDoc.class中,根据编号、大版本、小版本获取Doc的函数如下:

  public static WTDocument getDocument(String s, String s1, String s2)

  throws WTException

  {

  WTDocument wtdocument = getCachedDocument(s, s1, s2);

  if(wtdocument == null && s != null)

  {

  QuerySpec queryspec = new QuerySpec(wt.doc.WTDocument.class);

  queryspec.appendWhere(new SearchCondition(wt.doc.WTDocument.class, "master>number", "=", s.toUpperCase(), false));

  if(s1 == null)

  {

  queryspec.appendAnd();

  queryspec.appendWhere(new SearchCondition(wt.doc.WTDocument.class, "iterationInfo.latest", "TRUE"));

  } else

  {

  queryspec.appendAnd();

  queryspec.appendWhere(new SearchCondition(wt.doc.WTDocument.class, "versionInfo.identifier.versionId", "=", s1, false));

  if(s2 != null)

  {

  queryspec.appendAnd();

  queryspec.appendWhere(new SearchCondition(wt.doc.WTDocument.class, "iterationInfo.identifier.iterationId", "=", s2, false));

  }

  }

  QueryResult queryresult = PersistenceHelper.manager.find(queryspec);

  if(queryresult.size() > 0)

  {

  wtdocument = (WTDocument)queryresult.nextElement();

  if(s1 != null && s2 == null)

  {

  wtdocument = (WTDocument)VersionControlHelper.getLatestIteration(wtdocument);

  }

  wtdocument = cacheDocument(wtdocument);

  }

  }

  return wtdocument;

  }

  可见,文档的大版本和小版本都可以不写,系统能找到最新小版本。

  利用系统的导入程序导入文件注意以下几点:(否则会出现即使文件能正常导入但是主文件却不入库的情况)

  ——文件类型必须存在;

  ——导入数据中所指定了的软属性必须是该文件类型已经拥有的软属性;

  ——采用绝对路径的格式如下:“H:DocTest.txt”、“H:documentDocTest.txt”;

  ——如果采用相对路径是指“%WT_HOME%loadFilescontent”目录下的相对路径;

  ——只要采用系统提供的导入程序就可以了,但是为了正常导入,并加入文档的创建者需要修改系统提供的csvmapfile.txt文件,修改如下:

  ————系统:BeginWTDocument~create~wt.doc.LoadDoc.beginCreateWTDocument~name~title
~number~type~description~department~saveIn~teamTemplate~domain~
lifecycletemplate~lifecyclestate~typedef~version~iteration

  ————修改后:BeginWTDocument~create~wt.doc.LoadDoc.beginCreateWTDocument~user~name
~title~number~type~description~department~saveIn~teamTemplate~domain~
lifecycletemplate~lifecyclestate~typedef~version~iteration~parentContainerPath

  NOTE:一般对象(如:Group、AccessRule……)在导入时都要在系统的csvmapfile.txt字段的基础上加上字段“parentContainerPath”

  ----------------------------------------------------------------------

  软类型的导入

  当导入软类型时,如果你的主机名不是以ptc.com结尾的,必须填写完整的软类型名称,否则将无法导入。如:

  TypeNodeIconRoot,wt/clients/images,,,,,,,,,

  BeginTypeDefNode,com.ptc.SitePart,wt.part.WTPart,part.gif,SitePart,SitePart,SitePart,
TRUE,FALSE,TRUE,SitePart

  TypeDefAttrValue,ProjectPhase,Design,,,,,,,,,

  ...

  EndTypeDefNode