Sql bug fixed

This commit is contained in:
Eudes Inácio
2021-10-18 07:44:24 +01:00
parent 3ae19356c0
commit 6ed724877e
11 changed files with 389 additions and 127 deletions
@@ -100,22 +100,7 @@ export class ViewEventPage implements OnInit {
}
ngOnInit() {
if(synchro.connected === true) {
this.loadEvent();
console.log('Onlineee view-event')
} else {
this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0];
console.log("Event ditails local,", event[0])
})
console.log('Offlineee')
}
/* this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0];
console.log("Event ditails local,", event[0])
})
this.loadEvent(); */
this.getFromDb();
window.onresize = (event) => {
@@ -158,7 +143,7 @@ export class ViewEventPage implements OnInit {
const loader = this.toastService.loading();
this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res;
this.sqliteservice.addEvent(res);
this.addEventToDb(res);
console.log('Loaded one event', res)
/* this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
@@ -380,25 +365,64 @@ export class ViewEventPage implements OnInit {
}
addEventToDb(data) {
let event = {
Attendees: JSON.stringify(data.Attendees) || JSON.stringify(''),
Body: JSON.stringify(data.Body) || JSON.stringify(''),
CalendarId: data.CalendarId,
CalendarName: data.CalendarName,
Category: data.Category,
EndDate: data.EndDate,
EventId: data.EventId,
EventRecurrence: JSON.stringify(data.EventRecurrence) || JSON.stringify(''),
EventType: data.EventType,
HasAttachments: data.HasAttachments,
IsAllDayEvent: data.IsAllDayEvent,
IsMeeting: data.IsMeeting,
IsRecurring: data.IsRecurring,
Location: data.Location,
Organizer: JSON.stringify(data.Organizer) || JSON.stringify(''),
StartDate: data.StartDate,
Subject: data.Subject,
TimeZone: data.TimeZone
}
getEventsFromLocalDb() {
console.log("event id details ", this.eventId)
this.sqliteservice.updateEvent(event);
}
synchro.registerCallback('Online', () => {
getFromDb() {
if (synchro.connected === true) {
this.loadEvent();
console.log('Onlineee view-event')
})
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0];
console.log("Event ditails local,", event[0])
})
console.log('Offlineee')
} else {
this.sqliteservice.getEventById(this.eventId).then((event) => {
let arrayevent = [];
let elemet = {
Attendees: JSON.parse(event[0].Attendees) || "",
Body: JSON.parse(event[0].Body) || "",
CalendarId: event[0].CalendarId,
CalendarName: event[0].CalendarName,
Category: event[0].Category,
EndDate: event[0].EndDate,
EventId: event[0].EventId,
EventRecurrence: JSON.parse(event[0].EventRecurrence) || "",
EventType: event[0].EventType,
HasAttachments: event[0].HasAttachments,
IsAllDayEvent: event[0].IsAllDayEvent,
IsMeeting: event[0].IsMeeting,
IsRecurring: event[0].IsRecurring,
Location: event[0].Location,
Organizer: JSON.parse(event[0].Organizer) || "",
StartDate: event[0].StartDate,
Subject: event[0].Subject,
TimeZone: event[0].TimeZone
}
arrayevent.push(elemet);
this.loadedEvent = arrayevent[0];
console.log("Event ditails local,", elemet)
})
})
}
}
console.log('Offlineee')
}
}}
+77 -59
View File
@@ -18,7 +18,7 @@ import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from '../../services/socket/synchro.service';
import { BackgroundService } from 'src/app/services/background.service'
import { NetworkConnectionService } from 'src/app/services/network-connection.service'
@Component({
selector: 'app-events',
@@ -69,7 +69,7 @@ export class EventsPage implements OnInit {
expedienteGdStore = ExpedienteGdStore
listToPresent = [];
listToPresentexpediente =[]
listToPresentexpediente = []
expedienteTaskPipe = new ExpedienteTaskPipe()
@@ -93,7 +93,7 @@ export class EventsPage implements OnInit {
private screenOrientation: ScreenOrientation,
public platform: Platform,
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
private networkconnection: NetworkConnectionService
) {
this.existingScreenOrientation = this.screenOrientation.type;
console.log(this.existingScreenOrientation);
@@ -108,15 +108,14 @@ export class EventsPage implements OnInit {
});
/* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
try {
this.sqliteservice.databaseConn();
} catch (error) {
console.log("Error creating local database: ", error)
}
} */
}
}
ngOnInit() {
@@ -124,21 +123,19 @@ export class EventsPage implements OnInit {
this.segment = "Combinada";
this.profile = "mdgpr";
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.showGreeting();
this.showGreeting();
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
}
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
this.getEventsFromLocalDb();
//this.getEventsFromLocalDb();
//this.checkScreenOrientation();
@@ -206,7 +203,7 @@ export class EventsPage implements OnInit {
console.log("getAllMdOficialPessoalEvents", list)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
if(list.length > 0) {
if (list.length > 0) {
list.forEach(element => {
this.sqliteservice.addEvent(element)
});
@@ -234,7 +231,7 @@ export class EventsPage implements OnInit {
console.log("getAllPrOficialPessoalEvents", list)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
if(list.length > 0) {
if (list.length > 0) {
list.forEach(element => {
this.sqliteservice.addEvent(element)
});
@@ -324,21 +321,26 @@ export class EventsPage implements OnInit {
getEventsFromLocalDb() {
if (synchro.connected === true) {
this.showGreeting();
/* window.addEventListener('online', (on) => {
this.showGreeting();
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
}); */
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
} else {
this.platform.ready().then(async () => {
this.sqliteservice.getAllEvents().then((event:any[]) => {
// window.addEventListener('offline', (off) => {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
this.sqliteservice.getAllEvents().then((event: any[]) => {
this.listToPresent = event
this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject
@@ -346,29 +348,39 @@ export class EventsPage implements OnInit {
console.log("All events from local,", event)
})
this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
var expedientlist = [];
process.forEach((element) => {
let task = {
CreateDate: element.taskStartDate,
DocumentsQty: element.totalDocuments,
Senders: JSON.parse(element.workflowInstanceDataFields).Sender,
SerialNumber: element.serialNumber,
Status: JSON.parse(element.workflowInstanceDataFields).Status,
Subject: JSON.parse(element.workflowInstanceDataFields).Subject,
WorkflowName: element.workflowDisplayName,
activityInstanceName: element.activityInstanceName,
taskStartDate: element.taskStartDate,
}
expedientlist.push(task);
})
const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
this.sqliteservice.getAllProcess().then((res) => {
console.log('INICION ALL EVENTs', res)
})
this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
console.log('OFOFOFOOF', process)
if (process.length > 0 || process != undefined) {
var expedientlist: any = new Array();
process.forEach((element) => {
let task = {
activityInstanceName: element.activityInstanceName,
deadline: null,
serialNumber: element.serialNumber,
taskStartDate: element.taskStartDate,
totalDocuments: element.totalDocuments,
workflowDisplayName: element.workflowDisplayName,
workflowInstanceDataFields: JSON.parse(element.workflowInstanceDataFields)
}
expedientlist.push(task);
})
console.log('OFOFOFOOF22222', expedientlist)
const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
}
this.showLoader = false;
})
});
}
// });
}
@@ -426,10 +438,13 @@ export class EventsPage implements OnInit {
LoadList() {
this.processes.GetTaskListExpediente(false).subscribe(result => {
console.log("Expediente", result);
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
this.sqliteservice.addProcess(result)
result.forEach((element) => {
this.sqliteservice.addProcess(element)
})
}
const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
@@ -437,7 +452,10 @@ export class EventsPage implements OnInit {
console.log("Expediente 2", ExpedienteTask);
this.listToPresentexpediente = ExpedienteTask;
});
}, ((error) => {
console.log('Getlist error', error)
this.getEventsFromLocalDb();
}));
}
sortArrayISODate(myArray: any) {