firts commit

This commit is contained in:
2025-10-24 10:25:54 +09:00
commit edf42de8f9
45 changed files with 133446 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
using Microsoft.AspNetCore.Mvc;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
using System;
using System.Net;
using System.Data;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/export")]
[ApiController]
public class ExportAPI : ControllerBase
{
[Route("excel/table")]
[HttpPost]
[DisableRequestSizeLimit]
public IActionResult ExportExcelTable([FromHeader] string token, [FromBody] ExportExcelParam excelParam)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null && String.IsNullOrEmpty(excelParam.ExportTable) == false && excelParam.ExportTable != "[]")
{
MakeExcel makeExcel = new MakeExcel();
string fileName = token + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
string fileType = "application/vnd.ms-excel";
byte[] excelFile = makeExcel.getTableExcel(excelParam.ExportTable, excelParam.Turn);
Response.StatusCode = (int)HttpStatusCode.OK;
return File(excelFile, fileType, fileName);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("excel/quota")]
[HttpPost]
[DisableRequestSizeLimit]
public IActionResult ExportExcelQuota([FromHeader] string token, [FromBody] ExportExcelParam excelParam)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null && String.IsNullOrEmpty(excelParam.ExportTable) == false && excelParam.ExportTable != "[]")
{
MakeExcel makeExcel = new MakeExcel();
string fileName = token + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
string fileType = "application/vnd.ms-excel";
byte[] excelFile = makeExcel.getQuotaExcel(excelParam.ExportTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return File(excelFile, fileType, fileName);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("form/data")]
[HttpGet]
public IActionResult ExportDataForm([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable headerTable = project.getExportHeader(pkeyInfo.Pkey, pkeyInfo.isKiwi, userInfo.IsAdmin);
DataTable exportTable = project.makeExportTable(headerTable);
Response.StatusCode = (int)HttpStatusCode.OK;
string fileName = "[Header]" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
byte[] fileByteArray = Common.DataTableToExcel(exportTable);
return File(fileByteArray, "application/octet-stream", fileName);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("form/question")]
[HttpGet]
public IActionResult ExportQuestionForm([FromHeader] string token)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Response.StatusCode = (int)HttpStatusCode.OK;
byte[] fileByteArray = System.IO.File.ReadAllBytes(Common.MapPath("file_forms/KON 문항 등록 양식.xlsx"));
return File(fileByteArray, "application/octet-stream", "KON 문항 등록 양식.xlsx");
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("form/title")]
[HttpGet]
[DisableRequestSizeLimit]
public IActionResult ExportTitleForm([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable titleTable = project.getExportExplain(pkeyInfo.Pkey, pkeyInfo.isKiwi);
Response.StatusCode = (int)HttpStatusCode.OK;
string fileName = "[Explain]" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
byte[] fileByteArray = Common.DataTableToExcel(titleTable);
return File(fileByteArray, "application/octet-stream", fileName);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("data")]
[HttpGet]
public IActionResult ExportData([FromHeader] string token, [FromHeader] string skey, [FromHeader] string type)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable headerTable = project.getExportHeader(pkeyInfo.Pkey, pkeyInfo.isKiwi, userInfo.IsAdmin);
DataTable bodyTable = project.getProjectData(pkeyInfo.Pkey, "", "", "", "", pkeyInfo.isKiwi, 1,"", "", type);
DataTable exportTable = project.makeExportTable(headerTable, bodyTable);
string fileName = "[DATA]" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
byte[] fileByteArray = Common.DataTableToExcel(exportTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return File(fileByteArray, "application/octet-stream", fileName);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("guide")]
[HttpGet]
public IActionResult ExportGuide([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable guideTable = project.makeGuideTable(pkeyInfo.Pkey, pkeyInfo.isKiwi, userInfo.IsAdmin);
string fileName = "[GUIDE]" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
byte[] fileByteArray = Common.DataTableToExcel(guideTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return File(fileByteArray, "application/octet-stream", fileName);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}

View File

@@ -0,0 +1,122 @@
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
using System.Net;
using System.Collections.Generic;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/import")]
[ApiController]
public class ImportAPI : ControllerBase
{
[Route("data")]
[HttpPost]
[DisableRequestSizeLimit]
public IActionResult ImportData([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
if (Request.Form.Files.Count > 0)
{
string returnString = "업로드 성공";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
var file = Request.Form.Files[0];
string extension = System.IO.Path.GetExtension(file.FileName);
string fileName = "DATA_" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + extension;
Log.InsertSiteLog(userInfo.ID, pkeyInfo.Pkey, "Upload File", "{\"Type\":\"DATA\", \"Origin\": \"" + file.FileName + "\", \"FileName\":\"" + fileName + "\"}");
fileName = Common.uploadFile(fileName, file);
returnString = project.uploadProjectData(pkeyInfo.Pkey, pkeyInfo.isKiwi, fileName, extension);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("question")]
[HttpPost]
[DisableRequestSizeLimit]
public IActionResult ImportQuestion([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
if (Request.Form.Files.Count > 0)
{
string returnString = "업로드 성공";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
var file = Request.Form.Files[0];
string extension = System.IO.Path.GetExtension(file.FileName);
string fileName = "QUESTION_" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + extension;
Log.InsertSiteLog(userInfo.ID, pkeyInfo.Pkey, "Upload File", "{\"Type\":\"QUESTION\", \"Origin\": \"" + file.FileName + "\", \"FileName\":\"" + fileName + "\"}");
fileName = Common.uploadFile(fileName, file);
returnString = project.resetQuestion(pkeyInfo.Pkey, pkeyInfo.isKiwi);
if (String.IsNullOrEmpty(returnString))
{
returnString = project.uploadQuestion(pkeyInfo.Pkey, pkeyInfo.isKiwi, fileName, extension);
}
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("title")]
[HttpPost]
[DisableRequestSizeLimit]
public IActionResult ImportTitle([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
if (Request.Form.Files.Count > 0)
{
string returnString = "업로드 성공";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
var file = Request.Form.Files[0];
string extension = System.IO.Path.GetExtension(file.FileName);
string fileName = "TITLE_" + pkeyInfo.Pkey + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + extension;
Log.InsertSiteLog(userInfo.ID, pkeyInfo.Pkey, "Upload File", "{\"Type\":\"TITLE\", \"Origin\": \"" + file.FileName + "\", \"FileName\":\"" + fileName + "\"}");
fileName = Common.uploadFile(fileName, file);
returnString = project.resetExplain(pkeyInfo.Pkey, pkeyInfo.isKiwi);
if (String.IsNullOrEmpty(returnString))
{
returnString = project.uploadExplain(pkeyInfo.Pkey, pkeyInfo.isKiwi, fileName, extension);
}
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}

View File

@@ -0,0 +1,58 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Data;
using System.Net;
using System.Text;
using System.Web;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
using System.Net.Http;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/log")]
[ApiController]
public class LogAPI : ControllerBase
{
[Route("visit")]
[HttpPost]
public IActionResult visitLog([FromHeader] string token ,[FromBody] VisitLogParam visitLog, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if(userInfo != null)
{
PkeyInfo pkeyInfo = new PkeyInfo();
if (String.IsNullOrEmpty(skey) == false)
{
pkeyInfo = new PkeyInfo(skey);
}
Log.InsertVisitLog(userInfo.ID, pkeyInfo.Pkey, visitLog.LogContent);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content("PASS");
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("site")]
[HttpPost]
public IActionResult siteLog([FromHeader] string token, [FromBody] SiteLogParam siteLog, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
PkeyInfo pkeyInfo = new PkeyInfo(skey);
Log.InsertSiteLog(userInfo.ID, pkeyInfo.Pkey, siteLog.LogTitle, siteLog.LogContent);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content("PASS");
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}

View File

@@ -0,0 +1,544 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Data;
using System.Net;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
using Microsoft.AspNetCore.Cors;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/project")]
[ApiController]
public class ProjectAPI : ControllerBase
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
[Route("list")]
[HttpGet]
public IActionResult GetProjectList([FromHeader] string token)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
DataTable resultTable = project.getProjectList(userInfo.Team, userInfo.ID, userInfo.IsAdmin);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("assign")]
[HttpGet]
public IActionResult GetAssignList([FromHeader] string token)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
string returnString = project.getAssignCount(userInfo.ID).ToString();
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("last")]
[HttpGet]
public IActionResult GetStateCount([FromHeader] string token)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
DataTable resultTable = project.lastProjectCount(userInfo.Team, userInfo.ID, userInfo.IsAdmin, 6);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("custom/progress")]
[HttpGet]
public IActionResult GetCustomProgress([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
var konReportTable = project.getKonReportURL(pkeyInfo.Pkey, pkeyInfo.isKiwi);
var includeFileTable = project.projectIncludeFiles(pkeyInfo.Pkey, pkeyInfo.isKiwi);
DataTable resultTable = includeFileTable.Clone();
if (konReportTable.Rows.Count > 0)
{
string progressURL = konReportTable.Rows[0]["file_name"].ToString();
if (progressURL.IndexOf("http") < 0)
{
progressURL = "https://kon.kric.com" + progressURL;
}
resultTable.Rows.Add(new object[] { 0, 1, progressURL });
}
for (int i = 0; i < includeFileTable.Rows.Count; i++)
{
string realFileName = string.Empty;
string appendType = includeFileTable.Rows[i]["append_type"].ToString();
if (appendType == "0")
{
realFileName = Common.MapPath(includeFileTable.Rows[i]["file_name"].ToString());
}
else
{
realFileName = includeFileTable.Rows[i]["file_name"].ToString();
}
if (System.IO.File.Exists(realFileName) || appendType != "0")
{
var addRowArray = includeFileTable.Rows[i].ItemArray;
resultTable.Rows.Add(addRowArray);
}
}
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("progress/type")]
[HttpGet]
public IActionResult GetTypeByState([FromHeader] string token, [FromHeader] string skey, [FromHeader] string selectDate)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getTypeByState(pkeyInfo.Pkey, pkeyInfo.isKiwi, selectDate);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("progress/loi")]
[HttpGet]
public IActionResult GetLOI([FromHeader] string token, [FromHeader] string skey, [FromHeader] string selectDate)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getLOI(pkeyInfo.Pkey, pkeyInfo.isKiwi, selectDate);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("progress/day")]
[HttpGet]
public IActionResult GetDayByState([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getDayByState(pkeyInfo.Pkey, pkeyInfo.isKiwi);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("progress/screen")]
[HttpGet]
public IActionResult GetQidByScreen([FromHeader] string token, [FromHeader] string skey, [FromHeader] string selectDate)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getQidByScreen(pkeyInfo.Pkey, pkeyInfo.isKiwi, selectDate);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("question/{qid}")]
[HttpGet]
public IActionResult GetQuestionListWithQID([FromHeader] string token, [FromHeader] string skey, string qid)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getQuestionList(pkeyInfo.Pkey, qid, pkeyInfo.isKiwi, userInfo.IsAdmin);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("question")]
[HttpGet]
public IActionResult GetQuestionList([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getQuestionList(pkeyInfo.Pkey, "", pkeyInfo.isKiwi, userInfo.IsAdmin);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("quota")]
[HttpGet]
public IActionResult GetQuotaList([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getQuotaList(pkeyInfo.Pkey, pkeyInfo.isKiwi);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("bookmark/{page}")]
[HttpGet]
public IActionResult GetBookmarkList([FromHeader] string token, [FromHeader] string skey, string page)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getBookmark(pkeyInfo.Pkey, page, userInfo.Team, userInfo.ID);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("bookmark/create")]
[HttpPost]
public IActionResult CreateBookmark([FromHeader] string token, [FromBody] BookmarkParam bookmarkParam, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string returnString = project.insertBookmark(pkeyInfo.Pkey, bookmarkParam, userInfo.Team, userInfo.ID);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("bookmark/update")]
[HttpPost]
public IActionResult UpdateBookmark([FromHeader] string token, [FromBody] BookmarkParam bookmarkParam, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string returnString = project.updateBookmark(pkeyInfo.Pkey, bookmarkParam, userInfo.Team, userInfo.ID);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("bookmark/delete/{bookmarkID}")]
[HttpPost]
public IActionResult DeleteBookmark([FromHeader] string token, [FromHeader] string skey, string bookmarkID)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string returnString = project.deleteBookmark(pkeyInfo.Pkey, bookmarkID, userInfo.ID);
if (returnString.IndexOf("오류") > -1)
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
else
{
Response.StatusCode = (int)HttpStatusCode.OK;
}
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("derived")]
[HttpGet]
public IActionResult GetDerivedList([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "application/json";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
DataTable resultTable = project.getOnlyDerivedList(pkeyInfo.Pkey, pkeyInfo.isKiwi, userInfo.Team, userInfo.IsAdmin);
string returnString = Common.GetJsonFromObject(resultTable);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("derived/all")]
[HttpPost]
public IActionResult UpdateAllDerivedVariable([FromHeader] string token, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string returnString = project.updateAllDerived(pkeyInfo.Pkey, pkeyInfo.isKiwi, userInfo.ID);
if(returnString.IndexOf("오류") > -1)
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
else
{
Response.StatusCode = (int)HttpStatusCode.OK;
}
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("derived/create")]
[HttpPost]
public IActionResult CreateDerivedVariable([FromHeader] string token, [FromBody] DerivedParam derivedParam, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string returnString = project.insertDerivedVariable(pkeyInfo.Pkey, pkeyInfo.isKiwi, derivedParam, userInfo.Team, userInfo.ID);
if (returnString.IndexOf("오류") > -1)
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
else
{
Response.StatusCode = (int)HttpStatusCode.OK;
}
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("derived/update")]
[HttpPost]
public IActionResult UpdateDerivedVariable([FromHeader] string token, [FromBody] DerivedParam derivedParam, [FromHeader] string skey)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string returnString = project.updateDerivedVariable(pkeyInfo.Pkey, pkeyInfo.isKiwi, derivedParam, userInfo.Team, userInfo.ID);
if (returnString.IndexOf("오류") > -1)
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
else
{
Response.StatusCode = (int)HttpStatusCode.OK;
}
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("derived/delete/{variableID}")]
[HttpPost]
public IActionResult DeleteDerived([FromHeader] string token, [FromHeader] string skey, string variableID)
{
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
Project project = new Project();
PkeyInfo pkeyInfo = new PkeyInfo(skey);
variableID = variableID.Split('_')[0].ToUpper();
string returnString = project.deleteDerivedVariable(pkeyInfo.Pkey, pkeyInfo.isKiwi, variableID, userInfo.ID);
if (returnString.IndexOf("오류") > -1)
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
else
{
Response.StatusCode = (int)HttpStatusCode.OK;
}
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("derived/{iskiwi}/{pkey}/{idkey}")]
[HttpPost]
public IActionResult CreateDerivedData(string iskiwi,string pkey, string idkey)
{
hcAccessor.HttpContext.Response.ContentType = "text/plain";
if (Common.IsNumeric(iskiwi))
{
Project project = new Project();
string returnString = project.setDerivedDataWithID(pkey, Convert.ToInt32(iskiwi), idkey);
if (returnString.IndexOf("오류") > -1)
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
}
else
{
Response.StatusCode = (int)HttpStatusCode.OK;
}
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}

View File

@@ -0,0 +1,195 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/report")]
[ApiController]
public class ReportAPI : ControllerBase
{
[Route("result")]
[HttpPost]
public IActionResult Result([FromHeader] string token, [FromBody] ReportParam reportParam, [FromHeader] string skey)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
var context = hcAccessor.HttpContext;
hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Security security = new Security();
Report report = new Report();
string returnString = string.Empty;
PkeyInfo pkeyInfo = new PkeyInfo(skey);
string mkey = userInfo.ID;
#region data, param 정리
try
{
//"index":"Q1"
string indexString = reportParam.IndexParam.ToUpper().Replace(" ", "");
//"banner":"Q1,Q2|Q3" ','옆으로 붙이기 / '|'단으로 쌓기
string bannerString = reportParam.BannerParam.ToUpper().Replace(" ", "");
//"filter":"(Q1>3)"
//filter가 Q|로 시작하면 vname이 아닌 QID로 작성된 필터문 ex) Q|(Q1>3)
string filterString = reportParam.FilterParam;
JObject options = Common.GetJObjectFromString(reportParam.OptionParam);
//"0" ~ "14"
string pointerStr = Common.GetNullString(options["POINTER"]);
string mPointerStr = Common.GetNullString(options["MPOINTER"]);
//"1" -> cell은 N만 Total은 N 만/ "2" -> cell은 %,N Total은 %,N / default -> cell은 %만 Total은 N 만
string prtModeStr = Common.GetNullString(options["PRTMODE"]);
//ex) {"카테고리1":"1,2,3", "카테고리2":"4,5,6", "카테고리3":"7,8,9"}
string valueGroupStr = Common.GetNullString(options["VGROUP"]);
#region 옵션 파라미터
Report.ReportOptions reportOptions = new Report.ReportOptions();
//Tabulation 표본특성, Banner By Banner
reportOptions.mode = Common.GetNullString(options["MODE"]);
//ex) "2022-01-25"
reportOptions.startDate = Common.GetNullString(options["SDATE"]);
reportOptions.endDate = Common.GetNullString(options["EDATE"]);
// 쿼터 표 번호(QSORDER)
reportOptions.isQuota = Common.GetNullString(options["QUOTA"]);
// "TEST" 테스트 데이터 사용, ALL TEST와 실제 데이터 같이 사용 이외의 문자열 테스트 데이터 사용X
reportOptions.isTest = Common.GetNullString(options["TEST"]);
// "1" 행 열 전환 이외의 문자열 행 열 전환X
reportOptions.isTurn = Common.GetNullString(options["TURN"]);
//출력 default -> cell은 %만 Total은 N 만
reportOptions.prtTotalCase = 1;
reportOptions.prtTotalPercent = 0;
reportOptions.prtCase = 0;
reportOptions.prtPercent = 1;
//소수점 default -> 14자리
reportOptions.roundPointer = 14;
reportOptions.mRoundPointer = 14;
// "0" 헤더 출력 안함 이외의 문자열 헤더 출력
// "GPT" 추가 GPT용 Table에는 머지가 되지 않은 헤더를 붙임
reportOptions.prtHeader = Common.GetNullString(options["PRTHEAD"]);
// "0" sub total 출력 안함 이외의 문자열 sub total 출력
reportOptions.prtSubTotal = Common.GetNullString(options["PRTSUB"]);
// "1" 인덱스 레이블 출력 안함 이외의 문자열 인덱스 레이블 출력
reportOptions.prtIndexValue = Common.GetNullString(options["PRTIV"]);
// "1" Numeric문항 Sum값 출력 이외의 문자열 Numeric문항 Sum값 출력 안함
reportOptions.prtNumericSum = Common.GetNullString(options["PRTNS"]);
if (String.IsNullOrWhiteSpace(pointerStr) == false && Common.IsNumeric(pointerStr))
{
if (Convert.ToInt32(pointerStr) < 14)
{
reportOptions.roundPointer = Convert.ToInt32(pointerStr);
}
}
if (String.IsNullOrWhiteSpace(mPointerStr) == false && Common.IsNumeric(mPointerStr))
{
if (Convert.ToInt32(mPointerStr) < 14)
{
reportOptions.mRoundPointer = Convert.ToInt32(mPointerStr);
}
}
if (String.IsNullOrWhiteSpace(reportOptions.isQuota) == false)//쿼터표는 옵션이 특별
{
//쿼터표는 N만
reportOptions.prtCase = 1;
reportOptions.prtPercent = 0;
//쿼터표는 SubTotal X
reportOptions.prtSubTotal = "0";
}
else
{
if (prtModeStr == "1")
{
//출력 1 -> cell은 N만 Total은 N 만
reportOptions.prtCase = 1;
reportOptions.prtPercent = 0;
}
else if (prtModeStr == "2")
{
//출력 2 -> cell은 %,N Total은 %,N
reportOptions.prtTotalCase = 1;
reportOptions.prtTotalPercent = 1;
reportOptions.prtCase = 1;
reportOptions.prtPercent = 1;
}
}
if (Common.IsJson(valueGroupStr))
{
reportOptions.valueGroup = Common.GetJObjectFromString(valueGroupStr);
}
#endregion
if (Request.Headers["Referer"].ToString().IndexOf(context.Request.Host.ToString()) < 0)
{
JObject logJson = new JObject();
logJson["INDEX"] = indexString;
logJson["BANNER"] = bannerString;
logJson["FILTER"] = filterString;
JObject optionJson = new JObject();
optionJson["MODE"] = reportOptions.mode;
optionJson["SDATE"] = reportOptions.startDate;
optionJson["EDATE"] = reportOptions.endDate;
optionJson["TEST"] = reportOptions.isTest;
optionJson["TURN"] = reportOptions.isTurn;
optionJson["POINTER"] = pointerStr;
optionJson["MPOINTER"] = mPointerStr;
optionJson["PRTMODE"] = prtModeStr;
optionJson["PRTHEAD"] = reportOptions.prtHeader;
optionJson["PRTSUB"] = reportOptions.prtSubTotal;
optionJson["PRTIV"] = reportOptions.prtIndexValue;
optionJson["PRTNS"] = reportOptions.prtNumericSum;
optionJson["VGROUP"] = valueGroupStr;
List<string> keyList = optionJson.Properties().Select(x => x.Name).Distinct().ToList<string>();
for (int ki = 0; ki < keyList.Count; ki++)
{
if (optionJson[keyList[ki]].ToString() == "")
{
optionJson.Property(keyList[ki]).Remove();
}
}
logJson["OPTION"] = optionJson;
if (String.IsNullOrEmpty(mkey))
{
mkey = context.Request.Host.ToString();
}
Log.InsertSiteLog(mkey, pkeyInfo.Pkey, "Get Report Data", logJson.ToString());
}
#endregion
context.Response.ContentType = "application/json";
returnString = report.getResult(pkeyInfo.Pkey, pkeyInfo.isKiwi, indexString, bannerString, filterString, reportOptions);
}
catch (Exception ex)
{
returnString = ex.Message.ToString();
}
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}

View File

@@ -0,0 +1,150 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
using System.Data;
using System;
using System.Net;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/encrypt")]
[ApiController]
public class SecurityAPI : ControllerBase
{
[Route("pkey")]
[HttpGet]
public IActionResult EncryptString([FromHeader] string token, [FromHeader]string pkey, [FromHeader]string iskiwi)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Project project = new Project();
if (project.getProjectInfo(pkey, Convert.ToInt32(iskiwi)).Rows.Count > 0)
{
string returnString = string.Empty;
Security security = new Security();
if (iskiwi == "1")
{
pkey = "|K|W|" + pkey;
}
returnString = WebUtility.UrlEncode(security.encryptString(pkey));
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("login")]
[HttpPost]
public IActionResult Login([FromBody] LoginParam login)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "application/json";
User user = new User();
DataTable userTable = user.userLogin(login.ID, login.Password);
if (userTable.Rows.Count > 0)
{
string returnString = "";
string userID = userTable.Rows[0]["mail"].ToString();
string userPNO = userTable.Rows[0]["p_no"].ToString();
string userName = userTable.Rows[0]["member_name"].ToString();
string userTeam = userTable.Rows[0]["team"].ToString();
string isKri = userTable.Rows[0]["is_kri"].ToString();
// isAdmin - 0 : Admin, 1:DCO, 5:타부서, 7:클라이언트, 9:외부 링크
string isAdmin = "7";
if (userID == "jspark@kric.com")
{
isAdmin = "0";
}
else if (userTeam == "S301" || userTeam == "S401" || userTeam == "S501" || userPNO == "20191201")//온라인 사업, 데이터 사업, 개발팀 + 서지원 상무
{
isAdmin = "1";
}
else if (isKri == "1")
{
isAdmin = "4";
}
else if (isKri == "2")
{
isAdmin = "5";
}
else if (isKri == "3")
{
isAdmin = "6";
}
Log.insertLoginLog(userID);
Security security = new Security();
string token = security.GenerateToken(userID, userName, userTeam, isAdmin);
Authentication authentication = new Authentication(token, userName, isAdmin);
returnString = Common.GetJsonFromObject(authentication);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("authentication")]
[HttpGet]
public IActionResult Authentication([FromHeader] string token)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(null);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("external")]
[HttpPost]
public IActionResult External([FromBody] ExternalParam externalParam)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "text/plain";
if (externalParam.External == "KON" || externalParam.External == "KIWI" || externalParam.External == "CLIENT")
{
string returnString = "";
Log.insertLoginLog(externalParam.External);
Security security = new Security();
string tempID = externalParam.External + "_" + Common.GetRandomString();
string token = security.GenerateToken(tempID, externalParam.External, externalParam.External, "9");
Authentication authentication = new Authentication(token, externalParam.External, "9");
returnString = Common.GetJsonFromObject(authentication);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}

View File

@@ -0,0 +1,77 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Data;
using System.Net;
using System.Text;
using System.Web;
using REPORT_API_ver6.Services;
using REPORT_API_ver6.Models;
namespace REPORT_API_ver6.Controllers
{
[Route("api/v1/uri")]
[ApiController]
public class UriAPI : ControllerBase
{
[Route("short")]
[HttpPost]
public IActionResult ShortURL([FromHeader] string token, [FromBody] ShortURLParam shortURLParam, [FromHeader] string skey)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "text/plain";
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
string okey = "REPORT";
if(userInfo.ID == "KON" || userInfo.ID == "KIWI" || userInfo.ID == "NEWSSAK")
{
okey = userInfo.ID;
}
PkeyInfo pkeyInfo = new PkeyInfo(skey);
Project project = new Project();
DataTable proejctInfo = project.getProjectInfo(pkeyInfo.Pkey, pkeyInfo.isKiwi);
if(proejctInfo.Rows.Count > 0)
{
int mode = shortURLParam.Mode == "P" ? 1 : 0;
string returnString = "https://kart.kric.com/External/" + URI.GetURIKey(shortURLParam.RealURI, mode, skey, proejctInfo.Rows[0]["title"].ToString(), okey);
string cLogContent = "{ \"REAL_URI\": \"" + shortURLParam.RealURI + "\",\"MODE\": \"" + shortURLParam.Mode + "\", \"COPY_URI\": \"" + returnString + "\" }";
Log.InsertSiteLog(userInfo.ID, pkeyInfo.Pkey, "URL Copy", cLogContent);
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(returnString);
}
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
[Route("short/{urikey}")]
[HttpGet]
public IActionResult ShortURL([FromHeader] string token, string urikey)
{
HttpContextAccessor hcAccessor = new HttpContextAccessor();
hcAccessor.HttpContext.Response.ContentType = "application/json";
UserInfo userInfo = Security.ValidateToken(token);
if (userInfo != null)
{
DataTable realUritable = URI.GetRealURL(urikey, true);
if (realUritable.Rows.Count > 0)
{
Response.StatusCode = (int)HttpStatusCode.OK;
return Content(Common.GetJsonFromObject(realUritable));
}
}
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Content(null);
}
}
}