diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java index 1f7aeec63..db489fb3c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/SendHelper.java @@ -5,9 +5,10 @@ import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; -import java.io.IOException; import java.util.HashMap; +import java.util.Map; /** * 负责向服务器发送信息 @@ -30,14 +31,16 @@ class SendHelper { } private static boolean sendSingleTemplateInfo(String url, String content) { - HashMap para = new HashMap<>(); + Map para = new HashMap<>(); para.put("token", SiteCenterToken.generateToken()); para.put("content", content); try { - String res = HttpToolbox.get(url, para); + String res = HttpToolbox.post(url, para); return ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); - } catch (IOException ignore) { + } catch (Throwable e) { + // 客户不需要关心,错误等级为 debug 就行了 + FineLoggerFactory.getLogger().debug(e.getMessage(), e); } return false; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index c16c6b627..e7fc95594 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -145,10 +145,6 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { } private boolean shouldCollectInfo() { - //只收集本地环境的 - if (!WorkContext.getCurrent().isLocal()) { - return false; - } return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); } diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java new file mode 100644 index 000000000..fb89143d8 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/SendHelperTest.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.template.info; + +import com.fr.invoke.Reflect; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.javax.xml.stream.XMLStreamException; + +import java.io.StringReader; + +import static org.junit.Assert.assertTrue; + +/** + * Created by plough on 2019/4/25. + */ +public class SendHelperTest { + private static final String CONSUMING_URL = "http://cloud.fanruan.com/api/monitor/record_of_reports_consuming/single"; + private static final String PROCESS_URL = "http://cloud.fanruan.com/api/monitor/record_of_reports_process/single"; + + private static final String NORMAL_INFO = "\n" + + "\n" + + "\n" + + ""; + + // 只在调试的时候运行,不需要每次都自动运行 + public static void main(String[] args) throws XMLStreamException { + StringReader sr = new StringReader(NORMAL_INFO); + XMLableReader xmlReader = XMLableReader.createXMLableReader(sr); + TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(xmlReader); + + boolean res = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", CONSUMING_URL, templateInfo.getConsumingMapJsonString()).get(); + assertTrue(res); + + boolean res2 = Reflect.on(SendHelper.class).call("sendSingleTemplateInfo", PROCESS_URL, templateInfo.getProcessMapJsonString()).get(); + assertTrue(res2); + } +}