Accesslog done #69
@ -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:Body>
|
||||
<GetEmployeePunchLogs xmlns="http://tempuri.org/">
|
||||
<UserName>cosqclient</UserName>
|
||||
<Password>3bbb58d5</Password>
|
||||
<EmployeeCode>1</EmployeeCode>
|
||||
<AttendanceDate>2025-05-24</AttendanceDate>
|
||||
<UserName>${escapeXml(username)}</UserName>
|
||||
<Password>${escapeXml(password)}</Password>
|
||||
<EmployeeCode>${escapeXml(employeeCode)}</EmployeeCode>
|
||||
<AttendanceDate>${escapeXml(attendanceDate)}</AttendanceDate>
|
||||
</GetEmployeePunchLogs>
|
||||
</soap12:Body>
|
||||
</soap12:Envelope>`;
|
||||
@ -232,9 +232,15 @@ function parseGetEmployeePunchLogsResponse(soapResponse: string, attendanceDate:
|
||||
const xmlDoc = parser.parseFromString(soapResponse, "text/xml");
|
||||
const currentElement = xmlDoc.documentElement.firstChild as HTMLElement;
|
||||
const resultText = currentElement.textContent;
|
||||
if (!resultText || resultText.trim() === '' || resultText.trim() === ';;' || resultText.trim() === ';') {
|
||||
return [];
|
||||
}
|
||||
const punchLogs: Date[] = [];
|
||||
const parts = resultText!.split(';');
|
||||
const parts = resultText.split(';');
|
||||
for (const part of parts) {
|
||||
if (!part || part.trim() === '') {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const logDateTime = new Date(part);
|
||||
if (isNaN(logDateTime.getTime())) {
|
||||
@ -245,8 +251,12 @@ function parseGetEmployeePunchLogsResponse(soapResponse: string, attendanceDate:
|
||||
try {
|
||||
const timeParts = part.split(',');
|
||||
for (const timePart of timeParts) {
|
||||
if (!timePart || timePart.trim() === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
const logDateTime = createDateFromTime(rootDate, timePart);
|
||||
const logDateTime = createDateFromTime(rootDate, timePart.trim());
|
||||
punchLogs.push(logDateTime);
|
||||
} catch {
|
||||
continue;
|
||||
@ -261,6 +271,7 @@ function parseGetEmployeePunchLogsResponse(soapResponse: string, attendanceDate:
|
||||
return sortedLogs;
|
||||
}
|
||||
|
||||
|
||||
async function sendSoapRequest(soapRequest: string, endpoint: string) {
|
||||
try {
|
||||
const headers: any = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user