Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 250 → Rev 251

/trunk/DBViewer/database.cpp
1651,9 → 1651,9
 
 
TWmiVideoCard vCard;
TWmiMatherBoard mBoard;
TWmiProcessor processor;
 
 
 
vCard = MainWindow::getWmiVideoGard(IP_str, user_name_str, password_str);
 
if (!vCard.name.isEmpty()) {
1692,7 → 1692,71
}
 
 
mBoard = MainWindow::getWmiMatherBoard(IP_str, user_name_str, password_str);
if (!mBoard.manufacturer.isEmpty()) {
QTreeWidgetItem * itm_maherBoard;
QTreeWidgetItem * itm_maherBoard_model;
QTreeWidgetItem * itm_maherBoard_manufacturer;
QString tmp_str;
tmp_str = tr("Ìàòåðèíñêàÿ ïëàòà: ");
tmp_str.append(mBoard.manufacturer);
tmp_str.append( tr(" "));
tmp_str.append(mBoard.model);
itm_maherBoard = new QTreeWidgetItem(itm_tmp);
itm_maherBoard->setText(0, tmp_str);
 
tmp_str = tr("Ïðîèçâîäèòåëü: ");
tmp_str.append(mBoard.manufacturer);
 
itm_maherBoard_manufacturer = new QTreeWidgetItem(itm_maherBoard);
itm_maherBoard_manufacturer->setText(0, tmp_str);
 
itm_maherBoard_model = new QTreeWidgetItem(itm_maherBoard);
 
tmp_str = tr("Ìîäåëü: ");
tmp_str.append(mBoard.model);
 
itm_maherBoard_model->setText(0, tmp_str);
 
 
}
 
processor = MainWindow::getWmiProcessor(IP_str, user_name_str, password_str);
if (!processor.manufacturer.isEmpty()){
 
QTreeWidgetItem * itm_processor;
QTreeWidgetItem * itm_processor_manufacturer;
QTreeWidgetItem * itm_processor_clockSpeed;
QTreeWidgetItem * itm_processor_socket;
 
 
QString tmp_str;
tmp_str = tr("Ïðîöåññîð: ");
tmp_str.append(processor.name);
 
itm_processor = new QTreeWidgetItem(itm_tmp);
itm_processor->setText(0, tmp_str);
 
tmp_str = tr("Ïðîèçâîäèòåëü: ");
tmp_str.append(processor.manufacturer);
itm_processor_manufacturer = new QTreeWidgetItem(itm_processor);
itm_processor_manufacturer->setText(0, tmp_str);
 
tmp_str = tr("×àñòîòà: ");
tmp_str.append(QVariant(processor.clockSpeed).asString());
tmp_str.append(tr(" ÌÃö"));
itm_processor_clockSpeed = new QTreeWidgetItem(itm_processor);
itm_processor_clockSpeed->setText(0, tmp_str);
 
 
tmp_str = tr("Ñîêåò: ");
tmp_str.append(processor.socket);
itm_processor_socket = new QTreeWidgetItem(itm_processor);
itm_processor_socket->setText(0, tmp_str);
 
}
 
 
int i;
i++;
 
1701,4 → 1765,7
 
 
 
 
 
 
}
/trunk/DBViewer/mainwindow.cpp
1898,3 → 1898,124
return result;
 
}
 
 
TWmiMatherBoard MainWindow::getWmiMatherBoard(QString host, QString user_name, QString password){
TWmiMatherBoard result;
bool ok;
QString ansver_string;
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("SELECT Manufacturer, Product FROM Win32_BaseBoard"));
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("|");
tmp_str = split_new_line.at(2);
values_list = tmp_str.split("|");
int index_tmp;
index_tmp = fields_list.indexOf(tr("Manufacturer")); // ïðîèçâîäèòåëü
if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.manufacturer = values_list.at(index_tmp);
// index_tmp = fields_list.indexOf(tr("Name")); // íàçâàíèå âèäåîêàðòû
// if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.name = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("Product")); // ìîäåëü
if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.model = values_list.at(index_tmp);
// index_tmp = fields_list.indexOf(tr("AdapterRAM")); // ìîäåëü
// if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.video_ram = QVariant(values_list.at(index_tmp)).asInt();
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
else {
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
}
 
 
 
return result;
 
}
 
 
TWmiProcessor MainWindow::getWmiProcessor(QString host, QString user_name, QString password){
TWmiProcessor result;
bool ok;
QString ansver_string;
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("SELECT Name, Manufacturer, CurrentClockSpeed, SocketDesignation FROM Win32_Processor"));
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("|");
tmp_str = split_new_line.at(2);
values_list = tmp_str.split("|");
int index_tmp;
index_tmp = fields_list.indexOf(tr("Manufacturer")); // ïðîèçâîäèòåëü ïðîöåññîðà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.manufacturer = values_list.at(index_tmp);
 
index_tmp = fields_list.indexOf(tr("Name")); // íàçâàíèå ïðîöåññîðà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.name = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("SocketDesignation")); // ñîêåò
if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.socket = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("CurrentClockSpeed")); // ÷àñòîòà ïðîöåññîðà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) result.clockSpeed = QVariant(values_list.at(index_tmp)).asInt();
 
 
 
 
 
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
else {
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
}
 
 
 
return result;
 
 
 
}
 
/trunk/DBViewer/mainwindow.h
62,8 → 62,28
 
 
 
typedef struct wmiMatherBoard {
// QString name; // íàçâàíèå âèäåîêàðòû
QString manufacturer; // ïðîèçâîäèòåëü
QString model;
//int video_ram;
 
} TWmiMatherBoard;
 
 
typedef struct wmiProcessor {
QString name; // íàçâàíèå ïðîöåññîðà
QString manufacturer; // ïðîèçâîäèòåëü
int clockSpeed;
QString socket;
 
//int video_ram;
 
} TWmiProcessor;
 
 
 
 
namespace Ui {
class MainWindow;
}
128,11 → 148,11
void initComboBox();
QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
TWmiVideoCard getWmiVideoGard(QString host, QString user_name, QString password);
TWmiMatherBoard getWmiMatherBoard(QString host, QString user_name, QString password);
TWmiProcessor getWmiProcessor(QString host, QString user_name, QString password);
 
 
 
 
 
WmiThread wmiThread;
/////// QSqlTableModel * sql_mogel;