作者 朱兆平

几个测试文件。

  1 +//
  2 +// Source code recreated from a .class file by IntelliJ IDEA
  3 +// (powered by Fernflower decompiler)
  4 +//
  5 +
  6 +package com.airport;
  7 +
  8 +import com.airport.core.CDHZSender;
  9 +import com.airport.core.IMFNoDelaySender;
  10 +import com.airport.core.IMFReader;
  11 +import com.airport.util.ConfigUtils;
  12 +import com.airport.util.SystemBean;
  13 +import com.caac.imf.api.IMFClient;
  14 +import com.caac.imf.api.IMFClientFactory;
  15 +import org.apache.log4j.Logger;
  16 +import org.apache.log4j.PropertyConfigurator;
  17 +
  18 +import java.util.Timer;
  19 +
  20 +public class TESTMAIN {
  21 + private static final Logger logger = Logger.getLogger(TESTMAIN.class);
  22 + public static boolean LOGIN_OK = false;
  23 + public static boolean isSuc = true;
  24 + public static IMFClient client = null;
  25 +
  26 +
  27 + public TESTMAIN() {
  28 + }
  29 +
  30 + private static void start() throws Exception {
  31 + PropertyConfigurator.configure("config/log4j.properties");
  32 + SystemBean.createInstance("config/ApplicationContext.xml");
  33 + ConfigUtils conf = new ConfigUtils();
  34 + conf.Initialize();
  35 + client = IMFClientFactory.createInstance();
  36 + if ("R".equalsIgnoreCase(ConfigUtils.ROLE)) {
  37 + if (client != null) {
  38 + IMFReader reader = new IMFReader(client);
  39 + reader.start();
  40 + }
  41 +
  42 + loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties");
  43 + } else if ("S".equalsIgnoreCase(ConfigUtils.ROLE)) {
  44 + loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties");
  45 + if (LOGIN_OK && client != null) {
  46 + logger.info("start run Timer,client hasocde=" + client.hashCode());
  47 +
  48 + //代理人发送程序
  49 +// AgentSender send = new AgentSender(client);
  50 +// send.start();
  51 +
  52 + //数据仓库给九州的发送程序
  53 + Timer timer = new Timer();
  54 +
  55 + //从配置文件读取sql语句,发送货运数据
  56 +
  57 + CDHZSender cdhzSender = new CDHZSender(client,"data/fid_index.txt","","");
  58 + cdhzSender.start();
  59 +// timer.schedule(CangKu2Jiuzhou, 10000L, 1200000L);
  60 +
  61 + }
  62 + }
  63 +
  64 + }
  65 +
  66 + private static void loginIMF(IMFClient client, String userName, String password, String confFileName) {
  67 + if (client.initial(confFileName)) {
  68 + String message = client.login(userName, password);
  69 + logger.info("message=" + message);
  70 + if (message.indexOf("<CODE>1</CODE>") > 0) {
  71 + logger.info("登陆成功");
  72 + LOGIN_OK = true;
  73 + } else {
  74 + int times = 0;
  75 +
  76 + while(times <= 3) {
  77 + logger.info("try connection...");
  78 + ++times;
  79 + logger.info("message.=" + message);
  80 + if (message.indexOf("<CODE>1</CODE>") > 0) {
  81 + logger.info("登陆成功");
  82 + LOGIN_OK = true;
  83 + break;
  84 + }
  85 +
  86 + logger.info("登录失败~~~~");
  87 + message = client.login(userName, password);
  88 +
  89 + try {
  90 + Thread.sleep(4000L);
  91 + } catch (InterruptedException var7) {
  92 + var7.printStackTrace();
  93 + }
  94 + }
  95 +
  96 + if (!LOGIN_OK) {
  97 + logger.info("多次尝试登录失败,退出登陆");
  98 + client.disconnect();
  99 + isSuc =false;
  100 + System.exit(-1);
  101 + }
  102 + }
  103 + }
  104 +
  105 + }
  106 +
  107 + public static void main(String[] args) throws Exception {
  108 + start();
  109 + }
  110 +}