Skip to content

Commit 45f1c63

Browse files
整理代码
1 parent 4cfb097 commit 45f1c63

24 files changed

Lines changed: 922 additions & 83 deletions

DigitalPlatform.LibraryServer.Common/BarcodeValidator.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,66 @@ public ValidateResult Validate(string location,
174174
};
175175
}
176176

177+
// 2021/1/18
178+
/*
179+
<validator>
180+
<patron>
181+
<CMIS />
182+
<range value='P000001-P999999' />
183+
</patron>
184+
<entity>
185+
<range value='0000001-9999999'></range>
186+
</entity>
187+
<shelf>
188+
<range value='0101-0909'></range>
189+
</shelf>
190+
</validator>
191+
* */
192+
// 单独验证一种类型的号码
193+
// type 为 "patron" "entity" "shelf" 之一
194+
public ValidateResult ValidateByType(
195+
string type,
196+
string barcode)
197+
{
198+
XmlElement validator = _dom.DocumentElement;
199+
/*
200+
if (validator.GetAttributeNode("suppress") != null)
201+
{
202+
string comment = validator.GetAttribute("suppress");
203+
if (string.IsNullOrEmpty(comment))
204+
comment = $"馆藏地 '{location}' 不打算定义验证规则";
205+
return new ValidateResult
206+
{
207+
OK = false,
208+
ErrorInfo = comment,
209+
ErrorCode = "suppressed" // 不打算定义验证规则
210+
};
211+
}
212+
*/
213+
214+
XmlNodeList patron_or_entitys = validator.SelectNodes(type);
215+
foreach (XmlElement patron_or_entity in patron_or_entitys)
216+
{
217+
var ret = ProcessEntry(patron_or_entity,
218+
barcode);
219+
if (ret == true)
220+
{
221+
return new ValidateResult
222+
{
223+
OK = true,
224+
Type = patron_or_entity.Name,
225+
};
226+
}
227+
}
228+
229+
return new ValidateResult
230+
{
231+
OK = false,
232+
ErrorInfo = $"号码 '{barcode}' 不是合法的 {type} 类型号码",
233+
ErrorCode = "notMatch"
234+
};
235+
}
236+
177237
public TransformResult Transform(string location,
178238
string barcode)
179239
{
@@ -470,7 +530,7 @@ static string GetString(Engine engine, string name, string default_value)
470530
// return:
471531
// false barcode 不在定义的范围内
472532
// true barcode 在定义的范围内
473-
bool ProcessEntry(XmlElement container,
533+
public static bool ProcessEntry(XmlElement container,
474534
string barcode)
475535
{
476536
XmlNodeList nodes = container.SelectNodes("*");

RfidCenter/RfidCenter.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<SuiteName>dp2 V3</SuiteName>
3232
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
3333
<WebPage>publish.htm</WebPage>
34-
<ApplicationRevision>73</ApplicationRevision>
34+
<ApplicationRevision>74</ApplicationRevision>
3535
<ApplicationVersion>1.4.0.%2a</ApplicationVersion>
3636
<UseApplicationTrust>false</UseApplicationTrust>
3737
<CreateDesktopShortcut>true</CreateDesktopShortcut>

RfidDrivers.First/RfidDriver1.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,13 @@ static List<Reader> OpenComReaders(Hashtable name_table,
388388

389389
string[] rates = new string[] {
390390
"38400", // 最常见的放在最前面
391+
/*
391392
"19200",
392393
"9600",
393394
"57600",
394395
"115200",
395396
"230400",
397+
*/
396398
};
397399

398400
// 打开所有的 reader

RfidTool/BeginModifyDialog.Designer.cs

Lines changed: 35 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RfidTool/BeginModifyDialog.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public string UiState
3333
this.textBox_rfid_aoi,
3434
this.checkBox_uidPiiMap,
3535
this.comboBox_eas,
36+
this.checkBox_verifyPii,
37+
// this.textBox_verifyRule,
3638
};
3739
return GuiState.GetUiState(controls);
3840
}
@@ -47,6 +49,8 @@ public string UiState
4749
this.textBox_rfid_aoi,
4850
this.checkBox_uidPiiMap,
4951
this.comboBox_eas,
52+
this.checkBox_verifyPii,
53+
// this.textBox_verifyRule,
5054
};
5155
GuiState.SetUiState(controls, value);
5256
}
@@ -220,6 +224,38 @@ public bool WriteUidPiiLog
220224
}
221225
}
222226

