136 lines
4.6 KiB
C#
136 lines
4.6 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|