/** * @Title: testLogin.java 
 * @Package com.connor.signoff.soa.handler 
 * @Description: TODO(用一句话描述该文件做什么) 
 * @author admin * @date 2024年9月25日 
 * @version V1.0 
 */
package com.connor.signoff.soa.handler;

import java.io.FileNotFoundException;

import com.teamcenter.clientx.AppXSession;
import com.teamcenter.services.strong.administration.PreferenceManagementService;
import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.soa.client.FileManagementUtility;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.strong.ItemRevision;
import com.teamcenter.soa.client.model.strong.User;
import com.teamcenter.soa.exceptions.NotLoadedException;

/** 
 * @ClassName: testLogin 
 * @Description: TODO(这里用一句话描述这个类的作用) 
 * @author admin 
 * @date 2024年9月25日 
 *  
 */
public class testLogin {
    public static void main(String[] args) throws NotLoadedException {
        if(args.length > 0) {
            String id = args[0];
            System.out.println("id："+id);
            
            //开始登录
            String serverHost = "http://10.10.10.35:8080/tc";
            String host = System.getProperty("host");
            if (host != null && host.length() > 0) {
                serverHost = host;
            }

            AppXSession session = new AppXSession(serverHost);
            User user = session.login();

            DataManagementService dmService = DataManagementService.getService(AppXSession.getConnection());
            try {
                FileManagementUtility fileManagementUtility = new FileManagementUtility(AppXSession.getConnection(),
                        null,
                        new String[] { "http://10.10.10.35:4544" },
                        new String[] { "http://10.10.10.35:4544" },
                        "D://TEMP//fcc_tmp");
                PreferenceManagementService service2 = PreferenceManagementService.getService(AppXSession.getConnection());
                ItemRevision rev = null;
                rev = (ItemRevision) dmService.loadObjects(new String[] {id}).getPlainObject(0);
                ModelObject plainObject = dmService.loadObjects(new String[] {id}).getPlainObject(0);
                dmService.getProperties(new ModelObject[]{plainObject}, new String[]{"item_id"});
                String propertyDisplayableValue = plainObject.getPropertyDisplayableValue("item_id");
                System.out.println("id:"+propertyDisplayableValue);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
        }else {
            System.out.println("传入参数有误");
        }
        
    }
}
