package com.teamcenter.filemanagement;

import com.teamcenter.clientx.AppXSession;
import com.teamcenter.services.strong.core.SessionService;
import com.teamcenter.soa.client.model.Property;
import com.teamcenter.soa.client.model.ServiceData;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;


public class FMS {
    public static void main(String[] args) {
        System.out.println("upload:" + args.length);
        if (args.length < 2)
            return;
        String filePath = args[0];
        System.out.println("filePath===========" + filePath);
        System.out.println("args[1]===========" + args[1]);
        System.out.println("args[2]===========" + args[2]);
        System.out.println("args[3]===========" + args[3]);
        File file = new File(filePath);
        if (!file.exists())
            return;
        String str = null;
        try {
            BufferedReader reader = new BufferedReader(new FileReader(file));
            str = reader.readLine();
            reader.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        System.out.println("str===========" + str);
        if (str == null)
            return;
        String[] infos = new String[3];
        StringBuilder sb = new StringBuilder();
        String[] values = str.split("\\|");
        if (values != null && values.length == 3)
            for (int i = 0; i < values.length; i++) {
                infos[i] = values[i];
                System.out.println("values[" + i + "]===========" + values[i]);
            }
        if (infos.length < 3)
            return;
        AppXSession session = new AppXSession(infos[0]);
        try {
            FileManagement fm = new FileManagement();
            session.mylogin("infodba", "infodba");
            if (args[1].split("\\|").length != args[2].split("\\|").length
                    || args[2].split("\\|").length != args[3].split("\\|").length) {
                System.out.println(args[1].split("\\|").length);
                System.out.println(args[2].split("\\|").length);
                System.out.println(args[3].split("\\|").length);
                System.out.println("Êý¾Ý´íÎó");
            }
            String[] split1 = args[1].split("\\|");
            String[] split2 = args[2].split("\\|");
            String[] split3 = args[3].split("\\|");
            for (int i = 0; i < split1.length; i++) {
                fm.uploadFiles(split1[i], split2[i], split3[i]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        session.logout();
    }

}

