Console.WriteLine("Error:"+tRecord[0]+" is tran only.");
// transaction読み込み
tRecord=tRead(srt);
}
}
// ファイルクローズ
srm.Close();
srt.Close();
sw.Close();
}
// MasterファイルRead
staticstring[]mRead(StreamReader srm)
{
if(srm.Peek()==-1)
{
isSrmEof=true;
returnnull;
}
else
{
stringstr=srm.ReadLine();
returnstr.Split(',');
}
}
// TransactionファイルRead
staticstring[]tRead(StreamReader srt)
{
if(srt.Peek()==-1)
{
isSrtEof=true;
returnnull;
}
else
{
stringstr=srt.ReadLine();
returnstr.Split(',');
}
}
}
}
・商品マスタのレコード(files\master.csv)
1
2
3
4
5
6
0000001,00,hoge
0000002,00,fuga
0000004,01,piyo-Red
0000004,02,piyo-Blue
0000005,01,negi-Miku
0000005,02,negi-Rin
・販売履歴のレコード(files\transaction.csv)
1
2
3
4
5
6
0000001,20180401,00100,00010000
0000001,20180402,00200,00020000
0000003,20180401,00001,00001000
0000004,20180401,00002,00002000
0000004,20180402,00004,00004000
0000005,20180401,01000,00100000
・バッチ実行結果(標準出力)
1
2
3
4
5
6
7
8
Microsoft(R)VisualC# Compiler version 4.8.9032.0
forC# 5
Copyright(C)Microsoft Corporation.All rights reserved.
Thiscompiler isprovided aspart of the Microsoft(R).NET Framework,but only supports language versions up toC# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240