GW2GetIdInfo
ทุกปัญหาที่ Glasswall engine ระบุและรายงานจะมี issue ID ที่ไม่ซ้ำกันเชื่อมโยงอยู่ API นี้ให้คำอธิบายสำหรับหมายเลข Issue ID ที่ระบุ
- C++
- C#
- Java
- Python
- JavaScript
สรุป
สำหรับเซสชัน session นั้น GW2GetIdInfo จะใส่ตัวชี้ไปยังคำอธิบายของ Glasswall Issue ID issueId ลงในอ็อบเจ็กต์ที่ outputBuffer ชี้อยู่ ความยาวของคำอธิบายเป็นไบต์จะถูกใส่ไว้ในอ็อบเจ็กต์ size_t ที่ bufferLength ชี้อยู่
#include "glasswall.core2.api.h"
int GW2GetIdInfo(
Session session,
size_t issueId,
size_t *bufferLength,
char **outputBuffer);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ค่าติดลบหมายถึงเกิดความล้มเหลว หากสำเร็จ output buffer จะถูกเติมด้วยคำอธิบาย Issue
ตัวอย่าง
#include "glasswall.core2.api.h"
char *outbuf = NULL;
size_t buflen = 0;
if (GW2OpenSession() < 0)
/* error opening session */
else
{
int status = GW2GetIdInfo(session, issueId, &buflen, &outbuf);
/* outbuf points to a buffer containing the XML file.
* Either process the data pointed to, or copy the data and process it
* after GW2CloseSession is called
*/
if (GW2CloseSession() < 0)
/* error closing session */
}
สรุป
public int GetIdInfo(
int session,
uint IssueID,
ref UIntPtr bufferLength,
out IntPtr outputBuffer)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ค่าติดลบหมายถึงเกิดความล้มเหลว หากสำเร็จ output buffer จะถูกเติมด้วยคำอธิบาย Issue
ตัวอย่าง
using glasswall_core2;
...
Glasswall glasswall = new Glasswall(); // Instance of the Glasswall wrapper
int session = glasswall.OpenSession();
int returnStatus = glasswall.GetIdInfo(session, 96, ref bufferLength, out buffer);
if (bufferLength >= 0)
{
byte[] msgArray = glasswall.CreateArrayFromBuffer(buffer, bufferLength);
// Error description for issue ID 96 now stored in a byte array
}
if (glasswall.CloseSession(session))
{
// Error Handling
}
สรุป
import com.glasswall.core2javabridge.*;
public String GW2GetIdInfoString(int session, int issueId) throws GlasswallException
คำอธิบาย
ก่อนหน้านี้ ฟังก์ชันนี้ต้องใช้การเรียกใช้ฟังก์ชันแยกกันสองครั้งเพื่อดึงข้อมูล ID ขณะนี้ได้ปรับให้เรียบง่ายขึ้นโดยส่งคืนการตั้งค่าเป็น String แล้ว ฟังก์ชันดั้งเดิมทั้งสองรายการถูกเลิกใช้แล้ว
ส่งกลับ
ฟังก์ชัน GW2GetIdInfoString จะส่งกลับ String ที่มีคำอธิบายของ issueId ที่ระบุ
จะมีการ throw ข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงคำอธิบายของ issueId ได้
สรุป - ฟังก์ชันที่เลิกใช้แล้ว
import com.glasswall.core2javabridge.*;
(Deprecated)
public int GW2GetIdInfo(int session, int issueId) throws GlasswallException
public byte[] GetIDBuffer(int session) throws GlasswallException
คำอธิบาย - ฟังก์ชันที่เลิกใช้แล้ว
ฟังก์ชัน GW2GetIdInfo จะส่งออกคำอธิบายของ issueId ที่กำหนดสำหรับ session ที่กำหนดไปยัง internal ID Buffer ดึงข้อมูลนี้ได้โดยใช้ฟังก์ชัน GetIDBuffer
ค่าที่ส่งกลับ - ฟังก์ชันที่เลิกใช้แล้ว
ฟังก์ชัน GW2GetIdInfo จะส่งกลับค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าเป็นลบจะหมายความว่าเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
GetIDBuffer ส่งกลับ byte[] ที่มีคำอธิบาย ID โดยค่าจะเป็น null หากยังไม่ได้เรียก GetIDBuffer
จะมีการ throw ข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงคำอธิบาย issue ได้
สรุป
ดึงคำอธิบายกลุ่มสำหรับ Issue ID ที่กำหนด
def get_id_info(self, issue_id: int, raise_unsupported: bool = True):
""" Retrieves the group description for the given Issue ID. e.g. issue_id 96 returns "Document Processing Instances"
Args:
issue_id (int): The issue id.
raise_unsupported (bool, optional): Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
Returns:
id_info (str): The group description for the given Issue ID.
"""
ส่งกลับ
สตริง ซึ่งเป็นคำอธิบายกลุ่มสำหรับ Issue ID ที่กำหนด
สรุป
ฟังก์ชันนี้จะวางตัวชี้ไปยังคำอธิบายของ IssueID ที่ระบุไว้ในตำแหน่งที่ระบุ
/**
*
* @param {number} session The ID of the session.
* @param {number} issueId The ID of the issue.
* @param {number} bufferLength The length of the buffer.
* @param {string} outputBuffer The location of the output buffer.
*/
GW2GetIdInfo(
session,
issueId,
bufferLength,
outputBuffer)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ค่าติดลบหมายถึงเกิดความล้มเหลว หากสำเร็จ output buffer จะถูกเติมด้วยคำอธิบาย Issue
ตัวอย่าง
const ref = require('ref-napi');
...
function buffer_to_string(buffer, buffer_size) {
if (!buffer.isNull() && ref.deref(buffer_size) > 0) {
return Buffer.from(ref.reinterpret(ref.deref(buffer), ref.deref(buffer_size), 0)).toString();
}
else {
return "";
}
}
...
output_file_buffer = ref.alloc(ref.refType(ref.types.CString));
output_buffer_size = ref.alloc(ref.types.size_t, 0);
return_status = gw.GW2GetIdInfo(session_id, 96, output_buffer_size, output_file_buffer);
let error_description = buffer_to_string(output_file_buffer, output_buffer_size);
...