udpate login.html
This commit is contained in:
@@ -39,23 +39,43 @@ namespace Project.Web.Controllers
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetUserGroups()
|
||||
{
|
||||
var dt = DBM.GetUserGroups();
|
||||
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 GetholyUser()
|
||||
{
|
||||
var sql = string.Empty;
|
||||
sql = $"select uid,cate,sdate,edate,HolyReason " +
|
||||
$"from EETGW_HolydayRequest " +
|
||||
$"where gcode = '{FCOMMON.info.Login.gcode}'" +
|
||||
$"and conf = 1 and HolyDays > 0 and sdate <= GETDATE() and edate >= GETDATE()";
|
||||
|
||||
if (info.Login.gcode == null)
|
||||
info.Login.gcode = "EET1P";
|
||||
|
||||
sql = sql.Replace("{gcode}", FCOMMON.info.Login.gcode);
|
||||
sql = $" select uid,cate,sdate,edate,HolyReason,Users.name " +
|
||||
$" from EETGW_HolydayRequest INNER JOIN " +
|
||||
$" Users ON EETGW_HolydayRequest.uid = Users.id " +
|
||||
$" where EETGW_HolydayRequest.gcode = @gcode" +
|
||||
$" and conf = 1 and HolyDays > 0 and sdate <= GETDATE() and edate >= GETDATE()";
|
||||
|
||||
//sql = sql.Replace("{gcode}", FCOMMON.info.Login.gcode);
|
||||
|
||||
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 da = new System.Data.SqlClient.SqlDataAdapter(cmd);
|
||||
var dt = new System.Data.DataTable();
|
||||
da.Fill(dt);
|
||||
@@ -77,10 +97,9 @@ namespace Project.Web.Controllers
|
||||
};
|
||||
|
||||
return resp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
|
||||
@@ -1,299 +1,349 @@
|
||||
//using System;
|
||||
//using System.Linq;
|
||||
//using System.Net.Http;
|
||||
//using System.Web.Http;
|
||||
//using Newtonsoft.Json;
|
||||
//using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using FCOMMON;
|
||||
|
||||
//namespace Project.Web.Controllers
|
||||
//{
|
||||
// // 로그인 요청 모델
|
||||
// public class LoginRequest
|
||||
// {
|
||||
// public string UserId { get; set; }
|
||||
// public string Password { get; set; }
|
||||
// public bool RememberMe { get; set; }
|
||||
// }
|
||||
namespace Project.Web.Controllers
|
||||
{
|
||||
// 로그인 요청 모델
|
||||
public class LoginRequest
|
||||
{
|
||||
public string Gcode { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool RememberMe { get; set; }
|
||||
}
|
||||
|
||||
// // 로그인 응답 모델
|
||||
// public class LoginResponse
|
||||
// {
|
||||
// public bool Success { get; set; }
|
||||
// public string Message { get; set; }
|
||||
// public string RedirectUrl { get; set; }
|
||||
// public object UserData { get; set; }
|
||||
// }
|
||||
// 로그인 응답 모델
|
||||
public class LoginResponse
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string RedirectUrl { get; set; }
|
||||
public object UserData { get; set; }
|
||||
}
|
||||
|
||||
// public class HomeController : BaseController
|
||||
// {
|
||||
// [HttpPost]
|
||||
// public void Index([FromBody]string value)
|
||||
// {
|
||||
public class HomeController : BaseController
|
||||
{
|
||||
[HttpPost]
|
||||
public void Index([FromBody]string value)
|
||||
{
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// // PUT api/values/5
|
||||
// public void Put(int id, [FromBody]string value)
|
||||
// {
|
||||
// }
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody]string value)
|
||||
{
|
||||
}
|
||||
|
||||
// // DELETE api/values/5
|
||||
// public void Delete(int id)
|
||||
// {
|
||||
// }
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
|
||||
// [HttpGet]
|
||||
// public string Test()
|
||||
// {
|
||||
// return "test";
|
||||
// }
|
||||
[HttpGet]
|
||||
public string Test()
|
||||
{
|
||||
return "test";
|
||||
}
|
||||
|
||||
// [HttpPost]
|
||||
// public HttpResponseMessage Login([FromBody] LoginRequest request)
|
||||
// {
|
||||
// var response = new LoginResponse();
|
||||
[HttpGet]
|
||||
public string TestLogin()
|
||||
{
|
||||
return "HomeController Login Test - 접근 성공!";
|
||||
}
|
||||
|
||||
// try
|
||||
// {
|
||||
// // 입력값 검증
|
||||
// if (string.IsNullOrEmpty(request?.UserId) || string.IsNullOrEmpty(request?.Password))
|
||||
// {
|
||||
// response.Success = false;
|
||||
// response.Message = "사용자 ID와 비밀번호를 입력해주세요.";
|
||||
// return CreateJsonResponse(response);
|
||||
// }
|
||||
[HttpPost]
|
||||
public HttpResponseMessage Login([FromBody] LoginRequest request)
|
||||
{
|
||||
var response = new LoginResponse();
|
||||
|
||||
// // TODO: 여기에 실제 데이터베이스 로그인 로직을 구현하세요
|
||||
// // 예시: 데이터베이스에서 사용자 정보 확인
|
||||
// bool isValidUser = ValidateUser(request.UserId, request.Password);
|
||||
try
|
||||
{
|
||||
// 입력값 검증
|
||||
if (string.IsNullOrEmpty(request?.Gcode) || string.IsNullOrEmpty(request?.UserId) || string.IsNullOrEmpty(request?.Password))
|
||||
{
|
||||
response.Success = false;
|
||||
response.Message = "그룹코드/사용자ID/비밀번호를 입력해주세요.";
|
||||
return CreateJsonResponse(response);
|
||||
}
|
||||
|
||||
// if (isValidUser)
|
||||
// {
|
||||
// // 로그인 성공
|
||||
// response.Success = true;
|
||||
// response.Message = "로그인에 성공했습니다.";
|
||||
// response.RedirectUrl = "/DashBoard";
|
||||
|
||||
// // 사용자 정보 설정 (세션 또는 쿠키)
|
||||
// SetUserSession(request.UserId, request.RememberMe);
|
||||
|
||||
// // 사용자 데이터 반환
|
||||
// response.UserData = new
|
||||
// {
|
||||
// UserId = request.UserId,
|
||||
// LoginTime = DateTime.Now,
|
||||
// RememberMe = request.RememberMe
|
||||
// };
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 로그인 실패
|
||||
// response.Success = false;
|
||||
// response.Message = "사용자 ID 또는 비밀번호가 올바르지 않습니다.";
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// response.Success = false;
|
||||
// response.Message = "로그인 처리 중 오류가 발생했습니다: " + ex.Message;
|
||||
// }
|
||||
// TODO: 여기에 실제 데이터베이스 로그인 로직을 구현하세요
|
||||
// 예시: 데이터베이스에서 사용자 정보 확인
|
||||
bool isValidUser = ValidateUser(request.Gcode, request.UserId, request.Password);
|
||||
|
||||
// return CreateJsonResponse(response);
|
||||
// }
|
||||
if (isValidUser)
|
||||
{
|
||||
// 로그인 성공
|
||||
response.Success = true;
|
||||
response.Message = "로그인에 성공했습니다.";
|
||||
response.RedirectUrl = "/DashBoard";
|
||||
|
||||
// [HttpPost]
|
||||
// public HttpResponseMessage Logout()
|
||||
// {
|
||||
// var response = new LoginResponse();
|
||||
// 사용자 정보 설정 (세션 또는 쿠키)
|
||||
SetUserSession(request.Gcode, request.UserId, request.RememberMe);
|
||||
|
||||
// try
|
||||
// {
|
||||
// // TODO: 여기에 로그아웃 로직을 구현하세요
|
||||
// // 예시: 세션 정리, 쿠키 삭제 등
|
||||
// ClearUserSession();
|
||||
// 사용자 데이터 반환
|
||||
response.UserData = new
|
||||
{
|
||||
Gcode = request.Gcode,
|
||||
UserId = request.UserId,
|
||||
LoginTime = DateTime.Now,
|
||||
RememberMe = request.RememberMe
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
// 로그인 실패
|
||||
response.Success = false;
|
||||
response.Message = "사용자 ID 또는 비밀번호가 올바르지 않습니다.";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Success = false;
|
||||
response.Message = "로그인 처리 중 오류가 발생했습니다: " + ex.Message;
|
||||
}
|
||||
|
||||
// response.Success = true;
|
||||
// response.Message = "로그아웃되었습니다.";
|
||||
// response.RedirectUrl = "/Login";
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// response.Success = false;
|
||||
// response.Message = "로그아웃 처리 중 오류가 발생했습니다: " + ex.Message;
|
||||
// }
|
||||
return CreateJsonResponse(response);
|
||||
}
|
||||
|
||||
// return CreateJsonResponse(response);
|
||||
// }
|
||||
[HttpPost]
|
||||
public HttpResponseMessage Logout()
|
||||
{
|
||||
var response = new LoginResponse();
|
||||
|
||||
// [HttpGet]
|
||||
// public HttpResponseMessage CheckLoginStatus()
|
||||
// {
|
||||
// var response = new LoginResponse();
|
||||
try
|
||||
{
|
||||
// TODO: 여기에 로그아웃 로직을 구현하세요
|
||||
// 예시: 세션 정리, 쿠키 삭제 등
|
||||
ClearUserSession();
|
||||
|
||||
// try
|
||||
// {
|
||||
// // TODO: 여기에 로그인 상태 확인 로직을 구현하세요
|
||||
// // 예시: 세션 또는 쿠키에서 사용자 정보 확인
|
||||
// var currentUser = GetCurrentUser();
|
||||
response.Success = true;
|
||||
response.Message = "로그아웃되었습니다.";
|
||||
response.RedirectUrl = "/Login";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Success = false;
|
||||
response.Message = "로그아웃 처리 중 오류가 발생했습니다: " + ex.Message;
|
||||
}
|
||||
|
||||
// if (currentUser != null)
|
||||
// {
|
||||
// response.Success = true;
|
||||
// response.Message = "로그인된 상태입니다.";
|
||||
// response.UserData = currentUser;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// response.Success = false;
|
||||
// response.Message = "로그인되지 않은 상태입니다.";
|
||||
// response.RedirectUrl = "/Login";
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// response.Success = false;
|
||||
// response.Message = "로그인 상태 확인 중 오류가 발생했습니다: " + ex.Message;
|
||||
// }
|
||||
return CreateJsonResponse(response);
|
||||
}
|
||||
|
||||
// return CreateJsonResponse(response);
|
||||
// }
|
||||
[HttpGet]
|
||||
public HttpResponseMessage CheckLoginStatus()
|
||||
{
|
||||
var response = new LoginResponse();
|
||||
|
||||
// // 헬퍼 메서드들
|
||||
// private bool ValidateUser(string userId, string password)
|
||||
// {
|
||||
// // TODO: 실제 데이터베이스 검증 로직을 여기에 구현하세요
|
||||
// // 예시: 데이터베이스에서 사용자 정보 조회 및 비밀번호 검증
|
||||
// var encpass = Pub.MakePasswordEnc(password.Trim());
|
||||
try
|
||||
{
|
||||
// TODO: 여기에 로그인 상태 확인 로직을 구현하세요
|
||||
// 예시: 세션 또는 쿠키에서 사용자 정보 확인
|
||||
var currentUser = GetCurrentUser();
|
||||
|
||||
if (currentUser != null)
|
||||
{
|
||||
response.Success = true;
|
||||
response.Message = "로그인된 상태입니다.";
|
||||
response.UserData = currentUser;
|
||||
}
|
||||
else
|
||||
{
|
||||
response.Success = false;
|
||||
response.Message = "로그인되지 않은 상태입니다.";
|
||||
response.RedirectUrl = "/Login";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
response.Success = false;
|
||||
response.Message = "로그인 상태 확인 중 오류가 발생했습니다: " + ex.Message;
|
||||
}
|
||||
|
||||
return CreateJsonResponse(response);
|
||||
}
|
||||
|
||||
// 헬퍼 메서드들
|
||||
private bool ValidateUser(string gcode, string userId, string password)
|
||||
{
|
||||
// TODO: 실제 데이터베이스 검증 로직을 여기에 구현하세요
|
||||
// 예시: 데이터베이스에서 사용자 정보 조회 및 비밀번호 검증
|
||||
var encpass = Pub.MakePasswordEnc(password.Trim());
|
||||
|
||||
var GInfo = DBM.GetUserGroup(gcode);
|
||||
if (GInfo == null) return false;
|
||||
var UGInfo = DBM.GetGroupUser(gcode, userId);
|
||||
if (UGInfo == null) return false;
|
||||
var UInfo = DBM.GetUserInfo(userId);
|
||||
if (UInfo == null) return false;
|
||||
return UInfo.password.Equals(encpass);
|
||||
}
|
||||
|
||||
private void SetUserSession(string gcode, string userId, bool rememberMe)
|
||||
{
|
||||
// TODO: 세션 또는 쿠키에 사용자 정보 저장
|
||||
// 예시: HttpContext.Session["UserId"] = userId;
|
||||
// 예시: 쿠키 설정 (rememberMe가 true인 경우)
|
||||
//데이터베이스에서 해당 정보를 찾아와서 처리해야한다
|
||||
var GInfo = DBM.GetUserGroup(gcode);
|
||||
var UGInfo = DBM.GetGroupUser(gcode, userId);
|
||||
var UInfo = DBM.GetUserInfo(userId);
|
||||
|
||||
info.Login.no = userId;
|
||||
info.Login.nameK = UInfo.name;
|
||||
info.Login.dept = GInfo.name;
|
||||
info.Login.level = UGInfo.level;
|
||||
info.Login.email = UInfo.email;
|
||||
info.Login.hp = UInfo.hp;
|
||||
info.Login.tel = UInfo.tel;
|
||||
info.Login.title = GInfo.name + "(" + UInfo.grade + ")";
|
||||
info.NotShowJobReportview = Pub.setting.NotShowJobreportPRewView;
|
||||
info.Login.gcode = gcode;// gcode;
|
||||
info.Login.process = UInfo.id == "dev" ? "개발자" : UGInfo.Process;
|
||||
info.Login.permission = UGInfo.level;
|
||||
info.Login.gpermission = GInfo.perm;
|
||||
info.ShowBuyerror = Pub.setting.Showbuyerror; //210625
|
||||
|
||||
|
||||
// // 임시 테스트용 (실제로는 데이터베이스에서 확인)
|
||||
// return userId == "admin" && password == "admin";
|
||||
// }
|
||||
|
||||
// private void SetUserSession(string userId, bool rememberMe)
|
||||
// {
|
||||
// // TODO: 세션 또는 쿠키에 사용자 정보 저장
|
||||
// // 예시: HttpContext.Session["UserId"] = userId;
|
||||
// // 예시: 쿠키 설정 (rememberMe가 true인 경우)
|
||||
// //데이터베이스에서 해당 정보를 찾아와서 처리해야한다
|
||||
|
||||
// FCOMMON.info.Login.no = userId;
|
||||
// FCOMMON.info.Login.nameK = drUser.name;
|
||||
// FCOMMON.info.Login.dept = cmbDept.Text;// userdr.dept;// cmbDept.Text;
|
||||
// FCOMMON.info.Login.level = drGrpUser.level;
|
||||
// FCOMMON.info.Login.email = drUser.email;
|
||||
// FCOMMON.info.Login.nameE = drUser.nameE;
|
||||
// FCOMMON.info.Login.hp = drUser.hp;
|
||||
// FCOMMON.info.Login.tel = drUser.tel;
|
||||
// FCOMMON.info.Login.title = drUser.dept + "(" + drUser.grade + ")";
|
||||
// FCOMMON.info.NotShowJobReportview = Pub.setting.NotShowJobreportPRewView;
|
||||
// //var gcode = FCOMMON.DBM.ExecuteScalar("select isnull(gcode,'NOGCODE') from UserGroup where dept ='" + cmbDept.Text + "'");
|
||||
// var gperm = FCOMMON.DBM.ExecuteScalar("select isnull(permission,0) from UserGroup where dept ='" + cmbDept.Text + "'");
|
||||
// FCOMMON.info.Login.gcode = gCode;// gcode;
|
||||
// FCOMMON.info.Login.process = drUser.id == "dev" ? "개발자" : drGrpUser.Process;
|
||||
// FCOMMON.info.Login.permission = 0;
|
||||
// FCOMMON.info.Login.gpermission = int.Parse(gperm);
|
||||
// //FCOMMON.info.datapath = Pub.setting.SharedDataPath;
|
||||
// FCOMMON.info.ShowBuyerror = Pub.setting.Showbuyerror; //210625
|
||||
//로그인기록저장
|
||||
Pub.setting.lastid = userId;// tbID.Text.Trim();
|
||||
Pub.setting.lastdpt = GInfo.name;
|
||||
Pub.setting.lastgcode = GInfo.gcode;
|
||||
Pub.setting.Save();
|
||||
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
// private void ClearUserSession()
|
||||
// {
|
||||
// // TODO: 세션 또는 쿠키에서 사용자 정보 삭제
|
||||
// FCOMMON.info.Login.no = string.Empty;
|
||||
// FCOMMON.info.Login.level = 0;
|
||||
// FCOMMON.info.Login.gcode = string.Empty;
|
||||
// FCOMMON.info.Login.permission = 0;
|
||||
// FCOMMON.info.Login.gpermission = 0;
|
||||
// Console.WriteLine("logout");
|
||||
// }
|
||||
private void ClearUserSession()
|
||||
{
|
||||
// TODO: 세션 또는 쿠키에서 사용자 정보 삭제
|
||||
FCOMMON.info.Login.no = string.Empty;
|
||||
FCOMMON.info.Login.level = 0;
|
||||
FCOMMON.info.Login.gcode = string.Empty;
|
||||
FCOMMON.info.Login.permission = 0;
|
||||
FCOMMON.info.Login.gpermission = 0;
|
||||
Console.WriteLine("logout");
|
||||
}
|
||||
|
||||
// private object GetCurrentUser()
|
||||
// {
|
||||
// // TODO: 현재 로그인된 사용자 정보 반환
|
||||
// // 예시: HttpContext.Session["UserId"]에서 사용자 정보 조회
|
||||
// return null; // 임시로 null 반환
|
||||
// }
|
||||
private object GetCurrentUser()
|
||||
{
|
||||
// TODO: 현재 로그인된 사용자 정보 반환
|
||||
// 예시: HttpContext.Session["UserId"]에서 사용자 정보 조회
|
||||
if (string.IsNullOrEmpty(FCOMMON.info.Login.no)) return null;
|
||||
else return FCOMMON.info.Login;
|
||||
}
|
||||
|
||||
// private HttpResponseMessage CreateJsonResponse(object data)
|
||||
// {
|
||||
// var json = JsonConvert.SerializeObject(data, new JsonSerializerSettings
|
||||
// {
|
||||
// NullValueHandling = NullValueHandling.Ignore
|
||||
// });
|
||||
private HttpResponseMessage CreateJsonResponse(object data)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(data, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
|
||||
// return new HttpResponseMessage()
|
||||
// {
|
||||
// Content = new StringContent(
|
||||
// json,
|
||||
// System.Text.Encoding.UTF8,
|
||||
// "application/json")
|
||||
// };
|
||||
// }
|
||||
return new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
json,
|
||||
System.Text.Encoding.UTF8,
|
||||
"application/json")
|
||||
};
|
||||
}
|
||||
|
||||
// [HttpGet]
|
||||
// public HttpResponseMessage Login()
|
||||
// {
|
||||
// // 직접 파일을 읽어서 반환
|
||||
// var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "login.html");
|
||||
// var contents = string.Empty;
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Login()
|
||||
{
|
||||
// 직접 파일을 읽어서 반환
|
||||
var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "login.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>";
|
||||
// }
|
||||
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>";
|
||||
}
|
||||
|
||||
// //공용값 적용
|
||||
// ApplyCommonValue(ref contents);
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
// var resp = new HttpResponseMessage()
|
||||
// {
|
||||
// Content = new StringContent(
|
||||
// contents,
|
||||
// System.Text.Encoding.UTF8,
|
||||
// "text/html")
|
||||
// };
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
contents,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
// return resp;
|
||||
// }
|
||||
return resp;
|
||||
}
|
||||
|
||||
// [HttpGet]
|
||||
// public HttpResponseMessage Index()
|
||||
// {
|
||||
// // 직접 파일을 읽어서 반환
|
||||
// var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "index.html");
|
||||
// var contents = string.Empty;
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Index()
|
||||
{
|
||||
// 직접 파일을 읽어서 반환
|
||||
var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "index.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>";
|
||||
// }
|
||||
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>";
|
||||
}
|
||||
|
||||
// //공용값 적용
|
||||
// ApplyCommonValue(ref contents);
|
||||
//공용값 적용
|
||||
ApplyCommonValue(ref contents);
|
||||
|
||||
// var resp = new HttpResponseMessage()
|
||||
// {
|
||||
// Content = new StringContent(
|
||||
// contents,
|
||||
// System.Text.Encoding.UTF8,
|
||||
// "text/html")
|
||||
// };
|
||||
var resp = new HttpResponseMessage()
|
||||
{
|
||||
Content = new StringContent(
|
||||
contents,
|
||||
System.Text.Encoding.UTF8,
|
||||
"text/html")
|
||||
};
|
||||
|
||||
// return resp;
|
||||
// }
|
||||
|
||||
// }
|
||||
//}
|
||||
return resp;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetPreviousLoginInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
// pub.setting에서 이전 로그인 정보 읽기
|
||||
var previousLoginInfo = new
|
||||
{
|
||||
Gcode = Pub.setting.lastgcode ?? "",
|
||||
UserId = Pub.setting.lastid ?? "",
|
||||
Dept = Pub.setting.lastdpt ?? "",
|
||||
RememberMe = false // 기본값으로 설정
|
||||
};
|
||||
|
||||
return CreateJsonResponse(new
|
||||
{
|
||||
Success = true,
|
||||
Data = previousLoginInfo
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return CreateJsonResponse(new
|
||||
{
|
||||
Success = false,
|
||||
Message = "이전 로그인 정보를 가져오는 중 오류가 발생했습니다: " + ex.Message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Project.Web.Model
|
||||
{
|
||||
public class GroupUserModel
|
||||
{
|
||||
public string Gcode { get; set; }
|
||||
public string uid { get; set; }
|
||||
}
|
||||
public class UserModel
|
||||
{
|
||||
public string uid { get; set; }
|
||||
public string password { get; set; }
|
||||
}
|
||||
|
||||
public class PageModel
|
||||
{
|
||||
public List<KeyValuePair<string, object>> RouteData { get; set; }
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Project.OWIN
|
||||
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{action}/{id}",
|
||||
routeTemplate: "{controller}/{action}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@
|
||||
data.forEach(item => {
|
||||
tableRows += `
|
||||
<tr class="hover:bg-white/5 transition-colors">
|
||||
<td class="px-6 py-4 whitespace-nowrap text-white">${item.uid || '-'}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-white">${item.name || '-'}(${item.uid})</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-warning-500/20 text-warning-300">
|
||||
${item.cate || '-'}
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>근태현황 대시보드</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-5">
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">출근</h5>
|
||||
<p class="card-text fs-2" id="presentCount">0</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">휴가</h5>
|
||||
<p class="card-text fs-2" id="leaveCount">0</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">휴가요청</h5>
|
||||
<p class="card-text fs-2" id="leaveCount">0</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-center">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">구매요청</h5>
|
||||
<p class="card-text fs-2" id="leaveCount">0</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
휴가자 현황
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>이름</th>
|
||||
<th>출근 시간</th>
|
||||
<th>퇴근 시간</th>
|
||||
<th>상태</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="attendanceTable">
|
||||
<!-- 데이터가 여기에 표시됩니다 -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// 샘플 데이터
|
||||
const attendanceData = [
|
||||
{ name: '홍길동', checkIn: '09:01', checkOut: '18:00', status: '지각' },
|
||||
{ name: '김철수', checkIn: '08:55', checkOut: '18:05', status: '정상' },
|
||||
{ name: '이영희', checkIn: '-', checkOut: '-', status: '결근' },
|
||||
{ name: '박민수', checkIn: '09:00', checkOut: '18:10', status: '정상' },
|
||||
{ name: '최지우', checkIn: '09:20', checkOut: '18:00', status: '지각' }
|
||||
];
|
||||
|
||||
function updateDashboard(data) {
|
||||
let present = 0, leave = 0, late = 0, absent = 0;
|
||||
let tableRows = '';
|
||||
data.forEach(item => {
|
||||
if (item.status === '정상' || item.status === '지각') present++;
|
||||
if (item.checkOut !== '-') leave++;
|
||||
if (item.status === '지각') late++;
|
||||
if (item.status === '결근') absent++;
|
||||
tableRows += `<tr>
|
||||
<td>${item.name}</td>
|
||||
<td>${item.checkIn}</td>
|
||||
<td>${item.checkOut}</td>
|
||||
<td>${item.status}</td>
|
||||
</tr>`;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 페이지 로드 시 대시보드 업데이트
|
||||
updateDashboard(attendanceData);
|
||||
|
||||
// 휴가 인원 Ajax 업데이트
|
||||
function updateLeaveCount() {
|
||||
fetch('http://127.0.0.1:9000/Dashboard/TodayCountH')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
// 수신된 데이터가 "1" 형태로 반환되므로, 쌍따옴표를 제거하고 숫자로 변환
|
||||
const cleanData = data.replace(/"/g, '');
|
||||
document.getElementById('leaveCount').textContent = parseInt(cleanData, 10);
|
||||
})
|
||||
.catch(error => console.error('휴가 인원 업데이트 중 오류 발생:', error));
|
||||
}
|
||||
|
||||
// 페이지 로드 시 휴가 인원 업데이트
|
||||
updateLeaveCount();
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -116,6 +116,17 @@
|
||||
transform: translateY(-1.5rem) scale(0.85);
|
||||
color: #3b82f6;
|
||||
}
|
||||
/* 드롭다운 스타일 */
|
||||
select.input-field option {
|
||||
background-color: #1f2937;
|
||||
color: white;
|
||||
}
|
||||
select.input-field:focus option:checked {
|
||||
background-color: #3b82f6;
|
||||
}
|
||||
select.input-field option:hover {
|
||||
background-color: #374151;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="gradient-bg min-h-screen flex items-center justify-center p-4">
|
||||
@@ -133,8 +144,28 @@
|
||||
<p class="text-white/70 text-sm">로그인하여 시스템에 접속하세요</p>
|
||||
</div>
|
||||
|
||||
<!-- 로그인 폼 -->
|
||||
<!-- 로그인 폼 -->
|
||||
<form id="loginForm" class="space-y-6 animate-slide-up">
|
||||
<!-- Gcode 드롭다운 -->
|
||||
<div class="relative">
|
||||
<select
|
||||
id="gcode"
|
||||
name="gcode"
|
||||
class="input-field w-full px-4 py-3 bg-white/10 border border-white/20 rounded-xl text-white focus:outline-none focus:border-primary-400 input-focus appearance-none"
|
||||
required
|
||||
>
|
||||
<option value="" class="text-gray-800">부서를 선택하세요</option>
|
||||
</select>
|
||||
<label for="gcode" class="floating-label absolute left-4 top-3 text-white/60 text-sm pointer-events-none">
|
||||
부서 선택
|
||||
</label>
|
||||
<div class="absolute right-3 top-3 pointer-events-none">
|
||||
<svg class="w-5 h-5 text-white/40" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 사용자 ID 입력 -->
|
||||
<div class="relative">
|
||||
<input
|
||||
@@ -244,25 +275,27 @@
|
||||
document.getElementById('loginForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const gcode = document.getElementById('gcode').value;
|
||||
const userId = document.getElementById('userId').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const rememberMe = document.querySelector('input[type="checkbox"]').checked;
|
||||
|
||||
if (!userId || !password) {
|
||||
showError('사용자 ID와 비밀번호를 입력해주세요.');
|
||||
if (!gcode || !userId || !password) {
|
||||
showError('그룹코드/사용자ID/비밀번호를 입력해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 로딩 표시
|
||||
showLoading();
|
||||
|
||||
// HomeController의 로그인 API 호출
|
||||
// HomeController의 로그인 API 호출
|
||||
fetch('http://127.0.0.1:9000/Home/Login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
Gcode: gcode,
|
||||
UserId: userId,
|
||||
Password: password,
|
||||
RememberMe: rememberMe
|
||||
@@ -276,6 +309,11 @@
|
||||
// 로그인 성공
|
||||
showSuccess(data.Message);
|
||||
|
||||
// WebView2에 로그인 성공 메시지 전송
|
||||
if (window.chrome && window.chrome.webview) {
|
||||
window.chrome.webview.postMessage('LOGIN_SUCCESS');
|
||||
}
|
||||
|
||||
// 리다이렉트 URL이 있으면 이동
|
||||
if (data.RedirectUrl) {
|
||||
setTimeout(() => {
|
||||
@@ -342,12 +380,103 @@
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 그룹 목록 로드
|
||||
function loadUserGroups() {
|
||||
fetch('http://127.0.0.1:9000/DashBoard/GetUserGroups')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const gcodeSelect = document.getElementById('gcode');
|
||||
|
||||
// 기존 옵션 제거 (첫 번째 옵션 제외)
|
||||
while (gcodeSelect.children.length > 1) {
|
||||
gcodeSelect.removeChild(gcodeSelect.lastChild);
|
||||
}
|
||||
|
||||
// 데이터 추가
|
||||
data.forEach(group => {
|
||||
if (group.gcode && group.name) {
|
||||
const option = document.createElement('option');
|
||||
option.value = group.gcode;
|
||||
option.textContent = group.name;
|
||||
option.className = 'text-gray-800';
|
||||
gcodeSelect.appendChild(option);
|
||||
}
|
||||
});
|
||||
|
||||
// 이전 로그인 정보 설정
|
||||
setPreviousLoginInfo();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('그룹 목록 로드 중 오류 발생:', error);
|
||||
showError('부서 목록을 불러오는 중 오류가 발생했습니다.');
|
||||
});
|
||||
}
|
||||
|
||||
// 이전 로그인 정보 설정
|
||||
function setPreviousLoginInfo() {
|
||||
// HomeController의 GetPreviousLoginInfo API 호출
|
||||
fetch('http://127.0.0.1:9000/Home/GetPreviousLoginInfo')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.Success && data.Data) {
|
||||
handlePreviousLoginInfo(data.Data);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('이전 로그인 정보 로드 중 오류 발생:', error);
|
||||
// 오류가 발생해도 기본 포커스 설정
|
||||
setTimeout(() => {
|
||||
document.getElementById('gcode').focus();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
// 이전 로그인 정보 처리
|
||||
function handlePreviousLoginInfo(data) {
|
||||
let hasPreviousInfo = false;
|
||||
|
||||
if (data && data.Gcode) {
|
||||
// 부서 선택
|
||||
const gcodeSelect = document.getElementById('gcode');
|
||||
gcodeSelect.value = data.Gcode;
|
||||
|
||||
// 부서 선택 시 라벨 애니메이션 적용
|
||||
const label = gcodeSelect.nextElementSibling;
|
||||
if (label && label.classList.contains('floating-label')) {
|
||||
label.style.transform = 'translateY(-1.5rem) scale(0.85)';
|
||||
label.style.color = '#3b82f6';
|
||||
}
|
||||
hasPreviousInfo = true;
|
||||
}
|
||||
|
||||
if (data && data.UserId) {
|
||||
// 사용자 ID 설정
|
||||
document.getElementById('userId').value = data.UserId;
|
||||
|
||||
// 사용자 ID 입력 시 라벨 애니메이션 적용
|
||||
const userIdInput = document.getElementById('userId');
|
||||
const label = userIdInput.nextElementSibling;
|
||||
if (label && label.classList.contains('floating-label')) {
|
||||
label.style.transform = 'translateY(-1.5rem) scale(0.85)';
|
||||
label.style.color = '#3b82f6';
|
||||
}
|
||||
hasPreviousInfo = true;
|
||||
}
|
||||
|
||||
// 이전 로그인 정보가 있으면 비밀번호 필드에, 없으면 부서 선택에 포커스
|
||||
setTimeout(() => {
|
||||
if (hasPreviousInfo) {
|
||||
document.getElementById('password').focus();
|
||||
} else {
|
||||
document.getElementById('gcode').focus();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// 페이지 로드 시 애니메이션
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 입력 필드에 자동 포커스
|
||||
setTimeout(() => {
|
||||
document.getElementById('userId').focus();
|
||||
}, 500);
|
||||
// 그룹 목록 로드
|
||||
loadUserGroups();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user