|
|
|
|
@ -157,7 +157,7 @@ export class AttendScanService {
|
|
|
|
|
try {
|
|
|
|
|
let result = {};
|
|
|
|
|
await this.firebasex.fetchDocumentInFirestoreCollection(userID, this.collection, (document: any) => {
|
|
|
|
|
console.log("Successfully Fetched the document with id =");
|
|
|
|
|
console.log("Successfully Fetched the document with id =" + userID);
|
|
|
|
|
result = {
|
|
|
|
|
isDocumentAvailable: true,
|
|
|
|
|
document: document
|
|
|
|
|
@ -175,6 +175,11 @@ export class AttendScanService {
|
|
|
|
|
})
|
|
|
|
|
} catch(error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
const result = {
|
|
|
|
|
isDocumentAvailable: false,
|
|
|
|
|
document: null
|
|
|
|
|
};
|
|
|
|
|
this.common.sharedService.setSharedData(result, 'firebase-document');
|
|
|
|
|
this.common.stopLoading();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -198,13 +203,22 @@ export class AttendScanService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public processFirebaseDocument(mode: string, result: any, isDocumentAvailable: boolean) {
|
|
|
|
|
public checkDocumentAvailability(resultObject: any) {
|
|
|
|
|
const firestoreDocument = this.common.sharedService.getSharedData('firebase-document', false);
|
|
|
|
|
if (firestoreDocument) {
|
|
|
|
|
if (firestoreDocument.isDocumentAvailable) {
|
|
|
|
|
this.updateFirebaseDocument(resultObject);
|
|
|
|
|
} else {
|
|
|
|
|
this.createNewDocument(resultObject);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.createNewDocument(resultObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public processFirebaseDocument(mode: string, result: any) {
|
|
|
|
|
try {
|
|
|
|
|
console.log(mode);
|
|
|
|
|
console.log(result);
|
|
|
|
|
console.log(isDocumentAvailable);
|
|
|
|
|
this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false);
|
|
|
|
|
console.log(this.userData);
|
|
|
|
|
const resultObject = {
|
|
|
|
|
modeOfAttendance: mode,
|
|
|
|
|
messageStatus: result.MessageStatus,
|
|
|
|
|
@ -213,11 +227,7 @@ export class AttendScanService {
|
|
|
|
|
pointID: result.SWP_AuthenticateAndSwipeUserModel.PointID,
|
|
|
|
|
branchDescription: result.SWP_AuthenticateAndSwipeUserModel.BranchDescription
|
|
|
|
|
}
|
|
|
|
|
if (isDocumentAvailable) {
|
|
|
|
|
this.updateFirebaseDocument(resultObject);
|
|
|
|
|
} else {
|
|
|
|
|
this.createNewDocument(resultObject);
|
|
|
|
|
}
|
|
|
|
|
this.checkDocumentAvailability(resultObject);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
@ -237,7 +247,6 @@ export class AttendScanService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public swipeAttendance() {
|
|
|
|
|
const firestoreDocument = this.common.sharedService.getSharedData('firebase-document', false);
|
|
|
|
|
const isPlatformValue = this.platform.is('ios') ? 'QR-IOS' : 'QR-ANDROID';
|
|
|
|
|
const enableFirestore = this.common.sharedService.getSharedData('enableFirestore', false);
|
|
|
|
|
|
|
|
|
|
@ -258,7 +267,7 @@ export class AttendScanService {
|
|
|
|
|
})
|
|
|
|
|
.subscribe((result: Response) => {
|
|
|
|
|
if (enableFirestore) {
|
|
|
|
|
this.processFirebaseDocument(isPlatformValue, result, firestoreDocument.isDocumentAvailable);
|
|
|
|
|
this.processFirebaseDocument(isPlatformValue, result);
|
|
|
|
|
}
|
|
|
|
|
if (this.common.validResponse(result)) {
|
|
|
|
|
console.log('response');
|
|
|
|
|
@ -268,23 +277,4 @@ export class AttendScanService {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public swipeAttendanceNFC (nfcSerialCode: any) {
|
|
|
|
|
// const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
|
|
|
|
|
// request.PointType = 2;
|
|
|
|
|
// request.Latitude = 0;
|
|
|
|
|
// request.Longitude = 0;
|
|
|
|
|
// request.QRValue = "";
|
|
|
|
|
// request.NFCValue = nfcSerialCode;
|
|
|
|
|
// request.UID = this.device.uuid;
|
|
|
|
|
// request.UserName = this.userData.EMPLOYEE_NUMBER;
|
|
|
|
|
// this.attendance_service.attendanceSwipeScanner(request, () => {
|
|
|
|
|
// console.log('Error inside in swipe attendance');
|
|
|
|
|
// }).subscribe((result: Response) => {
|
|
|
|
|
// if (this.common.validResponse(result)) {
|
|
|
|
|
// this.modalController.dismiss();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|