通过读取xml文件存储的可执行文件描述符,获取可执行文件名称,并启动可执行文件
2014-04-09 22:48
387 查看
m_mvaAnalysisAction = new QAction(tr("mva Analysis"), this); connect(m_mvaAnalysisAction, SIGNAL(triggered()), this, SLOT(parallelSlot())); m_parallelActions->addAction(m_mvaAnalysisAction);
int CKsMPSActions::parallelSlot(){// 获得XML文件,Bin文件根目录QString sXMLPathName,szBinPath;QString exeName;//可执行文件名QList <QString> exeStrList,describeList;//可执行文件列表,可执行文件相对应的描述符列表if (!CKsPathManager::GetVelocityXMLPath(sXMLPathName))return -1;// 读XML文件,获得bin文件夹下的可执行文件列表,可执行文件相对应的描述符列表CKsPathManager::InitCategroy(sXMLPathName, exeStrList,describeList);// 规避无效值int iCount = exeStrList.size();if (iCount == 0){QMessageBox::warning(0, tr("Warning"), tr("Job execute failed!"));return 1;}//可执行文件所在的根目录,即bin目录if( !CKsPathManager::GetExecFilePath(szBinPath))return -1;//if(describeList.contains(tr("mva Analysis"))){exeName = exeStrList.at(describeList.indexOf(tr("mva Analysis")));//#ifdef Q_WS_WIN32szBinPath += exeName;#elseszBinPath = szBinPath +"/" + exeName;#endif//szBinPath = szBinPath.trimmed();if( !QProcess::startDetached(szBinPath) ){QMessageBox::warning(0, tr("Warning"), tr("Job execute failed!"));return 2;}} else { QMessageBox::warning(0, tr("Warning"), tr("Job execute failed!")); return 1; } return 0;}
char *CKsPathManager::m_pVelocityInitFile = "velocity.xml";// 获得速度XML文件路径bool CKsPathManager::GetVelocityXMLPath(QString& sXMLPath){QString sLocTemp;if (GetModuleInitPath(sLocTemp) == false)return false;sXMLPath += sLocTemp;sXMLPath += CKsPathManager::m_pVelocityInitFile;return true;}
void CKsPathManager::InitCategroy(QString szFileName, QList<QString> &listCategory,QList<QString> &listDescribe){QFile file(szFileName);QDomDocument domDocument;QString errorStr;int errorLine;int errorColumn;//设置QFileif (!domDocument.setContent((QIODevice *)&file, true, &errorStr, &errorLine,&errorColumn)) {return;}QDomElement root = domDocument.documentElement();if (root.tagName() == "xml")if (root.hasAttribute("version")&& root.attribute("version") == "1.0"){QDomElement child = root.firstChildElement("category");while (!child.isNull()){parseCategoryElement(child, listCategory,listDescribe);child = child.nextSiblingElement("category");}}}void CKsPathManager::parseCategoryElement(const QDomElement &element, QList<QString> &listCategory,QList<QString> &listDescribe){QString szValue ,szDescrible;QDomElement child = element.firstChildElement();while (!child.isNull()){if (child.tagName() == "module"){szValue = child.attribute("modulename");szDescrible = child.attribute("describe");listCategory.append(szValue);listDescribe.append(szDescrible);}child = child.nextSiblingElement();}}
bool CKsPathManager::GetExecFilePath(QString &szPath){QString szRes;char dbPath[320];char *tmp = getenv(CKsPathManager::m_pMPS_HOME);szPath = "";if (tmp == 0){return false;}strcpy(dbPath, tmp);#ifdef Q_WS_WINstrcat(dbPath, "\\bin\\");#elsestrcat(dbPath, "/bin");#endifszPath += dbPath;return true;}
//#ifdef Q_WS_WIN32szBinPath += exeName;#elseszBinPath = szBinPath +"/" + exeName;#endif//szBinPath = szBinPath.trimmed();if( !QProcess::startDetached(szBinPath) ){QMessageBox::warning(0, tr("Warning"), tr("Job execute failed!"));return 2;}
相关文章推荐
- java通过读取本地文件获取反射方法参数,执行对象方法
- 如何通过进程pid获取进程名、可执行文件的名称
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- [Script]Oracle EBS中,如何通过Form,Report的执行文件来查找对应的功能名称,或者如何反向查找
- 2.通过原始的Driver接口通过读取Properties属性文件获取JDBC数据库连接Connection
- Linux下获取当前进程的执行文件的绝对路径和所在目录(通过/proc/self/exe链接)
- 通过Spark程序读取CSV文件存储到ES
- 通过资源文件名称获取资源id
- C#通过属性名称获取(读取)属性值的方法
- linux c 通过文件描写叙述符获取文件名称
- Lucene4.2源码解析之fdt和fdx文件的读写——fdx文件存储一个个的Block,每个Block管理着一批Chunk,通过docID读取到document需要完成Segment、Block、Chunk、document四级查询,引入了LZ4算法对fdt的chunk docs进行了实时压缩/解压
- 转载Oracle EBS中,如何通过Form,Report的执行文件来查找对应的功能名称,或者如何反向查找
- 保存Excel文件、获取表的名称——Visual C#读取Excel和Access数据库
- 通过执行文件,启动mongodb
- Lucene4.2源码解析之fdt和fdx文件的读写(续)——fdx文件存储一个个的Block,每个Block管理着一批Chunk,通过docID读取到document需要完成Segment、Block、Chunk、document四级查询,引入了LZ4算法对fdt的chunk docs进行了实时压缩/解压
- android 通过URI获取文件名称Title
- 练习 2017-08-22 通过控制台,获取类名,字段名称,字段类型,根据一个模板文件,自动创建这个类文件,并且为字段提供setter和getter方法
- [Jmeter]通过批处理调用java,java从CSV动态读取登录的用户名和密码,并将其作为参数组合成字符串,写入外部.bat文件,然后通过Java执行这个外部批处理文件
- C#通过属性名称获取(读取)属性值的方法
- bash 中 while读取文件并通过 ssh执行命令出现的问题及解决方法