Beispiel #1
0
        // 根据 BookItem 对象构造一个 LogicChipItem 对象
        public static LogicChipItem BuildChip(ReaderEditControl patron,
                                              string library_code,
                                              out string strWarning)
        {
            strWarning = "";

            if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "3.11") < 0)
            {
                throw new Exception("当前连接的 dp2library 必须为 3.11 或以上版本,才能使用 RFID 有关功能");
            }

            LogicChipItem result = new LogicChipItem();

            result.AFI   = LogicChipItem.DefaultPatronAFI;
            result.DSFID = LogicChipItem.DefaultDSFID;
            result.EAS   = LogicChipItem.DefaultPatronEAS;

            // barcode --> PII
            result.NewElement(ElementOID.PII, patron.Barcode);

            // location --> OwnerInstitution 要配置映射关系
            // 定义一系列前缀对应的 ISIL 编码。如果 location 和前缀前方一致比对成功,则得到 ISIL 编码
            var ret = MainForm.GetOwnerInstitution(
                Program.MainForm.RfidCfgDom,
                library_code + "/", // 2020/7/17 增加 "/"
                out string isil,
                out string alternative);

            if (string.IsNullOrEmpty(isil) == false)
            {
                result.NewElement(ElementOID.OwnerInstitution, isil);
            }
            else if (string.IsNullOrEmpty(alternative) == false)
            {
                result.NewElement(ElementOID.AlternativeOwnerInstitution, alternative);
            }
            else
            {
                strWarning = $"当前 library.xml 中没有为馆代码 '{library_code}' 配置机构代码,这样创建的(没有包含机构代码的) 读者卡容易和其他机构的发生混淆";
            }

            // TypeOfUsage?
            // (十六进制两位数字)
            {
                string typeOfUsage = "80";
                result.NewElement(ElementOID.TypeOfUsage, typeOfUsage);
            }

            // TODO: 验证码,用扩展元素

            return(result);
        }
Beispiel #2
0
        // 根据 BookItem 对象构造一个 LogicChipItem 对象
        public static LogicChipItem BuildChip(BookItem book_item)
        {
            if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "3.11") < 0)
            {
                throw new Exception("当前连接的 dp2library 必须为 3.11 或以上版本,才能使用 RFID 有关功能");
            }

            LogicChipItem result = new LogicChipItem();

            result.AFI   = LogicChipItem.DefaultBookAFI;
            result.DSFID = LogicChipItem.DefaultDSFID;
            result.EAS   = LogicChipItem.DefaultBookEAS;

            // barcode --> PII
            result.NewElement(ElementOID.PII, book_item.Barcode);

            // location --> OwnerInstitution 要配置映射关系
            // 定义一系列前缀对应的 ISIL 编码。如果 location 和前缀前方一致比对成功,则得到 ISIL 编码
            MainForm.GetOwnerInstitution(
                Program.MainForm.RfidCfgDom,
                StringUtil.GetPureLocation(book_item.Location),
                out string isil,
                out string alternative);
            if (string.IsNullOrEmpty(isil) == false)
            {
                result.NewElement(ElementOID.OwnerInstitution, isil);
            }
            else if (string.IsNullOrEmpty(alternative) == false)
            {
                result.NewElement(ElementOID.AlternativeOwnerInstitution, alternative);
            }

            // SetInformation?
            // 可以考虑用 volume 元素映射过来。假设 volume 元素内容符合 (xx,xx) 格式
            string value = MainForm.GetSetInformation(book_item.Volume);

            if (value != null)
            {
                result.NewElement(ElementOID.SetInformation, value);
            }

            // TypeOfUsage?
            // (十六进制两位数字)
            // 10 一般流通馆藏
            // 20 非流通馆藏。保存本库? 加工中?
            // 70 被剔旧的馆藏。和 state 元素应该有某种对应关系,比如“注销”
            {
                string typeOfUsage = "";
                if (StringUtil.IsInList("注销", book_item.State) == true ||
                    StringUtil.IsInList("丢失", book_item.State) == true)
                {
                    typeOfUsage = "70";
                }
                else if (string.IsNullOrEmpty(book_item.State) == false &&
                         StringUtil.IsInList("加工中", book_item.State) == true)
                {
                    typeOfUsage = "20";
                }
                else
                {
                    typeOfUsage = "10";
                }

                result.NewElement(ElementOID.TypeOfUsage, typeOfUsage);
            }

            // AccessNo --> ShelfLocation
            // 注意去掉 {ns} 部分
            result.NewElement(ElementOID.ShelfLocation,
                              StringUtil.GetPlainTextCallNumber(book_item.AccessNo)
                              );

            return(result);
        }