Commit 0094233e authored by Reza Sahebgharan's avatar Reza Sahebgharan

feat(debug for serverside methods and publishs): debug for serverside methods and publishs

parent 4e360c9a
Pipeline #1100 passed with stage
in 5 minutes
...@@ -20,3 +20,4 @@ tmeasday:publish-counts ...@@ -20,3 +20,4 @@ tmeasday:publish-counts
ostrio:meteor-root ostrio:meteor-root
ostrio:files ostrio:files
ostrio:logger ostrio:logger
ostrio:loggerfile
...@@ -53,6 +53,7 @@ ordered-dict@1.1.0 ...@@ -53,6 +53,7 @@ ordered-dict@1.1.0
ostrio:cookies@2.5.0 ostrio:cookies@2.5.0
ostrio:files@1.13.0 ostrio:files@1.13.0
ostrio:logger@2.0.8 ostrio:logger@2.0.8
ostrio:loggerfile@2.0.7
ostrio:meteor-root@1.0.8 ostrio:meteor-root@1.0.8
promise@0.11.2 promise@0.11.2
random@1.1.0 random@1.1.0
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<title>کارنامه</title> <title>%title%</title>
</head> </head>
<body> <body>
......
...@@ -2,25 +2,46 @@ import { Meteor } from 'meteor/meteor'; ...@@ -2,25 +2,46 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { HTTP } from 'meteor/http'; import { HTTP } from 'meteor/http';
import Brands from '../collections/brands.js'; import Brands from '../collections/brands.js';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'getBrands' () { 'getBrands' () {
debugger
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug("getBrands() => start get brands list", {}, Meteor.user().username) : '';
const result = HTTP.call('GET', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/GetHISBrandsRest`); const result = HTTP.call('GET', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/GetHISBrandsRest`);
Meteor.settings.enableDebug ? log.debug("getBrands() => brands list have been fetched", result, Meteor.user().username) : '';
let brandsHttpResult = JSON.parse(result.content); let brandsHttpResult = JSON.parse(result.content);
Meteor.settings.enableDebug ? log.debug("getBrands() => start remove old brands from db", {}, Meteor.user().username) : '';
Brands.remove({}); Brands.remove({});
Meteor.settings.enableDebug ? log.debug("getBrands() => old brands have been removed from db", {}, Meteor.user().username) : '';
Meteor.settings.enableDebug ? log.debug("getBrands() => start add new brands to db", {}, Meteor.user().username) : '';
brandsHttpResult.Items.forEach((brand) => { brandsHttpResult.Items.forEach((brand) => {
Brands.insert({ Brands.insert({
...brand ...brand
}); });
}); });
Meteor.settings.enableDebug ? log.debug("getBrands() => new brands have been added to db", {}, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error("getBrands Error", e, Meteor.user().username);
return false; return false;
} }
} else {
log.error("getBrands() => no loggined user for getBrands");
} }
}, },
"getBrandsName" () { "getBrandsName" () {
...@@ -41,3 +62,4 @@ Meteor.methods({ ...@@ -41,3 +62,4 @@ Meteor.methods({
} }
}); });
Meteor.settings.enableDebug ? log.debug(`endof barnads`) : '';
\ No newline at end of file
...@@ -2,20 +2,26 @@ import { Meteor } from 'meteor/meteor'; ...@@ -2,20 +2,26 @@ import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base'; import { Accounts } from 'meteor/accounts-base';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'changePass' (username, oldPassword, newPassword) { 'changePass' (username, oldPassword, newPassword) {
this.unblock(); this.unblock();
Meteor.settings.enableDebug ? log.debug(`changePass() => start change password for username ${username}`, { username, oldPassword, newPassword }) : '';
check(username, String); check(username, String);
check(oldPassword, String); check(oldPassword, String);
check(newPassword, String); check(newPassword, String);
Meteor.settings.enableDebug ? log.debug(`changePass() => find username ${username}`, { username, oldPassword, newPassword }) : '';
const user = Accounts.findUserByUsername(username); const user = Accounts.findUserByUsername(username);
if (user == null) { if (user == null) {
Meteor.settings.enableDebug ? log.debug(`changePass() => username not found`, { username, oldPassword, newPassword }) : '';
throw new Meteor.Error("NotFoundUser"); throw new Meteor.Error("NotFoundUser");
} }
...@@ -23,11 +29,18 @@ Meteor.methods({ ...@@ -23,11 +29,18 @@ Meteor.methods({
// const password = { digest: digestOldPassword, algorithm: 'sha-256' }; // const password = { digest: digestOldPassword, algorithm: 'sha-256' };
Meteor.settings.enableDebug ? log.debug(`changePass() => check validation of old password`, { username, oldPassword, newPassword }) : '';
const result = Accounts._checkPassword(user, oldPassword); const result = Accounts._checkPassword(user, oldPassword);
if (result.error != null) { if (result.error != null) {
Meteor.settings.enableDebug ? log.debug(`changePass() => validation of old password rejected`, { username, oldPassword, newPassword }) : '';
throw new Meteor.Error("CheckPassError"); throw new Meteor.Error("CheckPassError");
} }
Accounts.setPassword(user._id, newPassword); Accounts.setPassword(user._id, newPassword);
Meteor.settings.enableDebug ? log.debug(`changePass() => set new password`, { username, oldPassword, newPassword }) : '';
}, },
}); });
Meteor.settings.enableDebug ? log.debug(`endofchangepassword`) : '';
\ No newline at end of file
...@@ -2,14 +2,20 @@ import { Meteor } from 'meteor/meteor'; ...@@ -2,14 +2,20 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { HTTP } from 'meteor/http'; import { HTTP } from 'meteor/http';
import DeviceMap from '../collections/devicemap.js' import DeviceMap from '../collections/devicemap.js';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
debugger
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'createClient' (item) { 'createClient' (item) {
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`createClient() => start create client`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -17,11 +23,12 @@ Meteor.methods({ ...@@ -17,11 +23,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`createClient() => call create client method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/clients/create`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/clients/create`, options);
Meteor.settings.enableDebug ? log.debug(`createClient() => createClient have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`createClient() => error in create client`, e, Meteor.user().username)
console.log(e);
return false; return false;
} }
} }
...@@ -30,6 +37,7 @@ Meteor.methods({ ...@@ -30,6 +37,7 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`editClient() => start edit client`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -37,19 +45,27 @@ Meteor.methods({ ...@@ -37,19 +45,27 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`editClient() => call edit client method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/clients/update`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/clients/update`, options);
Meteor.settings.enableDebug ? log.debug(`editClient() => editClient have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`editClient() => error in edit client`, e, Meteor.user().username)
console.log(e);
return false; return false;
} }
} }
}, },
"deleteClient" (item) { "deleteClient" (item) {
this.unblock(); this.unblock();
Meteor.settings.enableDebug ? log.debug(`deleteClient() => start delete client`, item, Meteor.user().username) : '';
let relationShipCount = DeviceMap.find({ ClientId: item._id }).count(); let relationShipCount = DeviceMap.find({ ClientId: item._id }).count();
Meteor.settings.enableDebug ? log.debug(`deleteClient() => get relationshipCount of deleted item`, relationShipCount, Meteor.user().username) : '';
if (relationShipCount > 0) { if (relationShipCount > 0) {
Meteor.settings.enableDebug ? log.debug(`deleteClient() => relationShipCount is greater than zero and selected client can not be deleted`, { relationShipCount, ...item }, Meteor.user().username) : '';
throw new Meteor.Error(500, "relationShipError"); throw new Meteor.Error(500, "relationShipError");
} }
...@@ -62,13 +78,15 @@ Meteor.methods({ ...@@ -62,13 +78,15 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`deleteClient() => call delete client method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/clients/delete`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/clients/delete`, options);
Meteor.settings.enableDebug ? log.debug(`deleteClient() => deleteClient have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`deleteClient() => error in delete client`, e, Meteor.user().username)
console.log(e);
return false; return false;
} }
} }
}, },
}); });
Meteor.settings.enableDebug ? log.debug(`endof clients`) : '';
\ No newline at end of file
...@@ -2,11 +2,18 @@ import { Meteor } from 'meteor/meteor'; ...@@ -2,11 +2,18 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { HTTP } from 'meteor/http'; import { HTTP } from 'meteor/http';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
const log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'createDevicemap' (item) { 'createDevicemap' (item) {
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`createDeviceMap() => start create devicemap`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -14,11 +21,12 @@ Meteor.methods({ ...@@ -14,11 +21,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`createDevicemap() => call create devicemap method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/devicemap/create`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/devicemap/create`, options);
Meteor.settings.enableDebug ? log.debug(`createDeviceMap() => createDevicemap have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`createDeviceMap() => error in create DeviceMap`, e, Meteor.user().username)
console.log(e);
return false; return false;
} }
} }
...@@ -26,7 +34,9 @@ Meteor.methods({ ...@@ -26,7 +34,9 @@ Meteor.methods({
"editDevicemap" (item) { "editDevicemap" (item) {
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`editDevicemap() => start edit Devicemap`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -34,11 +44,12 @@ Meteor.methods({ ...@@ -34,11 +44,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`editDevicemap() => call edit devicemap method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/devicemap/update`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/devicemap/update`, options);
Meteor.settings.enableDebug ? log.debug(`editDevicemap() => editDeviceMap have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`editDevicemap() => error in edit devicemap`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
...@@ -47,6 +58,7 @@ Meteor.methods({ ...@@ -47,6 +58,7 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`deleteDevicemap() => start delete Devicemap`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -54,13 +66,15 @@ Meteor.methods({ ...@@ -54,13 +66,15 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`deleteDevicemap() => call delete devicemap method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/devicemap/delete`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/devicemap/delete`, options);
Meteor.settings.enableDebug ? log.debug(`deleteDevicemap() => deleteDevicemap have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`deleteDevicemap() => error in delete devicemap`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
}, },
}); });
Meteor.settings.enableDebug ? log.debug(`endof devicemap`) : '';
\ No newline at end of file
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { HTTP } from 'meteor/http'; import { HTTP } from 'meteor/http';
import DeviceMap from '../collections/devicemap.js';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
import DeviceMap from '../collections/devicemap.js' var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'createHisLink' (item) { 'createHisLink' (item) {
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`createHisLink() => start create hislink`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -19,13 +20,12 @@ Meteor.methods({ ...@@ -19,13 +20,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`createHisLink() => call create hislink method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/create`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/create`, options);
Meteor.settings.enableDebug ? log.debug(`createHisLink() => createHisLink have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`createHisLink() => error in create HisLink`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
...@@ -34,7 +34,7 @@ Meteor.methods({ ...@@ -34,7 +34,7 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`editHisLink() => start edit hislink`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -42,13 +42,12 @@ Meteor.methods({ ...@@ -42,13 +42,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`editHisLink() => call edit hislink method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/update`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/update`, options);
Meteor.settings.enableDebug ? log.debug(`editHisLink() => editHisLink have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`editHisLink() => error in edit HisLink`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
...@@ -56,16 +55,14 @@ Meteor.methods({ ...@@ -56,16 +55,14 @@ Meteor.methods({
"deleteHisLink" (item) { "deleteHisLink" (item) {
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => start delete hislink`, item, Meteor.user().username) : '';
let relationShipCount = DeviceMap.find({ HisLinkId: item._id }).count(); let relationShipCount = DeviceMap.find({ HisLinkId: item._id }).count();
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => get relationshipCount of deleted item`, relationShipCount, Meteor.user().username) : '';
if (relationShipCount > 0) { if (relationShipCount > 0) {
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => relationShipCount is greater than zero and selected hislink can not be deleted`, { relationShipCount, ...item }, Meteor.user().username) : '';
throw new Meteor.Error(500, "relationShipError"); throw new Meteor.Error(500, "relationShipError");
} }
try { try {
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -73,13 +70,12 @@ Meteor.methods({ ...@@ -73,13 +70,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => call delete hislink method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/delete`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/delete`, options);
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => deleteHisLink have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`deleteHisLink() => error in delete hislink`, e, Meteor.user().username)
console.log(e);
return e.reason; return e.reason;
} }
} }
...@@ -88,6 +84,7 @@ Meteor.methods({ ...@@ -88,6 +84,7 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`activeHisLink() => start active hislink`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -95,13 +92,12 @@ Meteor.methods({ ...@@ -95,13 +92,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`activeHisLink() => call active hislink method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/active`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/active`, options);
Meteor.settings.enableDebug ? log.debug(`activeHisLink() => activeHisLink have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`activeHisLink() => error in active hislink`, e, Meteor.user().username)
console.log(e);
return false; return false;
} }
} }
...@@ -110,6 +106,7 @@ Meteor.methods({ ...@@ -110,6 +106,7 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`deactiveHisLink() => start deactive hislink`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -117,13 +114,12 @@ Meteor.methods({ ...@@ -117,13 +114,12 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`deactiveHisLink() => call active hislink method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/deactive`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/deactive`, options);
Meteor.settings.enableDebug ? log.debug(`deactiveHisLink() => deactiveHisLink have been called`, result, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`deactiveHisLink() => error in deactive hislink`, e, Meteor.user().username)
console.log(e);
return false; return false;
} }
} }
...@@ -132,6 +128,7 @@ Meteor.methods({ ...@@ -132,6 +128,7 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`authenticateHisLink() => start authenticate hislink`, item, Meteor.user().username) : '';
let options = { let options = {
data: item, data: item,
headers: { headers: {
...@@ -139,15 +136,15 @@ Meteor.methods({ ...@@ -139,15 +136,15 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`authenticateHisLink() => call active hislink method`, item, Meteor.user().username) : '';
const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/authenticate`, options); const result = HTTP.call("POST", `${Meteor.settings.databusUrl}/hislink/authenticate`, options);
Meteor.settings.enableDebug ? log.debug(`authenticateHisLink() => authenticateHisLink have been called`, result, Meteor.user().username) : '';
return result; return result;
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`authenticateHisLink() => error in authenticate hislink`, e, Meteor.user().username)
console.log(e);
throw new Meteor.Error(500, "error"); throw new Meteor.Error(500, "error");
} }
} }
} }
}); });
Meteor.settings.enableDebug ? log.debug(`endof hislinks`) : '';
\ No newline at end of file
...@@ -4,17 +4,30 @@ import { Mongo } from 'meteor/mongo'; ...@@ -4,17 +4,30 @@ import { Mongo } from 'meteor/mongo';
const sqlite3 = require('sqlite3').verbose(); const sqlite3 = require('sqlite3').verbose();
import TransliterationDb from '../collections/transliterationdb.js'; import TransliterationDb from '../collections/transliterationdb.js';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'sqlite2mongo' (sqliteAddress) { 'sqlite2mongo' (sqliteAddress) {
this.unblock(); this.unblock();
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start sqlite2mongo `, sqliteAddress) : '';
check(sqliteAddress, String); check(sqliteAddress, String);
if (this.userId) { if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start remove uploaded databases`, sqliteAddress, Meteor.user().username) : '';
TransliterationDb.remove({}); TransliterationDb.remove({});
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => uploaded databases have been removed`, sqliteAddress, Meteor.user().username) : '';
let dbFullAddress = Meteor.rootPath + "/" + sqliteAddress; let dbFullAddress = Meteor.rootPath + "/" + sqliteAddress;
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => database upload root is ${dbFullAddress}`, {}, Meteor.user().username) : '';
const promise = select(dbFullAddress, "transliteration_1") const promise = select(dbFullAddress, "transliteration_1")
.then((documentArray) => { .then((documentArray) => {
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start inserting fetched documents into mongodb`, documentArray.length, Meteor.user().username) : '';
let bulkOp = TransliterationDb.rawCollection().initializeUnorderedBulkOp(), let bulkOp = TransliterationDb.rawCollection().initializeUnorderedBulkOp(),
counter = 0; counter = 0;
...@@ -26,8 +39,8 @@ Meteor.methods({ ...@@ -26,8 +39,8 @@ Meteor.methods({
// Send to server in batch of 1000 insert operations // Send to server in batch of 1000 insert operations
if (counter % 1000 == 0) { if (counter % 1000 == 0) {
// Execute per 1000 operations and re-initialize every 1000 update statements // Execute per 1000 operations and re-initialize every 1000 update statements
bulkOp.execute(function(e, rresult) { bulkOp.execute(function(e, result) {
// do something with result // Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => ${counter} records have been inserted into mongodb`, counter, Meteor.user().username) : '';
}); });
bulkOp = TransliterationDb.rawCollection().initializeUnorderedBulkOp(); bulkOp = TransliterationDb.rawCollection().initializeUnorderedBulkOp();
} }
...@@ -35,11 +48,13 @@ Meteor.methods({ ...@@ -35,11 +48,13 @@ Meteor.methods({
// Clean up queues // Clean up queues
if (counter % 1000 != 0) { if (counter % 1000 != 0) {
bulkOp.execute(function(e, result) { bulkOp.execute(function(e, result) {
// do something with result // Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => ${counter} records have been inserted into mongodb`, counter, Meteor.user().username) : '';
}); });
} }
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => insertion into mongodb have done`, counter, Meteor.user().username) : '';
return true; return true;
}).catch((e) => { }).catch((e) => {
log.error(`sqlite2mongo() => error in fetching records from sqlite db`, e, Meteor.user().username);
throw new Meteor.Error('500', e); throw new Meteor.Error('500', e);
}); });
return promise.await(); return promise.await();
...@@ -50,22 +65,30 @@ Meteor.methods({ ...@@ -50,22 +65,30 @@ Meteor.methods({
function select(database, table) { function select(database, table) {
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start select db records`, { database, table }, Meteor.user().username) : '';
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => connect to uploaded db`, { database, table }, Meteor.user().username) : '';
const db = new sqlite3.Database(database); const db = new sqlite3.Database(database);
const queries = []; const queries = [];
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start query db records`, { database, table }, Meteor.user().username) : '';
db.each(`SELECT * FROM ${table}`, (err, row) => { db.each(`SELECT * FROM ${table}`, (err, row) => {
if (err) { if (err) {
reject(err); // optional: you might choose to swallow errors. // log.error(`sqlite2mongo() => 1.error in fetching records from sqlite db`, err, Meteor.user().username);
reject(err);
} else { } else {
queries.push(row); // accumulate the data queries.push(row);
} }
}, (err, n) => { }, (err, n) => {
if (err) { if (err) {
reject(err); // optional: again, you might choose to swallow this error. // log.error(`sqlite2mongo() => 2.error in fetching records from sqlite db`, err, Meteor.user().username);
reject(err);
} else { } else {
resolve(queries); // resolve the promise // Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => fetching from db have been done`, queries, Meteor.user().username) : '';
resolve(queries);
} }
}); });
}); });
} }
Meteor.settings.enableDebug ? log.debug(`endof translitdb`) : '';
\ No newline at end of file
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { HTTP } from 'meteor/http';
import { Accounts } from "meteor/accounts-base"; import { Accounts } from "meteor/accounts-base";
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'createUser1' (item) { 'createUser1' (item) {
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`createUser() => start createUser `, item, Meteor.user().username) : '';
let userExists = Meteor.users.findOne({ username: item.username }); let userExists = Meteor.users.findOne({ username: item.username });
if (userExists == undefined || userExists == null) if (userExists == undefined || userExists == null) {
Accounts.createUser({ Accounts.createUser({
...item ...item
// username: item.username,
// password: item.password,
// profile:{
// }
}); });
Meteor.settings.enableDebug ? log.debug(`createUser() => username created `, item, Meteor.user().username) : '';
} else {
Meteor.settings.enableDebug ? log.debug(`createUser() => username exists `, item, Meteor.user().username) : '';
}
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`createUser() => error creating user at meteor`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
...@@ -34,13 +34,13 @@ Meteor.methods({ ...@@ -34,13 +34,13 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`editUser() => start`, item, Meteor.user().username) : '';
Meteor.users.update({ _id: item._id }, { $set: { "profile.fullName": item.fullName } }, { upsert: true }) Meteor.users.update({ _id: item._id }, { $set: { "profile.fullName": item.fullName } }, { upsert: true });
// Accounts.setPassword(item._id, item.password, { logout: true }) Meteor.settings.enableDebug ? log.debug(`editUser() => user edited `, item, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e); log.error(`editUser() => error editing user`, e, Meteor.user().username);
return false; return false;
} }
} }
...@@ -49,12 +49,12 @@ Meteor.methods({ ...@@ -49,12 +49,12 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`setPassword() => start setPassword`, item, Meteor.user().username) : '';
Accounts.setPassword(item._id, item.password, { logout: true }) Accounts.setPassword(item._id, item.password, { logout: true })
Meteor.settings.enableDebug ? log.debug(`setPassword() => user password have been changed `, item, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`setPassword() => error setPassword`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
...@@ -64,12 +64,13 @@ Meteor.methods({ ...@@ -64,12 +64,13 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`deleteUser() => start delete user`, item, Meteor.user().username) : '';
Meteor.users.remove({ _id: item._id }); Meteor.users.remove({ _id: item._id });
Meteor.settings.enableDebug ? log.debug(`deleteUser() => user have been removed `, item, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e); log.error(`deleteUser() => error user removing`, e, Meteor.user().username);
return false; return false;
} }
} }
...@@ -79,15 +80,15 @@ Meteor.methods({ ...@@ -79,15 +80,15 @@ Meteor.methods({
this.unblock(); this.unblock();
if (this.userId) { if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`editUserProfile() => start`, item, Meteor.user().username) : '';
// db.collection.update( { _id:...} , { $set: { some_key.param2 : new_info } } Meteor.users.update({ _id: this.userId }, { $set: {...item } }, { upsert: true });
Meteor.users.update({ _id: this.userId }, { $set: {...item } }, { upsert: true }) Meteor.settings.enableDebug ? log.debug(`editUserProfile() => user profile have been edited`, item, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`editUserProfile() => error user profile editing`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
} }
}); });
Meteor.settings.enableDebug ? log.debug(`endof usersjs`) : '';
\ No newline at end of file
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Accounts } from 'meteor/accounts-base';
import { HTTP } from 'meteor/http'; import { HTTP } from 'meteor/http';
let uuidv4 = require("uuid/v4"); let uuidv4 = require("uuid/v4");
...@@ -17,18 +16,36 @@ let internalWorklistName = 'InternalHis'; ...@@ -17,18 +16,36 @@ let internalWorklistName = 'InternalHis';
// import workListItemSchema from '../collections/worklistItemSchema.js'; // import workListItemSchema from '../collections/worklistItemSchema.js';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.methods({ Meteor.methods({
'Fetchworklist' (devicemap) { 'Fetchworklist' (devicemap) {
this.unblock();
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => start Fetchworklist `, devicemap, Meteor.user().username) : '';
check(devicemap, String); check(devicemap, String);
if (devicemap.length == 0) { if (devicemap.length == 0) {
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => devicemap is empty `, devicemap, Meteor.user().username) : '';
return true; return true;
} }
this.unblock();
if (this.userId) {
try { try {
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => start get worklist from restapi `, devicemap, Meteor.user().username) : '';
const result = HTTP.call('GET', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/Fetchworklist/${devicemap}`); const result = HTTP.call('GET', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/Fetchworklist/${devicemap}`);
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => worklist have been fetched from restapi `, result, Meteor.user().username) : '';
let worklistHttp = JSON.parse(result.content); let worklistHttp = JSON.parse(result.content);
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => start remove worklist for user and devicemap `, devicemap, Meteor.user().username) : '';
Worklist.remove({ _userid: this.userId, _devicemap: devicemap }); Worklist.remove({ _userid: this.userId, _devicemap: devicemap });
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => worklist for user and devicemap have been removed`, devicemap, Meteor.user().username) : '';
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => start inserting worklist for user and devicemap into tempcollection `, devicemap, Meteor.user().username) : '';
worklistHttp.WorkListItems.forEach((patient) => { worklistHttp.WorkListItems.forEach((patient) => {
delete patient._id; delete patient._id;
Worklist.insert({ Worklist.insert({
...@@ -38,10 +55,11 @@ Meteor.methods({ ...@@ -38,10 +55,11 @@ Meteor.methods({
}); });
}); });
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => worklist for user and devicemap have been inserted into tempcollection `, devicemap, Meteor.user().username) : '';
return true return true
} catch (e) { } catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range. log.error(`Fetchworklist() => error fetching worklist`, e, Meteor.user().username);
console.log(e);
return false; return false;
} }
} }
...@@ -92,11 +110,12 @@ Meteor.methods({ ...@@ -92,11 +110,12 @@ Meteor.methods({
// "Smoking": 2, // "Smoking": 2,
// "StudyInstanceUID": "1.3.12.2.1107.5.2.30.26719.6.8122118808" // "StudyInstanceUID": "1.3.12.2.1107.5.2.30.26719.6.8122118808"
// } // }
// try { try {
if (this.userId) { if (this.userId) {
delete item._id; delete item._id;
// workListItemSchema.validate(item); // workListItemSchema.validate(item);
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => start EditWorklist `, item, Meteor.user().username) : '';
var options = { var options = {
data: item, data: item,
headers: { headers: {
...@@ -104,21 +123,33 @@ Meteor.methods({ ...@@ -104,21 +123,33 @@ Meteor.methods({
'Accept': 'application/json' 'Accept': 'application/json'
} }
} }
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => start calling editworklist restapi `, {}, Meteor.user().username) : '';
const result = HTTP.call('POST', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/EditworklistItem`, options); const result = HTTP.call('POST', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/EditworklistItem`, options);
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => editworklist restapi have been called `, result, Meteor.user().username) : '';
let result1 = JSON.parse(result.content); let result1 = JSON.parse(result.content);
delete result1._id; delete result1._id;
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => start updating temp collection for edited item in worklist `, result1, Meteor.user().username) : '';
let update = Worklist.update({ AdmissionID: result1.AdmissionID }, { $set: result1 }, { multi: true }); let update = Worklist.update({ AdmissionID: result1.AdmissionID }, { $set: result1 }, { multi: true });
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => updating temp collection for edited item in worklist have been done`, update, Meteor.user().username) : '';
return true; return true;
} }
} catch (e) {
log.error(`EditworklistItem() => error editing worklist`, e, Meteor.user().username);
return false;
}
}, },
"Register" (item) { "Register" (item) {
try {
if (this.userId) { if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`Register() => start Register patient into internalworklist `, item, Meteor.user().username) : '';
item._id = uuidv4(); item._id = uuidv4();
item.PatientDate = new Date(); item.PatientDate = new Date();
InternalWorklist.insert({ InternalWorklist.insert({
...item ...item
}); });
Meteor.settings.enableDebug ? log.debug(`Register() => patient inserted into internalworklist `, {}, Meteor.user().username) : '';
// Worklist.remove({ _userid: this.userId, _devicemap: internalWorklistName }); // Worklist.remove({ _userid: this.userId, _devicemap: internalWorklistName });
...@@ -129,5 +160,10 @@ Meteor.methods({ ...@@ -129,5 +160,10 @@ Meteor.methods({
// }); // });
return true; return true;
} }
} catch (e) {
log.error(`EditworklistItem() => error editing worklist`, e, Meteor.user().username);
return false;
}
} }
}); });
\ No newline at end of file
import Brands from '../../collections/brands.js'; import Brands from '../../collections/brands.js';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("brands", function() { Meteor.publish("brands", function() {
if (!this.userId) { if (!this.userId) {
return this.ready(); return this.ready();
} }
Meteor.settings.enableDebug ? log.debug(`brandPublisher => start publish brands `, {}, Meteor.user().username) : '';
return Brands.find({}, { return Brands.find({}, {
disableOplog: true, disableOplog: true,
// pollingThrottleMs: 1000, // pollingThrottleMs: 1000,
......
import Clients from '../../collections/clients.js'; import Clients from '../../collections/clients.js';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("clients", function() { Meteor.publish("clients", function() {
// if (!this.userId) { // if (!this.userId) {
...@@ -9,6 +14,7 @@ Meteor.publish("clients", function() { ...@@ -9,6 +14,7 @@ Meteor.publish("clients", function() {
// return Clients.find({}); // return Clients.find({});
if (this.userId) { if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`clientsPublisher => start publish clients `, {}, Meteor.user().username) : '';
return Clients.find({}, { return Clients.find({}, {
disableOplog: true, disableOplog: true,
......
import DeviceMap from '../../collections/devicemap'; import DeviceMap from '../../collections/devicemap';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("devicemaps", function() { Meteor.publish("devicemaps", function() {
if (!this.userId) { if (!this.userId) {
return this.ready(); return this.ready();
} }
Meteor.settings.enableDebug ? log.debug(`devicemapsPublisher => start publish devicemaps `, {}, Meteor.user().username) : '';
return DeviceMap.find({}, { return DeviceMap.find({}, {
disableOplog: true, disableOplog: true,
......
import HisLink from '../../collections/hislink.js'; import HisLink from '../../collections/hislink.js';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("hislink", function() { Meteor.publish("hislink", function() {
if (!this.userId) { if (!this.userId) {
return this.ready(); return this.ready();
} }
Meteor.settings.enableDebug ? log.debug(`hislinkPublisher => start publish hislink `, {}, Meteor.user().username) : '';
return HisLink.find({}, { return HisLink.find({}, {
disableOplog: true, disableOplog: true,
......
import TranslitDbUploads from '../../collections/translitdbuploads.js'; import TranslitDbUploads from '../../collections/translitdbuploads.js';
import { Meteor } from 'meteor/meteor'; import { Meteor } from 'meteor/meteor';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish('translitdbuploads', function() { Meteor.publish('translitdbuploads', function() {
if (!this.userId) if (!this.userId)
return []; return [];
Meteor.settings.enableDebug ? log.debug(`translitdbuploadsPublisher => start publish translitdbuploads `, {}, Meteor.user().username) : '';
return TranslitDbUploads.find({ userId: this.userId }).cursor; return TranslitDbUploads.find({ userId: this.userId }).cursor;
}); });
\ No newline at end of file
...@@ -3,13 +3,18 @@ import { Mongo } from 'meteor/mongo' ...@@ -3,13 +3,18 @@ import { Mongo } from 'meteor/mongo'
import TransliterationDb from '../../collections/transliterationdb'; import TransliterationDb from '../../collections/transliterationdb';
import { Counts } from 'meteor/tmeasday:publish-counts'; import { Counts } from 'meteor/tmeasday:publish-counts';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("transliterationdb", function({ limit }) { Meteor.publish("transliterationdb", function({ limit }) {
if (!this.userId) { if (!this.userId) {
return this.ready(); return this.ready();
} }
check(limit, Number); check(limit, Number);
Meteor.settings.enableDebug ? log.debug(`transliterationdbPublisher => start publish transliterationdb `, limit, Meteor.user().username) : '';
return TransliterationDb.find({}, { return TransliterationDb.find({}, {
sort: { ID: 1 }, sort: { ID: 1 },
limit: limit limit: limit
...@@ -20,5 +25,6 @@ Meteor.publish("transliterationdbCount", function() { ...@@ -20,5 +25,6 @@ Meteor.publish("transliterationdbCount", function() {
if (!this.userId) { if (!this.userId) {
return this.ready(); return this.ready();
} }
Meteor.settings.enableDebug ? log.debug(`transliterationdbCountPublisher => start publish transliterationdbCount `, {}, Meteor.user().username) : '';
Counts.publish(this, 'transliterationCount', TransliterationDb.find({}), { fastCount: true }); Counts.publish(this, 'transliterationCount', TransliterationDb.find({}), { fastCount: true });
}); });
\ No newline at end of file
import { check } from 'meteor/check'; import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("users", function() { Meteor.publish("users", function() {
// if (!this.userId) { // if (!this.userId) {
...@@ -7,6 +11,7 @@ Meteor.publish("users", function() { ...@@ -7,6 +11,7 @@ Meteor.publish("users", function() {
// return Clients.find({}); // return Clients.find({});
if (this.userId) { if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`usersPublisher => start publish users `, {}, Meteor.user().username) : '';
let isMarcoAdmin = Meteor.users.findOne({ _id: this.userId }); let isMarcoAdmin = Meteor.users.findOne({ _id: this.userId });
if (isMarcoAdmin.username == "marcoadmin") { if (isMarcoAdmin.username == "marcoadmin") {
return Meteor.users.find({ username: { $ne: "marcoadmin" } }, { return Meteor.users.find({ username: { $ne: "marcoadmin" } }, {
...@@ -15,23 +20,14 @@ Meteor.publish("users", function() { ...@@ -15,23 +20,14 @@ Meteor.publish("users", function() {
// pollingThrottleMs: 1000, // pollingThrottleMs: 1000,
pollingIntervalMs: 1000 pollingIntervalMs: 1000
}); });
} } else
// return Meteor.users.find({});
else
return Meteor.users.find({ _id: this.userId }, { return Meteor.users.find({ _id: this.userId }, {
disableOplog: true, disableOplog: true,
// pollingThrottleMs: 1000, // pollingThrottleMs: 1000,
pollingIntervalMs: 1000 pollingIntervalMs: 1000
}); });
// return Clients.find({}, {
// reactive: true,
// disableOplog: false,
// pollingThrottleMs: 1000,
// pollingIntervalMs: 1000
// })
} else { } else {
......
import Worklist from '../../collections/worklist.js'; import Worklist from '../../collections/worklist.js';
import { check } from 'meteor/check'; import { check } from 'meteor/check';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("worklist", function(devicemap) { Meteor.publish("worklist", function(devicemap) {
if (!this.userId) { if (!this.userId) {
...@@ -9,6 +15,7 @@ Meteor.publish("worklist", function(devicemap) { ...@@ -9,6 +15,7 @@ Meteor.publish("worklist", function(devicemap) {
const userid = this.userId; const userid = this.userId;
check(devicemap, String); check(devicemap, String);
// console.log(Worklist.find({ _userid: userid, _devicemap: devicemap }).fetch())
Meteor.settings.enableDebug ? log.debug(`worklistPublisher => start publish worklist `, devicemap, Meteor.user().username) : '';
return Worklist.find({ _userid: userid, _devicemap: devicemap }, { fields: { _devicemap: 0, _userid: 0 } }); return Worklist.find({ _userid: userid, _devicemap: devicemap }, { fields: { _devicemap: 0, _userid: 0 } });
}); });
\ No newline at end of file
...@@ -3,6 +3,12 @@ import { Mongo } from 'meteor/mongo' ...@@ -3,6 +3,12 @@ import { Mongo } from 'meteor/mongo'
import Collections from '../../collections/worklist4hislink.js'; import Collections from '../../collections/worklist4hislink.js';
import { Counts } from 'meteor/tmeasday:publish-counts'; import { Counts } from 'meteor/tmeasday:publish-counts';
import { Logger } from 'meteor/ostrio:logger';
import { LoggerFile } from 'meteor/ostrio:loggerfile';
var log = new Logger();
(new LoggerFile(log)).enable();
Meteor.publish("worklist4hislink", function({ brand, limit, query }) { Meteor.publish("worklist4hislink", function({ brand, limit, query }) {
if (brand == null) { if (brand == null) {
...@@ -32,6 +38,7 @@ Meteor.publish("worklist4hislink", function({ brand, limit, query }) { ...@@ -32,6 +38,7 @@ Meteor.publish("worklist4hislink", function({ brand, limit, query }) {
// limit: limit // limit: limit
// }); // });
// else // else
Meteor.settings.enableDebug ? log.debug(`worklist4hislink => start publish worklist4hislink `, { brand, limit, query }, Meteor.user().username) : '';
return Collections[brand].find(query, { return Collections[brand].find(query, {
disableOplog: true, disableOplog: true,
// pollingThrottleMs: 1000, // pollingThrottleMs: 1000,
...@@ -40,6 +47,7 @@ Meteor.publish("worklist4hislink", function({ brand, limit, query }) { ...@@ -40,6 +47,7 @@ Meteor.publish("worklist4hislink", function({ brand, limit, query }) {
}); });
} catch (e) { } catch (e) {
// Counts.publish(this, 'brandCount', Collections[brand].find({}), { noReady: false }); // Counts.publish(this, 'brandCount', Collections[brand].find({}), { noReady: false });
log.error(`worklist4hislinkPublisher => error publish worklist4hislink`, e, Meteor.user().username);
this.error(new Meteor.Error(e, 'error')); this.error(new Meteor.Error(e, 'error'));
return []; return [];
} }
......
...@@ -12,7 +12,6 @@ import '../imports/api/methods/devicemap.js'; ...@@ -12,7 +12,6 @@ import '../imports/api/methods/devicemap.js';
import '../imports/api/methods/users.js'; import '../imports/api/methods/users.js';
import '../imports/api/methods/translitdb.js'; import '../imports/api/methods/translitdb.js';
import '../imports/api/server/publications/worklist.js'; import '../imports/api/server/publications/worklist.js';
import '../imports/api/server/publications/hislink.js'; import '../imports/api/server/publications/hislink.js';
...@@ -27,12 +26,6 @@ import '../imports/api/server/publications/transliterationdb.js'; ...@@ -27,12 +26,6 @@ import '../imports/api/server/publications/transliterationdb.js';
import { Accounts } from "meteor/accounts-base"; import { Accounts } from "meteor/accounts-base";
Meteor.startup(() => { Meteor.startup(() => {
let marcoUser = Meteor.users.findOne({ username: "marcoadmin" }); let marcoUser = Meteor.users.findOne({ username: "marcoadmin" });
...@@ -51,6 +44,7 @@ Meteor.startup(() => { ...@@ -51,6 +44,7 @@ Meteor.startup(() => {
}); });
Meteor.users.deny({ update: () => true }); Meteor.users.deny({ update: () => true });
console.log("app started");
}); });
...@@ -62,7 +56,6 @@ function onRoute(req, res, next) { ...@@ -62,7 +56,6 @@ function onRoute(req, res, next) {
const middleWare = ConnectRoute(function(router) { const middleWare = ConnectRoute(function(router) {
router.get('/', onRoute); router.get('/', onRoute);
}); });
WebApp.connectHandlers WebApp.connectHandlers
......
{ {
"worklistUrl": "http://192.168.0.66:8086", "worklistUrl": "http://192.168.0.66:8086",
"databusUrl": "http://localhost:8090" "databusUrl": "http://localhost:8090",
"enableDebug": true
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment