Skip to content

Commit

Permalink
改进 MARC 机内格式转 ISO2709 格式函数,允许不强制修改 100 字段
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalPlatform committed Jun 13, 2019
1 parent e04a81c commit 2c21ecd
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 60 deletions.
7 changes: 6 additions & 1 deletion DigitalPlatform.Drawing/QrRecognitionControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ public bool StartCatch()

// camDevices.SelectCamera(((Device)(cmbDevice.SelectedItem)).Index);
camDevices.Current.NewFrame += Current_NewFrame;
// testing
// camDevices.Current.VideoResolution = camDevices.Current.VideoCapabilities[camDevices.Current.VideoCapabilities.Length - 1];
camDevices.Current.Start();
m_bInCatch = true;

Expand Down Expand Up @@ -340,8 +342,10 @@ void WaitForStop()
if (camDevices.Current == null)
return;

// this.camDevices.Current.WaitForStop();
this.camDevices.Current.WaitForStop();

// 注:不是太明白当初为啥要用这一段代码 2019/6/13
#if NO
DateTime start = DateTime.Now;
while (camDevices.Current.IsRunning)
{
Expand All @@ -351,6 +355,7 @@ void WaitForStop()
if (DateTime.Now - start > new TimeSpan(0, 0, 2))
break;
}
#endif
}

