diff --git a/Server/Git/AbstractGit.cs b/Server/Git/AbstractGit.cs index f4fd135..ecfc9a6 100644 --- a/Server/Git/AbstractGit.cs +++ b/Server/Git/AbstractGit.cs @@ -7,9 +7,9 @@ namespace Server.Git public abstract class AbstractGit { public bool isRestart; - string repositoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "excel"); + string _repositoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "excel"); - public string _repositoryPath { get { return repositoryPath; } } + public string repositoryPath { get { return _repositoryPath; } } /// /// 가장먼저 시작해야 하는 스크립트 @@ -36,18 +36,18 @@ namespace Server.Git private void Pull() { - if (!Directory.Exists(repositoryPath)) + if (!Directory.Exists(_repositoryPath)) { - Directory.CreateDirectory(repositoryPath); - RepositorySet($"clone {STATICS.remoteUrl} {repositoryPath}", null); + Directory.CreateDirectory(_repositoryPath); + RepositorySet($"clone {STATICS.remoteUrl} {_repositoryPath}", null); //main브렌치로 세팅 - RepositorySet("branch -m main", repositoryPath); - RepositorySet("branch --set-upstream-to=origin/main main", repositoryPath); + RepositorySet("branch -m main", _repositoryPath); + RepositorySet("branch --set-upstream-to=origin/main main", _repositoryPath); } // pull 명령어 실행 - RepositorySet("pull", repositoryPath); + RepositorySet("pull", _repositoryPath); } private static void RepositorySet(string command, string workingDirectory) diff --git a/Server/Git/ExcelManager.cs b/Server/Git/ExcelManager.cs index 0d4ba73..0618cc7 100644 --- a/Server/Git/ExcelManager.cs +++ b/Server/Git/ExcelManager.cs @@ -1,25 +1,43 @@ using Aspose.Cells; +using NLog; namespace Server.Git { class ExcelManager { - Dictionary>> _dicViewer; + private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger(); + public class sheet + { + string _name; + public string name { get { return _name; } } + List _variable; + public List variable { get { return _variable; } } + List _type; + public List type { get { return _type; } } + Dictionary> _dicViewer; + public Dictionary> dicViewer { get { return _dicViewer; } } + + public sheet(string name, List variable, List type, Dictionary> dicViewer) + { + this._name = name; + this._variable = variable; + this._type = type; + this._dicViewer = dicViewer; + } + } + List _sheets; + + public List sheets { get { return _sheets; } } + string _pathFile; public ExcelManager(string path, string file) { _pathFile = path + "\\" + file; - Console.WriteLine(_pathFile); - _dicViewer = new Dictionary>>(); - } - public Dictionary>> dicViewerOut - { - get { return _dicViewer; } } - public void Play() + public bool Play() { - ExcelLoad(_pathFile); + return ExcelLoad(_pathFile); } public bool ExcelLoad(string path)//엑셀 로드 { @@ -29,34 +47,67 @@ namespace Server.Git // 모든 워크시트 가져오기 WorksheetCollection collection = wb.Worksheets; + _sheets = new List(); + // 모든 워크시트 반복 - for (int worksheetIndex = 0; worksheetIndex < collection.Count; worksheetIndex++) + try { - - // 인덱스를 사용하여 워크시트 가져오기 - Worksheet worksheet = collection[worksheetIndex]; - - // 워크시트 이름 인쇄 - Console.WriteLine("Worksheet: " + worksheet.Name); - - // 행과 열의 수 얻기 - int rows = worksheet.Cells.MaxDataRow; - int cols = worksheet.Cells.MaxDataColumn; - - // 행 반복 - for (int i = 0; i < rows; i++) + for (int worksheetIndex = 0; worksheetIndex < collection.Count; worksheetIndex++) { + //변수이름 + List variable = new List(); + //변수 타입 + List type = new List(); + Dictionary> dicViewer = new Dictionary>(); - // 선택한 행의 각 열 반복 - for (int j = 0; j < cols; j++) + // 인덱스를 사용하여 워크시트 가져오기 + Worksheet worksheet = collection[worksheetIndex]; + + // 행과 열의 수 얻기 + int vertical = worksheet.Cells.MaxDataRow; + int horizontal = worksheet.Cells.MaxDataColumn; + + //변수 이름과 타입 삽입 + for (int n = 0; n <= horizontal; n++) { - // 프링 셀 값 - Console.Write(worksheet.Cells[i, j].Value + " | "); + // Console.Write(worksheet.Cells[i, j].Value + " | "); + variable.Add((string)worksheet.Cells[0, n].Value); + type.Add(((string)worksheet.Cells[2, n].Value).ToLower()); } - // 줄바꿈 인쇄 - Console.WriteLine(" "); + + for (int n = 3; n <= vertical; n++) + { + List dataList = new List(); + for (int m = 0; m <= horizontal; m++) + { + switch (type[m]) + { + case "enum": + case "int": + dataList.Add(worksheet.Cells[n, m].Value); + break; + case "string": + case "text": + case "time": + dataList.Add(worksheet.Cells[n, m].Value); + break; + default: + Console.WriteLine("알수없는 타입의 메세지 입니다."); + break; + } + } + dicViewer.Add(n, dataList); + } + sheet sheet = new sheet(worksheet.Name, variable, type, dicViewer); + _sheets.Add(sheet); } } + catch (Exception ex) + { + logger.Error(ex); + return false; + } + return true; } } diff --git a/Server/Git/XlsxToJson.cs b/Server/Git/XlsxToJson.cs index 96ccdb3..2d9a96f 100644 --- a/Server/Git/XlsxToJson.cs +++ b/Server/Git/XlsxToJson.cs @@ -10,10 +10,26 @@ //데이터 db에 업로드 //json화된 데이터 push - ExcelManager em = new ExcelManager(_repositoryPath, "TESTexl.xlsx"); - em.Play(); + ExcelManager em = new ExcelManager(repositoryPath, "TESTexl.xlsx"); + if (em.Play()) + { + List sheets = em.sheets; + + foreach (KeyValuePair> sheet in sheets[0].dicViewer) + { + foreach (object obj in sheet.Value) + { + //이것을 기반으로 서버 테이블을 생성뒤 데이터를 세팅 + //Console.WriteLine(obj); + } + } + } + else + { + Console.WriteLine("-1 : NotUpdate"); + } + - Console.WriteLine("집에가고싶다아"); //db에 데이터를올리는것은 이곳에 작성할 예정 diff --git a/Server/obj/Debug/net6.0/Server.dll b/Server/obj/Debug/net6.0/Server.dll index 0ede1f2..8d36b78 100644 Binary files a/Server/obj/Debug/net6.0/Server.dll and b/Server/obj/Debug/net6.0/Server.dll differ diff --git a/Server/obj/Debug/net6.0/Server.pdb b/Server/obj/Debug/net6.0/Server.pdb index c9d8f19..a82e0ce 100644 Binary files a/Server/obj/Debug/net6.0/Server.pdb and b/Server/obj/Debug/net6.0/Server.pdb differ diff --git a/Server/obj/Debug/net6.0/ref/Server.dll b/Server/obj/Debug/net6.0/ref/Server.dll index 38070ca..4730a47 100644 Binary files a/Server/obj/Debug/net6.0/ref/Server.dll and b/Server/obj/Debug/net6.0/ref/Server.dll differ diff --git a/Server/obj/Debug/net6.0/refint/Server.dll b/Server/obj/Debug/net6.0/refint/Server.dll index 38070ca..4730a47 100644 Binary files a/Server/obj/Debug/net6.0/refint/Server.dll and b/Server/obj/Debug/net6.0/refint/Server.dll differ