stimulsoft-data-adapter 2021.3.7 → 2021.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,142 +1,148 @@
1
- exports.process = function (command, onResult) {
2
-
3
- var end = function (result) {
4
- try {
5
- if (db) db.detach();
6
- onResult(result);
7
- }
8
- catch (e) {
9
- }
10
- }
11
-
12
- var onError = function (message) {
13
- end({ success: false, notice: message });
14
- }
15
-
16
- try {
17
- var connect = function () {
18
- Firebird.attach(options, function (error, db1) {
19
- db = db1;
20
- if (error) onError(error.message);
21
- else onConnect();
22
- });
23
- }
24
-
25
- var query = function (queryString) {
26
- db.query(queryString, undefined, function (error, recordset) {
27
- if (error) onError(error.message);
28
- else onQuery(recordset);
29
- db.detach();
30
- });
31
- }
32
-
33
- var onConnect = function () {
34
- if (command.queryString) query(command.queryString);
35
- else end({ success: true });
36
- }
37
-
38
- var onQuery = function (recordset) {
39
- var columns = [];
40
- var rows = [];
41
- var types = [];
42
- var isColumnsFill = false;
43
- for (var recordIndex in recordset) {
44
- var row = [];
45
- for (var columnName in recordset[recordIndex]) {
46
- if (!isColumnsFill) columns.push(columnName);
47
- var columnIndex = columns.indexOf(columnName);
48
- types[columnIndex] = typeof recordset[recordIndex][columnName];
49
- if (recordset[recordIndex][columnName] instanceof Uint8Array ||
50
- recordset[recordIndex][columnName] instanceof Buffer) {
51
- recordset[recordIndex][columnName] = recordset[recordIndex][columnName].toString();
52
- types[columnIndex] = "string";
53
- }
54
- if (recordset[recordIndex][columnName] != null && typeof recordset[recordIndex][columnName].toISOString === "function") {
55
- var dateTime = new Date(recordset[recordIndex][columnName].getTime() - (recordset[recordIndex][columnName].getTimezoneOffset() * 60000)).toISOString();
56
- recordset[recordIndex][columnName] = dateTime.replace("Z", "");
57
- types[columnIndex] = "datetime";
58
- }
59
-
60
- row[columnIndex] = recordset[recordIndex][columnName];
61
- }
62
- isColumnsFill = true;
63
- rows.push(row);
64
- }
65
-
66
- end({ success: true, columns: columns, rows: rows, types: types });
67
- }
68
-
69
- var getConnectionStringInfo = function (connectionString) {
70
- var info = { host: "localhost", port: "3050" };
71
- var isCorrect = false;
72
- for (var propertyIndex in connectionString.split(";")) {
73
- var property = connectionString.split(";")[propertyIndex];
74
- if (property) {
75
- var match = property.split("=");
76
- if (match && match.length >= 2) {
77
- match[0] = match[0].trim().toLowerCase();
78
- match[1] = match[1].trim();
79
-
80
- switch (match[0]) {
81
- case "server":
82
- case "host":
83
- case "location":
84
- case "datasource":
85
- case "data source":
86
- info["host"] = match[1];
87
- break;
88
-
89
- case "port":
90
- info["port"] = match[1];
91
- break;
92
-
93
- case "database":
94
- info["database"] = match[1];
95
- isCorrect = true;
96
- break;
97
-
98
- case "uid":
99
- case "user":
100
- case "user id":
101
- info["userId"] = match[1];
102
- break;
103
-
104
- case "pwd":
105
- case "password":
106
- info["password"] = match[1];
107
- break;
108
-
109
- case "charset":
110
- info["charset"] = match[1];
111
- break;
112
- }
113
- }
114
- }
115
- }
116
- if (!isCorrect) {
117
- onError("Connection String parse error");
118
- return null;
119
- }
120
- return info;
121
- };
122
-
123
- var Firebird = require('node-firebird');
124
- command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
125
- if (command.connectionStringInfo) {
126
- var options = {
127
- host: command.connectionStringInfo.host,
128
- port: command.connectionStringInfo.port,
129
- database: command.connectionStringInfo.database,
130
- user: command.connectionStringInfo.userId,
131
- password: command.connectionStringInfo.password,
132
- charset: command.connectionStringInfo.charset,
133
- };
134
-
135
- connect();
136
- var db;
137
- }
138
- }
139
- catch (e) {
140
- onError(e.stack);
141
- }
1
+ /*
2
+ Stimulsoft.Reports.JS
3
+ Version: 2021.4.4
4
+ Build date: 2021.11.18
5
+ License: https://www.stimulsoft.com/en/licensing/reports
6
+ */
7
+ exports.process = function (command, onResult) {
8
+ var end = function (result) {
9
+ try {
10
+ if (db) db.detach();
11
+ result.adapterVersion = "2021.4.4";
12
+ onResult(result);
13
+ }
14
+ catch (e) {
15
+ }
16
+ }
17
+
18
+ var onError = function (message) {
19
+ end({ success: false, notice: message });
20
+ }
21
+
22
+ try {
23
+ var connect = function () {
24
+ Firebird.attach(options, function (error, db1) {
25
+ db = db1;
26
+ if (error) onError(error.message);
27
+ else onConnect();
28
+ });
29
+ }
30
+
31
+ var query = function (queryString) {
32
+ db.query(queryString, undefined, function (error, recordset) {
33
+ if (error) onError(error.message);
34
+ else onQuery(recordset);
35
+ db.detach();
36
+ });
37
+ }
38
+
39
+ var onConnect = function () {
40
+ if (command.queryString) query(command.queryString);
41
+ else end({ success: true });
42
+ }
43
+
44
+ var onQuery = function (recordset) {
45
+ var columns = [];
46
+ var rows = [];
47
+ var types = [];
48
+ var isColumnsFill = false;
49
+ for (var recordIndex in recordset) {
50
+ var row = [];
51
+ for (var columnName in recordset[recordIndex]) {
52
+ if (!isColumnsFill) columns.push(columnName);
53
+ var columnIndex = columns.indexOf(columnName);
54
+ types[columnIndex] = typeof recordset[recordIndex][columnName];
55
+ if (recordset[recordIndex][columnName] instanceof Uint8Array ||
56
+ recordset[recordIndex][columnName] instanceof Buffer) {
57
+ recordset[recordIndex][columnName] = recordset[recordIndex][columnName].toString();
58
+ types[columnIndex] = "string";
59
+ }
60
+ if (recordset[recordIndex][columnName] != null && typeof recordset[recordIndex][columnName].toISOString === "function") {
61
+ var dateTime = new Date(recordset[recordIndex][columnName].getTime() - (recordset[recordIndex][columnName].getTimezoneOffset() * 60000)).toISOString();
62
+ recordset[recordIndex][columnName] = dateTime.replace("Z", "");
63
+ types[columnIndex] = "datetime";
64
+ }
65
+
66
+ row[columnIndex] = recordset[recordIndex][columnName];
67
+ }
68
+ isColumnsFill = true;
69
+ rows.push(row);
70
+ }
71
+
72
+ end({ success: true, columns: columns, rows: rows, types: types });
73
+ }
74
+
75
+ var getConnectionStringInfo = function (connectionString) {
76
+ var info = { host: "localhost", port: "3050" };
77
+ var isCorrect = false;
78
+ for (var propertyIndex in connectionString.split(";")) {
79
+ var property = connectionString.split(";")[propertyIndex];
80
+ if (property) {
81
+ var match = property.split("=");
82
+ if (match && match.length >= 2) {
83
+ match[0] = match[0].trim().toLowerCase();
84
+ match[1] = match[1].trim();
85
+
86
+ switch (match[0]) {
87
+ case "server":
88
+ case "host":
89
+ case "location":
90
+ case "datasource":
91
+ case "data source":
92
+ info["host"] = match[1];
93
+ break;
94
+
95
+ case "port":
96
+ info["port"] = match[1];
97
+ break;
98
+
99
+ case "database":
100
+ info["database"] = match[1];
101
+ isCorrect = true;
102
+ break;
103
+
104
+ case "uid":
105
+ case "user":
106
+ case "user id":
107
+ info["userId"] = match[1];
108
+ break;
109
+
110
+ case "pwd":
111
+ case "password":
112
+ info["password"] = match[1];
113
+ break;
114
+
115
+ case "charset":
116
+ info["charset"] = match[1];
117
+ break;
118
+ }
119
+ }
120
+ }
121
+ }
122
+ if (!isCorrect) {
123
+ onError("Connection String parse error");
124
+ return null;
125
+ }
126
+ return info;
127
+ };
128
+
129
+ var Firebird = require('node-firebird');
130
+ command.connectionStringInfo = getConnectionStringInfo(command.connectionString);
131
+ if (command.connectionStringInfo) {
132
+ var options = {
133
+ host: command.connectionStringInfo.host,
134
+ port: command.connectionStringInfo.port,
135
+ database: command.connectionStringInfo.database,
136
+ user: command.connectionStringInfo.userId,
137
+ password: command.connectionStringInfo.password,
138
+ charset: command.connectionStringInfo.charset,
139
+ };
140
+
141
+ connect();
142
+ var db;
143
+ }
144
+ }
145
+ catch (e) {
146
+ onError(e.stack);
147
+ }
142
148
  }