public bool InCatch
Expand Down
1 change: 1 addition & 0 deletions DigitalPlatform.LibraryServer/AppBiblio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ static int GetIso2709(string strXml,
strMARC,
strMarcSyntax,
targetEncoding,
"", // 2019/6/13
out result,
out strError);
if (nRet == -1)
Expand Down
43 changes: 39 additions & 4 deletions DigitalPlatform.MarcKernel/MarcUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4226,19 +4226,38 @@ public static int RemoveEmptySubfields(ref string strMARC,

#region 处理MARC记录转换为ISO209任务的静态函数

// 兼容原来的版本
public static int ModifyOutputMARC111(
string strMARC,
string strMarcSyntax,
Encoding encoding,
out string strResult)
{
return ModifyOutputMARC(
strMARC,
strMarcSyntax,
encoding,
"unimarc_100", // 默认的效果
out strResult);
}

// 2017/4/7 改为用 MarcRecord 处理 100$a
// 根据MARC格式类型和输出的编码方式要求,修改MARC记录的头标区或100字段。
// parameters:
// strMarcSyntax "unimarc" "usmarc"
// strStyle 修改方式。
// unimarc_100 自动覆盖修改 100 字段内和字符集编码方式有关的几个字符位
public static int ModifyOutputMARC(
string strMARC,
string strMarcSyntax,
Encoding encoding,
string strStyle,
out string strResult)
{
strResult = strMARC;

if (String.Compare(strMarcSyntax, "unimarc", true) == 0) // UNIMARC
if (StringUtil.IsInList("unimarc_100", strStyle)
&& String.Compare(strMarcSyntax, "unimarc", true) == 0) // UNIMARC
{
/*
In UNIMARC the information about enconding sets are stored in field 100,
Expand Down Expand Up @@ -4293,7 +4312,6 @@ contain blanks.
record.setFirstSubfield("100", "a", strValue, " ");
strResult = record.Text;
}

}

// 修改头标区
Expand Down Expand Up @@ -4824,6 +4842,22 @@ public static int CvtJineiToWorksheet(
return 0;
}

// 兼容原来的版本
public static int CvtJineiToISO2709(
string strSourceMARC,
string strMarcSyntax,
Encoding targetEncoding,
out byte[] baResult,
out string strError)
{
return CvtJineiToISO2709(
strSourceMARC,
strMarcSyntax,
targetEncoding,
"unimarc_100",
out baResult,
out strError);
}

// 将MARC机内格式转换为ISO2709格式
// parameters:
Expand All @@ -4838,6 +4872,7 @@ public static int CvtJineiToISO2709(
string strSourceMARC,
string strMarcSyntax,
Encoding targetEncoding,
string strStyle,
out byte[] baResult,
out string strError)
{
Expand Down Expand Up @@ -4868,11 +4903,11 @@ public static int CvtJineiToISO2709(
strSourceMARC = strSourceMARC.Replace(RECEND, '*');
}

string strMARC;
ModifyOutputMARC(strSourceMARC,
strMarcSyntax,
targetEncoding,
out strMARC);
strStyle,
out string strMARC);

// 先转换字符集
byte[] baMARC = targetEncoding.GetBytes(strMARC);
Expand Down
141 changes: 97 additions & 44 deletions DigitalPlatform.MarcKernel/OpenMarcFileDlg.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DigitalPlatform.MarcKernel/OpenMarcFileDlg.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down
1 change: 1 addition & 0 deletions DigitalPlatform.OPAC.Web/BrowseSearchResultControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ void export_Click(object sender, EventArgs e)
strMarc,
strOutMarcSyntax,
targetEncoding,
"", // 2019/6/11
out baResult,
out strError);
if (nRet == -1)
Expand Down
1 change: 1 addition & 0 deletions DigitalPlatform.rms.Client/ImportExport/ExportUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public int ExportOneRecord(
strMARC,
strOutMarcSyntax,
this.OutputEncoding,
"unimarc_100", // 2019/6/13
out byte[] baResult,
out strError);
if (nRet == -1)
Expand Down
32 changes: 23 additions & 9 deletions TestAccord/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,41 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
CloseCurrentVideoSource();
}

string _moniker = "";
Size _captureSize = new Size(0, 0);

private void ToolStripMenuItem_openCamera_Click(object sender, EventArgs e)
{
VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();
// 必须先关闭当前正在使用的的 Video Source
// CloseCurrentVideoSource();

if (form.ShowDialog(this) == DialogResult.OK)
using (VideoCaptureDeviceForm form = new VideoCaptureDeviceForm())
{
// create video source
VideoCaptureDevice videoSource = form.VideoDevice;

// open it
OpenVideoSource(videoSource);
form.VideoDeviceMoniker = _moniker;
form.CaptureSize = _captureSize;
if (form.ShowDialog(this) == DialogResult.OK)
{
// create video source
VideoCaptureDevice videoSource = form.VideoDevice;
// videoSource.VideoResolution = videoSource.VideoCapabilities[1];

// open it
OpenVideoSource(videoSource);
_moniker = form.VideoDeviceMoniker;
_captureSize = form.CaptureSize;
}
}
}

// Open video source
private void OpenVideoSource(IVideoSource source)

{
//
var test = source.Source;

// set busy cursor
this.Cursor = Cursors.WaitCursor;


// stop current video source
CloseCurrentVideoSource();

Expand All @@ -95,6 +108,7 @@ private void CloseCurrentVideoSource()
if (videoSourcePlayer.VideoSource != null)
{
videoSourcePlayer.SignalToStop();
videoSourcePlayer.WaitForStop();
videoSourcePlayer.VideoSource = null;
}
}
Expand Down
6 changes: 6 additions & 0 deletions dp2Batch/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class MainForm : System.Windows.Forms.Form
bool OutputCrLf = false; // ISO2709文件记录尾部是否加入回车换行符号
bool AddG01 = false; // ISO2709文件中的记录内是否加入-01字段?(不加时就要去除原有的,以免误会)
bool Remove998 = false; // 输出 ISO2709 文件的时候是否删除 998 字段?
bool UnimarcModify100 = true;

public CfgCache cfgCache = new CfgCache();

Expand Down Expand Up @@ -3777,6 +3778,7 @@ void DoExport(string strProjectName,
marcdlg.CrLf = this.OutputCrLf;
marcdlg.AddG01 = this.AddG01;
marcdlg.RemoveField998 = this.Remove998;
marcdlg.UnimarcModify100 = this.UnimarcModify100;

this.AppInfo.LinkFormState(marcdlg, "OpenMarcFileDlg_output_state");
marcdlg.ShowDialog(this);
Expand All @@ -3798,6 +3800,7 @@ void DoExport(string strProjectName,
this.OutputCrLf = marcdlg.CrLf;
this.AddG01 = marcdlg.AddG01;
this.Remove998 = marcdlg.RemoveField998;
this.UnimarcModify100 = marcdlg.UnimarcModify100;
encoding = marcdlg.Encoding;

return 1;
Expand Down Expand Up @@ -4808,6 +4811,7 @@ int DoExportFile(
this.OutputCrLf,
this.AddG01,
this.Remove998,
this.UnimarcModify100,
out strError);
if (nRet == -1)
{
Expand Down Expand Up @@ -5071,6 +5075,7 @@ int WriteRecordToISO2709File(
bool bOutputCrLf,
bool bAddG01,
bool bRemove998,
bool bUnimarcModify100,
out string strError)
{

Expand Down Expand Up @@ -5125,6 +5130,7 @@ int WriteRecordToISO2709File(
strMarc,
this.CurMarcSyntax,
targetEncoding,
bUnimarcModify100 ? "unimarc_100" : "",
out byte[] baResult,
out strError);

Expand Down
3 changes: 3 additions & 0 deletions dp2Catalog/Amazon/AmazonSearchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3085,6 +3085,8 @@ public void menuItem_saveOriginRecordToIso2709_Click(object sender,
if (dlg.DialogResult != DialogResult.OK)
return;

bool unimarc_modify_100 = dlg.UnimarcModify100;

Encoding targetEncoding = null;

if (dlg.EncodingName == "MARC-8")
Expand Down Expand Up @@ -3247,6 +3249,7 @@ public void menuItem_saveOriginRecordToIso2709_Click(object sender,
strMARC,
strMarcSyntax,
targetEncoding,
unimarc_modify_100 ? "unimarc_100" : "",
out baTarget,
out strError);
if (nRet == -1)
Expand Down
3 changes: 3 additions & 0 deletions dp2Catalog/MarcDetailForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,8 @@ public void SaveOriginRecordToIso2709()
if (dlg.DialogResult != DialogResult.OK)
return;

bool unimarc_modify_100 = dlg.UnimarcModify100;

Encoding targetEncoding = null;

if (dlg.EncodingName == "MARC-8"
Expand Down Expand Up @@ -2256,6 +2258,7 @@ public void SaveOriginRecordToIso2709()
strMarc,
strMarcSyntax,
targetEncoding,
unimarc_modify_100 ? "unimarc_100" : "",
out baTarget,
out strError);
if (nRet == -1)
Expand Down
1 change: 1 addition & 0 deletions dp2Catalog/Z39.50/ZSearchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4556,6 +4556,7 @@ public static int ChangeIso2709Encoding(
strMARC,
strMarcSyntax,
targetEncoding,
"", // 2019/6/13
out baTarget,
out strError);
if (nRet == -1)
Expand Down
3 changes: 3 additions & 0 deletions dp2Catalog/dp2/dp2SearchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5368,6 +5368,8 @@ public void SaveOriginRecordToIso2709()
if (dlg.DialogResult != DialogResult.OK)
return;

bool unimarc_modify_100 = dlg.UnimarcModify100;

Encoding targetEncoding = null;

if (dlg.EncodingName == "MARC-8"
Expand Down Expand Up @@ -5579,6 +5581,7 @@ public void SaveOriginRecordToIso2709()
strRecord,
strMarcSyntax,
targetEncoding,
unimarc_modify_100 ? "unimarc_100" : "",
out baTarget,
out strError);
if (nRet == -1)
Expand Down
11 changes: 11 additions & 0 deletions dp2Circulation/Charging/QuickChargingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,12 @@ static string GetEasType(string strText)
return "";
Hashtable table = StringUtil.ParseParameters(strText, ',', ':');
string strTypeOfUsage = GetValue(table, "tou");

// 2019/6/13
// 注意:特殊处理!
if (strTypeOfUsage == "32")
strTypeOfUsage = "10";

if (string.IsNullOrEmpty(strTypeOfUsage) == false && strTypeOfUsage[0] != '1')
return "";
string strBarcode = GetValue(table, "pii");
Expand Down Expand Up @@ -3880,9 +3886,14 @@ private async void toolStripButton_faceInput_Click(object sender, EventArgs e)
}
this.Invoke((Action)(() =>
{
// 2019/6/13
this.Activate();
API.SetForegroundWindow(this.Handle);

if (result.Value == 1)
{
this.textBox_input.Text = result.Patron;
this.textBox_input.Focus();
// 触发回车
DoEnter();
}
Expand Down
3 changes: 3 additions & 0 deletions dp2Circulation/SearchForms/BiblioSearchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9518,6 +9518,8 @@ void menu_saveToMarcFile_Click(object sender, EventArgs e)
if (dlg.DialogResult != DialogResult.OK)
return;

bool unimarc_modify_100 = dlg.UnimarcModify100;

string strCatalogingRule = dlg.Rule;
if (strCatalogingRule == "<无限制>")
strCatalogingRule = null;
Expand Down Expand Up @@ -9766,6 +9768,7 @@ void menu_saveToMarcFile_Click(object sender, EventArgs e)
strMARC,
strMarcSyntax,
targetEncoding,
unimarc_modify_100 ? "unimarc_100" : "",
out baTarget,
out strError);
if (nRet == -1)
Expand Down
3 changes: 3 additions & 0 deletions dp2Circulation/SearchForms/ItemSearchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9394,6 +9394,8 @@ void menu_saveBiblioRecordToMarcFile_Click(object sender, EventArgs e)
if (dlg.DialogResult != DialogResult.OK)
return;

bool unimarc_modify_100 = dlg.UnimarcModify100;

string strCatalogingRule = "";

if (bTableExists == false)
Expand Down Expand Up @@ -9698,6 +9700,7 @@ void menu_saveBiblioRecordToMarcFile_Click(object sender, EventArgs e)
record.Text,
strMarcSyntax,
targetEncoding,
unimarc_modify_100 ? "unimarc_100" : "",
out byte[] baTarget,
out strError);
if (nRet == -1)
Expand Down
3 changes: 3 additions & 0 deletions dp2Circulation/UtilityForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,8 @@ private void button_worToIso_convert_Click(object sender, EventArgs e)
if (dlg.DialogResult != DialogResult.OK)
return;

bool unimarc_modify_100 = dlg.UnimarcModify100;

Encoding targetEncoding = null;

nRet = Global.GetEncoding(dlg.EncodingName,
Expand Down Expand Up @@ -1263,6 +1265,7 @@ private void button_worToIso_convert_Click(object sender, EventArgs e)
strMARC,
dlg.MarcSyntax,
targetEncoding,
unimarc_modify_100 ? "unimarc_100" : "",
out baTarget,
out strError);
if (nRet == -1)
Expand Down
Loading

0 comments on commit 2c21ecd

Please sign in to comment.