필드없고 지시기호만 있는데이터도 필터링

This commit is contained in:
2025-10-11 14:31:24 +09:00
parent 2835f8d14e
commit 7d1286b7a7
7 changed files with 105 additions and 57 deletions

View File

@@ -8,7 +8,10 @@
"Bash(echo $OS)",
"Bash(claude mcp:*)",
"WebSearch",
"WebSearch"
"WebSearch",
"Bash(git commit:*)",
"Bash(git config:*)",
"Bash(git push:*)"
],
"deny": [],
"ask": []

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2025.10.11.0100")]
[assembly: AssemblyFileVersion("2025.10.11.0100")]
[assembly: AssemblyVersion("2025.10.11.1430")]
[assembly: AssemblyFileVersion("2025.10.11.1430")]

View File

@@ -2155,9 +2155,14 @@ namespace WindowsFormsApp1
/// </summary>
/// <param name="Marc">한줄짜리 마크</param>
/// <returns></returns>
public string ConvertMarcType(string Marc)
public string ConvertMarcType(string Marc, out string errmessage)
{
if (Marc.Length < 3) return "";
errmessage = string.Empty;
if (Marc.Length < 3)
{
errmessage = "MARC 데이터길이가 너무 짧습니다.";
return "";
}
string result = "";
@@ -2189,8 +2194,20 @@ namespace WindowsFormsApp1
else if (res.StartsWith("00")) { res += "\t \t" + Field[a]; }
else
{
if (Field[a].Replace("▲","").Trim().isEmpty()) //no data
var fieldValue = Field[a].Trim();
bool isEmpty = false;
if (fieldValue.IndexOf("▼") != -1)
{
var dataArea = fieldValue.Substring(fieldValue.IndexOf("▼") + 1);
isEmpty = dataArea.ToString().isEmpty();
}
else
{
isEmpty = fieldValue.Replace("▲", "").Trim().isEmpty();
}
if (isEmpty) //no data
{
errmessage = (errmessage.isEmpty() == false ? "\n" : "") + "태그 " + TagNum[a] + " 에 데이터가 없습니다.";
Console.WriteLine("field length error");
res = string.Empty;
}

View File

@@ -255,7 +255,7 @@ namespace UniMarc.마크
String_Text st = new String_Text();
string ViewMarc = st.ConvertMarcType(SelectMarc);
string ViewMarc = st.ConvertMarcType(SelectMarc,out string errmesage);
List<string> Tmp = new List<string>(ViewMarc.Split('\n'));
for (int a = 0; a < Tmp.Count; a++)
{

View File

@@ -272,7 +272,7 @@ namespace UniMarc.마크
else
return;
richTextBox1.Text = st.ConvertMarcType(dataGridView1.Rows[row].Cells["Marc"].Value.ToString());
richTextBox1.Text = st.ConvertMarcType(dataGridView1.Rows[row].Cells["Marc"].Value.ToString(),out string errmesage);
}
private void Btn_Excel_Click(object sender, EventArgs e)

View File

@@ -1,4 +1,5 @@
using ExcelTest;
using AR;
using ExcelTest;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -106,11 +107,13 @@ namespace WindowsFormsApp1.Mac
for (int a = 0; a < ary.Length; a++)
{
if (a % 16 == 00) { Grid[00] = ary[a]; } // idx
if (a % 16 == 01) { Grid[01] = ary[a];
if (a % 16 == 01)
{
Grid[01] = ary[a];
if (ary[a] == "") Grid[02] = tCnt.ToString();
tCnt++;
} // num
if (a % 16 == 02) { Grid[02] = ary[a];} // r_num
if (a % 16 == 02) { Grid[02] = ary[a]; } // r_num
if (a % 16 == 03) { Grid[03] = ary[a]; } // class_symbol
if (a % 16 == 04) { Grid[04] = ary[a]; } // author_symbol
if (a % 16 == 05) { Grid[09] = ary[a]; } // ISBN
@@ -123,7 +126,9 @@ namespace WindowsFormsApp1.Mac
if (a % 16 == 12) { Grid[16] = ary[a]; } // book_comp
if (a % 16 == 13) { Grid[17] = ary[a]; } // price
if (a % 16 == 14) { Grid[18] = ary[a]; } // midx
if (a % 16 == 15) { Grid[19] = ary[a]; // marc
if (a % 16 == 15)
{
Grid[19] = ary[a]; // marc
string[] vcf = st.Take_Tag(ary[a], GetTag);
Grid[5] = vcf[0];
@@ -189,7 +194,8 @@ namespace WindowsFormsApp1.Mac
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow r in dataGridView1.Rows) {
foreach (DataGridViewRow r in dataGridView1.Rows)
{
if (((CheckBox)sender).Checked)
r.Cells["colCheck"].Value = "T";
else
@@ -204,7 +210,8 @@ namespace WindowsFormsApp1.Mac
if (row < 0) return;
if (dataGridView1.Rows[row].Cells[col].ReadOnly) {
if (dataGridView1.Rows[row].Cells[col].ReadOnly)
{
string[] Marc = {
dataGridView1.Rows[row].Cells["marc"].Value.ToString(),
dataGridView1.Rows[row].Cells["midx"].Value.ToString(),
@@ -253,7 +260,8 @@ namespace WindowsFormsApp1.Mac
private void tb_SearchTag_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter) {
if (e.KeyCode == Keys.Enter)
{
Search_Tag();
}
}
@@ -269,7 +277,7 @@ namespace WindowsFormsApp1.Mac
for (int a = 0; a < dataGridView1.Rows.Count; a++)
{
string marc = dataGridView1.Rows[a].Cells["marc"].Value.ToString();
string[] tag = st.Take_Tag(marc, SearchTag,true);
string[] tag = st.Take_Tag(marc, SearchTag, true);
dataGridView1.Rows[a].Cells["search_tag2"].Value = tag[0];
BackUpTag.Add(tag[0]);
}
@@ -296,9 +304,9 @@ namespace WindowsFormsApp1.Mac
for (int a = 0; a < dataGridView1.Rows.Count; a++)
{
string Content = string.Empty;
if(dataGridView1.Rows[a].Cells["search_tag2"].Value!=null)
if (dataGridView1.Rows[a].Cells["search_tag2"].Value != null)
Content = dataGridView1.Rows[a].Cells["search_tag2"].Value.ToString();
else if(dataGridView1.Rows[a].Cells["search_tag2"].Value == null)
else if (dataGridView1.Rows[a].Cells["search_tag2"].Value == null)
Content = "delete";
if (Content == "") continue;
string marc = dataGridView1.Rows[a].Cells["marc"].Value.ToString();
@@ -435,7 +443,7 @@ namespace WindowsFormsApp1.Mac
private void btn_Save_Click(object sender, EventArgs e)
{
string table = "Specs_Marc";
string[] Edit_Col = { "marc", "r_num", "class_symbol", "author_symbol", "prefix","price", "user", "editDate" };
string[] Edit_Col = { "marc", "r_num", "class_symbol", "author_symbol", "prefix", "price", "user", "editDate" };
string[] Where_Col = { "idx" };
for (int a = 0; a < dataGridView1.Rows.Count; a++)
@@ -530,6 +538,7 @@ namespace WindowsFormsApp1.Mac
default: break;
}
string totalerrmsg = "";
for (int a = 0; a < dataGridView1.Rows.Count; a++)
{
if (dataGridView1.Rows[a].Cells["marc"].Value.ToString() == "" &&
@@ -539,14 +548,17 @@ namespace WindowsFormsApp1.Mac
if (dataGridView1.Rows[a].Cells["colCheck"].Value.ToString() != "T")
continue;
if (a==825) Console.WriteLine( "test" );
if (a == 825) Console.WriteLine("test");
string marc = dataGridView1.Rows[a].Cells["Marc"].Value.ToString().Replace("₩", "\\");
marc = st.ConvertMarcType(marc);
marc = st.ConvertMarcType(marc, out string errmesage);
marc = st.made_Ori_marc(marc, FileEncodingType);
Marc_data += marc;
if (errmesage.isEmpty() == false) totalerrmsg += (totalerrmsg.isEmpty() ? "\n" : "") + errmesage;
}
if (totalerrmsg.isEmpty() == false)
UTIL.MsgI("경고 발생\n"+totalerrmsg);
string FileName;
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "저장 경로를 지정하세요.";
@@ -555,15 +567,18 @@ namespace WindowsFormsApp1.Mac
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
if (FileEncodingType == "ANSI") {
if (FileEncodingType == "ANSI")
{
FileName = saveFileDialog.FileName;
System.IO.File.WriteAllText(FileName, Marc_data, Encoding.Default);
}
else if (FileEncodingType == "UTF-8") {
else if (FileEncodingType == "UTF-8")
{
FileName = saveFileDialog.FileName;
System.IO.File.WriteAllText(FileName, Marc_data, Encoding.UTF8);
}
else if (FileEncodingType == "UniCode") {
else if (FileEncodingType == "UniCode")
{
FileName = saveFileDialog.FileName;
System.IO.File.WriteAllText(FileName, Marc_data, Encoding.Unicode);
}
@@ -575,12 +590,17 @@ namespace WindowsFormsApp1.Mac
private void btn_ApplyMacro_Click(object sender, EventArgs e)
{
Set_Macro sm = new Set_Macro(this, dataGridView1);
sm.ViewMarcArray = Make_MarcArray();
sm.ViewMarcArray = Make_MarcArray(out string errmessage);
sm.Show();
if(errmessage.isEmpty() == false)
UTIL.MsgI("경고 발생\n" + errmessage);
}
private void btnTag040_Click(object sender, EventArgs e)
{
string[] tData = Make_MarcArray();
string[] tData = Make_MarcArray(out string errmessage);
if (errmessage.isEmpty() == false)
UTIL.MsgI("경고 발생\n" + errmessage);
string tNewTagData = tbTag040.Text;
List<string> tSplitMarc;
for (int i = 0; i < tData.Length; i++)
@@ -662,7 +682,7 @@ namespace WindowsFormsApp1.Mac
tField.Add(data[a] + "▲");
}
tTag008IDX = tTagNum.FindIndex(x => x == "008");
if (tTag008IDX == -1 ) continue;
if (tTag008IDX == -1) continue;
string tData = tField[tTag008IDX];
List<string> tListData = tData.ToCharArray().ToList().ConvertAll(x => x.ToString());
if (tListData.Count < 40) continue;
@@ -679,8 +699,9 @@ namespace WindowsFormsApp1.Mac
}
private string[] Make_MarcArray()
private string[] Make_MarcArray(out string totalerrmsg)
{
totalerrmsg = string.Empty;
String_Text st = new String_Text();
string[] MarcArray = new string[dataGridView1.RowCount];
for (int a = 0; a < dataGridView1.Rows.Count; a++)
@@ -693,8 +714,8 @@ namespace WindowsFormsApp1.Mac
continue;
string marc = dataGridView1.Rows[a].Cells["Marc"].Value.ToString().Replace("₩", "\\");
marc = st.ConvertMarcType(marc);
marc = st.ConvertMarcType(marc, out string errmesage);
if (errmesage.isEmpty() == false) totalerrmsg += (totalerrmsg.isEmpty() ? "\n" : "") + errmesage;
MarcArray[a] = marc;
}
return MarcArray;
@@ -754,7 +775,7 @@ namespace WindowsFormsApp1.Mac
int row = e.RowIndex;
int col = dataGridView1.CurrentCell.ColumnIndex;
if (col == 2 || col == 3 || col == 4 || col == 5 || col == 6 || col == 7|| col==17)
if (col == 2 || col == 3 || col == 4 || col == 5 || col == 6 || col == 7 || col == 17)
{
if (dataGridView1.Rows[row].Cells["num"].Value == null)
{
@@ -802,10 +823,12 @@ namespace WindowsFormsApp1.Mac
AddTag = string.Format("049\t \t{0}{1}{2}{3}▲", L, V, C, F);
if (L == "" && V == "" && C == "" && F == "") {
if (L == "" && V == "" && C == "" && F == "")
{
TypeView = st.RemoveTagNumber(TypeView, "049");
}
else {
else
{
TypeView = AddTagInMarc(AddTag, TypeView);
}
}
@@ -819,7 +842,8 @@ namespace WindowsFormsApp1.Mac
string B = dataGridView1.Rows[row].Cells[4].Value.ToString();
string V = dataGridView1.Rows[row].Cells[5].Value.ToString();
if (A != "") {
if (A != "")
{
A = string.Format("▼a{0}", A);
TypeView = st.ChangeTagInMarc("056a", A, TypeView);
}
@@ -832,10 +856,12 @@ namespace WindowsFormsApp1.Mac
AddTag = string.Format("090\t \t{0}{1}{2}▲", A, B, V);
if (A == "" && B == "" && V == "") {
if (A == "" && B == "" && V == "")
{
TypeView = st.RemoveTagNumber(TypeView, "090");
}
else {
else
{
TypeView = AddTagInMarc(AddTag, TypeView);
}
}
@@ -1235,7 +1261,8 @@ namespace WindowsFormsApp1.Mac
for (int b = 0; b < CheckList.GetLength(0); b++)
{
if (WorkFix.IndexOf(CheckList[b, 0]) > -1) {
if (WorkFix.IndexOf(CheckList[b, 0]) > -1)
{
dataGridView1.Rows[a].Cells[col].Style.BackColor = ColorList[Convert.ToInt32(CheckList[b, 1])];
break;
}
@@ -1360,7 +1387,8 @@ namespace WindowsFormsApp1.Mac
{
if (t == "") continue;
if (Target.IndexOf(t.TrimStart().TrimEnd()) > -1) {
if (Target.IndexOf(t.TrimStart().TrimEnd()) > -1)
{
dataGridView1.Rows[a].Cells["search_tag2"].Style.BackColor = Color.Yellow;
break;
}

View File

@@ -189,7 +189,7 @@ namespace UniMarc.마크
if (Author_res[3].IndexOf("[외]") > -1)
Author[0] = Marc[5];
string tmp_ViewMarc = st.ConvertMarcType(insert_marc_data[14]);
string tmp_ViewMarc = st.ConvertMarcType(insert_marc_data[14],out string errmessage);
// 마크에서 추출한 데이터 DB에 적용하기 위한 반복문
for (int b = 0; b < Marc.Length; b++)