diff --git a/FTP_DB_Adapt/FTP_DB_Adapt.sln b/FTP_DB_Adapt/FTP_DB_Adapt.sln
new file mode 100644
index 0000000..91b8f6a
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt.sln
@@ -0,0 +1,47 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.40629.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FTP_DB_Adapt", "FTP_DB_Adapt\FTP_DB_Adapt.csproj", "{BECE73DE-15C8-42B0-9F93-9484D745DF3A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FTPClass", "FTP_DB_Adapt\Sub\arftp\FTPClass.csproj", "{150859D3-1C5D-4E20-B324-F9EBE188D893}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ArLog", "FTP_DB_Adapt\Sub\arLog_CSharp\ArLog.csproj", "{E9E16A98-8F8D-4848-A27E-4571C184FB1A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "arSetting", "FTP_DB_Adapt\Sub\arSetting\arSetting.csproj", "{8870CE55-DF29-4E05-92FA-6D251DE4EC6C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sub", "Sub", "{97A5415A-4C67-4C76-95E6-4AB406BF67CD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BECE73DE-15C8-42B0-9F93-9484D745DF3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BECE73DE-15C8-42B0-9F93-9484D745DF3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BECE73DE-15C8-42B0-9F93-9484D745DF3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BECE73DE-15C8-42B0-9F93-9484D745DF3A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {150859D3-1C5D-4E20-B324-F9EBE188D893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {150859D3-1C5D-4E20-B324-F9EBE188D893}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {150859D3-1C5D-4E20-B324-F9EBE188D893}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {150859D3-1C5D-4E20-B324-F9EBE188D893}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E9E16A98-8F8D-4848-A27E-4571C184FB1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E9E16A98-8F8D-4848-A27E-4571C184FB1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E9E16A98-8F8D-4848-A27E-4571C184FB1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E9E16A98-8F8D-4848-A27E-4571C184FB1A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8870CE55-DF29-4E05-92FA-6D251DE4EC6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8870CE55-DF29-4E05-92FA-6D251DE4EC6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8870CE55-DF29-4E05-92FA-6D251DE4EC6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8870CE55-DF29-4E05-92FA-6D251DE4EC6C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {150859D3-1C5D-4E20-B324-F9EBE188D893} = {97A5415A-4C67-4C76-95E6-4AB406BF67CD}
+ {E9E16A98-8F8D-4848-A27E-4571C184FB1A} = {97A5415A-4C67-4C76-95E6-4AB406BF67CD}
+ {8870CE55-DF29-4E05-92FA-6D251DE4EC6C} = {97A5415A-4C67-4C76-95E6-4AB406BF67CD}
+ EndGlobalSection
+EndGlobal
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/CSetting.cs b/FTP_DB_Adapt/FTP_DB_Adapt/CSetting.cs
new file mode 100644
index 0000000..fcef6fb
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/CSetting.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FTP_DB_Adapt
+{
+ public class CSetting : arUtil.Setting
+ {
+ public string connstr { get; set; }
+ public string ftphost { get; set; }
+ public string ftpid { get; set; }
+ public string ftppw { get; set; }
+
+ public override void AfterLoad()
+ {
+ if (connstr == "")
+ connstr = "Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!";
+ }
+ public override void AfterSave()
+ {
+ //throw new NotImplementedException();
+ }
+ }
+}
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/FTP_DB_Adapt.csproj b/FTP_DB_Adapt/FTP_DB_Adapt/FTP_DB_Adapt.csproj
new file mode 100644
index 0000000..e037f1c
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/FTP_DB_Adapt.csproj
@@ -0,0 +1,86 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {BECE73DE-15C8-42B0-9F93-9484D745DF3A}
+ Exe
+ Properties
+ FTP_DB_Adapt
+ FTP_DB_Adapt
+ v4.5
+ 512
+
+
+
+ x86
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ ..\..\DLL\ArLog.Net4.dll
+
+
+ ..\..\DLL\ArSetting.Net4.dll
+
+
+ ..\..\DLL\Newtonsoft.Json.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+ {150859d3-1c5d-4e20-b324-f9ebe188d893}
+ FTPClass
+
+
+
+
+
\ No newline at end of file
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Program.cs b/FTP_DB_Adapt/FTP_DB_Adapt/Program.cs
new file mode 100644
index 0000000..e950481
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Program.cs
@@ -0,0 +1,236 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+namespace FTP_DB_Adapt
+{
+ class Program
+ {
+ static System.Data.SqlClient.SqlConnection cn;
+ static System.Data.SqlClient.SqlCommand cmd;
+ static System.Data.SqlClient.SqlDataAdapter da;
+ static arUtil.FTPClient.FTPClient ftp;
+ static CSetting setting;
+ static arUtil.Log log;
+
+ static string lastfile = "";
+ static DateTime lasttime = DateTime.Now;
+
+ class retdata
+ {
+ public int count { get; set; }
+ public System.Data.DataTable result { get; set; }
+ public string message { get; set; }
+ }
+
+ static void Main(string[] args)
+ {
+ //var jstest = JsonConvert.SerializeObject(retval);
+ // var jsontest = "{\"count\":1,\"result\":[{\"id\":\"395552\",\"password\":\"B6589FC6AB0DC82CF12099D1C2D40AB994E8410C\",\"nameE\":\"Chikyun.Kim\",\"name\":\"��ġ��\",\"dept\":\"�������� ������� K4�����1��Ʈ\",\"grade\":\"å��\",\"email\":\"Chikyun.Kim@amkor.co.kr\",\"level\":1,\"indate\":\"2018-04-11\",\"outdate\":null";
+ /// var json = JObject.Parse(jsontest);
+ // // var cnt = json["count"];
+
+ cw("setting load");
+ setting = new CSetting();
+ setting.Load();
+ if (setting.Xml.Exist() == false)
+ {
+ setting.Xml.CreateFile();
+ cw("setting file created");
+ }
+
+ if (setting.ftphost == "")
+ {
+ setting.ftphost = "ftp.amkor.co.kr";
+ setting.ftpid = "k4pcbmgr";
+ setting.ftppw = "W2$fYiXp";
+ setting.Save();
+ cw("setting default");
+ }
+ cw(string.Format("ftp info - {0}", setting.ftphost));
+
+
+ Properties.Settings.Default["cs"] = setting.connstr; // "Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!";
+
+
+ cw("program start v191212-0950" );
+ cn = new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.cs);
+ DateTime conntime = DateTime.Now;
+
+
+
+ //ftp = new arUtil.FTPClient();
+ while(true)
+ {
+ if(cn.State == System.Data.ConnectionState.Open)
+ {
+ if(ftp == null)
+ {
+ ftp = new arUtil.FTPClient.FTPClient();
+ ftp.Host = setting.ftphost;
+ ftp.UserPassword = setting.ftppw;
+ ftp.UserID = setting.ftpid;
+ ftp.Port = 21;
+ cw(string.Format("ftp Initialize {0}",ftp.Host));
+ }
+
+ //monitor file list
+ string path = "/2D TEST/101369103/Log/QryResult";
+ var list = ftp.directoryListSimple(path);
+ var sqllist = list.Where(t => t.ToLower().EndsWith(".sql"));
+ DateTime findtime = DateTime.Parse("1982-11-23");
+ foreach(var sqlfile in sqllist)
+ {
+ string fn = sqlfile.Substring(0, sqlfile.Length - 3);
+ string resultfile = fn + "json";
+ if (list.Contains(resultfile)) continue;
+
+ if(lastfile == sqlfile)
+ {
+ var ts = DateTime.Now - lasttime;
+ if (ts.TotalSeconds < 3) continue; //3초이내 연속 실행 불가
+ }
+
+ //다운로드전에 무조건 대기해준다.
+ System.Threading.Thread.Sleep(200);
+
+ // //이파일명에 해당하는 json 파일을 찾는다.
+ // string rltfile =
+ var file_local = AppDomain.CurrentDomain.BaseDirectory + sqlfile;
+ var file_remote = path + "/" + sqlfile;
+ try
+ {
+ if (System.IO.File.Exists(file_local)) System.IO.File.Delete(file_local);
+ cw(string.Format("Down {0} to {1}",file_remote, file_local));
+ lastfile = sqlfile;
+ lasttime = DateTime.Now;
+ if(ftp.Download(file_remote,file_local))
+ {
+ retdata retval = new retdata();
+ retval.count = 0;
+ retval.result = null;
+ retval.message = "";
+
+
+ cw("download ok : " + file_remote);
+
+ var jsonStr = "";
+ var sql = System.IO.File.ReadAllText(file_local, System.Text.Encoding.Default);
+ if (cmd == null) cmd = new System.Data.SqlClient.SqlCommand(sql);
+
+ var downfi = new System.IO.FileInfo(file_local);
+ if (downfi.Length < 1)
+ {
+ retval.message = "0byte File Downaloaded : " + file_local;
+ }
+ else if(sql.Trim() == "")
+ {
+ retval.message = "No Sql data";
+ }
+ else
+ {
+ cmd.CommandText = sql;
+ cmd.Connection = cn;
+ if (cn.State == System.Data.ConnectionState.Closed) cn.Open();
+
+ if (sql.ToLower().StartsWith("select"))
+ {
+ cw("select query");
+ //data table
+ if (da == null) da = new System.Data.SqlClient.SqlDataAdapter(cmd);
+ using (var ds = new System.Data.DataSet())
+ {
+ try
+ {
+ da.Fill(ds);
+ if (ds != null && ds.Tables.Count > 0)
+ {
+ retval.result = ds.Tables[0];
+ retval.count = retval.result.Rows.Count;
+ }
+ }
+ catch (Exception ex)
+ {
+ retval.message = ex.Message + ",sql=" + sql;
+ }
+ }
+ }
+ else
+ {
+ cw("non query");
+ //insert /update/ delete
+ cmd.Connection = cn;
+ try
+ {
+ retval.count = cmd.ExecuteNonQuery();
+ }
+ catch (Exception ex)
+ {
+ retval.message = ex.Message + ",sql=" + sql;
+ }
+ }
+
+ jsonStr = JsonConvert.SerializeObject(retval);
+ if (jsonStr != "")
+ {
+ file_local = AppDomain.CurrentDomain.BaseDirectory + resultfile;
+ System.IO.File.WriteAllText(file_local, jsonStr, System.Text.Encoding.Default);
+ cw("result file save : " + file_local);
+
+ file_remote = path + "/" + resultfile;
+ if (!ftp.Upload(file_remote, file_local))
+ cw("ftp Upload error remote = " + file_remote + "," + file_local);
+ }
+ }
+ }
+ else
+ {
+ cw("ftp down error remote = " + file_remote);
+ }
+ }
+ catch (Exception ex)
+ {
+ cw("conn error:" + ex.Message);
+ }
+ }
+
+ }
+ else
+ {
+ var ts = DateTime.Now - conntime;
+ if(ts.TotalSeconds > 5)
+ {
+ try
+ {
+ cw("Try Database Connect ");
+ cn.Open();
+ cw("Database Connected\n\nFTP Monitor ON");
+ }
+ catch (Exception ex)
+ {
+ cw("conn error:" + ex.Message);
+ }
+ finally
+ {
+ conntime = DateTime.Now;
+ }
+ }
+ }
+ System.Threading.Thread.Sleep(1);
+ }
+
+ }
+ static void cw(string msg,Boolean logon=true)
+ {
+ if(log == null)
+ {
+ log = new arUtil.Log();
+ }
+ if (logon) log.Add(msg);
+ Console.WriteLine(msg);
+ }
+
+ }
+}
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Properties/AssemblyInfo.cs b/FTP_DB_Adapt/FTP_DB_Adapt/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3b05de8
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다.
+// 어셈블리와 관련된 정보를 수정하려면
+// 이 특성 값을 변경하십시오.
+[assembly: AssemblyTitle("FTP_DB_Adapt")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("FTP_DB_Adapt")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
+// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
+// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오.
+[assembly: ComVisible(false)]
+
+// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
+[assembly: Guid("0d606978-0719-4d02-aea0-740db9f2a058")]
+
+// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
+//
+// 주 버전
+// 부 버전
+// 빌드 번호
+// 수정 버전
+//
+// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로
+// 지정되도록 할 수 있습니다.
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("19.12.12.0950")]
+[assembly: AssemblyFileVersion("19.12.12.0950")]
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Properties/Settings.Designer.cs b/FTP_DB_Adapt/FTP_DB_Adapt/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..5f08a8d
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Properties/Settings.Designer.cs
@@ -0,0 +1,37 @@
+//------------------------------------------------------------------------------
+//
+// 이 코드는 도구를 사용하여 생성되었습니다.
+// 런타임 버전:4.0.30319.42000
+//
+// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
+// 이러한 변경 내용이 손실됩니다.
+//
+//------------------------------------------------------------------------------
+
+namespace FTP_DB_Adapt.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
+ [global::System.Configuration.DefaultSettingValueAttribute("Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=ee" +
+ "user;Password=EEmicro123!")]
+ public string cs {
+ get {
+ return ((string)(this["cs"]));
+ }
+ }
+ }
+}
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Properties/Settings.settings b/FTP_DB_Adapt/FTP_DB_Adapt/Properties/Settings.settings
new file mode 100644
index 0000000..44add71
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Properties/Settings.settings
@@ -0,0 +1,14 @@
+
+
+
+
+
+ <?xml version="1.0" encoding="utf-16"?>
+<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <ConnectionString>Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=EEmicro123!</ConnectionString>
+ <ProviderName>System.Data.SqlClient</ProviderName>
+</SerializableConnectionString>
+ Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=EEmicro123!
+
+
+
\ No newline at end of file
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arLog_CSharp b/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arLog_CSharp
new file mode 160000
index 0000000..106f873
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arLog_CSharp
@@ -0,0 +1 @@
+Subproject commit 106f873d3755c65f5e5d2bee865416a8fd95c36e
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arSetting b/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arSetting
new file mode 160000
index 0000000..a09d4eb
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arSetting
@@ -0,0 +1 @@
+Subproject commit a09d4eb9f84e578ca93d5413f118d3370ca32dae
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arftp b/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arftp
new file mode 160000
index 0000000..0826cbe
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/Sub/arftp
@@ -0,0 +1 @@
+Subproject commit 0826cbe09b31b0c3b3bb0f4f55b3ab17aaa76b51
diff --git a/FTP_DB_Adapt/FTP_DB_Adapt/app.config b/FTP_DB_Adapt/FTP_DB_Adapt/app.config
new file mode 100644
index 0000000..51c6552
--- /dev/null
+++ b/FTP_DB_Adapt/FTP_DB_Adapt/app.config
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/FTP_DB_Adapt/Newtonsoft.Json.dll b/FTP_DB_Adapt/Newtonsoft.Json.dll
new file mode 100644
index 0000000..05c95b2
Binary files /dev/null and b/FTP_DB_Adapt/Newtonsoft.Json.dll differ