109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
using FCM0000;
|
|
using Microsoft.Owin;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Web;
|
|
using System.Web.Http;
|
|
|
|
namespace Project.Web.Controllers
|
|
{
|
|
public class CommonController : BaseController
|
|
{
|
|
[HttpGet]
|
|
public HttpResponseMessage GetList(string grp=null)
|
|
{
|
|
var sql = string.Empty;
|
|
sql = "select *" +
|
|
" from common" +
|
|
" where gcode = @gcode" +
|
|
" and grp = @grp" +
|
|
" order by code,svalue";
|
|
|
|
var cs = Properties.Settings.Default.gwcs;// "Data Source=K4FASQL.kr.ds.amkor.com,50150;Initial Catalog=EE;Persist Security Info=True;User ID=eeadm;Password=uJnU8a8q&DJ+ug-D!";
|
|
var cn = new System.Data.SqlClient.SqlConnection(cs);
|
|
var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
|
|
cmd.Parameters.AddWithValue("gcode", FCOMMON.info.Login.gcode);
|
|
|
|
// 날짜 파라미터가 없으면 기본값 사용 (현재 월)
|
|
var grpCode = !string.IsNullOrEmpty(grp) ? grp : "99";
|
|
cmd.Parameters.AddWithValue("grp", grpCode);
|
|
|
|
var da = new System.Data.SqlClient.SqlDataAdapter(cmd);
|
|
var dt = new System.Data.DataTable();
|
|
da.Fill(dt);
|
|
da.Dispose();
|
|
cmd.Dispose();
|
|
cn.Dispose();
|
|
|
|
var txtjson = JsonConvert.SerializeObject(dt, new JsonSerializerSettings
|
|
{
|
|
NullValueHandling = NullValueHandling.Ignore
|
|
});
|
|
|
|
var resp = new HttpResponseMessage()
|
|
{
|
|
Content = new StringContent(
|
|
txtjson,
|
|
System.Text.Encoding.UTF8,
|
|
"application/json")
|
|
};
|
|
|
|
return resp;
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public HttpResponseMessage Index()
|
|
{
|
|
// 직접 파일을 읽어서 반환
|
|
var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "Common.html");
|
|
var contents = string.Empty;
|
|
|
|
if (System.IO.File.Exists(filePath))
|
|
{
|
|
contents = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8);
|
|
}
|
|
else
|
|
{
|
|
// 파일이 없으면 404 에러 페이지 또는 기본 메시지
|
|
contents = "<html><body><h1>404 - File Not Found</h1><p>The requested file was not found: " + filePath + "</p></body></html>";
|
|
}
|
|
|
|
|
|
var resp = new HttpResponseMessage()
|
|
{
|
|
Content = new StringContent(
|
|
contents,
|
|
System.Text.Encoding.UTF8,
|
|
"text/html")
|
|
};
|
|
|
|
return resp;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public class CommonModel
|
|
{
|
|
|
|
|
|
public int idx { get; set; } // 데이터고유번호
|
|
public string gcode { get; set; } // 그룹코드(데이터 그룹간 식별)
|
|
public string grp { get; set; } // 코드그룹
|
|
public string code { get; set; } // 코드
|
|
public string svalue { get; set; } // 값(문자열)
|
|
public int ivalue { get; set; } // 값(숫자)
|
|
public float fvalue { get; set; } // 값(실수)
|
|
public string memo { get; set; } // 비고
|
|
public string svalue2 { get; set; } // 값2(문자열)
|
|
public string wuid { get; set; } // 데이터기록자 사원번호
|
|
public string wdate { get; set; } // 데이터를기록한일시
|
|
}
|
|
}
|
|
|
|
|
|
|