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