@@ -3214,7 +3214,7 @@ public LibraryServerResult GetSearchResult(
3214
3214
string filePath = app.GetMemorySetFilePath(
3215
3215
sessioninfo,
3216
3216
strResultSetName,
3217
- strBrowseInfoStyle);
3217
+ strBrowseInfoStyle);
3218
3218
3219
3219
BeginSearch(); // 如果创建本地结果集的时间太长,前端可以用 Stop() API 中断
3220
3220
channel.Idle += new IdleEventHandler(channel_IdleEvent);
@@ -3276,6 +3276,14 @@ public LibraryServerResult GetSearchResult(
3276
3276
return result;
3277
3277
}
3278
3278
3279
+ // 2022/11/29
3280
+ if (searchresults != null
3281
+ && StringUtil.IsInList("keycount", strBrowseInfoStyle) == false)
3282
+ {
3283
+ FilterResultSet(searchresults,
3284
+ strBrowseInfoStyle);
3285
+ }
3286
+ #if OLD
3279
3287
// 2021/7/15
3280
3288
// 过滤结果
3281
3289
// 对 XML 记录进行过滤或者修改
@@ -3476,6 +3484,8 @@ public LibraryServerResult GetSearchResult(
3476
3484
}
3477
3485
}
3478
3486
}
3487
+ #endif
3488
+
3479
3489
3480
3490
result.Value = lRet;
3481
3491
result.ErrorInfo = strError;
@@ -3493,6 +3503,206 @@ public LibraryServerResult GetSearchResult(
3493
3503
}
3494
3504
}
3495
3505
3506
+ // 2022/11/29 从 GetSearchResult() 处理中转移到此处。可能和 GetBrowseRecords() 中的旧代码有差异
3507
+ // 对 XML 记录进行过滤或者修改
3508
+ void FilterResultSet(Record[] searchresults,
3509
+ string strBrowseInfoStyle)
3510
+ {
3511
+ // 2012/9/15
3512
+ // 当前用户是否能管辖一个读者库。key 为数据库名,value 为 true 或 false
3513
+ Hashtable table = new Hashtable(); // 加快运算速度
3514
+
3515
+ // return:
3516
+ // null 没有找到 getreaderinfo 前缀
3517
+ // "" 找到了前缀,并且 level 部分为空
3518
+ // 其他 返回 level 部分
3519
+ string read_level = LibraryApplication.GetReaderInfoLevel("getreaderinfo", sessioninfo.RightsOrigin);
3520
+ bool bHasGetReaderInfoRight = read_level != null;
3521
+ // bool bHasGetReaderInfoRight = StringUtil.IsInList("getreaderinfo", sessioninfo.RightsOrigin);
3522
+
3523
+ bool bHasGetBiblioInfoRight = StringUtil.IsInList("getbiblioinfo", sessioninfo.RightsOrigin);
3524
+
3525
+ foreach (Record record in searchresults)
3526
+ {
3527
+ string strDbName = ResPath.GetDbName(record.Path);
3528
+
3529
+ bool bIsReader = sessioninfo.UserType == "reader";
3530
+
3531
+ if (app.IsReaderDbName(strDbName))
3532
+ {
3533
+ // 2021/7/20
3534
+ // 先检测当前用户是否能管辖读者库 strDbName
3535
+ bool bChangeable = true;
3536
+
3537
+ if (bIsReader)
3538
+ {
3539
+ // 不是读者自己的读者记录或者下级记录(比如对象记录)
3540
+ if (sessioninfo.Account == null
3541
+ || StringUtil.IsEqualOrSubPath(sessioninfo.Account.ReaderDomPath, record.Path) == false)
3542
+ bChangeable = false;
3543
+ }
3544
+ else
3545
+ {
3546
+ object o = table[strDbName];
3547
+ if (o == null)
3548
+ {
3549
+ if (app.IsReaderDbName(strDbName,
3550
+ out bool bReaderDbInCirculation,
3551
+ out string strLibraryCode) == true)
3552
+ {
3553
+ // 检查当前操作者是否管辖这个读者库
3554
+ // 观察一个读者记录路径,看看是不是在当前用户管辖的读者库范围内?
3555
+ bChangeable = app.IsCurrentChangeableReaderPath(strDbName + "/?",
3556
+ sessioninfo.ExpandLibraryCodeList/*sessioninfo.LibraryCodeList*/);
3557
+ }
3558
+ table[strDbName] = bChangeable; // 记忆
3559
+ }
3560
+ else
3561
+ bChangeable = (bool)o;
3562
+ }
3563
+
3564
+ if (bChangeable == false)
3565
+ {
3566
+ // 当前用户不管辖此读者库
3567
+ ClearRecord(record, $"当前用户不管辖读者库 '{strDbName}'");
3568
+ record.Path = "";
3569
+ /*
3570
+ record.Cols = null;
3571
+ record.RecordBody = null;
3572
+ */
3573
+ }
3574
+ else
3575
+ {
3576
+ // 过滤
3577
+ FilterPatronRecord(record,
3578
+ strDbName,
3579
+ read_level,
3580
+ strBrowseInfoStyle);
3581
+ }
3582
+ }
3583
+ else if (app.IsBiblioDbName(strDbName))
3584
+ {
3585
+ /*
3586
+ if (bHasGetBiblioInfoRight == false)
3587
+ {
3588
+ ClearCols(record, "[滤除]");
3589
+ }
3590
+ */
3591
+ FilterBiblioRecord(record,
3592
+ strDbName,
3593
+ bHasGetBiblioInfoRight,
3594
+ sessioninfo.Access,
3595
+ strBrowseInfoStyle);
3596
+ }
3597
+ else if (app.IsItemDbName(strDbName))
3598
+ {
3599
+ if (StringUtil.IsInList("getiteminfo,getentities,order", sessioninfo.RightsOrigin) == false)
3600
+ {
3601
+ ClearXml(record);
3602
+ ClearCols(record, LibraryApplication.FILTERED);
3603
+ }
3604
+ else
3605
+ AddItemOI(app, sessioninfo, record, "filter_borrower");
3606
+ }
3607
+ else if (app.IsIssueDbName(strDbName))
3608
+ {
3609
+ if (StringUtil.IsInList("getissues,getissueinfo,order", sessioninfo.RightsOrigin) == false)
3610
+ {
3611
+ ClearXml(record);
3612
+ ClearCols(record, LibraryApplication.FILTERED);
3613
+ }
3614
+ }
3615
+ else if (app.IsOrderDbName(strDbName))
3616
+ {
3617
+ if (StringUtil.IsInList("getorders,getorderinfo,order", sessioninfo.RightsOrigin) == false)
3618
+ {
3619
+ ClearXml(record);
3620
+ ClearCols(record, LibraryApplication.FILTERED);
3621
+ }
3622
+ }
3623
+ else if (app.IsCommentDbName(strDbName))
3624
+ {
3625
+ if (StringUtil.IsInList("getcommentinfo,order", sessioninfo.RightsOrigin) == false)
3626
+ {
3627
+ ClearXml(record);
3628
+ ClearCols(record, LibraryApplication.FILTERED);
3629
+ }
3630
+ }
3631
+ else if (app.ArrivedDbName == strDbName)
3632
+ {
3633
+ if (StringUtil.IsInList("borrow,return", sessioninfo.RightsOrigin) == true
3634
+ || read_level == "")
3635
+ {
3636
+
3637
+ }
3638
+ else
3639
+ {
3640
+ ClearXml(record);
3641
+ ClearCols(record, LibraryApplication.FILTERED);
3642
+ }
3643
+ }
3644
+ else if (app.AmerceDbName == strDbName)
3645
+ {
3646
+ if (StringUtil.IsInList("getrecord", sessioninfo.RightsOrigin) == false
3647
+ || sessioninfo.UserType == "reader")
3648
+ {
3649
+ ClearXml(record);
3650
+ ClearCols(record, LibraryApplication.FILTERED);
3651
+ }
3652
+ else
3653
+ FilterAmerceRecord(record);
3654
+ // 注: GetRecord() API 可以获取违约金记录
3655
+ // settlement undosettlement deletesettlement
3656
+ }
3657
+ else if (app.MessageDbName == strDbName)
3658
+ {
3659
+ if (StringUtil.IsInList("managedatabase", sessioninfo.RightsOrigin) == false)
3660
+ {
3661
+ ClearXml(record);
3662
+ ClearCols(record, LibraryApplication.FILTERED);
3663
+ }
3664
+ }
3665
+ else if (app.PinyinDbName == strDbName
3666
+ || app.GcatDbName == strDbName
3667
+ || app.WordDbName == strDbName)
3668
+ {
3669
+ if (StringUtil.IsInList("managedatabase", sessioninfo.RightsOrigin) == false)
3670
+ {
3671
+ ClearXml(record);
3672
+ ClearCols(record, LibraryApplication.FILTERED);
3673
+ }
3674
+ }
3675
+ else
3676
+ {
3677
+ // 实用库包括 publisher / zhongcihao / dictionary / inventory 类型
3678
+ string util_type = ServerDatabaseUtility.GetUtilDbType(app.LibraryCfgDom,
3679
+ strDbName);
3680
+ if (util_type != null)
3681
+ {
3682
+ if (util_type == "inventory")
3683
+ {
3684
+ // TODO: 盘点操作的用户具有什么权限?
3685
+ if (StringUtil.IsInList("inventory", sessioninfo.RightsOrigin) == false)
3686
+ {
3687
+ ClearXml(record);
3688
+ ClearCols(record, LibraryApplication.FILTERED);
3689
+ }
3690
+ }
3691
+ else if (util_type == "publisher")
3692
+ {
3693
+ // 公开
3694
+ }
3695
+ }
3696
+ else
3697
+ {
3698
+ // TODO: 根据具体情况再扩展 if
3699
+ ClearXml(record);
3700
+ ClearCols(record, LibraryApplication.FILTERED);
3701
+ }
3702
+ }
3703
+ }
3704
+ }
3705
+
3496
3706
/*
3497
3707
* record.Cols 和 record.RecordBody.Xml 需要进行过滤处理
3498
3708
* 1) (style 中包含 xml)如果 .Xml 被 access 处理(减少字段或者禁止)
@@ -4204,6 +4414,13 @@ public LibraryServerResult GetBrowseRecords(
4204
4414
4205
4415
#endif
4206
4416
4417
+ // 2022/11/29
4418
+ if (searchresults != null)
4419
+ {
4420
+ FilterResultSet(searchresults,
4421
+ strBrowseInfoStyle);
4422
+ }
4423
+ #if OLD
4207
4424
// 对 XML 记录进行过滤或者修改
4208
4425
if (searchresults != null)
4209
4426
{
@@ -4291,6 +4508,50 @@ public LibraryServerResult GetBrowseRecords(
4291
4508
ClearCols(record, LibraryApplication.FILTERED);
4292
4509
}
4293
4510
}
4511
+ else if (app.ArrivedDbName == strDbName)
4512
+ {
4513
+ if (StringUtil.IsInList("borrow,return", sessioninfo.RightsOrigin) == true
4514
+ || read_level == "")
4515
+ {
4516
+
4517
+ }
4518
+ else
4519
+ {
4520
+ ClearXml(record);
4521
+ ClearCols(record, LibraryApplication.FILTERED);
4522
+ }
4523
+ }
4524
+ else if (app.AmerceDbName == strDbName)
4525
+ {
4526
+ if (StringUtil.IsInList("getrecord", sessioninfo.RightsOrigin) == false
4527
+ || sessioninfo.UserType == "reader")
4528
+ {
4529
+ ClearXml(record);
4530
+ ClearCols(record, LibraryApplication.FILTERED);
4531
+ }
4532
+ else
4533
+ FilterAmerceRecord(record);
4534
+ // 注: GetRecord() API 可以获取违约金记录
4535
+ // settlement undosettlement deletesettlement
4536
+ }
4537
+ else if (app.MessageDbName == strDbName)
4538
+ {
4539
+ if (StringUtil.IsInList("managedatabase", sessioninfo.RightsOrigin) == false)
4540
+ {
4541
+ ClearXml(record);
4542
+ ClearCols(record, LibraryApplication.FILTERED);
4543
+ }
4544
+ }
4545
+ else if (app.PinyinDbName == strDbName
4546
+ || app.GcatDbName == strDbName
4547
+ || app.WordDbName == strDbName)
4548
+ {
4549
+ if (StringUtil.IsInList("managedatabase", sessioninfo.RightsOrigin) == false)
4550
+ {
4551
+ ClearXml(record);
4552
+ ClearCols(record, LibraryApplication.FILTERED);
4553
+ }
4554
+ }
4294
4555
else
4295
4556
{
4296
4557
// TODO: 根据实际需要增补 else if
@@ -4357,8 +4618,10 @@ public LibraryServerResult GetBrowseRecords(
4357
4618
}
4358
4619
}
4359
4620
4360
- // 注: 0 并不表示没有命中。命中数要看 searchresults.Length
4361
- result.Value = lRet;
4621
+ #endif
4622
+
4623
+ // 注: 0 并不表示没有命中。命中数要看 searchresults.Length
4624
+ result.Value = lRet;
4362
4625
result.ErrorInfo = strError;
4363
4626
return result;
4364
4627
}
0 commit comments