Quantcast
Channel: PTC Community: Message List - Windchill
Viewing all articles
Browse latest Browse all 8876

Re: Developing code in Workflow Template Administrator

$
0
0

Already Solved my Problem! Thanks to all of you!

 

This is my final code, it's lot of parts from another sites and forums but it worked for me..

 

that's it:

 

wt.fc.QueryResult theQueryResult;
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.content._ContentHolder cHolder;try{    theQueryResult = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);    wt.vc.Versioned theVersioned = null ;    wt.epm.EPMDocument myDoc;    if (theQueryResult != null){        int queCnt = 0;        while(theQueryResult.hasMoreElements()){            theVersioned = (wt.vc.Versioned)theQueryResult.nextElement();            if (theVersioned instanceof wt.epm.EPMDocument) {                System.out.println("IS A EPM DOCUMENT");                myDoc = (wt.epm.EPMDocument)theVersioned;                if(myDoc.getDocType().toString().equals("CADDRAWING")){                    //GET THE PDF:                     wt.lifecycle.LifeCycleManaged LMObject = (wt.lifecycle.LifeCycleManaged)myDoc;                    String StStg = (String)LMObject.getLifeCycleState().toString();                    if (StStg.compareTo("RELEASED") == 0) {                        System.out.println( "\nEPMDoc - Number: " + myDoc.getNumber() + " - Name: " + myDoc.getName()+ " - CadName: " + myDoc.getCADName() );                        System.out.println( "EPMDocument " + myDoc.getNumber() + " -Version: " + myDoc.getVersionIdentifier().getValue() + " - Iteration:"+myDoc.getIterationIdentifier().getValue());                        System.out.println( "Life Cycle State: "+StStg);                        try{                            wt.representation.Representation defaultRep=wt.representation.RepresentationHelper.service.getDefaultRepresentation(myDoc);                            wt.content.ContentHolder holder=wt.content.ContentHelper.service.getContents(defaultRep);                            Vector contents=wt.content.ContentHelper.getContentListAll(holder);                            wt.content.ApplicationData data=null;                            for (int i=0;i<contents.size();i++)                            {                                if (contents.get(i) instanceof wt.content.ApplicationData)                                {                                    data=(wt.content.ApplicationData)contents.get(i);                                    System.out.println("Avaliando o " + data.getFileName());                                    if (data!=null&& data.getFileName().endsWith("pdf"))                                    {                                        System.out.println("Vou copiar este: " + data.getFileName() + " pois ele é PDF");                                        String path = "D:"+"\\pdf\\"+data.getFileName();                                        System.out.println("Vai copiar o : " + data.getFileName() + " para " + path);                                        wt.content.ContentServerHelper.service.writeContentStream(data, path);                                        System.out.println("Copiado : " + data.getFileName() + " para " + path);                                        break;                                    }                                }                            }                        }catch(Exception exception){                            errorMsg = "NOVO ERRO " + exception.getMessage();                        }                    queCnt++;                    }                }            }else{                System.out.println("THIS IS NOT A  EPM");            }        }    }    result="Approved";}catch (wt.maturity.MaturityException me){         errorMsg=me.getMessage();         result="Rejected";   }

Viewing all articles
Browse latest Browse all 8876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>