mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
Refactoring made on offline
This commit is contained in:
+45
-48
@@ -28,7 +28,7 @@ import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.pag
|
||||
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { synchro } from 'src/app/services/socket/synchro.service';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-expediente-detail',
|
||||
@@ -56,7 +56,6 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
hideSendToPendentes = true
|
||||
searchDocumentPipe = new SearchDocumentPipe()
|
||||
|
||||
synch = synchro
|
||||
onlinecheck: boolean;
|
||||
|
||||
constructor(
|
||||
@@ -76,6 +75,7 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
private expedienteService: ExpedienteService,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService
|
||||
) {
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
if (params["params"].SerialNumber) {
|
||||
@@ -88,7 +88,11 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.getFromDB();
|
||||
|
||||
this.LoadTaskDetail(this.serialNumber);
|
||||
this.backgroundservice.registerBackService('Online', () => {
|
||||
this.LoadTaskDetail(this.serialNumber);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -102,44 +106,37 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
|
||||
getFromDB() {
|
||||
|
||||
if(synchro.connected === true) {
|
||||
this.LoadTaskDetail(this.serialNumber);
|
||||
}
|
||||
this.platform.ready().then(() => {
|
||||
this.onlinecheck = false;
|
||||
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
|
||||
console.log("expedient ditail", process)
|
||||
|
||||
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
|
||||
var origina
|
||||
if (process[0].originator === "undefined") {
|
||||
origina = ""
|
||||
} else {
|
||||
origina = JSON.parse(process[0].originator)
|
||||
}
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.onlinecheck = false;
|
||||
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
|
||||
console.log("expedient ditail", process)
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": workflow.Subject,
|
||||
"Senders": origina.email || process[0].originator,
|
||||
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
|
||||
"DocumentURL": workflow.ViewerRequest,
|
||||
"Remetente": workflow.Sender,
|
||||
"Note": workflow.TaskMessage || workflow.Note,
|
||||
"FolderId": workflow.FolderID,
|
||||
"FsId": workflow.FsId,
|
||||
"DocId": workflow.DocID,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"Status": workflow.Status,
|
||||
"DispatchNumber": workflow.DispatchNumber,
|
||||
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
|
||||
"InstanceID": workflow.InstanceID
|
||||
}
|
||||
|
||||
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
|
||||
var origina
|
||||
if (process[0].originator === "undefined") {
|
||||
origina = ""
|
||||
} else {
|
||||
origina = JSON.parse(process[0].originator)
|
||||
}
|
||||
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": workflow.Subject,
|
||||
"Senders": origina.email || process[0].originator,
|
||||
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
|
||||
"DocumentURL": workflow.ViewerRequest,
|
||||
"Remetente": workflow.Sender,
|
||||
"Note": workflow.TaskMessage || workflow.Note,
|
||||
"FolderId": workflow.FolderID,
|
||||
"FsId": workflow.FsId,
|
||||
"DocId": workflow.DocID,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"Status": workflow.Status,
|
||||
"DispatchNumber": workflow.DispatchNumber,
|
||||
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
|
||||
"InstanceID": workflow.InstanceID
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -336,17 +333,17 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
console.log('this.task.DocumentURL', this.task.DocumentURL)
|
||||
|
||||
}, (error) => {
|
||||
try {
|
||||
this.toastService.badRequest('Processo não encontrado')
|
||||
this.goBack()
|
||||
} catch (e) {
|
||||
window.history.back();
|
||||
} finally {
|
||||
if (error.status == 0) {
|
||||
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
|
||||
} else {
|
||||
|
||||
if (error.status == 0) {
|
||||
this.getFromDB();
|
||||
} else {
|
||||
try {
|
||||
this.toastService.badRequest('Processo não encontrado')
|
||||
this.goBack()
|
||||
} catch (e) {
|
||||
window.history.back();
|
||||
}
|
||||
this.toastService.badRequest('Processo não encontrado')
|
||||
}
|
||||
});
|
||||
|
||||
@@ -358,7 +355,7 @@ export class ExpedienteDetailPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async viewDocument(DocId:string, Document) {
|
||||
async viewDocument(DocId: string, Document) {
|
||||
|
||||
// this.expedienteService.viewDocument({ApplicationId:'361', DocId})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user