Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 255 → Rev 256

/trunk/DBViewer/mainwindow.h
105,7 → 105,21
 
 
 
typedef struct wmiCDROM {
QString name; // íàçâàíèå âèäåîêàðòû
QString manufacturer; // ïðîèçâîäèòåëü
 
} TWmiCDROM;
 
 
typedef struct wmiNetCard {
QString caption; // íàçâàíèå âèäåîêàðòû
QString MACAddress; // ïðîèçâîäèòåëü
 
} TWmiNetCard;
 
 
 
namespace Ui {
class MainWindow;
}
176,7 → 190,14
QList<TWmiHDD> getWmiHDD(QString host, QString user_name, QString password);
QList<ThddSerialNumber> getHDDSerNum(QString host, QString user_name, QString password);
 
QList<TWmiCDROM> getWmiCDROM(QString host, QString user_name, QString password);
QList<TWmiNetCard> getWmiNetCard(QString host, QString user_name, QString password);
 
 
 
 
 
 
WmiThread wmiThread;
/////// QSqlTableModel * sql_mogel;
 
/trunk/DBViewer/wmithread.h
51,8 → 51,10
QMutex mutex;
QByteArray p_buffer; //çäåñü áóäåì õðàíèòü äàííûå, ñ÷èòàííûå èç ñòàíäàðòíîãî ïîòîêà äëÿ ÷òåíèÿ (ïðîöåññà)
QString wmi_string; //çäåñü áóäåì õðàíèòü wmi-çàïðîñ
QEventLoop *loop;
 
signals:
void stop_now();
 
public slots:
void readStandartProcessOutput();
/trunk/DBViewer/database.cpp
1655,6 → 1655,8
TWmiProcessor processor;
QList<TWmiMemoryModul> memory_moduls;
QList<TWmiHDD> hdd_list;
QList<TWmiCDROM> cdrom_list;
QList<TWmiNetCard> netcadr_list;
 
vCard = MainWindow::getWmiVideoGard(IP_str, user_name_str, password_str);
 
1865,19 → 1867,112
 
}
 
 
cdrom_list = MainWindow::getWmiCDROM(IP_str, user_name_str, password_str);
 
 
if (!cdrom_list.isEmpty()){
QTreeWidgetItem * itm_cdrom_list;
 
itm_cdrom_list = new QTreeWidgetItem(itm_tmp);
itm_cdrom_list->setText(0, tr("CD/DVD Ïðèâîäû:"));
 
 
for (int i = 0; i < cdrom_list.count(); i++){
 
QTreeWidgetItem * itm_cdrom;
QTreeWidgetItem * itm_cdrom_man;
QTreeWidgetItem * itm_cdrom_cap;
QString tmp_str;
tmp_str = tr("Ïðèâîä: ");
tmp_str.append(cdrom_list.at(i).name);
 
itm_cdrom = new QTreeWidgetItem(itm_cdrom_list);
itm_cdrom->setText(0, tmp_str);
 
tmp_str = tr("Ìîäåëü: ");
tmp_str.append(cdrom_list.at(i).name);
 
 
itm_cdrom_cap = new QTreeWidgetItem( itm_cdrom);
itm_cdrom_cap->setText(0, tmp_str);
 
 
tmp_str = tr("Ïðîèçâîäèòåëü: ");
tmp_str.append(cdrom_list.at(i).manufacturer);
itm_cdrom_man = new QTreeWidgetItem( itm_cdrom);
itm_cdrom_man->setText(0, tmp_str);
 
ui->treeWidget_3->expandItem( itm_cdrom_list);
 
}
 
 
 
}
 
 
netcadr_list = MainWindow::getWmiNetCard(IP_str, user_name_str, password_str);
 
 
if (!netcadr_list.isEmpty()){
QTreeWidgetItem * itm_netCard_list;
 
itm_netCard_list = new QTreeWidgetItem(itm_tmp);
itm_netCard_list->setText(0, tr("Ñåòåâûå êàðòû:"));
 
 
for (int i = 0; i < cdrom_list.count(); i++){
 
QTreeWidgetItem * itm_net_card;
QTreeWidgetItem * itm_net_card_mac;
QTreeWidgetItem * itm_net_card_cap;
QString tmp_str;
tmp_str = tr("Ñåòåâàÿ êàðòà: ");
tmp_str.append(netcadr_list.at(i).caption);
 
itm_net_card = new QTreeWidgetItem(itm_netCard_list);
itm_net_card->setText(0, tmp_str);
 
 
tmp_str = tr("Ìîäåëü: ");
tmp_str.append(netcadr_list.at(i).caption);
 
 
itm_net_card_cap = new QTreeWidgetItem(itm_net_card);
itm_net_card_cap->setText(0, tmp_str);
 
 
tmp_str = tr("MAC àäðåñ: ");
tmp_str.append(netcadr_list.at(i).MACAddress);
itm_net_card_mac = new QTreeWidgetItem(itm_net_card);
itm_net_card_mac->setText(0, tmp_str);
 
ui->treeWidget_3->expandItem( itm_netCard_list);
 
}
 
 
 
 
 
 
 
 
 
ui->treeWidget_3->expandItem(itm_tmp);
// itm_tmp->setChildIndicatorPolicy(QTreeWidget::
int i;
i++;
 
}
}
 
 
 
} //while
 
 
 
 
}
 
 
/trunk/DBViewer/mainwindow.cpp
1869,10 → 1869,14
m++;
}
else {
 
wmiThread.terminate();
/*********************
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
**********************/
}
 
