firts commit
This commit is contained in:
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user