Subversion Repositories OpenInventory

Compare Revisions

Ignore whitespace Rev 240 → Rev 241

/trunk/DBViewer/wmithread.h
17,6 → 17,8
void setPassword(QString new_password){password = new_password;}
QByteArray buffer(){return p_buffer;}
void clearBuffer(){p_buffer.clear();}
bool isError(){return error;}
void setWmiString(QString new_wmi_string){wmi_string = new_wmi_string;}
private:
volatile bool stopped;
volatile bool error;
26,17 → 28,18
QString password;
QMutex mutex;
QByteArray p_buffer; //çäåñü áóäåì õðàíèòü äàííûå, ñ÷èòàííûå èç ñòàíäàðòíîãî ïîòîêà äëÿ ÷òåíèÿ (ïðîöåññà)
QString wmi_string; //çäåñü áóäåì õðàíèòü wmi-çàïðîñ
 
signals:
 
public slots:
void readStandartProcessOutput();
void readStandartProcessError();
 
 
private slots:
 
void readStandartProcessOutput();
void readStandartProcessError();
 
 
};
 
#endif // WMITHREAD_H
/trunk/DBViewer/database.cpp
993,6 → 993,8
void MainWindow::on_pushButton_18_clicked()// âûïîëíèòü wmi çàïðîñ
 
{
/*
 
// QString program = tr(" wmic -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
QString program = tr("wmic");
QStringList arguments;
999,7 → 1001,7
 
// arguments << tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
// program.append(tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\""));
program.append(tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from ")); //Win32_Product\""));
program.append(tr(" -U admin --password=samba //192.168.0.101 \"select * from ")); //Win32_Product\""));
program.append(ui->comboBox_2->currentText());
program.append(tr("\""));
 
1006,6 → 1008,8
int i;
i++;
wmiProcess.start(program);
*/
MainWindow::getWmiVideoGard(tr("192.168.0.101"), tr("admin"), tr("samba"));
 
}
 
/trunk/DBViewer/mainwindow.cpp
97,9 → 97,9
connect(model_for_ListModelsTable, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_model_for_ListModelsTable_dataChanged(QModelIndex,QModelIndex)));
connect(filter_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(on_filter_model_dataChanged(QModelIndex,QModelIndex)));
connect(&wmiProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
connect(&wmiProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
 
 
 
ui->pushButton_3->setEnabled(false);
ui->pushButton_4->setEnabled(false);
 
128,6 → 128,8
cursor = new QTextCursor(doc);
// buildReport(true);
 
all_reading = false; // íåò ïðî÷èòàííûõ äàííûõ èç ïðîöåññà
wmiThread = new WmiThread(this);
 
}
 
1796,11 → 1798,66
// str1 = result.at(0);
i++;
//lineEdit->insert(str1);
all_reading = true;
 
}
 
void MainWindow::readStandartProcessError(){
QByteArray arr;
QTextDocument * wmiDoc = ui->textEdit_2->document();
QTextCursor * wmiCursor;
wmiCursor = new QTextCursor(wmiDoc);
QString str;
 
QByteArray arr;
arr = wmiProcess.readAllStandardError();
str = QString(tr(arr));
wmiCursor->insertText(str);
wmiCursor->insertText(tr("\n"));
 
}
 
 
 
