|
|
|
@ -136,29 +136,6 @@ export class AttendScanService {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async checkFirestoreDocument(userID : string) {
|
|
|
|
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
await this.firebasex.fetchDocumentInFirestoreCollection(userID, this.collection, (document: any) => {
|
|
|
|
|
|
|
|
console.log("Successfully Fetched the document with id =");
|
|
|
|
|
|
|
|
result = {
|
|
|
|
|
|
|
|
isDocumentAvailable: true,
|
|
|
|
|
|
|
|
document: document
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.common.sharedService.setSharedData(result, 'firebase-document');
|
|
|
|
|
|
|
|
this.common.stopLoading();
|
|
|
|
|
|
|
|
}, (error: any) => {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
result = {
|
|
|
|
|
|
|
|
isDocumentAvailable: false,
|
|
|
|
|
|
|
|
document: null
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.common.sharedService.setSharedData(result, 'firebase-document');
|
|
|
|
|
|
|
|
this.common.stopLoading();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fakeSwipeAttendance() {
|
|
|
|
fakeSwipeAttendance() {
|
|
|
|
const request: any = {};
|
|
|
|
const request: any = {};
|
|
|
|
request.Latitude = this.lat;
|
|
|
|
request.Latitude = this.lat;
|
|
|
|
@ -176,39 +153,73 @@ export class AttendScanService {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async checkFirestoreDocument(userID : string) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
await this.firebasex.fetchDocumentInFirestoreCollection(userID, this.collection, (document: any) => {
|
|
|
|
|
|
|
|
console.log("Successfully Fetched the document with id =");
|
|
|
|
|
|
|
|
result = {
|
|
|
|
|
|
|
|
isDocumentAvailable: true,
|
|
|
|
|
|
|
|
document: document
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.common.sharedService.setSharedData(result, 'firebase-document');
|
|
|
|
|
|
|
|
this.common.stopLoading();
|
|
|
|
|
|
|
|
}, (error: any) => {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
result = {
|
|
|
|
|
|
|
|
isDocumentAvailable: false,
|
|
|
|
|
|
|
|
document: null
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.common.sharedService.setSharedData(result, 'firebase-document');
|
|
|
|
|
|
|
|
this.common.stopLoading();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
} catch(error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
this.common.stopLoading();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public updateFirebaseDocument(resultObject: any) {
|
|
|
|
public updateFirebaseDocument(resultObject: any) {
|
|
|
|
let currentFirebaseDocument = this.common.sharedService.getSharedData('firebase-document');
|
|
|
|
try {
|
|
|
|
let currentSwipeArray = currentFirebaseDocument.document.swipeData;
|
|
|
|
let currentFirebaseDocument = this.common.sharedService.getSharedData('firebase-document');
|
|
|
|
currentSwipeArray.push(resultObject);
|
|
|
|
let currentSwipeArray = currentFirebaseDocument.document.swipeData;
|
|
|
|
const updatedDocument = {
|
|
|
|
currentSwipeArray.push(resultObject);
|
|
|
|
swipeData: currentSwipeArray
|
|
|
|
const updatedDocument = {
|
|
|
|
};
|
|
|
|
swipeData: currentSwipeArray
|
|
|
|
console.log(updatedDocument);
|
|
|
|
};
|
|
|
|
this.firebasex.updateDocumentInFirestoreCollection(this.userData.EMPLOYEE_NUMBER, updatedDocument, this.collection, () => {
|
|
|
|
console.log(updatedDocument);
|
|
|
|
console.log("Successfully added document with id=" + this.userData.EMPLOYEE_NUMBER);
|
|
|
|
this.firebasex.updateDocumentInFirestoreCollection(this.userData.EMPLOYEE_NUMBER, updatedDocument, this.collection, () => {
|
|
|
|
}, (error) => {
|
|
|
|
console.log("Successfully added document with id=" + this.userData.EMPLOYEE_NUMBER);
|
|
|
|
console.error("Error adding document: " + error);
|
|
|
|
}, (error) => {
|
|
|
|
});
|
|
|
|
console.error("Error adding document: " + error);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public processFirebaseDocument(mode: string, result: any, isDocumentAvailable: boolean) {
|
|
|
|
public processFirebaseDocument(mode: string, result: any, isDocumentAvailable: boolean) {
|
|
|
|
console.log(mode);
|
|
|
|
try {
|
|
|
|
console.log(result);
|
|
|
|
console.log(mode);
|
|
|
|
console.log(isDocumentAvailable);
|
|
|
|
console.log(result);
|
|
|
|
this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false);
|
|
|
|
console.log(isDocumentAvailable);
|
|
|
|
console.log(this.userData);
|
|
|
|
this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false);
|
|
|
|
const resultObject = {
|
|
|
|
console.log(this.userData);
|
|
|
|
modeOfAttendance: mode,
|
|
|
|
const resultObject = {
|
|
|
|
messageStatus: result.MessageStatus,
|
|
|
|
modeOfAttendance: mode,
|
|
|
|
transactionID: result.SWP_AuthenticateAndSwipeUserModel.TransactionID,
|
|
|
|
messageStatus: result.MessageStatus,
|
|
|
|
userID: result.SWP_AuthenticateAndSwipeUserModel.UserID,
|
|
|
|
transactionID: result.SWP_AuthenticateAndSwipeUserModel.TransactionID,
|
|
|
|
pointID: result.SWP_AuthenticateAndSwipeUserModel.PointID,
|
|
|
|
userID: result.SWP_AuthenticateAndSwipeUserModel.UserID,
|
|
|
|
branchDescription: result.SWP_AuthenticateAndSwipeUserModel.BranchDescription
|
|
|
|
pointID: result.SWP_AuthenticateAndSwipeUserModel.PointID,
|
|
|
|
}
|
|
|
|
branchDescription: result.SWP_AuthenticateAndSwipeUserModel.BranchDescription
|
|
|
|
if (isDocumentAvailable) {
|
|
|
|
}
|
|
|
|
this.updateFirebaseDocument(resultObject);
|
|
|
|
if (isDocumentAvailable) {
|
|
|
|
} else {
|
|
|
|
this.updateFirebaseDocument(resultObject);
|
|
|
|
this.createNewDocument(resultObject);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.createNewDocument(resultObject);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|