-
Notifications
You must be signed in to change notification settings - Fork 54
library.xml 中脚本配置指南
本文介绍 library.xml 文件中 script 元素内的脚本配置方法
本函数用于定制册是否允许外借的特性。
早期版本里,本函数的类型是这样的:
public bool ItemCanBorrow(
bool bRenew,
Account account,
XmlDocument itemdom,
out string strMessageText)
新版本(dp2library 3.7)继续兼容这种类型。但新版本提供了新的类型,能更好地参考读者记录信息:
public bool ItemCanBorrow(
bool bRenew,
Account account,
XmlDocument readerdom, // 这是新增加的参数
XmlDocument itemdom,
out string strMessageText)
本函数会在 Borrow() API 调用的时候内部调用,用以决定一册图书是否允许外借。如果 library.xml 中定义了本函数,则馆藏地定义中的是否允许外借参数被超越,以本函数为准。
本函数还可能会在 GetEntities() API 调用的时候内部调用。当 strStyle 参数中包含 "opac" 这个子串的时候,本函数会被调用,用以判断一册是否允许外借,以便给即将返回的册记录 XML 结构中根元素添加 canBorrow 元素,此元素的文本部分是是否允许外界的说明性文字,此元素还有一个 canBorrow 属性,属性值 yes 或者 no 表示是否允许外借。但需要注意:
因为 GetEntities() API 执行的时候,场景不允许给出具体的读者记录,所以触发调用脚本函数 ItemCanBorrow() 的时候,其 readerdom 参数为 null。因为这个 API 可以理解为比较泛泛地了解册记录是否允许外借,并不针对具体的读者记录。那么,当编写这个脚本函数的时候,要注意判断 readerdom 是否为 null,并在 null 情况下做适当变通处理。这里也可以看出,这时候返回的册记录中 canBorrow 元素可能得不到很精确的(是否允许外借)信息。
本函数用于定制册是否允许还回的特性。
早期版本里,本函数的类型是这样的:
public bool ItemCanReturn(Account account,
XmlDocument itemdom,
out string strMessageText)
新版本(dp2library 3.7)继续兼容这种类型。但新版本提供了新的类型,能更好地参考读者记录信息:
public bool ItemCanReturn(Account account,
XmlDocument readerdom, // 这是新增加的参数
XmlDocument itemdom,
out string strMessageText)
继续卖力的生长吧 / 离参天还很远呢 / 继续飞快的发芽吧 / 要遮天蔽日还要许久呢