Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 254 → Rev 255

/trunk/DBViewer/wmithread.h
29,8 → 29,15
}
void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;}
QString resultString(){
return QString(tr(p_buffer));
 
QTextCodec *codec = QTextCodec::codecForName("cp1251");
QTextCodec *codecUTF = QTextCodec::codecForName("utf8");
QTextCodec::setCodecForTr(codecUTF);
QString tmp_str;
tmp_str = tr(p_buffer);
QTextCodec::setCodecForTr(codec);
// return QString(tr(p_buffer));
return tmp_str;
}
volatile bool stopped;
private:
/trunk/DBViewer/database.cpp
1654,6 → 1654,7
TWmiMatherBoard mBoard;
TWmiProcessor processor;
QList<TWmiMemoryModul> memory_moduls;
QList<TWmiHDD> hdd_list;
 
vCard = MainWindow::getWmiVideoGard(IP_str, user_name_str, password_str);
 
1665,6 → 1666,9
QString tmp_str;
tmp_str = tr("Âèäåîêàðòà: ");
tmp_str.append(vCard.name);
tmp_str.append(tr(" "));
tmp_str.append(QVariant(vCard.video_ram/1024/1024).asString());
tmp_str.append(tr(" ÌÁò"));
itm_video = new QTreeWidgetItem(itm_tmp);
itm_video->setText(0, tmp_str);
 
1761,6 → 1765,11
memory_moduls = MainWindow::getWmiRAM(IP_str, user_name_str, password_str);
 
if (!memory_moduls.isEmpty()){
QTreeWidgetItem * itm_ram;
int sum_cap=0;
itm_ram = new QTreeWidgetItem(itm_tmp);
 
 
for (int i = 0; i < memory_moduls.count(); i++){
 
QTreeWidgetItem * itm_ram_modul;
1769,19 → 1778,95
 
QString tmp_str;
tmp_str = tr("Ìîäóëü ïàìÿòè: ");
sum_cap = sum_cap + memory_moduls.at(i).capacity/1024/1024;
tmp_str.append(QVariant(memory_moduls.at(i).capacity/1024/1024).asString());
 
tmp_str.append(tr(" ÌÁò"));
itm_ram_modul = new QTreeWidgetItem(itm_tmp);
itm_ram_modul = new QTreeWidgetItem(itm_ram);
itm_ram_modul->setText(0, tmp_str);
 
 
}
QString cap_str;
cap_str = tr("Îáúåì ïàìÿòè: ");
cap_str.append(QVariant(sum_cap).asString());
cap_str.append(tr(" ÌÁò"));
itm_ram->setText(0, cap_str);
 
}
 
 
hdd_list = MainWindow::getWmiHDD(IP_str, user_name_str, password_str);
 
 
if (!hdd_list.isEmpty()){
QTreeWidgetItem * itm_hdd_list;
int sum_cap = 0;
itm_hdd_list = new QTreeWidgetItem(itm_tmp);
 
 
for (int i = 0; i < hdd_list.count(); i++){
 
QTreeWidgetItem * itm_hdd;
QTreeWidgetItem * itm_hdd_man;
QTreeWidgetItem * itm_hdd_cap;
QTreeWidgetItem * itm_hdd_serNum;
QTreeWidgetItem * itm_hdd_size; // îáúåì ïàìÿòè
long size_lng;
QString tmp_str;
tmp_str = tr("Ƹñòêèé äèñê: ");
sum_cap = sum_cap + hdd_list.at(i).size/1000/1000;
 
tmp_str.append(hdd_list.at(i).caption);
tmp_str.append(tr(" "));
size_lng = hdd_list.at(i).size;
size_lng = size_lng/1000/1000;
 
tmp_str.append(QVariant(int(size_lng)).asString());
tmp_str.append(tr(" ÌÁò s/n: "));
 
tmp_str.append(hdd_list.at(i).serialNumber);
 
itm_hdd = new QTreeWidgetItem(itm_hdd_list);
itm_hdd->setText(0, tmp_str);
 
 
tmp_str = tr("Ìîäåëü: ");
tmp_str.append((hdd_list.at(i).caption));
 
itm_hdd_cap = new QTreeWidgetItem(itm_hdd);
itm_hdd_cap->setText(0, tmp_str);
 
tmp_str = tr("Ïðîèçâîäèòåëü: ");
tmp_str.append((hdd_list.at(i).manufacturer));
 
itm_hdd_man = new QTreeWidgetItem(itm_hdd);
itm_hdd_man->setText(0, tmp_str);
 
tmp_str = tr("Ðàçìåð äèñêà: ");
tmp_str.append(QVariant(int(size_lng)).asString());
tmp_str.append(tr(" ÌÁò"));
 
itm_hdd_size = new QTreeWidgetItem(itm_hdd);
itm_hdd_size->setText(0, tmp_str);
 
tmp_str = tr("Ñåðèéíûé íîìåð: ");
tmp_str.append((hdd_list.at(i).serialNumber));
itm_hdd_serNum = itm_hdd_size = new QTreeWidgetItem(itm_hdd);
itm_hdd_serNum->setText(0, tmp_str);
 
 
}
QString cap_str;
cap_str = tr("Îáùèé îáú¸ì äèñêîâîãî ïðîñòðàíñòâà: ");
cap_str.append(QVariant(sum_cap).asString());
cap_str.append(tr(" ÌÁò"));
itm_hdd_list->setText(0, cap_str);
 
}
 
 
ui->treeWidget_3->expandItem(itm_tmp);
// itm_tmp->setChildIndicatorPolicy(QTreeWidget::
int i;
i++;
 
