80 lines
3.7 KiB
C#
80 lines
3.7 KiB
C#
using Newtonsoft.Json;
|
|
|
|
namespace Server.Git
|
|
{
|
|
public class XlsxToJson : AbstractGit
|
|
{
|
|
public override string ChangeScript()
|
|
{
|
|
//저장경로 : repositoryPath
|
|
|
|
List<string> fileList = GetFiles(repositoryPath, ".xlsx");
|
|
|
|
Dictionary<string, Dictionary<long, Dictionary<string, object>>> clientSheetList = new Dictionary<string, Dictionary<long, Dictionary<string, object>>>();
|
|
List<sheet> serverSheetList = new List<sheet>();
|
|
|
|
for (int n = 0; n < fileList.Count; n++)
|
|
{
|
|
ExcelManager em = new ExcelManager(fileList[n]);
|
|
if (em.Play())
|
|
{
|
|
sheets = em.sheets;
|
|
for (int m = 0; m < sheets.Count; m++)
|
|
{
|
|
|
|
switch (sheets[m].dataEnum[0])
|
|
{
|
|
case "server":
|
|
serverSheetList.Add(sheets[m]);
|
|
break;
|
|
case "client":
|
|
clientSheetList.Add(sheets[m].name, sheets[m].dicViewer);
|
|
break;
|
|
case "all":
|
|
//수정할것 이렇게 작업되면 데이터가 2개로 나눠지는것이 아닌 한개의 데이터가 중복으로 제거됨.
|
|
string name = sheets[m].name;
|
|
Dictionary<long, Dictionary<string, object>> serverSheet = new Dictionary<long, Dictionary<string, object>>(sheets[m].dicViewer);
|
|
Dictionary<long, Dictionary<string, object>> clientSheet = new Dictionary<long, Dictionary<string, object>>(sheets[m].dicViewer);
|
|
for (int i = 1; i < sheets[m].dataEnum.Count; i++)
|
|
{
|
|
if (sheets[m].dataEnum[i] == "client")
|
|
{
|
|
foreach (var item in serverSheet)
|
|
{
|
|
item.Value.Remove(sheets[m].variable[i]);
|
|
}
|
|
}
|
|
}
|
|
for (int i = 1; i < sheets[m].dataEnum.Count; i++)
|
|
{
|
|
if (sheets[m].dataEnum[i] == "server")
|
|
{
|
|
foreach (var item in clientSheet)
|
|
{
|
|
item.Value.Remove(sheets[m].variable[i]);
|
|
}
|
|
}
|
|
}
|
|
serverSheetList.Add(sheets[m]);
|
|
clientSheetList.Add(name, clientSheet);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Console.WriteLine("-1 : NotUpdate");
|
|
return "";
|
|
}
|
|
}
|
|
//현재 서버는 PostgreSQL기준으로 쿼리를 생성하는 코드와 패키지가 세팅되어 있습니다 이점 참고바랍니다
|
|
//추가로 해당 기능을 사용하려면 서버에 excel이라는 스키마가 존재하여야 합니다.
|
|
if (sheets != null && serverSheetList.Count != 0)
|
|
{
|
|
ExcelSQL sql = new ExcelSQL(serverSheetList);
|
|
sql.DataUpdate();
|
|
}
|
|
return JsonConvert.SerializeObject(clientSheetList);
|
|
}
|
|
}
|
|
} |