-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathViewResultsetControl.cs
211 lines (185 loc) · 6.1 KB
/
ViewResultsetControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#if NO
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.Collections;
using System.Threading;
using System.Resources;
using System.Globalization;
using System.Xml;
using DigitalPlatform.ResultSet;
using DigitalPlatform.Text;
using DigitalPlatform.Marc;
using DigitalPlatform.Xml;
using DigitalPlatform.OPAC.Server;
//using DigitalPlatform.CirculationClient;
using DigitalPlatform.LibraryClient.localhost;
namespace DigitalPlatform.OPAC.Web
{
[ToolboxData("<{0}:ViewResultsetControl runat=server></{0}:ViewResultsetControl>")]
public class ViewResultsetControl : WebControl, INamingContainer
{
protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Div;
}
}
public string ResultSetName
{
get
{
this.EnsureChildControls();
HiddenField resultsetname = (HiddenField)this.FindControl("resultsetname");
if (resultsetname == null)
return "";
return resultsetname.Value;
}
set
{
this.EnsureChildControls();
HiddenField resultsetname = (HiddenField)this.FindControl("resultsetname");
resultsetname.Value = value;
}
}
public string FormatName
{
get
{
this.EnsureChildControls();
HiddenField formatname = (HiddenField)this.FindControl("formatname");
if (formatname == null)
return "";
return formatname.Value;
}
set
{
this.EnsureChildControls();
HiddenField formatname = (HiddenField)this.FindControl("formatname");
formatname.Value = value;
}
}
public int ResultCount
{
get
{
this.EnsureChildControls();
HiddenField resultcount = (HiddenField)this.FindControl("resultcount");
if (resultcount == null)
return 0;
if (string.IsNullOrEmpty(resultcount.Value) == true)
return 0;
return Convert.ToInt32(resultcount.Value);
}
set
{
this.EnsureChildControls();
HiddenField resultcount = (HiddenField)this.FindControl("resultcount");
resultcount.Value = value.ToString();
}
}
public int StartIndex
{
get
{
this.EnsureChildControls();
HiddenField startindex = (HiddenField)this.FindControl("startindex");
if (startindex == null)
return 0;
if (string.IsNullOrEmpty(startindex.Value) == true)
return 0;
return Convert.ToInt32(startindex.Value);
}
set
{
this.EnsureChildControls();
HiddenField startindex = (HiddenField)this.FindControl("startindex");
startindex.Value = value.ToString();
}
}
protected override void CreateChildControls()
{
HiddenField resultsetname = new HiddenField();
resultsetname.ID = "resultsetname";
this.Controls.Add(resultsetname);
HiddenField formatname = new HiddenField();
formatname.ID = "formatname";
this.Controls.Add(formatname);
HiddenField resultcount = new HiddenField();
resultcount.ID = "resultcount";
this.Controls.Add(resultcount);
HiddenField startindex = new HiddenField();
startindex.ID = "startindex";
this.Controls.Add(startindex);
}
public string Lang
{
get
{
return Thread.CurrentThread.CurrentUICulture.Name;
}
}
public int PageMaxLines = 10;
// 获得当前渲染内容的 HTML 片断代码
public static int GetContentText(
OpacApplication app,
SessionInfo sessioninfo,
string strResultSetName,
int nStart,
int nCount,
string strLang,
out string strResult,
out string strError)
{
strError = "";
strResult = "";
long lRet = 0;
StringBuilder text = new StringBuilder(4096);
Record[] searchresults = null;
long lStart = nStart;
long lCount = nCount;
long lTotalCount = 0;
for (; ; )
{
lRet = sessioninfo.Channel.GetSearchResult(
null,
strResultSetName,
lStart,
lCount,
"id", // cols
strLang,
out searchresults,
out strError);
if (lRet == -1 && searchresults == null)
return -1;
if (lRet != -1)
lTotalCount = lRet;
int i = 0;
foreach (Record record in searchresults)
{
// data-index 书目记录位于结果集中的偏移量
// data_recpath 书目记录路径
text.Append("<div class='bibliorecord' data-index='"+(lStart+i).ToString()+"' data-recpath='"+HttpUtility.HtmlAttributeEncode(record.Path)+"'></div>\r\n");
i++;
}
lStart += searchresults.Length;
lCount -= searchresults.Length;
if (lStart >= lTotalCount)
break;
if (lStart + lCount > lTotalCount)
lCount = lTotalCount - lStart;
if (lCount <= 0)
break;
}
strResult = text.ToString();
return 0;
}
}
}
#endif