initial commit
This commit is contained in:
126
GetReport/Program.cs
Normal file
126
GetReport/Program.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace GetReport
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Ecl2파일에서 최종보고서를 불러옵니다.
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
struct s_Porject
|
||||
{
|
||||
public string Filename;
|
||||
public string Maketime;
|
||||
public string Desc;
|
||||
public string UIVersion;
|
||||
public string LGVersion;
|
||||
public string Name;
|
||||
public string SFType;
|
||||
public string MakeTime;
|
||||
public string EditTime;
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//#if(DEBUG)
|
||||
// Console.WriteLine("Debug Mode");
|
||||
// Console.WriteLine(string.Format("Param len={0}", args.Length));
|
||||
//#endif
|
||||
string msgtitle =
|
||||
"이 프로그램은 ECO2-OD의 저장파일(*.ecl2)에서 최종결과 보고서를 추출하는 프로그램입니다.\r\n" +
|
||||
"프로그램 실행시 파라미터로 추출하고자하는 파일명을 입력하세요\r\n\r\n" +
|
||||
"경로 및 파일명에 공백이 있는 경우에는 큰따옴표로 묶어서 입력하시기 바랍니다.\r\n\r\n" +
|
||||
"예) GetReport.exe " + (char)(0x22) + "c:\\Sample File\\test.ecl2" + (char)(0x22) +
|
||||
"\r\n예) GetReport.exe new.ecl2";
|
||||
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
//display Usage
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine(msgtitle);
|
||||
sb.AppendLine();
|
||||
//sb.AppendLine("아무키나 누르면 종료합니다");
|
||||
Console.WriteLine(sb.ToString());
|
||||
//Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
System.IO.FileInfo fi = new System.IO.FileInfo(args[0]);
|
||||
if (!fi.Exists)
|
||||
{
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine(msgtitle);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("존재하지 않는 파일명을 입력했습니다");
|
||||
sb.AppendLine("파일명 : " + fi.FullName);
|
||||
Console.WriteLine(sb.ToString());
|
||||
//Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
//자료를 읽어서 테이블을 추출한 후 그 정보를 역 출력한다
|
||||
byte[] source = System.IO.File.ReadAllBytes(fi.FullName);
|
||||
if (source.Length < 4)
|
||||
{
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine(msgtitle);
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("데이터가 올바르지 않습니다.");
|
||||
sb.AppendLine("데이터길이 : " + source.Length.ToString());
|
||||
Console.WriteLine(sb.ToString());
|
||||
//Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
System.IO.MemoryStream fs = new System.IO.MemoryStream(source);
|
||||
System.IO.BinaryReader Br = new System.IO.BinaryReader(fs, System.Text.Encoding.Default);
|
||||
s_Porject prj = new s_Porject();
|
||||
|
||||
//read data
|
||||
prj.Filename = fi.FullName;
|
||||
prj.SFType = System.Text.Encoding.Default.GetString(Br.ReadBytes(2));
|
||||
prj.UIVersion = System.Text.Encoding.Default.GetString(Br.ReadBytes(10));
|
||||
prj.LGVersion = System.Text.Encoding.Default.GetString(Br.ReadBytes(10));
|
||||
|
||||
prj.Name = System.Text.Encoding.Default.GetString(Br.ReadBytes(100));
|
||||
prj.Desc = System.Text.Encoding.Default.GetString(Br.ReadBytes(256));
|
||||
prj.MakeTime = System.Text.Encoding.Default.GetString(Br.ReadBytes(19));
|
||||
prj.EditTime = System.Text.Encoding.Default.GetString(Br.ReadBytes(19));
|
||||
|
||||
//setting data read
|
||||
System.Data.DataSet DSET1 = new System.Data.DataSet();
|
||||
Int64 DS1Len = Br.ReadInt64();
|
||||
byte[] DS1 = Br.ReadBytes((int)DS1Len);
|
||||
System.IO.MemoryStream Ms = new System.IO.MemoryStream(DS1);
|
||||
DSET1.ReadXml(Ms);
|
||||
DSET1.AcceptChanges();
|
||||
Ms.Close();
|
||||
|
||||
//readreport
|
||||
System.Data.DataSet DSETR1 = new System.Data.DataSet();
|
||||
DS1Len = Br.ReadInt64();
|
||||
DS1 = Br.ReadBytes((int)DS1Len);
|
||||
Ms = new System.IO.MemoryStream(DS1);
|
||||
DSETR1.ReadXml(Ms);
|
||||
DSETR1.AcceptChanges();
|
||||
Ms.Close();
|
||||
|
||||
//System.Text.StringBuilder sb2 = new StringBuilder();
|
||||
//sb2.AppendLine("Table Count = " + DSETR1.Tables.Count.ToString());
|
||||
//sb2.AppendLine("Table 1 = " + DSETR1.Tables[0].ToString());
|
||||
|
||||
//보고서테이블의 내용을 화면에 출력한다.
|
||||
System.IO.StringWriter sw = new System.IO.StringWriter();
|
||||
DSETR1.Tables[0].WriteXml(sw, false);
|
||||
Console.WriteLine(sw.ToString());
|
||||
//sb2.AppendLine(sw.ToString());
|
||||
sw.Dispose();
|
||||
//Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user