using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace SystemX.Product.CP.TRA.Extract { internal class Program { static void Main(string[] args) { bool isError = false; var config = JsonConvert.DeserializeObject(File.ReadAllText("Config.json")); DBService dbS = new DBService(); dbS.CPXV2ConnectionString = $"Server={config.CPXV2Server};Database=CPXV2;User Id={config.User};Password={config.Passwd};"; dbS.ConnectionString = $"Server={config.Server};Database={config.DataBase};User Id={config.User};Password={config.Passwd};"; //db check try { using (SqlConnection conn = new SqlConnection(dbS.CPXV2ConnectionString)) { conn.Open(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("Config.json, CPXV2 server connect success."); } using (SqlConnection conn = new SqlConnection(dbS.ConnectionString)) { conn.Open(); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"Config.json, {config.DataBase} server connect success."); } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Config.json, Invalid Server Set."); isError = true; } Console.WriteLine(""); Thread.Sleep(1000); //mo check if (string.IsNullOrEmpty(config.MO) == true) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Config.json, MO Value is Empty"); isError = true; } //date check try { var start = Convert.ToDateTime(config.StartDate); var end = Convert.ToDateTime(config.EndDate); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Config.json, StartDate ~ EndDate are Invalid Format. Fix to yyyy-MM-dd"); isError = true; } if (isError == true) { return; } Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"ProductNO:{config.ProductNo}, TestCode:{config.TestCode}"); Console.WriteLine($"StartDate:{config.StartDate}, EndDate:{config.EndDate}"); Console.WriteLine($"MO:{config.MO}"); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(""); Thread.Sleep(1000); var finsList = dbS.GetTestList(config); dbS.GetLargeData(finsList, config); } } }