/trunk/DBViewer/mainwindow.cpp
2087,3 → 2087,187
}
 
 
QList<TWmiHDD> MainWindow::getWmiHDD(QString host, QString user_name, QString password)
{
QList<TWmiHDD> result;
TWmiHDD hdd_tmp;
bool ok;
QString ansver_string;
 
QList<ThddSerialNumber> serNum_list;
serNum_list = MainWindow::getHDDSerNum(host, user_name, password); // îïðåäåëÿåì ñåðèéíûå íîìåðà äèñêîâ
 
 
 
 
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("SELECT Caption, Manufacturer, Size, DeviceID from Win32_DiskDrive"));
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++)
{
hdd_tmp.caption = "";
hdd_tmp.deviceID="";
hdd_tmp.manufacturer="";
hdd_tmp.serialNumber="";
hdd_tmp.size=0;
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())) hdd_tmp.caption = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("Manufacturer")); // ïðîèçâîäèòåëü äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) hdd_tmp.manufacturer = values_list.at(index_tmp);
 
 
 
 
index_tmp = fields_list.indexOf(tr("Size")); // Ðàçìåð äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) {
 
QString size_str;
bool ok;
size_str = values_list.at(index_tmp);
int size_int=0;
long size_lng;
size_int = size_str.toInt(&ok);
size_lng = size_str.toLong(&ok);
hdd_tmp.size= size_lng;
}
 
 
 
 
index_tmp = fields_list.indexOf(tr("DeviceID")); // èäåíòèôèêàòîð äèñêà äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) {
hdd_tmp.deviceID = values_list.at(index_tmp);
for (int k=0; k < serNum_list.count(); k++){
if ((serNum_list.at(k).deviceID == hdd_tmp.deviceID)&&(serNum_list.at(k).deviceID !="")) hdd_tmp.serialNumber = serNum_list.at(k).serialNumber;
}
 
}
result << hdd_tmp;
 
 
 
 
};
 
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
else {
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
}
 
 
 
 
 
 
 
 
 
return result;
 
}
 
 
 
QList<ThddSerialNumber> MainWindow::getHDDSerNum(QString host, QString user_name, QString password){
 
QList<ThddSerialNumber> result;
ThddSerialNumber serNum_tmp;
bool ok;
QString ansver_string;
 
 
wmiThread.setHost(host); // çàäàåì õîñò
wmiThread.setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread.setPassword( password);
wmiThread.setWmiString(tr("SELECT SerialNumber, Tag FROM Win32_PhysicalMedia"));
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++)
{
serNum_tmp.serialNumber = "";
serNum_tmp.deviceID = "";
tmp_str = split_new_line.at(i);
values_list = tmp_str.split("|");
int index_tmp;
index_tmp = fields_list.indexOf(tr("SerialNumber")); // ñåðèéíûé íîìåð äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) serNum_tmp.serialNumber = values_list.at(index_tmp);
index_tmp = fields_list.indexOf(tr("Tag")); // èäåíòèôèêàòîð äèñêà
if ((index_tmp!=-1) && (index_tmp < values_list.count())) serNum_tmp.deviceID = values_list.at(index_tmp);
 
result << serNum_tmp;
 
};
 
return result;
}
else return result; //ïîëó÷èëè íå êîððåêòíûé îòâåò
int m;
m++;
}
else {
wmiThread.stop();
ok = wmiThread.wait(10000);
int k;
k++;
}
 
 
 
 
 
}
/trunk/DBViewer/mainwindow.h
88,9 → 88,24
 
} TWmiMemoryModul;
 
typedef struct wmiHDD {
QString caption; // íàèìåíîâàíèå äèñêà
long size; // ðàçìåð
QString manufacturer; // ïðîèçâîäèòåëü
QString serialNumber; // ñåðèéíûé íîìåð äèñêà
QString deviceID; // èäåíòèôèêàòîð äèñêà â ñèñòåìå
 
} TWmiHDD;
 
typedef struct hddSerialNumber {
QString serialNumber; // ñåðèéíûé íîìåð äèñêà
QString deviceID; // èäåíòèôèêàòîð äèñêà â ñèñòåìå
 
} ThddSerialNumber;
 
 
 
 
namespace Ui {
class MainWindow;
}
158,6 → 173,8
TWmiMatherBoard getWmiMatherBoard(QString host, QString user_name, QString password);
TWmiProcessor getWmiProcessor(QString host, QString user_name, QString password);
QList<TWmiMemoryModul> getWmiRAM(QString host, QString user_name, QString password);
QList<TWmiHDD> getWmiHDD(QString host, QString user_name, QString password);
QList<ThddSerialNumber> getHDDSerNum(QString host, QString user_name, QString password);
 
 
WmiThread wmiThread;