| 1 | #include "xmlprocessor.h" | 
 
 
 
 
 | 2 |  | 
 
 
 
 
 | 3 | XmlProcessor::XmlProcessor(Logger *myLogger, QStringList *commands) | 
 
 
 
 
 | 4 | { | 
 
 
 
 
 | 5 | this->myLogger=myLogger; | 
 
 
 
 
 | 6 | this->commands=commands; | 
 
 
 
 
 | 7 | } | 
 
 
 
 
 | 8 |  | 
 
 
 
 
 | 9 | void XmlProcessor::run() | 
 
 
 
 
 | 10 | { | 
 
 
 
 
 | 11 | QProcess *myProcess = new QProcess(); | 
 
 
 
 
 | 12 | QString result = QString(); | 
 
 
 
 
 | 13 | QString errorMessage = ""; | 
 
 
 
 
 | 14 | int numErrors=0; | 
 
 
 
 
 | 15 |  | 
 
 
 
 
 | 16 | for(int i=0; i<this->commands->size(); i++){ | 
 
 
 
 
 | 17 |  | 
 
 
 
 
 | 18 | myProcess->start(GlobalVars::XmlToolsExeName+" "+this->commands->at(i)); | 
 
 
 
 
 | 19 | myProcess->waitForFinished(-1); | 
 
 
 
 
 | 20 | result=myProcess->readAllStandardError(); | 
 
 
 
 
 | 21 |  | 
 
 
 
 
 | 22 | if(!result.isEmpty()){ | 
 
 
 
 
 | 23 | //catch exception | 
 
 
 
 
 | 24 | myLogger->writeString("Xml Tools Error: \n"+this->commands->at(i)+"\n"+result); | 
 
 
 
 
 | 25 | errorMessage=result; | 
 
 
 
 
 | 26 | numErrors++; | 
 
 
 
 
 | 27 | } | 
 
 
 
 
 | 28 |  | 
 
 
 
 
 | 29 | } | 
 
 
 
 
 | 30 |  | 
 
 
 
 
 | 31 | delete myProcess; //delete object and make pointer invalid | 
 
 
 
 
 | 32 | this->commands->clear(); //clean list | 
 
 
 
 
 | 33 |  | 
 
 
 
 
 | 34 | //let's cut it a bit, complete error is in log file. | 
 
 
 
 
 | 35 | if(errorMessage.size()>600){ | 
 
 
 
 
 | 36 | //limit it at 400 characters (not counting the warning at the begin) | 
 
 
 
 
 | 37 | errorMessage.remove(299,errorMessage.size()-600); | 
 
 
 
 
 | 38 | errorMessage.insert(299,"\n \t ... \n"); | 
 
 
 
 
 | 39 | errorMessage.insert(0,"This error was been shortened. \nSee the complete error at Vago log file.\n\n"); | 
 
 
 
 
 | 40 | } | 
 
 
 
 
 | 41 |  | 
 
 
 
 
 | 42 | emit resultConversion(errorMessage,numErrors); | 
 
 
 
 
 | 43 | } | 
 
 
 
 
 | 44 |  |