Generify job
This commit is contained in:
@@ -35,15 +35,7 @@ export abstract class RequestHandler {
|
|||||||
doConfigureSingleJob(req: any, res: any): void {
|
doConfigureSingleJob(req: any, res: any): void {
|
||||||
this.sessionManager.getSession(Number(req.params.id)).then((session: SmppSession) => {
|
this.sessionManager.getSession(Number(req.params.id)).then((session: SmppSession) => {
|
||||||
let job: Job = session.getDefaultSingleJob();
|
let job: Job = session.getDefaultSingleJob();
|
||||||
if (job.pdu.source_addr !== req.body.source) {
|
job.update(req);
|
||||||
job.pdu.source_addr = req.body.source;
|
|
||||||
}
|
|
||||||
if (job.pdu.destination_addr !== req.body.destination) {
|
|
||||||
job.pdu.destination_addr = req.body.destination;
|
|
||||||
}
|
|
||||||
if (job.pdu.short_message !== req.body.message) {
|
|
||||||
job.pdu.short_message = req.body.message;
|
|
||||||
}
|
|
||||||
this.logger.log1(`Updating default job on session with ID ${req.params.id}`);
|
this.logger.log1(`Updating default job on session with ID ${req.params.id}`);
|
||||||
res.send(session.serialize());
|
res.send(session.serialize());
|
||||||
}, this.handleSessionNotFound.bind(this, req, res));
|
}, this.handleSessionNotFound.bind(this, req, res));
|
||||||
@@ -80,21 +72,7 @@ export abstract class RequestHandler {
|
|||||||
doConfigureManyJob(req: any, res: any): void {
|
doConfigureManyJob(req: any, res: any): void {
|
||||||
this.sessionManager.getSession(req.params.id).then((session: SmppSession) => {
|
this.sessionManager.getSession(req.params.id).then((session: SmppSession) => {
|
||||||
let job: Job = session.getDefaultMultipleJob();
|
let job: Job = session.getDefaultMultipleJob();
|
||||||
if (!job.pdu.source_addr && job.pdu.source_addr !== req.body.source) {
|
job.update(req);
|
||||||
job.pdu.source_addr = req.body.source;
|
|
||||||
}
|
|
||||||
if (!job.pdu.destination_addr && job.pdu.destination_addr !== req.body.destination) {
|
|
||||||
job.pdu.destination_addr = req.body.destination;
|
|
||||||
}
|
|
||||||
if (!job.pdu.short_message && job.pdu.short_message !== req.body.message) {
|
|
||||||
job.pdu.short_message = req.body.message;
|
|
||||||
}
|
|
||||||
if (!job.perSecond && job.perSecond !== req.body.perSecond) {
|
|
||||||
job.perSecond = req.body.perSecond;
|
|
||||||
}
|
|
||||||
if (!job.count && job.count !== req.body.count) {
|
|
||||||
job.count = req.body.count;
|
|
||||||
}
|
|
||||||
this.logger.log1(`Updating default job on session with ID ${req.params.id}`)
|
this.logger.log1(`Updating default job on session with ID ${req.params.id}`)
|
||||||
res.send(session.serialize());
|
res.send(session.serialize());
|
||||||
}, this.handleSessionNotFound.bind(this, req, res));
|
}, this.handleSessionNotFound.bind(this, req, res));
|
||||||
|
@@ -61,6 +61,24 @@ export class Job {
|
|||||||
return new Job({}, 1, 1);
|
return new Job({}, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(req: any) {
|
||||||
|
if (req.body.source != this._pdu.source_addr) {
|
||||||
|
this._pdu.source_addr = req.body.source;
|
||||||
|
}
|
||||||
|
if (req.body.destination != this._pdu.destination_addr) {
|
||||||
|
this._pdu.destination_addr = req.body.destination;
|
||||||
|
}
|
||||||
|
if (req.body.message != this._pdu.short_message) {
|
||||||
|
this._pdu.short_message = req.body.message;
|
||||||
|
}
|
||||||
|
if (!!req.body.perSecond && req.body.perSecond != this._perSecond) {
|
||||||
|
this._perSecond = req.body.perSecond;
|
||||||
|
}
|
||||||
|
if (!!req.body.count && req.body.count != this._count) {
|
||||||
|
this._count = req.body.count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
serialize(): object {
|
serialize(): object {
|
||||||
return {
|
return {
|
||||||
pdu: this.pdu,
|
pdu: this.pdu,
|
||||||
|
Reference in New Issue
Block a user