This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbetaReport.cpp
147 lines (120 loc) · 4.57 KB
/
betaReport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "stdafx.h"
#include <fstream>
#include "main.h"
#include "beta.h"
#include "tables.h"
#include "profiles.h"
#include <Stamina\Time64.h>
namespace Konnekt { namespace Beta {
void printValue(std::ofstream& f, const CStdString& name, const CStdString& value) {
f << "<tr>" << endl;
f << "<td class=\"name\">" << name << "</td>" << endl;
f << "<td class=\"value\">" << value << "</td>" << endl;
f << "</tr>" << endl;
}
void printHeader(std::ofstream& f, const CStdString& name, const CStdString& css = "") {
f << "<tr>" << endl;
f << "<td colspan=\"2\" class=\"header " << css << "\">" << name << "</td>" << endl;
f << "</tr>" << endl ;
}
void makeReport(CStdString filename, bool open, bool usedate, bool silent) {
std::ofstream f;
if (filename.empty()) {
if (usedate) {
filename = Stamina::Time64(true).strftime(("betaReport " + Stamina::RegEx::doReplace("/[^a-zA-Z0-9_-]/", "", Konnekt::profile) + " (%d-%m-%Y %H.%M).html").c_str());
} else {
filename = "betaReport.html";
}
}
CdtFileBin FBin;
Tables::savePrepare(FBin);
FBin.assign(&Beta);
FBin.load(FILE_BETA);
Stamina::Time64 startDate(false);
if (usedate) {
Stamina::Date64 date(Beta.get64(0, BETA_LAST_STATICREPORT));
date.msec = 0; // zerujemy koñcówkê...
date.sec = 0;
startDate = date;
Stamina::Date64 now(true);
now.sec = 0;
if (now == date) {
if (!silent)
ShellExecute(0, "OPEN", filename, 0, 0, SW_SHOW);
return;
}
Beta.set64(0, BETA_LAST_STATICREPORT, _time64(0));
FBin.save(FILE_BETA);
}
FBin.assign(&Reports);
FBin.load(FILE_REPORTS);
FBin.assign(&Stats);
FBin.load(FILE_STATS);
if (silent) {
int count = 0;
for (unsigned int i=0; i<Reports.getrowcount(); i++) {
if (Reports.get64(i, REP_DATE) >= startDate) {
count ++;
}
}
if (count == 0)
return;
}
f.open(filename);
f << "<html>" << endl;
f << "<style> @import url('betaReport.css'); </style>" << endl;
f << "<body>" << endl;
f << "<table id=\"beta\">" << endl;
printHeader(f, "Beta");
printValue(f, "Wygenerowany", Stamina::Time64(true).strftime("%d-%m-%Y %H:%M:%S"));
if (!startDate.empty()) {
printValue(f, "Raporty od", startDate.strftime("%d-%m-%Y %H:%M"));
}
printValue(f, "Login", Beta.getch(0, BETA_LOGIN));
printValue(f, "Urid", inttostr( Beta.getint(0, BETA_URID), 16 ));
printValue(f, "Serial", info_serial());
printValue(f, "LastReport", Stamina::Time64(Beta.get64(0, BETA_LAST_REPORT)).strftime("%d-%m-%Y %H:%M:%S"));
printHeader(f, "Raporty");
for (unsigned int i=0; i<Reports.getrowcount(); i++) {
if (Reports.get64(i, REP_DATE) < startDate) {
continue;
}
printHeader(f, "Raport", "report");
f << "<tr><td colspan=2><table class=\"report\"><tr>" << endl;
f << "<td valign=\"top\"><table class=\"rep_fields\">" << endl;
// dane
printValue(f, "LastReport", Stamina::Time64(Reports.get64(i, REP_DATE)).strftime("%d-%m-%Y %H:%M:%S"));
printValue(f, "Tytu³", Reports.getch(i, REP_TITLE));
printValue(f, "Typ", inttostr(Reports.getint(i, REP_TYPE)));
printValue(f, "Wersja", inttostr( Reports.getint(i, REP_VERSION), 16));
CStdString plugs = Reports.getch(i, REP_PLUGS);
Stamina::tStringVector plugList;
Stamina::split(plugs, ",", plugList);
plugs = "";
for (Stamina::tStringVector::iterator plug = plugList.begin(); plug != plugList.end(); ++plug) {
size_t sep = plug->find(' ');
if (sep == -1) continue;
if (!plugs.empty()) plugs += ", ";
int v = chtoint(plug->substr(sep + 1).c_str(), 16);
plugs += stringf("<abbr title=\"%s\">%s</abbr>", stringf("%d.%d.%d.%d", VERSION_MAJ(v), VERSION_MIN(v), VERSION_RLS(v), VERSION_BLD(v)).c_str(), plug->substr(0, sep).c_str());
}
printValue(f, "Wtyczki", plugs);
f << "</table></td>" << endl;
f << "<td class=\"rep_add\" valign=\"top\">" << endl;
// zrzut i log
f << "<h2>Message</h2>" << endl;
f << "<div class=\"rep_message\"><pre>"<< Reports.getch(i, REP_MSG) <<"</pre></div>" << endl;
f << "<h2>Info</h2>" << endl;
f << "<div class=\"rep_info\"><pre>"<< Reports.getch(i, REP_INFO) <<"</pre></div>" << endl;
f << "<h2>Log</h2>" << endl;
f << "<div class=\"rep_log\"><pre>"<< Reports.getch(i, REP_LOG) <<"</pre></div>" << endl;
f << "</td>" << endl;
f << "</tr></table></td></tr>" << endl;
}
f << "</table>" << endl;
f << "</body></html>" << endl;
f.close();
if (!silent)
ShellExecute(0, "OPEN", filename, 0, 0, SW_SHOW);
}
}; };