firts commit
This commit is contained in:
179
KART_API/Controllers/ExportController.cs
Normal file
179
KART_API/Controllers/ExportController.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using KART_API.Services;
|
||||
using KART_API.Utils;
|
||||
using KART_API.Dto;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/export")]
|
||||
[ApiController]
|
||||
public class ExportController : 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 != "[]")
|
||||
{
|
||||
MakeExcelService makeExcel = new MakeExcelService();
|
||||
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 != "[]")
|
||||
{
|
||||
MakeExcelService makeExcel = new MakeExcelService();
|
||||
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)
|
||||
{
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable headerTable = project.getExportHeader(projectCodeInfo.projectCode, userInfo.IsAdmin);
|
||||
DataTable exportTable = project.makeExportTable(headerTable);
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
string fileName = "(Header)" + projectCodeInfo.projectCode + "_" + 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/새싹 문항 등록 양식.xlsx"));
|
||||
// return File(fileByteArray, "application/octet-stream", "새싹 문항 등록 양식.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)
|
||||
{
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable titleTable = project.getExportExplain(projectCodeInfo.projectCode);
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
string fileName = "(Explain)" + projectCodeInfo.projectCode + "_" + 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, [FromHeader] string isTest = "")
|
||||
{
|
||||
UserInfo userInfo = Security.ValidateToken(token);
|
||||
if (userInfo != null)
|
||||
{
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable headerTable = project.getExportHeader(projectCodeInfo.projectCode, userInfo.IsAdmin);
|
||||
|
||||
DataTable bodyTable = project.getProjectData(projectCodeInfo.projectCode, "", "", "", "", 1, isTest, "", type);
|
||||
DataTable exportTable = project.makeExportTable(headerTable, bodyTable);
|
||||
|
||||
DataTable guideTable = project.makeGuideTable(projectCodeInfo.projectCode, userInfo.IsAdmin);
|
||||
|
||||
List<DataTabelToExcelSheet> excelDataList =
|
||||
[
|
||||
new DataTabelToExcelSheet(exportTable, "DATA"),
|
||||
new DataTabelToExcelSheet(guideTable, "GUIDE")
|
||||
];
|
||||
|
||||
|
||||
string fileName = "(DATA)" + projectCodeInfo.projectCode + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx";
|
||||
byte[] fileByteArray = Common.DataTableToExcel(excelDataList);
|
||||
|
||||
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)
|
||||
{
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
DataTable guideTable = project.makeGuideTable(projectCodeInfo.projectCode, userInfo.IsAdmin);
|
||||
|
||||
string fileName = "(GUIDE)" + projectCodeInfo.projectCode + "_" + 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
135
KART_API/Controllers/ImportController.cs
Normal file
135
KART_API/Controllers/ImportController.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using KART_API.Services;
|
||||
using KART_API.Dto;
|
||||
using KART_API.Utils;
|
||||
using System.Net;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/import")]
|
||||
[ApiController]
|
||||
public class ImportController : ControllerBase
|
||||
{
|
||||
//ToDo : 해야해
|
||||
[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 = "업로드 성공";
|
||||
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
var file = Request.Form.Files[0];
|
||||
string extension = System.IO.Path.GetExtension(file.FileName);
|
||||
string fileName = "DATA_" + projectCodeInfo.projectCode + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + extension;
|
||||
|
||||
LogService.InsertSiteLog(userInfo.ID, projectCodeInfo.projectCode, "Upload File", "{\"Type\":\"DATA\", \"Origin\": \"" + file.FileName + "\", \"FileName\":\"" + fileName + "\"}");
|
||||
fileName = Common.uploadFile(fileName, file);
|
||||
|
||||
returnString = project.uploadProjectData(projectCodeInfo.projectCode, fileName, extension);
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content(returnString);
|
||||
*/
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("새싹은 미지원");
|
||||
}
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
return Content(null);
|
||||
}
|
||||
//ToDo : 해야해
|
||||
[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 = "업로드 성공";
|
||||
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
var file = Request.Form.Files[0];
|
||||
string extension = System.IO.Path.GetExtension(file.FileName);
|
||||
string fileName = "QUESTION_" + projectCodeInfo.projectCode + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + extension;
|
||||
|
||||
LogService.InsertSiteLog(userInfo.ID, projectCodeInfo.projectCode, "Upload File", "{\"Type\":\"QUESTION\", \"Origin\": \"" + file.FileName + "\", \"FileName\":\"" + fileName + "\"}");
|
||||
fileName = Common.uploadFile(fileName, file);
|
||||
|
||||
returnString = project.resetQuestion(projectCodeInfo.projectCode);
|
||||
if (String.IsNullOrEmpty(returnString))
|
||||
{
|
||||
returnString = project.uploadQuestion(projectCodeInfo.projectCode, fileName, extension);
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content(returnString);
|
||||
*/
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("새싹은 미지원");
|
||||
}
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
return Content(null);
|
||||
}
|
||||
//ToDo : 해야해
|
||||
[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 = "업로드 성공";
|
||||
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
var file = Request.Form.Files[0];
|
||||
string extension = System.IO.Path.GetExtension(file.FileName);
|
||||
string fileName = "TITLE_" + projectCodeInfo.projectCode + "_" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + extension;
|
||||
|
||||
LogService.InsertSiteLog(userInfo.ID, projectCodeInfo.projectCode, "Upload File", "{\"Type\":\"TITLE\", \"Origin\": \"" + file.FileName + "\", \"FileName\":\"" + fileName + "\"}");
|
||||
fileName = Common.uploadFile(fileName, file);
|
||||
|
||||
returnString = project.resetExplain(projectCodeInfo.projectCode);
|
||||
if (String.IsNullOrEmpty(returnString))
|
||||
{
|
||||
returnString = project.uploadExplain(projectCodeInfo.projectCode, fileName, extension);
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content(returnString);
|
||||
*/
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("새싹은 미지원");
|
||||
}
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
return Content(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
KART_API/Controllers/LogController.cs
Normal file
59
KART_API/Controllers/LogController.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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 KART_API.Services;
|
||||
using KART_API.Dto;
|
||||
using KART_API.Utils;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/log")]
|
||||
[ApiController]
|
||||
public class LogController : ControllerBase
|
||||
{
|
||||
[Route("visit")] //확인
|
||||
[HttpPost]
|
||||
public IActionResult visitLog([FromHeader] string token ,[FromBody] VisitLogParam visitLog, [FromHeader] string skey)
|
||||
{
|
||||
UserInfo userInfo = Security.ValidateToken(token);
|
||||
if(userInfo != null)
|
||||
{
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo();
|
||||
if (String.IsNullOrEmpty(skey) == false)
|
||||
{
|
||||
projectCodeInfo = new projectCodeInfo(skey);
|
||||
}
|
||||
LogService.InsertVisitLog(userInfo.ID, projectCodeInfo.projectCode, 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)
|
||||
{
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
LogService.InsertSiteLog(userInfo.ID, projectCodeInfo.projectCode, siteLog.LogTitle, siteLog.LogContent);
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("PASS");
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
return Content(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
512
KART_API/Controllers/ProjectController.cs
Normal file
512
KART_API/Controllers/ProjectController.cs
Normal file
@@ -0,0 +1,512 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using KART_API.Services;
|
||||
using KART_API.Utils;
|
||||
using KART_API.Dto;
|
||||
using System.IO;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
||||
using OfficeOpenXml.Style;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/project")]
|
||||
[ApiController]
|
||||
public class ProjectController : 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";
|
||||
ProjectService project = new ProjectService();
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
|
||||
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("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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getTypeByState(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getLOI(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getDayByState(projectCodeInfo.projectCode);
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getQidByScreen(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getQuestionList(projectCodeInfo.projectCode, qid);
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getQuestionList(projectCodeInfo.projectCode, "");
|
||||
resultTable = resultTable.AsEnumerable().Where(dr => dr.Field<string>("QTYPE").ToLower() != "file").CopyToDataTable();
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getQuotaList(projectCodeInfo.projectCode);
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getBookmark(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
string returnString = project.insertBookmark(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
string returnString = project.updateBookmark(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
string returnString = project.deleteBookmark(projectCodeInfo.projectCode, 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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
DataTable resultTable = project.getOnlyDerivedList(projectCodeInfo.projectCode, userInfo.Team, userInfo.IsAdmin);
|
||||
string returnString = Common.GetJsonFromObject(resultTable);
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content(returnString);
|
||||
|
||||
/* Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("새싹은 미지원");*/
|
||||
}
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
string returnString = project.updateAllDerived(projectCodeInfo.projectCode, userInfo.ID);
|
||||
|
||||
if(returnString.IndexOf("오류") > -1)
|
||||
{
|
||||
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
}
|
||||
|
||||
return Content(returnString);
|
||||
|
||||
/* Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("새싹은 미지원");*/
|
||||
}
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
string returnString = project.insertDerivedVariable(projectCodeInfo.projectCode, 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.OK;
|
||||
return Content("새싹은 미지원");*/
|
||||
}
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
string returnString = project.updateDerivedVariable(projectCodeInfo.projectCode, 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.OK;
|
||||
return Content("새싹은 미지원");*/
|
||||
}
|
||||
|
||||
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";
|
||||
ProjectService project = new ProjectService();
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
|
||||
variableID = variableID.Split('_')[0].ToUpper();
|
||||
string returnString = project.deleteDerivedVariable(projectCodeInfo.projectCode, 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.OK;
|
||||
return Content("새싹은 미지원");*/
|
||||
}
|
||||
|
||||
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
||||
return Content(null);
|
||||
}
|
||||
|
||||
//kon에서 문항 완료시 Derived 변수 만드는 거 새싹을 위해 준비해 놓도록 하자
|
||||
[Route("derived/{projectCode}/{answerID}")] //확인
|
||||
[HttpPost]
|
||||
public IActionResult CreateDerivedData(string projectCode, string answerID)
|
||||
{
|
||||
hcAccessor.HttpContext.Response.ContentType = "text/plain";
|
||||
|
||||
/* Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
return Content("새싹은 미지원");*/
|
||||
|
||||
ProjectService project = new ProjectService();
|
||||
string returnString = project.updateAllDerived(projectCode, "NEWSSAK", answerID);
|
||||
|
||||
if (returnString.IndexOf("오류") > -1)
|
||||
{
|
||||
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
}
|
||||
return Content(returnString);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
195
KART_API/Controllers/ReportController.cs
Normal file
195
KART_API/Controllers/ReportController.cs
Normal 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 KART_API.Services;
|
||||
using KART_API.Dto;
|
||||
using KART_API.Utils;
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/report")]
|
||||
[ApiController]
|
||||
public class ReportController : 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();
|
||||
ReportService report = new ReportService();
|
||||
string returnString = string.Empty;
|
||||
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
string mkey = userInfo.ID;
|
||||
|
||||
#region data, param 정리
|
||||
try
|
||||
{
|
||||
//"index":"1"
|
||||
string indexString = reportParam.IndexParam.ToUpper().Replace(" ", "");
|
||||
//"banner":"2,3|4" ','옆으로 붙이기 / '|'단으로 쌓기
|
||||
string bannerString = reportParam.BannerParam.ToUpper().Replace(" ", "");
|
||||
//filter 새싹 로직 참조
|
||||
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 옵션 파라미터
|
||||
ReportService.ReportOptions reportOptions = new ReportService.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();
|
||||
}
|
||||
LogService.InsertSiteLog(mkey, projectCodeInfo.projectCode, "Get Report Data", logJson.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
context.Response.ContentType = "application/json";
|
||||
returnString = report.getResult(projectCodeInfo.projectCode, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
145
KART_API/Controllers/SecurityController.cs
Normal file
145
KART_API/Controllers/SecurityController.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using KART_API.Services;
|
||||
using KART_API.Utils;
|
||||
using KART_API.Dto;
|
||||
using System.Data;
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/encrypt")]
|
||||
[ApiController]
|
||||
public class SecurityController : ControllerBase
|
||||
{
|
||||
|
||||
[Route("pkey")]//확인
|
||||
[HttpGet]
|
||||
public IActionResult EncryptString([FromHeader] string token, [FromHeader]string pkey)
|
||||
{
|
||||
HttpContextAccessor hcAccessor = new HttpContextAccessor();
|
||||
hcAccessor.HttpContext.Response.ContentType = "text/plain";
|
||||
|
||||
UserInfo userInfo = Security.ValidateToken(token);
|
||||
if (userInfo != null)
|
||||
{
|
||||
ProjectService project = new ProjectService();
|
||||
if (project.getProjectInfo(pkey).Rows.Count > 0)
|
||||
{
|
||||
Security security = new Security();
|
||||
string 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";
|
||||
|
||||
UserService user = new UserService();
|
||||
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, 4:BC 팀, 5:타부서, 6:외부인 인데 파생변수까지 접근, 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";
|
||||
}
|
||||
|
||||
LogService.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 == "NS" || externalParam.External == "KON" || externalParam.External == "KIWI" || externalParam.External == "CLIENT")
|
||||
{
|
||||
string returnString = "";
|
||||
LogService.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
78
KART_API/Controllers/UriController.cs
Normal file
78
KART_API/Controllers/UriController.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
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 KART_API.Services;
|
||||
using KART_API.Utils;
|
||||
using KART_API.Dto;
|
||||
|
||||
namespace KART_API.Controllers
|
||||
{
|
||||
[Route("api/v2/uri")]
|
||||
[ApiController]
|
||||
public class UriController : 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;
|
||||
}
|
||||
|
||||
projectCodeInfo projectCodeInfo = new projectCodeInfo(skey);
|
||||
ProjectService project = new ProjectService();
|
||||
DataTable proejctInfo = project.getProjectInfo(projectCodeInfo.projectCode);
|
||||
|
||||
if(proejctInfo.Rows.Count > 0)
|
||||
{
|
||||
int mode = shortURLParam.Mode == "P" ? 1 : 0;
|
||||
string returnString = "https://kart.kric.com/External/" + URIService.GetURIKey(shortURLParam.RealURI, mode, skey, proejctInfo.Rows[0]["IN_TT"].ToString(), okey);
|
||||
string cLogContent = "{ \"REAL_URI\": \"" + shortURLParam.RealURI + "\",\"MODE\": \"" + shortURLParam.Mode + "\", \"COPY_URI\": \"" + returnString + "\" }";
|
||||
LogService.InsertSiteLog(userInfo.ID, projectCodeInfo.projectCode, "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 = URIService.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user