Accesslog done #69

Merged
dhanshas merged 1 commits from feature/fitlien-accesslog into dev 2025-07-16 05:31:33 +00:00

View File

@ -207,10 +207,10 @@ function createGetEmployeePunchLogsRequest(username: string, password: string,
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body> <soap12:Body>
<GetEmployeePunchLogs xmlns="http://tempuri.org/"> <GetEmployeePunchLogs xmlns="http://tempuri.org/">
<UserName>cosqclient</UserName> <UserName>${escapeXml(username)}</UserName>
<Password>3bbb58d5</Password> <Password>${escapeXml(password)}</Password>
<EmployeeCode>1</EmployeeCode> <EmployeeCode>${escapeXml(employeeCode)}</EmployeeCode>
<AttendanceDate>2025-05-24</AttendanceDate> <AttendanceDate>${escapeXml(attendanceDate)}</AttendanceDate>
</GetEmployeePunchLogs> </GetEmployeePunchLogs>
</soap12:Body> </soap12:Body>
</soap12:Envelope>`; </soap12:Envelope>`;
@ -232,9 +232,15 @@ function parseGetEmployeePunchLogsResponse(soapResponse: string, attendanceDate:
const xmlDoc = parser.parseFromString(soapResponse, "text/xml"); const xmlDoc = parser.parseFromString(soapResponse, "text/xml");
const currentElement = xmlDoc.documentElement.firstChild as HTMLElement; const currentElement = xmlDoc.documentElement.firstChild as HTMLElement;
const resultText = currentElement.textContent; const resultText = currentElement.textContent;
if (!resultText || resultText.trim() === '' || resultText.trim() === ';;' || resultText.trim() === ';') {
return [];
}
const punchLogs: Date[] = []; const punchLogs: Date[] = [];
const parts = resultText!.split(';'); const parts = resultText.split(';');
for (const part of parts) { for (const part of parts) {
if (!part || part.trim() === '') {
continue;
}
try { try {
const logDateTime = new Date(part); const logDateTime = new Date(part);
if (isNaN(logDateTime.getTime())) { if (isNaN(logDateTime.getTime())) {
@ -245,8 +251,12 @@ function parseGetEmployeePunchLogsResponse(soapResponse: string, attendanceDate:
try { try {
const timeParts = part.split(','); const timeParts = part.split(',');
for (const timePart of timeParts) { for (const timePart of timeParts) {
if (!timePart || timePart.trim() === '') {
continue;
}
try { try {
const logDateTime = createDateFromTime(rootDate, timePart); const logDateTime = createDateFromTime(rootDate, timePart.trim());
punchLogs.push(logDateTime); punchLogs.push(logDateTime);
} catch { } catch {
continue; continue;
@ -261,6 +271,7 @@ function parseGetEmployeePunchLogsResponse(soapResponse: string, attendanceDate:
return sortedLogs; return sortedLogs;
} }
async function sendSoapRequest(soapRequest: string, endpoint: string) { async function sendSoapRequest(soapRequest: string, endpoint: string) {
try { try {
const headers: any = { const headers: any = {