Rev 228 | Rev 232 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 228 | Rev 231 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | OutputManager::OutputManager() |
20 | OutputManager::OutputManager() |
21 | {
|
21 | {
|
- | 22 | mTransactionOpen = false; |
|
22 | // add all the outputs
|
23 | // add all the outputs
|
23 | mOutputs.append(new TreeOut); |
24 | mOutputs.append(new TreeOut); |
24 | mOutputs.append(new StandOut); |
25 | mOutputs.append(new StandOut); |
25 | mOutputs.append(new DynamicStandOut); |
26 | mOutputs.append(new DynamicStandOut); |
26 | mOutputs.append(new ProductionOut); |
27 | mOutputs.append(new ProductionOut); |
Line 44... | Line 45... | ||
44 | bool enabled = xml.valueBool(".enabled", false); |
45 | bool enabled = xml.valueBool(".enabled", false); |
45 | o->setEnabled(enabled); |
46 | o->setEnabled(enabled); |
46 | if (enabled) |
47 | if (enabled) |
47 | o->open(); |
48 | o->open(); |
48 | }
|
49 | }
|
- | 50 | endTransaction(); // just to be sur |
|
49 | }
|
51 | }
|
50 | 52 | ||
51 | Output *OutputManager::find(const QString& tableName) |
53 | Output *OutputManager::find(const QString& tableName) |
52 | {
|
54 | {
|
53 | foreach(Output* p,mOutputs) |
55 | foreach(Output* p,mOutputs) |
Line 56... | Line 58... | ||
56 | return NULL; |
58 | return NULL; |
57 | }
|
59 | }
|
58 | 60 | ||
59 | void OutputManager::save() |
61 | void OutputManager::save() |
60 | {
|
62 | {
|
61 | foreach(Output *p, mOutputs) |
- | |
62 | p->endTransaction(); |
- | |
- | 63 | endTransaction(); |
|
- | 64 | }
|
|
- | 65 | ||
- | 66 | void OutputManager::startTransaction() |
|
- | 67 | {
|
|
- | 68 | if (!mTransactionOpen && GlobalSettings::instance()->dbout().isValid()) { |
|
- | 69 | GlobalSettings::instance()->dbout().transaction(); |
|
- | 70 | qDebug() << "opening transaction"; |
|
- | 71 | mTransactionOpen = true; |
|
- | 72 | }
|
|
- | 73 | }
|
|
- | 74 | void OutputManager::endTransaction() |
|
- | 75 | {
|
|
- | 76 | if (mTransactionOpen && GlobalSettings::instance()->dbout().isValid()) { |
|
- | 77 | GlobalSettings::instance()->dbout().commit(); |
|
- | 78 | mTransactionOpen = false; |
|
- | 79 | qDebug() << "database transaction commited"; |
|
- | 80 | }
|
|
63 | }
|
81 | }
|
64 | 82 | ||
65 | bool OutputManager::execute(const QString& tableName) |
83 | bool OutputManager::execute(const QString& tableName) |
66 | {
|
84 | {
|
67 | DebugTimer t("OutputManager::execute()"); |
85 | DebugTimer t("OutputManager::execute()"); |
Line 75... | Line 93... | ||
75 | if (!p->onNewRow()) { |
93 | if (!p->onNewRow()) { |
76 | qWarning() << "Output" << p->name() << "invalid (not at new row)!!!"; |
94 | qWarning() << "Output" << p->name() << "invalid (not at new row)!!!"; |
77 | return false; |
95 | return false; |
78 | }
|
96 | }
|
79 | 97 | ||
80 | p->startTransaction(); // just assure a transaction is open.... nothing happens if already inside a transaction |
- | |
- | 98 | startTransaction(); // just assure a transaction is open.... nothing happens if already inside a transaction |
|
81 | p->exec(); |
99 | p->exec(); |
82 | 100 | ||
83 | return true; |
101 | return true; |
84 | }
|
102 | }
|
85 | qDebug() << "output" << tableName << "not found!"; |
103 | qDebug() << "output" << tableName << "not found!"; |