Exemplo n.º 1
0
        public void workflow_publish(String wfTemplate, ModelObject obj)
        {
            WorkflowService wfService = WorkflowService.getService(Session2.getConnection());



            if (wfService == null)
            {
                throw new Exception("The workflow service not found in Teamcenter.");
            }

            String[] arrObjectUID = new String[] { obj.Uid };
            int[]    arrTypes     = new int[arrObjectUID.Length];
            arrTypes[0] = 1;

            ContextData contextData = new ContextData();

            contextData.AttachmentCount = arrObjectUID.Length; //
            contextData.Attachments     = arrObjectUID;        //List of UID of objects to submit to workflow
            contextData.AttachmentTypes = arrTypes;            //Types of attachment  EPM_target_attachment (target attachment) and EPM_reference_attachment (reference attachment).
            contextData.ProcessTemplate = wfTemplate;          //"ReleaseObjectsWorkflow";

            InstanceInfo instanceResponse = wfService.CreateInstance(true, null, "maxtt-syn-process", null, "", contextData);

            if (instanceResponse.ServiceData.sizeOfPartialErrors() == 0)
            {
                //System.out.println("Process created Successfully");
            }
            else
            {
                throw new Exception("Submit To Workflow: 001" + "Submit To Workflow - " + instanceResponse.ServiceData.GetPartialError(0).Messages[0]);
            }
        }
Exemplo n.º 2
0
        public void wf(String wfTemplate, ModelObject obj)
        {
            //connection -> TC connection objects
            //WorkflowService is from package com.teamcenter.services.strong.workflow
            WorkflowService wfService = WorkflowService.getService(Session2.getConnection());

            if (wfService == null)
            {
                throw new Exception("The workflow service not found in Teamcenter.");
            }

            String[] arrObjectUID = new String[] { obj.Uid };
            int[]    arrTypes     = new int[arrObjectUID.Length];
            arrTypes[0] = 1;
            //Arrays.fill(arrTypes, 1);//Target attachment type to be initialized for all UIDs


            ContextData contextData = new ContextData();

            contextData.AttachmentCount = arrObjectUID.Length; //
            contextData.Attachments     = arrObjectUID;        //List of UID of objects to submit to workflow
            contextData.AttachmentTypes = arrTypes;            //Types of attachment  EPM_target_attachment (target attachment) and EPM_reference_attachment (reference attachment).
            contextData.ProcessTemplate = wfTemplate;          //"ReleaseObjectsWorkflow";

            //processname -> Name by which initiated workflow appear in the user mail box .
            //processDescription -> Description for the initiated workflow
            InstanceInfo instanceResponse = wfService.CreateInstance(true, null, "processName-maxtt-demo", null, "processDescription-maxtt-demo", contextData);

            if (instanceResponse.ServiceData.sizeOfPartialErrors() == 0)
            {
                //System.out.println("Process created Successfully");
            }
            else
            {
                //System.out.println("Error :" + instanceResponse.serviceData.getPartialError(0).getMessages());
                //System.out.println("Error :" + instanceResponse.serviceData.getPartialError(0).getErrorValues());
                //throw new Exception("Submit To Workflow: 001", "Submit To Workflow - " + instanceResponse.ServiceData.GetPartialError(0).GetMessages()[0]);
                throw new Exception("Submit To Workflow: 001" + "Submit To Workflow - ");
            }
        }