227+
// 是否校验 PII
228+
public bool VerifyPii
229+
{
230+
get
231+
{
232+
return this.checkBox_verifyPii.Checked;
233+
}
234+
set
235+
{
236+
this.checkBox_verifyPii.Checked = value;
237+
}
238+
}
239+
240+
// 校验规则 XML 代码
241+
public string PiiVerifyRule
242+
{
243+
/*
244+
get
245+
{
246+
return this.textBox_verifyRule.Text;
247+
}
248+
set
249+
{
250+
this.textBox_verifyRule.Text = value;
251+
}
252+
*/
253+
get
254+
{
255+
return DataModel.PiiVerifyRule;
256+
}
257+
}
258+
223259
private void comboBox_eas_TextChanged(object sender, EventArgs e)
224260
{
225261
if (string.IsNullOrEmpty(this.comboBox_eas.Text)
@@ -244,5 +280,15 @@ private void checkBox_writeUidLog_CheckedChanged(object sender, EventArgs e)
244280
this.checkBox_writeUidLog.BackColor = Color.Transparent;
245281
}
246282
}
283+
284+
private void BeginModifyDialog_Load(object sender, EventArgs e)
285+
{
286+
// this.textBox_verifyRule.Text = DataModel.PiiVerifyRule;
287+
}
288+
289+
private void button_modifyVerifyRule_Click(object sender, EventArgs e)
290+
{
291+
MainForm.OpenSettingDialog(this, "activateVerifyRule");
292+
}
247293
}
248294
}

RfidTool/DataModel.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,33 @@ public static int BeforeScanSeconds
340340
}
341341
}
342342

343+
// PII 号码校验规则
344+
public static string PiiVerifyRule
345+
{
346+
get
347+
{
348+
return ClientInfo.Config.Get("general", "pii_verify_rule", null);
349+
}
350+
set
351+
{
352+
ClientInfo.Config.Set("general", "pii_verify_rule", value);
353+
}
354+
}
355+
356+
// 当写入标签的时候是否校验条码号
357+
public static bool VerifyPiiWhenWriteTag
358+
{
359+
get
360+
{
361+
return ClientInfo.Config.GetBoolean("writeTag", "verifyBarcode", false);
362+
}
363+
set
364+
{
365+
ClientInfo.Config.SetBoolean("writeTag", "verifyBarcode", value);
366+
}
367+
368+
}
369+
343370
// 写入标签
344371
public static NormalResult WriteTagInfo(string one_reader_name,
345372
TagInfo old_tag_info,

RfidTool/MainForm.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,19 @@ private void MenuItem_writeBookTags_Click(object sender, EventArgs e)
557557

558558
// 设置
559559
private void MenuItem_settings_Click(object sender, EventArgs e)
560+
{
561+
OpenSettingDialog(this);
562+
}
563+
564+
public static void OpenSettingDialog(Form parent,
565+
string style = "")
560566
{
561567
using (SettingDialog dlg = new SettingDialog())
562568
{
563-
GuiUtil.SetControlFont(dlg, this.Font);
569+
GuiUtil.SetControlFont(dlg, parent.Font);
564570
ClientInfo.MemoryState(dlg, "settingDialog", "state");
565-
566-
dlg.ShowDialog(this);
571+
dlg.OpenStyle = style;
572+
dlg.ShowDialog(parent);
567573
if (dlg.DialogResult == DialogResult.OK)
568574
DataModel.TagList.EnableTagCache = DataModel.EnableTagCache;
569575
}

0 commit comments

Comments
 (0)