diff --git a/.gitignore b/.gitignore index bb9ffe3..5f9083d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ client/nbproject/private/private.properties *.class *.jar *.class +*.class diff --git a/JuderUI/build/classes/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl b/JuderUI/build/classes/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl index e3a5ea8..0da2ae1 100644 --- a/JuderUI/build/classes/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl +++ b/JuderUI/build/classes/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl @@ -872,7 +872,7 @@ - + \ No newline at end of file diff --git a/JuderUI/catalog.xml b/JuderUI/catalog.xml index f1ec77b..72b3536 100644 --- a/JuderUI/catalog.xml +++ b/JuderUI/catalog.xml @@ -3,4 +3,6 @@ + + \ No newline at end of file diff --git a/JuderUI/config.xml b/JuderUI/config.xml index 9e9423f..d12be63 100644 --- a/JuderUI/config.xml +++ b/JuderUI/config.xml @@ -1,63 +1,43 @@ - + + + K:\msvc\MSVC + $compilerPath$/bin/cl.exe /O2 /Fo"$objFile$" /Fe"$exeFile$" /I $compilerPath$\include /EHsc "$sourceFile$" /link /LIBPATH:"$compilerPath$\lib" + + + + + $exeFile$ + K:\Dev-Cpp\MinGW64\bin - g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$ + "$compilerPath$\g++" -Wall -g -c -std=c++1y "$sourceFile$" -o "$objFile$" - g++.exe -o $exeFile$ $objFile$ -O1 + $compilerPath$\g++ "$objFile$" "$exeFile$" -o -O1 - "$exeFile$" - - - C:/MinGW/bin/ - g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$ - - g++.exe -o $exeFile$ $objFile$ -O1 - - msvc + $exeFile$ + + + - C:/JDK8/bin - g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$ - - g++.exe -o $exeFile$ $objFile$ -O1 - - "$compilerPath$ java -cp $sourceFile$\output\$exeFile$" - - - C:/MinGW/bin/ - g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$ - - g++.exe -o $exeFile$ $objFile$ -O1 - - - - - - - - C:/MinGW/bin/ - g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$ - + C:\Program Files\Java\jdk1.8.0_121\bin + "$compilerPath$/javac" $sourceFile$ + g++.exe -o $exeFile$ $objFile$ -O1 $exeFile$ + + - C:/MinGW/bin/ - g++.exe -Wall -g -std=c++14 -c $sourceFile$ -o $objFile$ - - g++.exe -o $exeFile$ $objFile$ -O1 - - - + F:\裁判机\python3.12 + + + $compilerPath$/python "$sourceFile$" - - - - \ No newline at end of file diff --git a/JuderUI/dist/JuderUI.jar b/JuderUI/dist/JuderUI.jar index caf63dd..1cb903f 100644 Binary files a/JuderUI/dist/JuderUI.jar and b/JuderUI/dist/JuderUI.jar differ diff --git a/JuderUI/dist/lib/Common.jar b/JuderUI/dist/lib/Common.jar index ff5cc18..8329a08 100644 Binary files a/JuderUI/dist/lib/Common.jar and b/JuderUI/dist/lib/Common.jar differ diff --git a/JuderUI/dist/lib/Judger.jar b/JuderUI/dist/lib/Judger.jar index d682263..d6260c0 100644 Binary files a/JuderUI/dist/lib/Judger.jar and b/JuderUI/dist/lib/Judger.jar differ diff --git a/JuderUI/src/data/JudgeFromQueue.java b/JuderUI/src/data/JudgeFromQueue.java index da6e722..3eb9a42 100644 --- a/JuderUI/src/data/JudgeFromQueue.java +++ b/JuderUI/src/data/JudgeFromQueue.java @@ -157,22 +157,43 @@ public class JudgeFromQueue extends Thread { String problem = (String) problemsCachManager .getObject("problemId" + problemId); if (problem == null) { - problem = Control.getWebService().getProblem(Integer.parseInt(problemId)); - problemsCachManager.putObject("problemId" + problemId, + try{ + problem = Control.getWebService().getProblem(Integer.parseInt(problemId)); + problemsCachManager.putObject("problemId" + problemId, problem); + }catch(Exception e){ + Result.status = Const.SE; + CompileInfo.remark = "ȡĿϢʧܣϵԱϢ"+e.getMessage(); + e.printStackTrace(); + EventQueue.invokeLater(() -> { + Control.addExceptionInfo(threadNo, e.toString()); + }); + } + } if(problem.isEmpty()){ Result.status = Const.CE; CompileInfo.remark = "ȡĿϢʧܣ"; + return; } // System.out.println(Integer.parseInt(problemId)); // System.out.println(xml); - xtp.readXmlString(problem); - problemBean = xtp.convertXML(); - Control.addJudgeInfo(threadNo, "get problemId: " + problemId); - problemBeanMap.put(problemId, problemBean); + try{ + xtp.readXmlString(problem); + problemBean = xtp.convertXML(); + Control.addJudgeInfo(threadNo, "get problemId: " + problemId); + problemBeanMap.put(problemId, problemBean); + }catch(Exception e){ + Result.status = Const.SE; + CompileInfo.remark = "ĿϢʧܣϵԱϢ"+"problemId:"+problemId+e.getMessage(); + e.printStackTrace(); + EventQueue.invokeLater(() -> { + Control.addExceptionInfo(threadNo, e.toString()); + }); + } + } // @@ -219,6 +240,9 @@ public class JudgeFromQueue extends Thread { Control.addJudgeInfo(threadNo, "server result:" + req.getRspMsg()); // Control.addJudgeInfo("ok"); } catch (Exception e) { + EventQueue.invokeLater(() -> { + Control.addExceptionInfo(threadNo, e.toString()); + }); e.printStackTrace(); } diff --git a/JuderUI/src/data/MainForNet.java b/JuderUI/src/data/MainForNet.java index 39510ff..bb71256 100644 --- a/JuderUI/src/data/MainForNet.java +++ b/JuderUI/src/data/MainForNet.java @@ -97,11 +97,29 @@ public class MainForNet extends Thread { private List getWebServiceSolutions() throws Exception { Control.setWebService(new Webservice(new URL(Control.getUrl()), Control.getQname())); - String xml = Control.getWebService().getSolutions(5); + String xml = null; + try{ + xml=Control.getWebService().getSolutions(5); + } + catch(Exception ex){ + ex.printStackTrace(); + EventQueue.invokeLater(() -> { + Control.addExceptionInfo(0, ex.getStackTrace().toString()); + }); + } XmlToSolution xts = new XmlToSolution(); xts.readXmlString(xml); - this.solutions = xts.convertXML(); + + try{ + this.solutions = xts.convertXML(); + } + catch(Exception ex){ + ex.printStackTrace(); + EventQueue.invokeLater(() -> { + Control.addExceptionInfo(0, ex.getStackTrace().toString()); + }); + } // Control.addJudgeInfo(" get "+solutions.getSolution().size()+" solutioins "); if (solutions.getSolution().size() != 0) { //System.out.println("get " + solutions.getSolution().size() + " solution"); diff --git a/JuderUI/src/gui/MainFrame.form b/JuderUI/src/gui/MainFrame.form index 5ef3fe5..09202ce 100644 --- a/JuderUI/src/gui/MainFrame.form +++ b/JuderUI/src/gui/MainFrame.form @@ -79,7 +79,7 @@ - + @@ -103,20 +103,11 @@ - - + - - - - - - - - - + @@ -126,17 +117,24 @@ - + + + + + + - - - + + + + + + - - + @@ -144,21 +142,15 @@ - - - - - - - - - - - - - - - + + + + + + + + + @@ -300,22 +292,19 @@ - - - - - - - - + + - - - - + + + + + + + @@ -404,7 +393,7 @@ - + @@ -529,14 +518,6 @@ - - - - - - - - @@ -553,14 +534,6 @@ - - - - - - - - diff --git a/JuderUI/src/gui/MainFrame.java b/JuderUI/src/gui/MainFrame.java index cc9c78b..49939d0 100644 --- a/JuderUI/src/gui/MainFrame.java +++ b/JuderUI/src/gui/MainFrame.java @@ -127,9 +127,7 @@ public class MainFrame extends javax.swing.JFrame { jLabel17 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); - jLabel8 = new javax.swing.JLabel(); comboCppCompiler = new javax.swing.JComboBox(); - jLabel10 = new javax.swing.JLabel(); comboJavaCompiler = new javax.swing.JComboBox(); jCheckBox2 = new javax.swing.JCheckBox(); @@ -176,18 +174,16 @@ public class MainFrame extends javax.swing.JFrame { jPanel7Layout.setHorizontalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup() - .addContainerGap() .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 379, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel15)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel15)) + .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel7Layout.createSequentialGroup() - .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE) - .addContainerGap()) - .addGroup(jPanel7Layout.createSequentialGroup() - .addComponent(jLabel16) - .addGap(35, 501, Short.MAX_VALUE)))) + .addComponent(jLabel16) + .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 542, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel7Layout.setVerticalGroup( jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -226,7 +222,7 @@ public class MainFrame extends javax.swing.JFrame { .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(jLabel9) .addGap(0, 0, Short.MAX_VALUE)) - .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)) + .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)) .addContainerGap()) ); jPanel6Layout.setVerticalGroup( @@ -283,9 +279,6 @@ public class MainFrame extends javax.swing.JFrame { } }); - jLabel8.setFont(new java.awt.Font("", 0, 10)); // NOI18N - jLabel8.setText("ĬC/C++:"); - comboCppCompiler.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); comboCppCompiler.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { @@ -298,9 +291,6 @@ public class MainFrame extends javax.swing.JFrame { } }); - jLabel10.setFont(new java.awt.Font("", 0, 10)); // NOI18N - jLabel10.setText("ĬJava:"); - comboJavaCompiler.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); comboJavaCompiler.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { @@ -330,7 +320,7 @@ public class MainFrame extends javax.swing.JFrame { jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSeparator2) .addGroup(jPanel2Layout.createSequentialGroup() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -354,19 +344,10 @@ public class MainFrame extends javax.swing.JFrame { .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(button_StartThread)) + .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jButton2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel8) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(9, 9, 9) - .addComponent(jLabel10) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) + .addGap(353, 353, 353) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -376,30 +357,32 @@ public class MainFrame extends javax.swing.JFrame { .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(36, 36, 36)))) + .addGap(18, 18, 18) + .addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(83, 83, 83))) + .addGap(21, 21, 21)) .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(threadManagerTabb, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(28, 28, 28))) - .addGap(21, 21, 21) - .addComponent(jSeparator1)) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(button_StartThread) + .addComponent(threadManagerTabb, javax.swing.GroupLayout.PREFERRED_SIZE, 945, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jButton2) - .addComponent(jLabel8) - .addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel10) - .addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4) - .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3) - .addComponent(jCheckBox2))) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton2) + .addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4) + .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3) + .addComponent(jCheckBox2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) @@ -512,25 +495,25 @@ public class MainFrame extends javax.swing.JFrame { } }//GEN-LAST:event_jLabel17MouseClicked private boolean checkForCompile() { - String tmp = null; - tmp = Config.getCompilerDir("c",comboCppCompiler.getSelectedItem().toString()); - if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "gcc.exe")&&!FileFinder.isExistFile(tmp + File.separator + "g++.exe")&&!FileFinder.isExistFile(tmp + File.separator + "/bin/cl.exe")) { + //String tmp = null; + //tmp = Config.getCompilerDir("c",comboCppCompiler.getSelectedItem().toString()); + //if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "gcc.exe")&&!FileFinder.isExistFile(tmp + File.separator + "g++.exe")&&!FileFinder.isExistFile(tmp + File.separator + "/bin/cl.exe")) { //ñ - JOptionPane.showMessageDialog(this, "C/C++"); + // JOptionPane.showMessageDialog(this, "C/C++"); // NewCompileSetting window = new NewCompileSetting("c", this, true); // window.setVisible(true); - return false; - } + // return false; + //} - tmp = Config.getCompilerDir("java",comboJavaCompiler.getSelectedItem().toString()); - if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "javac.exe")) { + // tmp = Config.getCompilerDir("java",comboJavaCompiler.getSelectedItem().toString()); + //if (tmp == null || "".equals(tmp) || !FileFinder.isExistFile(tmp + File.separator + "javac.exe")) { - JOptionPane.showMessageDialog(this, "Java"); + // JOptionPane.showMessageDialog(this, "Java"); // NewCompileSetting window = new NewCompileSetting("java", this, true); // window.setVisible(true); - return false; - } + // return false; + //} return true; } public String getSelectedCppCompilerName(){ @@ -684,7 +667,6 @@ public class MainFrame extends javax.swing.JFrame { private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBox jCheckBox2; javax.swing.JComboBox jComboBox1; - private javax.swing.JLabel jLabel10; javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; @@ -695,7 +677,6 @@ public class MainFrame extends javax.swing.JFrame { private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; public javax.swing.JPanel jPanel2; diff --git a/JuderUI/src/swingworker/MySwingWorker.java b/JuderUI/src/swingworker/MySwingWorker.java index 019c80a..2fb7617 100644 --- a/JuderUI/src/swingworker/MySwingWorker.java +++ b/JuderUI/src/swingworker/MySwingWorker.java @@ -5,6 +5,9 @@ */ package swingworker; +import common.Const; +import gui.Control; +import java.awt.EventQueue; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; @@ -12,6 +15,8 @@ import javax.swing.SwingWorker; import main.Answer; import main.Process; import persistence.oj_beans.ProblemTestCaseBean; +import resultData.CompileInfo; +import resultData.Result; /** * @@ -44,7 +49,9 @@ public class MySwingWorker extends SwingWorker{ @Override protected Answer doInBackground() throws Exception { - return new Process().Judge(getSolutionId(),getProblemId(),getLanguage(),getCompiler(), getSourceCode(), timeOut, getTestCaseList(),this::writeToGui); + + return new Process().Judge(getSolutionId(),getProblemId(),getLanguage(),getCompiler(), getSourceCode(), timeOut, getTestCaseList(),this::writeToGui); + } public void writeToGui(String s){ diff --git a/JuderUI/src/web/Webservice.java b/JuderUI/src/web/Webservice.java index 2f25b1f..d557a0c 100644 --- a/JuderUI/src/web/Webservice.java +++ b/JuderUI/src/web/Webservice.java @@ -13,6 +13,7 @@ import edu.dhu.ws.OJWS; import edu.dhu.ws.OJWS_Service; import static gui.Control.getDistributorField; import static gui.Control.getJudgeInfoEditorPane; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.rmi.RemoteException; @@ -26,6 +27,7 @@ import javax.swing.JTextField; import javax.xml.namespace.QName; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.boot.logging.LogLevel; /** * * @author ytxlo @@ -34,7 +36,7 @@ import org.apache.dubbo.config.annotation.DubboService; public class Webservice implements java.rmi.Remote{ private OJWS_Service webs; private OJWS servicePort; - public static boolean ENABLE_DUBBO=false; + public static boolean ENABLE_DUBBO=true; public static boolean existDubbo=false; //@DubboReference(url = "http://106.15.36.190:3000/edu.dhu.ws.OJWS") //http://106.15.36.190:3000/edu.dhu.ws.OJWS @@ -45,6 +47,7 @@ public class Webservice implements java.rmi.Remote{ //@DubboReference(url = "dubbo://10.10.10.1:20880/edu.dhu.ws.OJWS") //@Resource public OJWS dubboPort; + common.Logger logger; public static OJWS initDubboPort(String url) { // Ӧ ApplicationConfig application = new ApplicationConfig(); @@ -60,7 +63,7 @@ public class Webservice implements java.rmi.Remote{ return reference.get(); } private void setDubbo(){ - + logger = common.Logger.getInstance(); String url = "dubbo://localhost:8080/edu.dhu.ws.OJWS"; JTextField ip=getDistributorField(0); JTextField port=getDistributorField(1); @@ -69,16 +72,17 @@ public class Webservice implements java.rmi.Remote{ try { JEditorPane infoPane=getJudgeInfoEditorPane(0); - if(!existDubbo&&infoPane!=null) + if(!existDubbo&&infoPane!=null){ infoPane.setText(infoPane.getText()+LocalTime.now().toString()+"Dubbo...\n"); - + logger.log("dubbo", common.LogLevel.INFO); + } dubboPort = initDubboPort(url); //infoPane.setText(infoPane.getText()+LocalTime.now().toString()+"test..."+dubboPort.test("aa")+"\n"); } catch(Exception e){ - JEditorPane infoPane=getJudgeInfoEditorPane(1); - infoPane.setText(infoPane.getText()+LocalTime.now().toString()+e.getMessage()+"\n"); + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+"\n"+LocalTime.now().toString()+e.getMessage()+"\n"); e.printStackTrace(); } if(dubboPort!=null){ @@ -90,6 +94,7 @@ public class Webservice implements java.rmi.Remote{ }else{ existDubbo=false; JEditorPane infoPane=getJudgeInfoEditorPane(1); + logger.log("dubboʧ", common.LogLevel.ERROR); infoPane.setText(infoPane.getText()+LocalTime.now().toString()+"\nDubboʧܣURL:"+url+"\n"); } @@ -110,6 +115,7 @@ public class Webservice implements java.rmi.Remote{ servicePort = webs.getOJWSImplPort(); } catch(Exception e){ + logger.log(e.getMessage(), common.LogLevel.ERROR); e.printStackTrace(); } } @@ -138,20 +144,56 @@ public class Webservice implements java.rmi.Remote{ setDubbo(); } public String getSolutions(int arg0)throws java.rmi.RemoteException{ - String s =this.servicePort.wsGetSolutions("judge","judge123",arg0); - return s; + try{ + String s =this.servicePort.wsGetSolutions("judge","judge123",arg0); + return s; + } + catch(Exception e){ + logger.log(e.getMessage(), common.LogLevel.ERROR); + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+e.getMessage()+"\n"); + return ""; + } } public String getProblem(int arg)throws java.rmi.RemoteException{ // servicePort.wsGetProblem(arg0, arg1, arg, arg) - byte[] soucre = this.servicePort.wsGetProblem4Judge("felix", "felix", arg); - String result = Decrypt.decrypt("felix10000", soucre); - //String prob = result.replaceFirst("GBK", "UTF-8"); - return result; + try{ + byte[] soucre = this.servicePort.wsGetProblem4Judge("felix", "felix", arg); + String result = Decrypt.decrypt("felix10000", soucre); + //String prob = result.replaceFirst("GBK", "UTF-8"); + return result; + } + + catch(Exception e){ + logger.log(e.getMessage(), common.LogLevel.ERROR); + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+e.getMessage()+"\n"); + return ""; + } } public String updateResult(String arg)throws java.rmi.RemoteException{ + try{ byte[] data=Decrypt.encrypt("judge123", arg); String s = servicePort.wsUpdateResult("judge","judge123",data); return s; + } + catch(Exception e){ + logger.log(e.getMessage(), common.LogLevel.ERROR); + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+e.getMessage()+"\n"); + return ""; + } + } + private static String getGbkString(String string) { + try { + // Convert the string to byte array using GBK encoding + byte[] gbkBytes = string.getBytes("GBK"); + // Create a new string from the byte array using GBK encoding + return new String(gbkBytes, "GBK"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return string; + } } public static void main(String[] args) { Webservice ws=new Webservice(); @@ -160,6 +202,7 @@ public class Webservice implements java.rmi.Remote{ System.out.println(ws.getProblem(75)); } catch (RemoteException ex) { Logger.getLogger(Webservice.class.getName()).log(Level.SEVERE, null, ex); + } } } diff --git a/Judger/src/kernel/ExeCommand.java b/Judger/src/kernel/ExeCommand.java index 96ab38b..3acfb4b 100644 --- a/Judger/src/kernel/ExeCommand.java +++ b/Judger/src/kernel/ExeCommand.java @@ -18,6 +18,7 @@ import resultData.Result; import tool.ThreadTool; import com.sun.jna.Library; import com.sun.jna.Native; +import java.awt.EventQueue; import java.lang.reflect.Field; import resultData.JudgerInfo; @@ -152,14 +153,14 @@ public class ExeCommand { RunInfo.remark = JudgerInfo.remark; } else if (flag) { - RunInfo.remark = "ʱ" + RunInfo.errorInfo; + RunInfo.remark = "ʱ"; Result.status = Const.RE; } else if (RunInfo.isKilled == 1) { Result.status = Const.TLE; RunInfo.remark = "гʱ" + RunInfo.errorInfo; } else if (result != 0) { Result.status = Const.RE; - RunInfo.remark = "ʱ󣺳ֵΪ" + RunInfo.errorInfo; + RunInfo.remark = "ʱ󣺳ֵΪ"; } if (result == 0) { RunInfo.remark = ""; @@ -229,7 +230,7 @@ public class ExeCommand { } catch (Exception ex) { ex.printStackTrace(); Result.status = Const.SE; - JudgerInfo.remark = "ϵͳ,"; + JudgerInfo.remark = "ϵͳ,"+ex.getMessage(); Log.writeExceptionLog("compileCommand line:3:" + ex.getMessage() + "\n" + ex.getStackTrace()); return -1; } finally { diff --git a/Judger/src/kernel/Judger.java b/Judger/src/kernel/Judger.java index f2cbab8..dc8fc4c 100644 --- a/Judger/src/kernel/Judger.java +++ b/Judger/src/kernel/Judger.java @@ -56,6 +56,7 @@ public class Judger { // if (!file1.exists() || !file2.exists()) { // System.out.println("δҵ"); // isFound = false; + // } // } @@ -121,7 +122,7 @@ public class Judger { else map.put(LangSelector.PlaceHolder.ObjFile.getStr(),Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main.obj"); map.put(LangSelector.PlaceHolder.ExeFile.getStr(),Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main.exe"); - String linkCommand = LangSelector.matchPlaceHolder(LangSelector.getCompileCommand("C++",compiler), map); + String linkCommand = LangSelector.matchPlaceHolder(LangSelector.getCompileCommand(language,compiler), map); //String linkCommand = Config.getCompilerDir(language) + File.separator + "g++ " +"\""+ Config.getTargetPath() +File.separator+"output"+File.separator+ "Main"+".o"+"\"" + " -o " +"\""+ Config.getTargetPath()+File.separator+"output"+File.separator + "Main"+".exe"+"\"\n"; return linkCommand; } @@ -134,14 +135,7 @@ public class Judger { compiler=LangSelector.getDefaultCompilerName(language); } language = language.toLowerCase();//todo - if (language.equals("c")) { - - compileCommand += "\"" + Config.getCompilerDir(language,compiler) + File.separator + "gcc\" -c " + "\""+sourceFile +"\""+ " -o " +"\""+Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main"+".o"+"\"\n"; - } else if (language.equals("java")) { - compileCommand += "\"" + Config.getCompilerDir(language,compiler) + File.separator + "javac\" " + sourceFile; //todoļ· - } else if (language.equals("cpp")||language.equals("c++")) { - //compileCommand +=Config.getCompilerDir(language) + File.separator +LangSelector.getCompileCommand("C++",null); - + HashMapmap=new HashMap<>(); map.put(LangSelector.PlaceHolder.CompilerPath.getStr(),Config.getCompilerDir(language,compiler)); map.put(LangSelector.PlaceHolder.SourceFile.getStr(),sourceFile); @@ -150,41 +144,38 @@ public class Judger { else map.put(LangSelector.PlaceHolder.ObjFile.getStr(),Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main.obj"); map.put(LangSelector.PlaceHolder.ExeFile.getStr(),Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main.exe"); - compileCommand = LangSelector.matchPlaceHolder(LangSelector.getCompileCommand("C++",compiler), map); - //compileCommand += "\"" + Config.getCompilerDir(language) + File.separator + "g++\" -Wall -g -c -std=c++1y "//todo:C++14 - // + "\""+sourceFile+"\"" + " -o " + "\""+Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main"+".o"+"\"\n"; - } else { - CompileInfo.info = "this programing language is not support!!!"; - } + compileCommand = LangSelector.matchPlaceHolder(LangSelector.getCompileCommand(language,compiler), map); return compileCommand; } private String runCommand(String language,String compiler) { String runCommand = ""; - if (language.equals("c")) { - runCommand +="\""+ Config.getTargetPath()+ File.separator+"output"+File.separator + "Main"+"\""; + runCommand+=LangSelector.getRunCommand(language, compiler);//ԣPython + HashMapmap=new HashMap<>(); + if (language.equals("java")) { + String rawCmd= Config.getCompilerDir(language,compiler) + File.separator + "java"+ " -cp " + Config.getSourcePath()+ File.separator+"output"+File.separator+ " "+mainClassName; // TODO ļ· start + map.put(LangSelector.PlaceHolder.ExeFile.getStr(),rawCmd); +//System.err.println(runCommand); + } else if (language.equals("cpp")||language.equals("c++")||language.equals("c")) { + String rawCmd="\""+ Config.getTargetPath()+ File.separator+"output"+File.separator + "Main"+"\""; + map.put(LangSelector.PlaceHolder.ExeFile.getStr(),rawCmd); + } + else{ - } else if (language.equals("java")) { - runCommand += Config.getCompilerDir(language,compiler) + File.separator + "java"+ " -cp " + Config.getSourcePath()+ File.separator+"output"+File.separator+ " "+mainClassName; // TODO ļ· start - //System.err.println(runCommand); - } else if (language.equals("cpp")||language.equals("c++")) { - runCommand += "\""+ Config.getTargetPath()+ File.separator+"output"+File.separator + "Main"+"\""; + } // System.out.println(runCommand); + + map.put(LangSelector.PlaceHolder.CompilerPath.getStr(),Config.getCompilerDir(language,compiler)); + map.put(LangSelector.PlaceHolder.SourceFile.getStr(),sourceFile); + runCommand=LangSelector.matchPlaceHolder(runCommand, map); return runCommand; } public int compile(String sourceCode, String language,String compiler) { int result = -1; - //ǷڷΧ + language = language.toLowerCase(); - if (language.equals("c") || language.equals("cpp")|| language.equals("c++") || language.equals("java")) { - //ok - } else { - Result.status = Const.CE; -// CompileInfo.remark = "಻Ҫ"; - return result; - } try { if (Shared.PID!=-1&&ThreadTool.findProcess(Shared.PID)) { //tore0 Runtime.getRuntime().exec("taskkill /f /t /PID "+Shared.PID).waitFor(); @@ -199,7 +190,12 @@ public class Judger { int repeatTime = 3; String compileCom = compileCommand(language,compiler); + if(compileCom==null){ + result=0; + return result; + } for (int i = 0; i < repeatTime; i++) { + result = exe.exeCompile(compileCom,"Path="+Config.getCompilerDir(language,compiler)); if (result == 0) { if (language.equals("c") || language.equals("cpp")||language.equals("c++")) { diff --git a/Judger/src/main/Process.java b/Judger/src/main/Process.java index 10b8fdb..26726ef 100644 --- a/Judger/src/main/Process.java +++ b/Judger/src/main/Process.java @@ -373,33 +373,53 @@ public class Process { } solutionBean.setStatus(Const.STATUS[maxLevelStatus]); //ߵȼӦϢ - if (maxLevelStatus == Const.CE) { - solutionBean.setRemark(remarks[index]); - } else if (result[index] == Const.WA || result[index] == Const.PE) { -// solutionBean.setRemark(""); - String message = new String(); - for (int i = 0; i < remarks.length; i++) { - message += " " + testCaseBeans.get(i).getId() + "Ϊ " + Const.STATUS[result[i]] + ":"; - message += remarks[i] + "\n"; - } - solutionBean.setRemark(message); - } else {//RE,TLE - String wrongCaseIds = ""; - for (int j = 0; j < sumTestcaseNum; j++) { - if (result[j] == result[index]) { - wrongCaseIds += ((ProblemTestCaseBean) testCaseBeans.get(j)).getId() + ","; - } - } - solutionBean.setRemark("IDΪ" + wrongCaseIds + remarks[index]); - String message = new String(); - for (int i = 0; i < remarks.length; i++) { - message += "\n"; - message += remarks[i]; - } - solutionBean.setRemark(solutionBean.getRemark() + message); + + + + String message=""; + for (int i = 0; i < remarks.length; i++) { + message += " " + testCaseBeans.get(i).getId() + "Ϊ " + Const.STATUS[result[i]] + ":"; + message += remarks[i] + "\n"; } + solutionBean.setRemark(message); + + //old +// if (maxLevelStatus == Const.CE) { +// solutionBean.setRemark(remarks[index]); +// } else if (result[index] == Const.WA || result[index] == Const.PE) { +//// solutionBean.setRemark(""); +// String message = new String(); +// for (int i = 0; i < remarks.length; i++) { +// message += " " + testCaseBeans.get(i).getId() + "Ϊ " + Const.STATUS[result[i]] + ":"; +// message += remarks[i] + "\n"; +// } +// solutionBean.setRemark(message); +// } else {//RE,TLE +// String wrongCaseIds = ""; +// for (int j = 0; j < sumTestcaseNum; j++) { +// if (result[j] == result[index]) { +// wrongCaseIds += ((ProblemTestCaseBean) testCaseBeans.get(j)).getId() + ","; +// } +// } +// solutionBean.setRemark("IDΪ" + wrongCaseIds + remarks[index]); +// String message = new String(); +// for (int i = 0; i < remarks.length; i++) { +// message += "\n"; +// message += remarks[i]; +// } +// solutionBean.setRemark(solutionBean.getRemark() + message); +// } } solutionBean.setCorrectCaseIds(correctCaseIds); + //remarkתΪGBKַ + String originalRemark=solutionBean.getRemark(); + try{ + solutionBean.setRemark(new String(solutionBean.getRemark().getBytes("GBK"),"GBK")); + }catch(Exception e){ + solutionBean.setRemark(originalRemark); + } + //Jared + //SolutionDAO.update(solutionBean); } } diff --git a/config.xml b/config.xml new file mode 100644 index 0000000..e706bb1 --- /dev/null +++ b/config.xml @@ -0,0 +1 @@ + \ No newline at end of file