TWmiVideoCard MainWindow::getWmiVideoGard(QString host, QString user_name, QString password){
TWmiVideoCard result;
bool ok;
wmiThread->setHost(host); // çàäàåì õîñò
wmiThread->setUser(user_name);//çàäàåì èìÿ ïîëüçîâàòåëÿ
wmiThread->setPassword( password);
wmiThread->start(QThread::NormalPriority);
wmiThread->setWmiString(tr("select * from Win32_ComputerSystem"));
ok = wmiThread->wait(10000);
if (ok){
int m;
m++;
}
else {
wmiThread->stop();
ok = wmiThread->wait(10000);
int k;
k++;
}
 
/*
 
QString program = tr("wmic");
QStringList arguments;
 
// arguments << tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\"");
// program.append(tr(" -U Àäìèíèñòðàòîð%Patr10t //192.168.0.135 \"select * from Win32_ComputerSystem\""));
program.append(tr(" -U admin --password=samba //192.168.0.101 \"select * from ")); //Win32_Product\""));
program.append(ui->comboBox_2->currentText());
program.append(tr("\""));
all_reading = false;
int i;
i++;
wmiProcess.start(program);
 
 
 
while (!all_reading){}; //æäåì, ïîêà íå ñ÷èòàåòñÿ ðåçóëüòàò çàïðîñà
 
*/
return result;
 
}
/trunk/DBViewer/mainwindow.h
9,6 → 9,7
#include "delegate.h"
// #include "fileform.h"
#include "treedelegateform.h"
#include "wmithread.h"
 
#include <QMainWindow>
#include <QStandardItemModel>
49,7 → 50,18
 
 
 
typedef struct wmiVideoCard {
QString name; // íàçâàíèå âèäåîêàðòû
QString manufacturer; // ïðîèçâîäèòåëü
QString model;
 
} TWmiVideoCard;
 
 
 
 
 
 
namespace Ui {
class MainWindow;
}
66,6 → 78,9
private:
Ui::MainWindow *ui;
//FileForm fileForm;
 
volatile bool all_reading;
 
TreeDelegateForm treeForm;
 
settingForm setFrm;
107,7 → 122,13
QMap <QString, QString> getFieldsList(QString class_id); // ïîëó÷àåì ñïèñîê ïîëåé êëàññà
void initComboBox();
QList<QTreeWidgetItem *> rootItems; // ñïèñîê óêàçàòåëåé êîðíåâûõ óçëîâ (ìîäåëåé)
TWmiVideoCard getWmiVideoGard(QString host, QString user_name, QString password);
 
 
 
 
 
WmiThread * wmiThread;
/////// QSqlTableModel * sql_mogel;
 
MyModel * sql_mogel;
/trunk/DBViewer/wmithread.cpp
3,16 → 3,35
WmiThread::WmiThread(QObject *parent) :
QThread(parent)
{
connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandartProcessOutput()));
connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(readStandartProcessError()));
mutex.lock();
stopped = false;
mutex.unlock();
 
 
 
 
 
}
 
void WmiThread::run(){
error = false; //ñáðîñèì ôëàã îøèáêè
 
 
 
QString query_string;
error = false; //ñáðîñèì ôëàã îøèáêè
query_string = tr("wmic -U ");
query_string.append(user_name);
query_string.append(tr("%"));
query_string.append(password);
query_string.append(tr(" //"));
query_string.append(host);
query_string.append(tr(" \""));
query_string.append(wmi_string);
query_string.append(tr("\""));
process.start(query_string);
 
while (!stopped);
// exec();
}
 
void WmiThread::stop(){
23,9 → 42,12
 
void WmiThread::readStandartProcessOutput(){
p_buffer = process.readAllStandardOutput();
mutex.lock();
stopped = true;
mutex.unlock();
}
 
void WmiThread::readStandartProcessError(){
p_buffer = process.readAllStandardError();
error = true;
error = true; // åñëè îøèáêà, óñòàíîâèì ôëàã îøèáêè âûïîëíåíèÿ WMI-çàïðîñà
}
/trunk/DBViewer/DBViewer.pro
9,6 → 9,7
svg \
xml \
xmlpatterns \
thread\
# multimedia \
qt3support
TARGET = DBViewer
21,7 → 22,8
settingform.cpp \
iconform.cpp \
fileform.cpp \
treedelegateform.cpp
treedelegateform.cpp \
wmithread.cpp
HEADERS += mainwindow.h \
delegate.h \
mymodel.h \
28,7 → 30,8
settingform.h \
iconform.h \
fileform.h \
treedelegateform.h
treedelegateform.h \
wmithread.h
FORMS += mainwindow.ui \
settingform.ui \
iconform.ui \