/*
1943,10 → 1947,13
m++;
}
else {
wmiThread.terminate();
/***********************
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
**********************/
}
 
 
2005,10 → 2012,14
m++;
}
else {
 
wmiThread.terminate();
/************************
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
********************/
}
 
 
2075,10 → 2086,13
m++;
}
else {
wmiThread.terminate();
/*********************
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
****************/
}
 
 
2183,10 → 2197,13
m++;
}
else {
wmiThread.terminate();
/***********************
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
***************************/
}
 
 
2260,10 → 2277,13
m++;
}
else {
wmiThread.terminate();
/****************************
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
*************************/
}
 
 
2271,3 → 2291,163
 
 
}
 
 
 
 
 
 
 
 
QList<TWmiCDROM> MainWindow::getWmiCDROM(QString host, QString user_name, QString password)
{
QList<TWmiCDROM> result;
TWmiCDROM cdrom_tmp;
bool ok;
QString ansver_string;
 
 
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("select Caption, Manufacturer from Win32_CDRomDrive"));
wmiThread.start(QThread::NormalPriority);
ok = wmiThread.wait(10000);
 
if (ok){
QTextDocument * wmiDoc = ui->textEdit_2->document();
QTextCursor * wmiCursor;
QStringList split_new_line; //
QStringList fields_list; //â ýòîì ñïèñêå ñîõðàíèì ïîëÿ
QStringList values_list; //à â ýòîì ñïèñêå - çíà÷åíèÿ
wmiCursor = new QTextCursor(wmiDoc);
 
 
ansver_string = wmiThread.resultString();
 
 
wmiCursor->insertText(ansver_string);
split_new_line = ansver_string.split("\n", QString::SkipEmptyParts); // ðàçáèâàåíì îòâåò íà ñòðîêè
if(split_new_line.count()>2) {
QString tmp_str;
tmp_str = split_new_line.at(1);
fields_list = tmp_str.split("|");
 
for(int i=2; i< split_new_line.count(); i++)
{
cdrom_tmp.name = "";
cdrom_tmp.manufacturer = "";
tmp_str = split_new_line.at(i);
values_list = tmp_str.split("|");
int index_tmp;
index_tmp = fields_list.indexOf(tr("Caption")); // íàèìåíîâàíèå ïðèíòåðà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) cdrom_tmp.name = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("Manufacturer")); // ïðîèçâîäèòåëü äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) cdrom_tmp.manufacturer = values_list.at(index_tmp);
 
result << cdrom_tmp;
 
};
 
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
else {
wmiThread.terminate();
return result;
/*********
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
*******/
}
 
 
 
 
 
}
 
 
 
QList<TWmiNetCard> MainWindow::getWmiNetCard(QString host, QString user_name, QString password){
 
QList<TWmiNetCard> result;
TWmiNetCard netCard_tmp;
bool ok;
QString ansver_string;
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("Select Description, Caption, MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE"));
wmiThread.start(QThread::NormalPriority);
ok = wmiThread.wait(10000);
 
 
 
if (ok){
QTextDocument * wmiDoc = ui->textEdit_2->document();
QTextCursor * wmiCursor;
QStringList split_new_line; //
QStringList fields_list; //â ýòîì ñïèñêå ñîõðàíèì ïîëÿ
QStringList values_list; //à â ýòîì ñïèñêå - çíà÷åíèÿ
wmiCursor = new QTextCursor(wmiDoc);
 
 
ansver_string = wmiThread.resultString();
 
 
wmiCursor->insertText(ansver_string);
split_new_line = ansver_string.split("\n", QString::SkipEmptyParts); // ðàçáèâàåíì îòâåò íà ñòðîêè
if(split_new_line.count()>2) {
QString tmp_str;
tmp_str = split_new_line.at(1);
fields_list = tmp_str.split("|");
 
for(int i=2; i< split_new_line.count(); i++)
{
netCard_tmp.caption = "";
netCard_tmp.MACAddress= "";
tmp_str = split_new_line.at(i);
values_list = tmp_str.split("|");
int index_tmp;
index_tmp = fields_list.indexOf(tr("Description")); // íàèìåíîâàíèå ïðèíòåðà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) netCard_tmp.caption = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("MACAddress")); // ïðîèçâîäèòåëü äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) netCard_tmp.MACAddress = values_list.at(index_tmp);
 
result << netCard_tmp;
 
};
 
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
else {
wmiThread.terminate();
return result;
/*********
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
*******/
}
 
 
 
 
 
 
 
 
 
 
}