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
ostrio:meteor-root
ostrio:files
ostrio:logger
ostrio:loggerfile
......@@ -53,6 +53,7 @@ ordered-dict@1.1.0
ostrio:cookies@2.5.0
ostrio:files@1.13.0
ostrio:logger@2.0.8
ostrio:loggerfile@2.0.7
ostrio:meteor-root@1.0.8
promise@0.11.2
random@1.1.0
......
......@@ -3,7 +3,7 @@
<meta charset="utf-8">
<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">
<title>کارنامه</title>
<title>%title%</title>
</head>
<body>
......
......@@ -2,25 +2,46 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { HTTP } from 'meteor/http';
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({
'getBrands' () {
debugger
this.unblock();
if (this.userId) {
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`);
Meteor.settings.enableDebug ? log.debug("getBrands() => brands list have been fetched", result, Meteor.user().username) : '';
let brandsHttpResult = JSON.parse(result.content);
Meteor.settings.enableDebug ? log.debug("getBrands() => start remove old brands from db", {}, Meteor.user().username) : '';
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) => {
Brands.insert({
...brand
});
});
Meteor.settings.enableDebug ? log.debug("getBrands() => new brands have been added to db", {}, Meteor.user().username) : '';
return true
} 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;
}
} else {
log.error("getBrands() => no loggined user for getBrands");
}
},
"getBrandsName" () {
......@@ -40,4 +61,5 @@ Meteor.methods({
}
}
});
\ No newline at end of file
});
Meteor.settings.enableDebug ? log.debug(`endof barnads`) : '';
\ No newline at end of file
......@@ -2,20 +2,26 @@ import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
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({
'changePass' (username, oldPassword, newPassword) {
this.unblock();
Meteor.settings.enableDebug ? log.debug(`changePass() => start change password for username ${username}`, { username, oldPassword, newPassword }) : '';
check(username, String);
check(oldPassword, String);
check(newPassword, String);
Meteor.settings.enableDebug ? log.debug(`changePass() => find username ${username}`, { username, oldPassword, newPassword }) : '';
const user = Accounts.findUserByUsername(username);
if (user == null) {
Meteor.settings.enableDebug ? log.debug(`changePass() => username not found`, { username, oldPassword, newPassword }) : '';
throw new Meteor.Error("NotFoundUser");
}
......@@ -23,11 +29,18 @@ Meteor.methods({
// 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);
if (result.error != null) {
Meteor.settings.enableDebug ? log.debug(`changePass() => validation of old password rejected`, { username, oldPassword, newPassword }) : '';
throw new Meteor.Error("CheckPassError");
}
Accounts.setPassword(user._id, newPassword);
Meteor.settings.enableDebug ? log.debug(`changePass() => set new password`, { username, oldPassword, newPassword }) : '';
},
});
\ No newline at end of file
});
Meteor.settings.enableDebug ? log.debug(`endofchangepassword`) : '';
\ No newline at end of file
......@@ -2,14 +2,20 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
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({
'createClient' (item) {
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`createClient() => start create client`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -17,11 +23,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`createClient() => createClient have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`createClient() => error in create client`, e, Meteor.user().username)
return false;
}
}
......@@ -30,6 +37,7 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`editClient() => start edit client`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -37,19 +45,27 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`editClient() => editClient have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`editClient() => error in edit client`, e, Meteor.user().username)
return false;
}
}
},
"deleteClient" (item) {
this.unblock();
Meteor.settings.enableDebug ? log.debug(`deleteClient() => start delete client`, item, Meteor.user().username) : '';
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) {
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");
}
......@@ -62,13 +78,15 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`deleteClient() => deleteClient have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`deleteClient() => error in delete client`, e, Meteor.user().username)
return false;
}
}
},
});
\ No newline at end of file
});
Meteor.settings.enableDebug ? log.debug(`endof clients`) : '';
\ No newline at end of file
......@@ -2,11 +2,18 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
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({
'createDevicemap' (item) {
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`createDeviceMap() => start create devicemap`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -14,11 +21,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`createDeviceMap() => createDevicemap have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`createDeviceMap() => error in create DeviceMap`, e, Meteor.user().username)
return false;
}
}
......@@ -26,7 +34,9 @@ Meteor.methods({
"editDevicemap" (item) {
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`editDevicemap() => start edit Devicemap`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -34,11 +44,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`editDevicemap() => editDeviceMap have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`editDevicemap() => error in edit devicemap`, e, Meteor.user().username);
return false;
}
}
......@@ -47,6 +58,7 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`deleteDevicemap() => start delete Devicemap`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -54,13 +66,15 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`deleteDevicemap() => deleteDevicemap have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`deleteDevicemap() => error in delete devicemap`, e, Meteor.user().username);
return false;
}
}
},
});
\ No newline at end of file
});
Meteor.settings.enableDebug ? log.debug(`endof devicemap`) : '';
\ No newline at end of file
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
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({
'createHisLink' (item) {
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`createHisLink() => start create hislink`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -19,13 +20,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`createHisLink() => createHisLink have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`createHisLink() => error in create HisLink`, e, Meteor.user().username);
return false;
}
}
......@@ -34,7 +34,7 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`editHisLink() => start edit hislink`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -42,13 +42,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`editHisLink() => editHisLink have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`editHisLink() => error in edit HisLink`, e, Meteor.user().username);
return false;
}
}
......@@ -56,16 +55,14 @@ Meteor.methods({
"deleteHisLink" (item) {
this.unblock();
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => start delete hislink`, item, Meteor.user().username) : '';
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) {
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");
}
try {
let options = {
data: item,
headers: {
......@@ -73,13 +70,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`deleteHisLink() => deleteHisLink have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`deleteHisLink() => error in delete hislink`, e, Meteor.user().username)
return e.reason;
}
}
......@@ -88,6 +84,7 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`activeHisLink() => start active hislink`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -95,13 +92,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`activeHisLink() => activeHisLink have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`activeHisLink() => error in active hislink`, e, Meteor.user().username)
return false;
}
}
......@@ -110,6 +106,7 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`deactiveHisLink() => start deactive hislink`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -117,13 +114,12 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`deactiveHisLink() => deactiveHisLink have been called`, result, Meteor.user().username) : '';
return true
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`deactiveHisLink() => error in deactive hislink`, e, Meteor.user().username)
return false;
}
}
......@@ -132,6 +128,7 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`authenticateHisLink() => start authenticate hislink`, item, Meteor.user().username) : '';
let options = {
data: item,
headers: {
......@@ -139,15 +136,15 @@ Meteor.methods({
'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);
Meteor.settings.enableDebug ? log.debug(`authenticateHisLink() => authenticateHisLink have been called`, result, Meteor.user().username) : '';
return result;
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`authenticateHisLink() => error in authenticate hislink`, e, Meteor.user().username)
throw new Meteor.Error(500, "error");
}
}
}
});
\ No newline at end of file
});
Meteor.settings.enableDebug ? log.debug(`endof hislinks`) : '';
\ No newline at end of file
......@@ -4,17 +4,30 @@ import { Mongo } from 'meteor/mongo';
const sqlite3 = require('sqlite3').verbose();
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({
'sqlite2mongo' (sqliteAddress) {
this.unblock();
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start sqlite2mongo `, sqliteAddress) : '';
check(sqliteAddress, String);
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start remove uploaded databases`, sqliteAddress, Meteor.user().username) : '';
TransliterationDb.remove({});
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => uploaded databases have been removed`, sqliteAddress, Meteor.user().username) : '';
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")
.then((documentArray) => {
Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start inserting fetched documents into mongodb`, documentArray.length, Meteor.user().username) : '';
let bulkOp = TransliterationDb.rawCollection().initializeUnorderedBulkOp(),
counter = 0;
......@@ -26,8 +39,8 @@ Meteor.methods({
// Send to server in batch of 1000 insert operations
if (counter % 1000 == 0) {
// Execute per 1000 operations and re-initialize every 1000 update statements
bulkOp.execute(function(e, rresult) {
// do something with result
bulkOp.execute(function(e, result) {
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => ${counter} records have been inserted into mongodb`, counter, Meteor.user().username) : '';
});
bulkOp = TransliterationDb.rawCollection().initializeUnorderedBulkOp();
}
......@@ -35,11 +48,13 @@ Meteor.methods({
// Clean up queues
if (counter % 1000 != 0) {
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;
}).catch((e) => {
log.error(`sqlite2mongo() => error in fetching records from sqlite db`, e, Meteor.user().username);
throw new Meteor.Error('500', e);
});
return promise.await();
......@@ -50,22 +65,30 @@ Meteor.methods({
function select(database, table) {
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start select db records`, { database, table }, Meteor.user().username) : '';
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 queries = [];
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => start query db records`, { database, table }, Meteor.user().username) : '';
db.each(`SELECT * FROM ${table}`, (err, row) => {
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 {
queries.push(row); // accumulate the data
queries.push(row);
}
}, (err, n) => {
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 {
resolve(queries); // resolve the promise
// Meteor.settings.enableDebug ? log.debug(`sqlite2mongo() => fetching from db have been done`, queries, Meteor.user().username) : '';
resolve(queries);
}
});
});
}
\ No newline at end of file
}
Meteor.settings.enableDebug ? log.debug(`endof translitdb`) : '';
\ No newline at end of file
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { HTTP } from 'meteor/http';
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({
'createUser1' (item) {
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`createUser() => start createUser `, item, Meteor.user().username) : '';
let userExists = Meteor.users.findOne({ username: item.username });
if (userExists == undefined || userExists == null)
if (userExists == undefined || userExists == null) {
Accounts.createUser({
...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
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`createUser() => error creating user at meteor`, e, Meteor.user().username);
return false;
}
}
......@@ -34,13 +34,13 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
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() => start`, item, Meteor.user().username) : '';
Meteor.users.update({ _id: item._id }, { $set: { "profile.fullName": item.fullName } }, { upsert: true });
Meteor.settings.enableDebug ? log.debug(`editUser() => user edited `, item, Meteor.user().username) : '';
return true
} 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;
}
}
......@@ -49,12 +49,12 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`setPassword() => start setPassword`, item, Meteor.user().username) : '';
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
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`setPassword() => error setPassword`, e, Meteor.user().username);
return false;
}
}
......@@ -64,12 +64,13 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
Meteor.settings.enableDebug ? log.debug(`deleteUser() => start delete user`, item, Meteor.user().username) : '';
Meteor.users.remove({ _id: item._id });
Meteor.settings.enableDebug ? log.debug(`deleteUser() => user have been removed `, item, Meteor.user().username) : '';
return true
} 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;
}
}
......@@ -79,15 +80,15 @@ Meteor.methods({
this.unblock();
if (this.userId) {
try {
// db.collection.update( { _id:...} , { $set: { some_key.param2 : new_info } }
Meteor.users.update({ _id: this.userId }, { $set: {...item } }, { upsert: true })
Meteor.settings.enableDebug ? log.debug(`editUserProfile() => start`, item, Meteor.user().username) : '';
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
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`editUserProfile() => error user profile editing`, e, Meteor.user().username);
return false;
}
}
}
});
\ No newline at end of file
});
Meteor.settings.enableDebug ? log.debug(`endof usersjs`) : '';
\ No newline at end of file
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Accounts } from 'meteor/accounts-base';
import { HTTP } from 'meteor/http';
let uuidv4 = require("uuid/v4");
......@@ -17,18 +16,36 @@ let internalWorklistName = 'InternalHis';
// 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({
'Fetchworklist' (devicemap) {
check(devicemap, String);
if (devicemap.length == 0) {
return true;
}
this.unblock();
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => start Fetchworklist `, devicemap, Meteor.user().username) : '';
check(devicemap, String);
if (devicemap.length == 0) {
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => devicemap is empty `, devicemap, Meteor.user().username) : '';
return true;
}
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}`);
Meteor.settings.enableDebug ? log.debug(`Fetchworklist() => worklist have been fetched from restapi `, result, Meteor.user().username) : '';
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 });
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) => {
delete patient._id;
Worklist.insert({
......@@ -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
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
log.error(`Fetchworklist() => error fetching worklist`, e, Meteor.user().username);
return false;
}
}
......@@ -92,42 +110,60 @@ Meteor.methods({
// "Smoking": 2,
// "StudyInstanceUID": "1.3.12.2.1107.5.2.30.26719.6.8122118808"
// }
// try {
try {
if (this.userId) {
delete item._id;
// workListItemSchema.validate(item);
var options = {
data: item,
headers: {
'content-type': 'application/json',
'Accept': 'application/json'
if (this.userId) {
delete item._id;
// workListItemSchema.validate(item);
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => start EditWorklist `, item, Meteor.user().username) : '';
var options = {
data: item,
headers: {
'content-type': '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);
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => editworklist restapi have been called `, result, Meteor.user().username) : '';
let result1 = JSON.parse(result.content);
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 });
Meteor.settings.enableDebug ? log.debug(`EditworklistItem() => updating temp collection for edited item in worklist have been done`, update, Meteor.user().username) : '';
return true;
}
const result = HTTP.call('POST', `${Meteor.settings.worklistUrl}/HISIntegration.svc/rest/EditworklistItem`, options);
let result1 = JSON.parse(result.content);
delete result1._id;
let update = Worklist.update({ AdmissionID: result1.AdmissionID }, { $set: result1 }, { multi: true });
return true;
} catch (e) {
log.error(`EditworklistItem() => error editing worklist`, e, Meteor.user().username);
return false;
}
},
"Register" (item) {
if (this.userId) {
item._id = uuidv4();
item.PatientDate = new Date();
try {
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`Register() => start Register patient into internalworklist `, item, Meteor.user().username) : '';
item._id = uuidv4();
item.PatientDate = new Date();
InternalWorklist.insert({
...item
});
Meteor.settings.enableDebug ? log.debug(`Register() => patient inserted into internalworklist `, {}, Meteor.user().username) : '';
InternalWorklist.insert({
...item
});
// Worklist.remove({ _userid: this.userId, _devicemap: internalWorklistName });
// Worklist.remove({ _userid: this.userId, _devicemap: internalWorklistName });
// Worklist.insert({
// ...item,
// _userid: this.userId,
// _devicemap: internalWorklistName
// });
return true;
// Worklist.insert({
// ...item,
// _userid: this.userId,
// _devicemap: internalWorklistName
// });
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 { 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() {
if (!this.userId) {
return this.ready();
}
Meteor.settings.enableDebug ? log.debug(`brandPublisher => start publish brands `, {}, Meteor.user().username) : '';
return Brands.find({}, {
disableOplog: true,
// pollingThrottleMs: 1000,
......
import Clients from '../../collections/clients.js';
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() {
// if (!this.userId) {
......@@ -9,6 +14,7 @@ Meteor.publish("clients", function() {
// return Clients.find({});
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`clientsPublisher => start publish clients `, {}, Meteor.user().username) : '';
return Clients.find({}, {
disableOplog: true,
......
import DeviceMap from '../../collections/devicemap';
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() {
if (!this.userId) {
return this.ready();
}
Meteor.settings.enableDebug ? log.debug(`devicemapsPublisher => start publish devicemaps `, {}, Meteor.user().username) : '';
return DeviceMap.find({}, {
disableOplog: true,
......
import HisLink from '../../collections/hislink.js';
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() {
if (!this.userId) {
return this.ready();
}
Meteor.settings.enableDebug ? log.debug(`hislinkPublisher => start publish hislink `, {}, Meteor.user().username) : '';
return HisLink.find({}, {
disableOplog: true,
......
import TranslitDbUploads from '../../collections/translitdbuploads.js';
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() {
if (!this.userId)
return [];
Meteor.settings.enableDebug ? log.debug(`translitdbuploadsPublisher => start publish translitdbuploads `, {}, Meteor.user().username) : '';
return TranslitDbUploads.find({ userId: this.userId }).cursor;
});
\ No newline at end of file
......@@ -3,13 +3,18 @@ import { Mongo } from 'meteor/mongo'
import TransliterationDb from '../../collections/transliterationdb';
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 }) {
if (!this.userId) {
return this.ready();
}
check(limit, Number);
Meteor.settings.enableDebug ? log.debug(`transliterationdbPublisher => start publish transliterationdb `, limit, Meteor.user().username) : '';
return TransliterationDb.find({}, {
sort: { ID: 1 },
limit: limit
......@@ -20,5 +25,6 @@ Meteor.publish("transliterationdbCount", function() {
if (!this.userId) {
return this.ready();
}
Meteor.settings.enableDebug ? log.debug(`transliterationdbCountPublisher => start publish transliterationdbCount `, {}, Meteor.user().username) : '';
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() {
// if (!this.userId) {
......@@ -7,6 +11,7 @@ Meteor.publish("users", function() {
// return Clients.find({});
if (this.userId) {
Meteor.settings.enableDebug ? log.debug(`usersPublisher => start publish users `, {}, Meteor.user().username) : '';
let isMarcoAdmin = Meteor.users.findOne({ _id: this.userId });
if (isMarcoAdmin.username == "marcoadmin") {
return Meteor.users.find({ username: { $ne: "marcoadmin" } }, {
......@@ -15,23 +20,14 @@ Meteor.publish("users", function() {
// pollingThrottleMs: 1000,
pollingIntervalMs: 1000
});
}
// return Meteor.users.find({});
else
} else
return Meteor.users.find({ _id: this.userId }, {
disableOplog: true,
// pollingThrottleMs: 1000,
pollingIntervalMs: 1000
});
// return Clients.find({}, {
// reactive: true,
// disableOplog: false,
// pollingThrottleMs: 1000,
// pollingIntervalMs: 1000
// })
} else {
......
import Worklist from '../../collections/worklist.js';
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) {
if (!this.userId) {
......@@ -9,6 +15,7 @@ Meteor.publish("worklist", function(devicemap) {
const userid = this.userId;
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 } });
});
\ No newline at end of file
......@@ -3,6 +3,12 @@ import { Mongo } from 'meteor/mongo'
import Collections from '../../collections/worklist4hislink.js';
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 }) {
if (brand == null) {
......@@ -32,6 +38,7 @@ Meteor.publish("worklist4hislink", function({ brand, limit, query }) {
// limit: limit
// });
// else
Meteor.settings.enableDebug ? log.debug(`worklist4hislink => start publish worklist4hislink `, { brand, limit, query }, Meteor.user().username) : '';
return Collections[brand].find(query, {
disableOplog: true,
// pollingThrottleMs: 1000,
......@@ -40,6 +47,7 @@ Meteor.publish("worklist4hislink", function({ brand, limit, query }) {
});
} catch (e) {
// 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'));
return [];
}
......
......@@ -12,7 +12,6 @@ import '../imports/api/methods/devicemap.js';
import '../imports/api/methods/users.js';
import '../imports/api/methods/translitdb.js';
import '../imports/api/server/publications/worklist.js';
import '../imports/api/server/publications/hislink.js';
......@@ -27,12 +26,6 @@ import '../imports/api/server/publications/transliterationdb.js';
import { Accounts } from "meteor/accounts-base";
Meteor.startup(() => {
let marcoUser = Meteor.users.findOne({ username: "marcoadmin" });
......@@ -51,6 +44,7 @@ Meteor.startup(() => {
});
Meteor.users.deny({ update: () => true });
console.log("app started");
});
......@@ -62,7 +56,6 @@ function onRoute(req, res, next) {
const middleWare = ConnectRoute(function(router) {
router.get('/', onRoute);
});
WebApp.connectHandlers
......
{
"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