- {
- public string Content;
- public byte[] Contentb;
- public string Redirecturl;
-
- public override bool Equals(object obj)
- {
- if (!(obj is MethodResult))
- return false;
-
- return Equals((MethodResult)obj);
- }
-
- public override int GetHashCode()
- {
- if (Contentb == null)
- return Content.GetHashCode() ^ Redirecturl.GetHashCode();
- else
- return Content.GetHashCode() ^ Redirecturl.GetHashCode() ^ Contentb.GetHexString().GetHashCode();
-
- }
-
- public bool Equals(MethodResult other)
- {
- if (Content != other.Content)
- return false;
-
- if (Redirecturl != other.Redirecturl)
- return false;
-
- return Contentb == other.Contentb;
- }
-
-
- public static bool operator ==(MethodResult point1, MethodResult point2)
- {
- return point1.Equals(point2);
- }
-
- public static bool operator !=(MethodResult point1, MethodResult point2)
- {
- return !point1.Equals(point2);
- }
- }
-
- sealed class PostRequest : Attribute
- {
-
- }
-
- public class BaseController : ApiController
- {
- public string QueryString { get; set; }
- public string PostData { get; set; }
- public string ParamData { get; set; }
-
- protected string Trig_Ctrl { get; set; }
- protected string Trig_func { get; set; }
-
- public PageModel GetGlobalModel()
- {
- var config = RequestContext.Configuration;
- var routeData = config.Routes.GetRouteData(Request).Values.ToList();
- var name_ctrl = routeData[0].Value.ToString();
- var name_action = routeData[1].Value.ToString();
-
-
- return new PageModel
- {
- RouteData = routeData,
- urlcontrol = name_ctrl,
- urlaction = name_action
- };
- }
-
-
- public MethodResult View(bool nosubdir=false)
- {
- var config = RequestContext.Configuration;
- if (config != null)
- {
- var routeData = config.Routes.GetRouteData(Request).Values.ToList();
- var name_ctrl = routeData[0].Value.ToString();
- if (nosubdir) name_ctrl = string.Empty;
- var name_action = routeData[1].Value.ToString();
- return View(name_ctrl, name_action);
- }
- else
- {
- return View(Trig_Ctrl + "/" + Trig_func);
- }
-
- }
-
-
- public static void ApplyCommonValue(ref string contents)
- {
- //메뉴 푸터 - 개발자 정보
- if (contents.Contains("{title}"))
- contents = contents.Replace("{title}", FCOMMON.info.Login.gcode + " Groupware");
-
- }
-
- public MethodResult View(string Controller, string Action, Boolean applydefaultview = true)
- {
- var retval = new MethodResult();
-
- if (Action.IndexOf(".") == -1)
- Action += ".html"; //기본값 html 을 넣는다
-
- var file = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "View", Controller, Action);
-
- var contents = string.Empty;
-
- if (System.IO.File.Exists(file) == false)
- {
- //error 폴더의 404.html 파일을 찾는다.
- var file404 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "View", "Error", "404.html");
- if (System.IO.File.Exists(file404))
- {
- contents = System.IO.File.ReadAllText(file404, System.Text.Encoding.UTF8);
- contents = contents.Replace("{errorfilename}", file);
- }
-
- else
- contents = "ERROR CODE - 404 (NOT FOUND)
" + file;
-
- Console.WriteLine("view File not found : " + file);
- }
- else
- {
- //디폴트뷰의 내용을 가져온다 (있다면 적용한다)
- if (applydefaultview)
- {
- //뷰파일이 있다면 그것을 적용한다
- var laytoutfile = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "View", "Layout", "default.html");
- if (System.IO.File.Exists(laytoutfile))
- contents = System.IO.File.ReadAllText(laytoutfile, System.Text.Encoding.UTF8);
-
- var fileContents = System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8);
- if (String.IsNullOrEmpty(contents)) contents = fileContents;
- else contents = contents.Replace("{contents}", fileContents);
- }
- else
- {
- //해당 뷰를 가져와서 반환한다
- contents = System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8);
- }
- }
-
-
-
-
- //시스템변수 replace
- contents = contents.Replace("{param_control}", Trig_Ctrl);
- contents = contents.Replace("{param_function}", Trig_func);
-
- retval.Content = contents;
- return retval;
- }
- public MethodResult View(string viewfilename, Boolean applydefaultview = true)
- {
- var retval = new MethodResult();
-
- if (viewfilename.IndexOf(".") == -1)
- viewfilename += ".html"; //기본값 html 을 넣는다
-
- var file = AppDomain.CurrentDomain.BaseDirectory + "View" + viewfilename.Replace("/", "\\");
-
- var contents = string.Empty;
-
- if (System.IO.File.Exists(file) == false)
- {
- //error 폴더의 404.html 파일을 찾는다.
- var file404 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "View", "Error", "404.html");
- if (System.IO.File.Exists(file404))
- {
- contents = System.IO.File.ReadAllText(file404, System.Text.Encoding.UTF8);
- contents = contents.Replace("{errorfilename}", file);
- }
-
- else
- contents = "ERROR CODE - 404 (NOT FOUND)
" + file;
-
- Console.WriteLine("view File not found : " + file);
- }
- else
- {
- //디폴트뷰의 내용을 가져온다 (있다면 적용한다)
- if (applydefaultview)
- {
- //뷰파일이 있다면 그것을 적용한다
- var laytoutfile = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "View", "Layout", "default.html");
- if (System.IO.File.Exists(laytoutfile))
- contents = System.IO.File.ReadAllText(laytoutfile, System.Text.Encoding.UTF8);
-
- var fileContents = System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8);
- if (String.IsNullOrEmpty(contents)) contents = fileContents;
- else contents = contents.Replace("{contents}", fileContents);
- }
- else
- {
- //해당 뷰를 가져와서 반환한다
- contents = System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8);
- }
- }
-
-
-
-
-
- //콘텐츠내의 file 을 찾아서 처리한다. ; 정규식의 처리속도가 느릴듯하여, 그냥 처리해본다
- while (true)
- {
- var fileindexS = contents.IndexOf("{file:");
- if (fileindexS == -1) break;
- var fileindexE = contents.IndexOf("}", fileindexS);
- if (fileindexE == -1) break;
- if (fileindexE <= fileindexS + 5) break;
- var inlinestr = contents.Substring(fileindexS, fileindexE - fileindexS + 1);
- var filename = contents.Substring(fileindexS + 7, fileindexE - fileindexS - 8);
- var load_file = String.Concat(AppDomain.CurrentDomain.BaseDirectory, "View", "\\", filename.Replace("/", "\\"));
- load_file = load_file.Replace("\\\\", "\\");
- String fileContents;// = String.Empty;
-
- Console.WriteLine("file impot : " + load_file);
- if (System.IO.File.Exists(load_file))
- {
- fileContents = System.IO.File.ReadAllText(load_file, System.Text.Encoding.UTF8);
- }
- else
- {
- fileContents = "{FileNotFound:" + filename + "}"; //파일이없다면 해당 부분은 오류 처리한다.
- }
- contents = contents.Replace(inlinestr, fileContents);
- }
-
- //시스템변수 replace
- contents = contents.Replace("{param_control}", Trig_Ctrl);
- contents = contents.Replace("{param_function}", Trig_func);
-
- retval.Content = contents;
- return retval;
- }
- protected class Parameter
- {
- public string Key { get; set; }
- public string Value { get; set; }
- public Parameter(string key_, string value_)
- {
- Key = key_;
- Value = value_;
- }
- }
-
- }
-}
diff --git a/Project/Web/Controller/CommonController.cs b/Project/Web/Controller/CommonController.cs
deleted file mode 100644
index 3bf0dd2..0000000
--- a/Project/Web/Controller/CommonController.cs
+++ /dev/null
@@ -1,454 +0,0 @@
-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;
-
- //코드그룹이 없다면 전체 목록을 조회할 수 있도록 99를 조회한다
- if (string.IsNullOrEmpty(grp)) grp = "99";
-
- // 특정 그룹의 데이터만 가져옴
- sql = "select *" +
- " from common" +
- " where gcode = @gcode" +
- " and grp = @grp" +
- " order by code,svalue";
-
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
-
- if (!string.IsNullOrEmpty(grp))
- {
- cmd.Parameters.AddWithValue("grp", grp);
- }
-
- 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 = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpPost]
- public HttpResponseMessage Save([FromBody] CommonModel model)
- {
- try
- {
- var cs = Properties.Settings.Default.gwcs;
- var cn = new System.Data.SqlClient.SqlConnection(cs);
- var sql = string.Empty;
- var cmd = new System.Data.SqlClient.SqlCommand();
- cmd.Connection = cn;
-
- if (model.idx > 0)
- {
- // 업데이트
- sql = @"UPDATE common SET
- grp = @grp,
- code = @code,
- svalue = @svalue,
- ivalue = @ivalue,
- fvalue = @fvalue,
- svalue2 = @svalue2,
- memo = @memo,
- wuid = @wuid,
- wdate = GETDATE()
- WHERE idx = @idx AND gcode = @gcode";
- }
- else
- {
- // 신규 추가
- sql = @"INSERT INTO common (gcode, grp, code, svalue, ivalue, fvalue, svalue2, memo, wuid, wdate)
- VALUES (@gcode, @grp, @code, @svalue, @ivalue, @fvalue, @svalue2, @memo, @wuid, GETDATE())";
- }
-
- cmd.CommandText = sql;
- cmd.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- cmd.Parameters.AddWithValue("@grp", model.grp ?? "");
- cmd.Parameters.AddWithValue("@code", model.code ?? "");
- cmd.Parameters.AddWithValue("@svalue", model.svalue ?? "");
- cmd.Parameters.AddWithValue("@ivalue", model.ivalue);
- cmd.Parameters.AddWithValue("@fvalue", model.fvalue);
- cmd.Parameters.AddWithValue("@svalue2", model.svalue2 ?? "");
- cmd.Parameters.AddWithValue("@memo", model.memo ?? "");
- cmd.Parameters.AddWithValue("@wuid", FCOMMON.info.Login.no);
-
- if (model.idx > 0)
- {
- cmd.Parameters.AddWithValue("@idx", model.idx);
- }
-
- cn.Open();
- var result = cmd.ExecuteNonQuery();
- cn.Close();
-
- cmd.Dispose();
- cn.Dispose();
-
- var response = new
- {
- Success = result > 0,
- Message = result > 0 ? "저장되었습니다." : "저장에 실패했습니다."
- };
-
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- Success = false,
- Message = "오류가 발생했습니다: " + ex.Message
- };
- return CreateJsonResponse(response);
- }
- }
-
- [HttpPost]
- public HttpResponseMessage Delete([FromBody] DeleteModel model)
- {
- try
- {
- var cs = Properties.Settings.Default.gwcs;
- var cn = new System.Data.SqlClient.SqlConnection(cs);
- var sql = "DELETE FROM common WHERE idx = @idx AND gcode = @gcode";
- var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
-
- cmd.Parameters.AddWithValue("@idx", model.idx);
- cmd.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
-
- cn.Open();
- var result = cmd.ExecuteNonQuery();
- cn.Close();
-
- cmd.Dispose();
- cn.Dispose();
-
- var response = new
- {
- Success = result > 0,
- Message = result > 0 ? "삭제되었습니다." : "삭제에 실패했습니다."
- };
-
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- Success = false,
- Message = "오류가 발생했습니다: " + ex.Message
- };
- return CreateJsonResponse(response);
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetGroups()
- {
- try
- {
- var sql = "select code, svalue, memo from common WITH (nolock) " +
- "where gcode = @gcode and grp = '99' " +
- "order by code";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- 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;
- }
- catch (Exception ex)
- {
- var response = new
- {
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
- }
-
- [HttpPost]
- public HttpResponseMessage InitializeGroups()
- {
- try
- {
- var cs = Properties.Settings.Default.gwcs;
- var cn = new System.Data.SqlClient.SqlConnection(cs);
-
- // 기본 그룹코드들 정의
- var defaultGroups = new[]
- {
- new { code = "01", svalue = "부서코드" },
- new { code = "02", svalue = "직급코드" },
- new { code = "03", svalue = "공정코드" },
- new { code = "04", svalue = "품목분류" },
- new { code = "05", svalue = "업체분류" },
- new { code = "06", svalue = "제조공정" },
- new { code = "07", svalue = "장비제조" },
- new { code = "08", svalue = "장비모델" },
- new { code = "09", svalue = "장비기술" },
- new { code = "99", svalue = "기타" }
- };
-
- cn.Open();
-
- int insertedCount = 0;
- foreach (var group in defaultGroups)
- {
- // 이미 존재하는지 확인
- var checkSql = "SELECT COUNT(*) FROM common WHERE gcode = @gcode AND grp = '99' AND code = @code";
- var checkCmd = new System.Data.SqlClient.SqlCommand(checkSql, cn);
- checkCmd.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- checkCmd.Parameters.AddWithValue("@code", group.code);
-
- var exists = (int)checkCmd.ExecuteScalar() > 0;
- checkCmd.Dispose();
-
- if (!exists)
- {
- // 새로 추가
- var insertSql = @"INSERT INTO common (gcode, grp, code, svalue, ivalue, fvalue, svalue2, memo, wuid, wdate)
- VALUES (@gcode, '99', @code, @svalue, 0, 0.0, '', '코드그룹 정의', @wuid, GETDATE())";
- var insertCmd = new System.Data.SqlClient.SqlCommand(insertSql, cn);
- insertCmd.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- insertCmd.Parameters.AddWithValue("@code", group.code);
- insertCmd.Parameters.AddWithValue("@svalue", group.svalue);
- insertCmd.Parameters.AddWithValue("@wuid", FCOMMON.info.Login.no);
-
- insertCmd.ExecuteNonQuery();
- insertCmd.Dispose();
- insertedCount++;
- }
- }
-
- cn.Close();
- cn.Dispose();
-
- var response = new
- {
- Success = true,
- Message = $"그룹코드 초기화 완료. {insertedCount}개 추가됨."
- };
-
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- Success = false,
- Message = "오류가 발생했습니다: " + ex.Message
- };
- return CreateJsonResponse(response);
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetNavigationMenu()
- {
- try
- {
- // 메뉴 정보를 하드코딩하거나 데이터베이스에서 가져올 수 있습니다.
- // 향후 사용자 권한에 따른 메뉴 표시/숨김 기능도 추가 가능합니다.
- var menuItems = new[]
- {
- new {
- key = "dashboard",
- title = "대시보드",
- url = "/Dashboard/",
- icon = "M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z M8 5a2 2 0 012-2h4a2 2 0 012 2v2H8V5z",
- isVisible = true,
- sortOrder = 1
- },
- new {
- key = "common",
- title = "공용코드",
- url = "/Common",
- icon = "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z",
- isVisible = true,
- sortOrder = 2
- },
- new {
- key = "jobreport",
- title = "업무일지",
- url = "/Jobreport/",
- icon = "M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",
- isVisible = true,
- sortOrder = 3
- },
- new {
- key = "kuntae",
- title = "근태관리",
- url = "/Kuntae/",
- icon = "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z",
- isVisible = true,
- sortOrder = 4
- },
- new {
- key = "todo",
- title = "할일관리",
- url = "/Todo/",
- icon = "M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2M12 12l2 2 4-4",
- isVisible = true,
- sortOrder = 5
- },
- new {
- key = "project",
- title = "프로젝트",
- url = "/Project/",
- icon = "M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10",
- isVisible = true,
- sortOrder = 6
- }
- };
-
- // 사용자 권한에 따른 메뉴 필터링 로직을 여기에 추가할 수 있습니다.
- // 예: var userLevel = FCOMMON.info.Login.level;
- // if (userLevel < 5) { /* 특정 메뉴 숨김 */ }
-
- var response = new
- {
- Success = true,
- Data = menuItems,
- Message = "메뉴 정보를 성공적으로 가져왔습니다."
- };
-
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- Success = false,
- Data = (object)null,
- Message = "메뉴 정보를 가져오는 중 오류가 발생했습니다: " + ex.Message
- };
- return CreateJsonResponse(response);
- }
- }
-
- 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")
- };
- }
- }
-
- public class DeleteModel
- {
- public int idx { get; set; }
- }
-
- 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; } // 데이터를기록한일시
- }
-}
-
-
-
diff --git a/Project/Web/Controller/CustomerController.cs b/Project/Web/Controller/CustomerController.cs
deleted file mode 100644
index bb1bc79..0000000
--- a/Project/Web/Controller/CustomerController.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-
-namespace Project.Web.Controllers
-{
- public class CustomerController : BaseController
- {
-
- // PUT api/values/5
- public void Put(int id, [FromBody] string value)
- {
- }
-
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
-
- [HttpGet]
- public string Test()
- {
- return "test";
- }
-
- [HttpGet]
- public HttpResponseMessage Find()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- if (searchkey.isEmpty() == false)
- {
- var db = new dsMSSQLTableAdapters.CustomsTableAdapter();//.custrom EEEntitiesCommon();
- var rows = db.GetData(FCOMMON.info.Login.gcode);// db.Customs.Where(t => t.gcode == FCOMMON.info.Login.gcode).OrderBy(t => t.name);
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
- tbody.AppendLine($"| {item.name} | ");
- tbody.AppendLine($"{item.name2} | ");
- tbody.AppendLine($"{item.name} | ");
- //tbody.AppendLine($"{item.model} | ");
-
- //if (item.price == null)
- // tbody.AppendLine($"-- | ");
- //else
- //{
- // var price = (double)item.price / 1000.0;
-
- // tbody.AppendLine($"{price.ToString("N0")} | ");
- //}
-
-
- //tbody.AppendLine($"{item.manu} | ");
- //tbody.AppendLine($"{item.supply} | ");
-
- //if (item.remark.Length > 10)
- // tbody.AppendLine($"{item.remark.Substring(0, 10)}... | ");
- //else
- // tbody.AppendLine($"{item.remark} | ");
- tbody.AppendLine("
");
- }
- }
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 1 | ");
- tbody.AppendLine("자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- //if (searchkey.isEmpty() == false)
- {
- var db = new dsMSSQLTableAdapters.CustomsTableAdapter();// EEEntitiesCommon();
- var sd = DateTime.Now.ToString("yyyy-MM-01");
- var rows = db.GetData(FCOMMON.info.Login.gcode);// .Customs.AsNoTracking().Where(t => t.gcode == FCOMMON.info.Login.gcode).OrderBy(t=>t.name);
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
- tbody.AppendLine($"| {item.grp} | ");
- tbody.AppendLine($"{item.name} | ");
- tbody.AppendLine($"{item.name2} | ");
- tbody.AppendLine($"{item.tel} | ");
- tbody.AppendLine($"{item.fax} | ");
- tbody.AppendLine($"{item.email} | ");
- tbody.AppendLine($"{item.address} | ");
-
-
-
- if (string.IsNullOrEmpty( item.memo)==false && item.memo.Length > 10) tbody.AppendLine($"{item.memo.Substring(0, 10)}... | ");
- else tbody.AppendLine($"{item.memo} | ");
-
- tbody.AppendLine("
");
- }
- }
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 1 | ");
- tbody.AppendLine("자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- }
-}
diff --git a/Project/Web/Controller/DashBoardController.cs b/Project/Web/Controller/DashBoardController.cs
deleted file mode 100644
index 8ad5471..0000000
--- a/Project/Web/Controller/DashBoardController.cs
+++ /dev/null
@@ -1,496 +0,0 @@
-using FCOMMON;
-using Newtonsoft.Json;
-using System;
-using System.Data;
-using System.Linq;
-using System.Net.Http;
-using System.Security.Cryptography;
-using System.Web.Http;
-
-namespace Project.Web.Controllers
-{
- public class DashBoardController : BaseController
- {
- [HttpPost]
- public void Index([FromBody] string value)
- {
-
- }
-
- //// PUT api/values/5
- //public void Put(int id, [FromBody] string value)
- //{
- //}
-
- //// DELETE api/values/5
- //public void Delete(int id)
- //{
- //}
-
- [HttpGet]
- public string TodayCountH()
- {
-
- var sql = "select count(*) from EETGW_HolydayRequest WITH (nolock) " +
- " where gcode = @gcode and isnull(conf,0) = 1 " +
- " and sdate <= convert(varchar(10),GETDATE(),120) and edate >= convert(varchar(10),GETDATE(),120)";
-
- var cn = DBM.getCn();
- cn.Open();
-
- var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
- cmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = FCOMMON.info.Login.gcode;
- var cnt1 = (int)cmd.ExecuteScalar();
- cmd.Dispose();
- cn.Dispose();
-
- return cnt1.ToString();
- }
-
- [HttpGet]
- public HttpResponseMessage GetHolydayRequestCount()
- {
-
- try
- {
- var cn = DBM.getCn();
-
- var sql = "select count(*) from EETGW_HolydayRequest WITH (nolock) " +
- " where gcode = @gcode" +
- " and isnull(conf,0) = 0";
-
- cn.Open();
-
- var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
- cmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = FCOMMON.info.Login.gcode;
- var cnt1 = (int)cmd.ExecuteScalar();
- cn.Dispose();
-
- var response = new
- {
- HOLY = cnt1,
- Message = string.Empty,
- };
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- HOLY = 0,
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
- }
-
-
- [HttpGet]
- public HttpResponseMessage GetholyRequestUser()
- {
- var sql = string.Empty;
- sql = $" select uid,cate,sdate,edate,HolyReason,Users.name,holydays,holytimes,remark " +
- $" from EETGW_HolydayRequest WITH (nolock) INNER JOIN " +
- $" Users ON EETGW_HolydayRequest.uid = Users.id " +
- $" where EETGW_HolydayRequest.gcode = @gcode" +
- $" and isnull(conf,0) = 0 ";
- //" and sdate <= convert(varchar(10),GETDATE(),120) and edate >= convert(varchar(10),GETDATE(),120)";
-
- //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);
- 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 GetJobData(string startDate = "", string endDate = "")
- {
- var sql = string.Empty;
-
- // 기본값 설정 (이번 달)
- if (string.IsNullOrEmpty(startDate) || string.IsNullOrEmpty(endDate))
- {
- var now = DateTime.Now;
- var firstDayOfMonth = new DateTime(now.Year, now.Month, 1);
- var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
- startDate = firstDayOfMonth.ToString("yyyy-MM-dd");
- endDate = lastDayOfMonth.ToString("yyyy-MM-dd");
- }
-
- sql = $" select idx,pdate,status,projectName, uid, requestpart, package,type,process,description," +
- " hrs,ot,otStart,otEnd" +
- " from JobReport WITH (nolock)" +
- " where gcode = @gcode and uid = @uid" +
- " and pdate between @startDate and @endDate" +
- " order by pdate desc, wdate desc";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- cmd.Parameters.AddWithValue("uid", FCOMMON.info.Login.no);
- cmd.Parameters.AddWithValue("startDate", startDate);
- cmd.Parameters.AddWithValue("endDate", endDate);
- 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 GetCurrentUserCount()
- {
-
- try
- {
- var cn = DBM.getCn();
-
-
-
- var sql = "select count(*) from vGroupUser WITH (nolock) " +
- " where gcode = @gcode and useUserState = 1 and useJobReport = 1" +
- " and id not in (select uid from vEETGW_TodayNoneWorkUser where gcode = @gcode and kunmu = 0)";
-
-
- cn.Open();
-
- var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
- cmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = FCOMMON.info.Login.gcode;
- var cnt1 = (int)cmd.ExecuteScalar();
- cn.Dispose();
-
- var response = new
- {
- Count = cnt1,
- Message = string.Empty,
- };
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- Count = 0,
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
-
-
- }
-
- [HttpGet]
- public HttpResponseMessage GetPurchaseWaitCount()
- {
-
- try
- {
- FCOMMON.DBM.GetPurchaseWaitCount(FCOMMON.info.Login.gcode, out int cnt1, out int cnt2);
- var response = new
- {
- NR = cnt1,
- CR = cnt2,
- Message = string.Empty,
- };
- return CreateJsonResponse(response);
- }
- catch (Exception ex)
- {
- var response = new
- {
- NR = 0,
- CR = 0,
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
-
-
- }
-
-
-
- [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,type,cate,sdate,edate,title,dbo.getusername(uid) as name " +
- $" from vEETGW_TodayNoneWorkUser WITH (nolock)" +
- $" where gcode = @gcode and kunmu=0";
-
- //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);
- 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 GetPresentUserList()
- {
- try
- {
- var sql = "select * from vGroupUser WITH (nolock) " +
- " where gcode = @gcode and useUserState = 1 and useJobReport = 1" +
- " and id not in (select uid from vEETGW_TodayNoneWorkUser where gcode = @gcode and kunmu = 0)";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- 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;
- }
- catch (Exception ex)
- {
- var response = new
- {
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetPurchaseNRList()
- {
- try
- {
- var sql = "select pdate, process, pumname, pumscale, pumunit, pumqtyreq, pumprice, pumamt from Purchase WITH (nolock) where gcode = @gcode and state = '---' order by pdate desc";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- 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;
- }
- catch (Exception ex)
- {
- var response = new
- {
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetPurchaseCRList()
- {
- try
- {
- var sql = "select pdate, process, pumname, pumscale, pumunit, pumqtyreq, pumprice, pumamt " +
- " from EETGW_PurchaseCR WITH (nolock) " +
- " where gcode = @gcode and state = '---'" +
- " order by pdate desc";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- 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;
- }
- catch (Exception ex)
- {
- var response = new
- {
- Message = ex.Message,
- };
- return CreateJsonResponse(response);
- }
- }
-
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- // 직접 파일을 읽어서 반환
- var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "DashBoard", "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 = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
- //공용값 적용
- //ApplyCommonValue(ref contents);
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- 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")
- };
- }
-
- }
-}
diff --git a/Project/Web/Controller/HomeController.cs b/Project/Web/Controller/HomeController.cs
deleted file mode 100644
index b861d9c..0000000
--- a/Project/Web/Controller/HomeController.cs
+++ /dev/null
@@ -1,334 +0,0 @@
-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 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 HomeController : BaseController
- {
- [HttpGet]
- public string TestLogin()
- {
- return "HomeController Login Test - 접근 성공!";
- }
-
- [HttpPost]
- public HttpResponseMessage Login([FromBody] LoginRequest request)
- {
- var response = new LoginResponse();
-
- try
- {
- // 입력값 검증
- if (string.IsNullOrEmpty(request?.Gcode) || string.IsNullOrEmpty(request?.UserId) || string.IsNullOrEmpty(request?.Password))
- {
- response.Success = false;
- response.Message = "그룹코드/사용자ID/비밀번호를 입력해주세요.";
- return CreateJsonResponse(response);
- }
-
- // TODO: 여기에 실제 데이터베이스 로그인 로직을 구현하세요
- // 예시: 데이터베이스에서 사용자 정보 확인
- bool isValidUser = ValidateUser(request.Gcode, request.UserId, request.Password);
-
- if (isValidUser)
- {
- // 로그인 성공
- response.Success = true;
- response.Message = "로그인에 성공했습니다.";
- response.RedirectUrl = "/DashBoard";
-
- // 사용자 정보 설정 (세션 또는 쿠키)
- SetUserSession(request.Gcode, request.UserId, request.RememberMe);
-
- // 사용자 데이터 반환
- 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)
- {
- Console.WriteLine( ex.Message);
- response.Success = false;
- response.Message = "로그인 처리 중 오류가 발생했습니다: " + ex.Message;
- }
-
- return CreateJsonResponse(response);
- }
-
- [HttpPost]
- public HttpResponseMessage Logout()
- {
- var response = new LoginResponse();
-
- try
- {
- // TODO: 여기에 로그아웃 로직을 구현하세요
- // 예시: 세션 정리, 쿠키 삭제 등
- ClearUserSession();
-
- response.Success = true;
- response.Message = "로그아웃되었습니다.";
- response.RedirectUrl = "/Login";
- }
- catch (Exception ex)
- {
- response.Success = false;
- response.Message = "로그아웃 처리 중 오류가 발생했습니다: " + ex.Message;
- }
-
- return CreateJsonResponse(response);
- }
-
-
-
-
-
- [HttpGet]
- public HttpResponseMessage CheckLoginStatus()
- {
- var response = new LoginResponse();
-
- 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());
-
- if(userId.ToLower()=="dev" && password == "123")
- {
- return true;
- }
-
- 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)
- {
- if(userId.ToLower().Equals("dev"))
- {
- var GInfo = DBM.GetUserGroup(gcode);
- var UInfo = DBM.GetUserInfo(userId);
-
- info.Login.no = "dev";
- info.Login.nameK = "개발자";
- info.Login.dept = GInfo.name;
- info.Login.level = 10;
- 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 = "개발자";
- info.Login.permission =GInfo.perm;
- info.Login.gpermission = GInfo.perm;
- info.ShowBuyerror = Pub.setting.Showbuyerror; //210625
-
- }
- else
- {
- // TODO: 세션 또는 쿠키에 사용자 정보 저장
- // 예시: HttpContext.Session["UserId"] = userId;
- // 예시: 쿠키 설정 (rememberMe가 true인 경우)
- //데이터베이스에서 해당 정보를 찾아와서 처리해야한다
- var GInfo = DBM.GetUserGroup(gcode);
- var UInfo = DBM.GetUserInfo(userId);
- var UGInfo = DBM.GetGroupUser(gcode, 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
-
-
- //로그인기록저장
- 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 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
- });
-
- 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;
-
- if (System.IO.File.Exists(filePath))
- {
- contents = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8);
- }
- else
- {
- // 파일이 없으면 404 에러 페이지 또는 기본 메시지
- contents = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- 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
- });
- }
- }
-
- }
-}
diff --git a/Project/Web/Controller/ItemController.cs b/Project/Web/Controller/ItemController.cs
deleted file mode 100644
index b93d019..0000000
--- a/Project/Web/Controller/ItemController.cs
+++ /dev/null
@@ -1,153 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-using System.Windows.Forms;
-
-namespace Project.Web.Controllers
-{
- public class ItemController : BaseController
- {
-
-
- // PUT api/values/5
- public void Put(int id, [FromBody] string value)
- {
- }
-
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
-
- [HttpGet]
- public string Test()
- {
- return "test";
- }
-
- [HttpGet]
- public HttpResponseMessage Find()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
- if (searchkey.isEmpty() == false && searchkey != "%")
- {
- if (searchkey.StartsWith("%") == false) searchkey = "%" + searchkey;
- if (searchkey.EndsWith("%") == false) searchkey = searchkey + "%";
- }
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- if (searchkey.isEmpty() == false)
- {
- var db = new dsMSSQLTableAdapters.vFindSIDTableAdapter();// EEEntitiesMain();
- var rows = db.GetData(searchkey);// .vFindSID.Where(t => t.sid.Contains(searchkey) || t.name.Contains(searchkey) || t.model.Contains(searchkey));
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
- tbody.AppendLine($"| {item.Location} | ");
- tbody.AppendLine($"{item.sid} | ");
- tbody.AppendLine($"{item.name} | ");
- tbody.AppendLine($"{item.model} | ");
-
- if (item.IspriceNull())
- tbody.AppendLine($"-- | ");
- else
- {
- var price = (double)item.price / 1000.0;
-
- tbody.AppendLine($"{price.ToString("N0")} | ");
- }
-
-
- tbody.AppendLine($"{item.manu} | ");
- tbody.AppendLine($"{item.supply} | ");
-
- if (item.remark.Length > 10)
- tbody.AppendLine($"{item.remark.Substring(0, 10)}... | ");
- else
- tbody.AppendLine($"{item.remark} | ");
- tbody.AppendLine("
");
- }
- }
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var contents = result.Content;
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- }
-}
diff --git a/Project/Web/Controller/JobreportController.cs b/Project/Web/Controller/JobreportController.cs
deleted file mode 100644
index f49d2d9..0000000
--- a/Project/Web/Controller/JobreportController.cs
+++ /dev/null
@@ -1,919 +0,0 @@
-using Microsoft.Owin;
-using Project.Web.Controllers;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Web;
-using System.Web.Http;
-using System.Data;
-using System.Web.Http.Results;
-using System.Data.SqlClient;
-
-namespace Project.Web.Controllers
-{
- public class JobreportController : BaseController
- {
-
-
- // PUT api/values/5
- public void Put(int id, [FromBody] string value)
- {
- }
-
- // DELETE api/values/5
- [HttpDelete]
- public HttpResponseMessage Delete(int id)
- {
- try
- {
- if (id <= 0)
- {
- throw new Exception("유효하지 않은 업무일지 ID입니다.");
- }
-
- // 직접 SQL 삭제 실행
- string connectionString = Properties.Settings.Default.gwcs;
- using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
- {
- connection.Open();
-
- string deleteSql = @"
- DELETE FROM JobReport
- WHERE idx = @idx AND gcode = @gcode";
-
- using (var command = new System.Data.SqlClient.SqlCommand(deleteSql, connection))
- {
- command.Parameters.AddWithValue("@idx", id);
- command.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
-
- int rowsAffected = command.ExecuteNonQuery();
-
- if (rowsAffected == 0)
- {
- throw new Exception("업무일지를 찾을 수 없거나 삭제 권한이 없습니다.");
- }
- }
- }
-
- var jsonData = "{\"success\":true,\"message\":\"데이터가 성공적으로 삭제되었습니다.\"}";
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- jsonData,
- System.Text.Encoding.UTF8,
- "application/json")
- };
-
- return resp;
- }
- catch (Exception ex)
- {
- var errorResp = new HttpResponseMessage()
- {
- Content = new StringContent(
- $"{{\"success\":false,\"message\":\"{EscapeJsonString(ex.Message)}\"}}",
- System.Text.Encoding.UTF8,
- "application/json")
- };
- return errorResp;
- }
- }
-
- [HttpPost]
- public string Add(FormCollection formData)
- {
- try
- {
- // 폼 데이터에서 값 추출
- var pdate = formData["pdate"] ?? DateTime.Now.ToShortDateString();
- var status = formData["status"] ?? "";
- var projectName = formData["projectName"] ?? "";
- var requestpart = formData["requestpart"] ?? "";
- var type = formData["type"] ?? "";
- var description = formData["description"] ?? "";
- var otStart = formData["otStart"] ?? "";
- var otEnd = formData["otEnd"] ?? "";
-
- decimal hrs = 0;
- decimal.TryParse(formData["hrs"], out hrs);
-
- decimal ot = 0;
- decimal.TryParse(formData["ot"], out ot);
-
- // 직접 SQL 삽입 실행
- string connectionString = Properties.Settings.Default.gwcs;
- using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
- {
- connection.Open();
-
- string insertSql = @"
- INSERT INTO JobReport
- (gcode, pdate, projectName, uid, requestpart, status, type, description, hrs, ot, otStart, otEnd, wuid, wdate)
- VALUES
- (@gcode, @pdate, @projectName, @uid, @requestpart, @status, @type, @description, @hrs, @ot, @otStart, @otEnd, @wuid, @wdate)";
-
- using (var command = new System.Data.SqlClient.SqlCommand(insertSql, connection))
- {
- command.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- command.Parameters.AddWithValue("@pdate", pdate);
- command.Parameters.AddWithValue("@projectName", projectName);
- command.Parameters.AddWithValue("@uid", FCOMMON.info.Login.no);
- command.Parameters.AddWithValue("@requestpart", requestpart);
- command.Parameters.AddWithValue("@status", status);
- command.Parameters.AddWithValue("@type", type);
- command.Parameters.AddWithValue("@description", description);
- command.Parameters.AddWithValue("@hrs", hrs);
- command.Parameters.AddWithValue("@ot", ot);
- command.Parameters.AddWithValue("@otStart", string.IsNullOrEmpty(otStart) ? (object)DBNull.Value : otStart);
- command.Parameters.AddWithValue("@otEnd", string.IsNullOrEmpty(otEnd) ? (object)DBNull.Value : otEnd);
- command.Parameters.AddWithValue("@wuid", FCOMMON.info.Login.no);
- command.Parameters.AddWithValue("@wdate", DateTime.Now);
-
- command.ExecuteNonQuery();
- }
- }
-
- return "{\"success\":true,\"message\":\"데이터가 성공적으로 저장되었습니다.\"}";
- }
- catch (Exception ex)
- {
- return $"{{\"success\":false,\"message\":\"{EscapeJsonString(ex.Message)}\"}}";
- }
- }
-
- [HttpPost]
- public HttpResponseMessage Edit()
- {
- try
- {
- // Request.Form에서 직접 값 추출
- var idx = HttpContext.Current.Request.Form["idx"];
- var pdate = HttpContext.Current.Request.Form["pdate"] ?? DateTime.Now.ToShortDateString();
- var status = HttpContext.Current.Request.Form["status"] ?? "";
- var projectName = HttpContext.Current.Request.Form["projectName"] ?? "";
- var requestpart = HttpContext.Current.Request.Form["requestpart"] ?? "";
- var type = HttpContext.Current.Request.Form["type"] ?? "";
- var description = HttpContext.Current.Request.Form["description"] ?? "";
- var otStart = HttpContext.Current.Request.Form["otStart"] ?? "";
- var otEnd = HttpContext.Current.Request.Form["otEnd"] ?? "";
-
- decimal hrs = 0;
- decimal.TryParse(HttpContext.Current.Request.Form["hrs"], out hrs);
-
- decimal ot = 0;
- decimal.TryParse(HttpContext.Current.Request.Form["ot"], out ot);
-
- int idxNum = 0;
- int.TryParse(idx, out idxNum);
-
- if (idxNum <= 0)
- {
- throw new Exception("유효하지 않은 업무일지 ID입니다.");
- }
-
- // 직접 SQL 업데이트 실행
- string connectionString = Properties.Settings.Default.gwcs;
- using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
- {
- connection.Open();
-
- string updateSql = @"
- UPDATE JobReport
- SET pdate = @pdate,
- status = @status,
- projectName = @projectName,
- requestpart = @requestpart,
- type = @type,
- description = @description,
- hrs = @hrs,
- ot = @ot,
- otStart = @otStart,
- otEnd = @otEnd,
- wuid = @wuid,
- wdate = @wdate
- WHERE idx = @idx AND gcode = @gcode";
-
- using (var command = new System.Data.SqlClient.SqlCommand(updateSql, connection))
- {
- command.Parameters.AddWithValue("@idx", idxNum);
- command.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- command.Parameters.AddWithValue("@pdate", pdate);
- command.Parameters.AddWithValue("@status", status);
- command.Parameters.AddWithValue("@projectName", projectName);
- command.Parameters.AddWithValue("@requestpart", requestpart);
- command.Parameters.AddWithValue("@type", type);
- command.Parameters.AddWithValue("@description", description);
- command.Parameters.AddWithValue("@hrs", hrs);
- command.Parameters.AddWithValue("@ot", ot);
- command.Parameters.AddWithValue("@otStart", string.IsNullOrEmpty(otStart) ? (object)DBNull.Value : otStart);
- command.Parameters.AddWithValue("@otEnd", string.IsNullOrEmpty(otEnd) ? (object)DBNull.Value : otEnd);
- command.Parameters.AddWithValue("@wuid", FCOMMON.info.Login.no);
- command.Parameters.AddWithValue("@wdate", DateTime.Now);
-
- int rowsAffected = command.ExecuteNonQuery();
-
- if (rowsAffected == 0)
- {
- throw new Exception("업무일지를 찾을 수 없거나 수정 권한이 없습니다.");
- }
- }
- }
-
- var jsonData = "{\"success\":true,\"message\":\"데이터가 성공적으로 수정되었습니다.\"}";
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- jsonData,
- System.Text.Encoding.UTF8,
- "application/json")
- };
-
- return resp;
- }
- catch (Exception ex)
- {
- var errorResp = new HttpResponseMessage()
- {
- Content = new StringContent(
- $"{{\"success\":false,\"message\":\"{EscapeJsonString(ex.Message)}\"}}",
- System.Text.Encoding.UTF8,
- "application/json")
- };
- return errorResp;
- }
- }
-
- [HttpGet]
- public HttpResponseMessage Edit(int id)
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View("/jobreport/edit");
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var db = new dsMSSQLTableAdapters.vJobReportForUserTableAdapter();//. EEEntitiesJobreport();
- var sd = DateTime.Now.ToString("yyyy-MM-01");
- var ed = DateTime.Now.ToShortDateString();
- var rows = db.GetData(FCOMMON.info.Login.gcode, id).FirstOrDefault();//.vJobReportForUser.AsNoTracking().Where(t => t.gcode == FCOMMON.info.Login.gcode && t.idx == id).FirstOrDefault();
-
- var contents = result.Content;
- if (rows == null)
- {
- //아이템이 없는 메시지를 표시한다
- }
- else
- {
- //치환작업을 진행한다
- contents = contents.Replace("{pdate}", rows.pdate);
- contents = contents.Replace("{status}", rows.status);
- contents = contents.Replace("{name}", rows.name);
- contents = contents.Replace("{package}", rows.package);
- contents = contents.Replace("{process}", rows.process);
- contents = contents.Replace("{type}", rows.type);
- contents = contents.Replace("{userProcess}", rows.userProcess);
- contents = contents.Replace("{projectName}", rows.projectName);
- contents = contents.Replace("{hrs}", rows.hrs.ToString());
- contents = contents.Replace("{ot}", rows.ot.ToString());
- contents = contents.Replace("{requestpart}", rows.requestpart);
- contents = contents.Replace("{description}", rows.description);
-
- }
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
-
- [HttpGet]
- public HttpResponseMessage Add()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View("/jobreport/add");
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- //if (searchkey.isEmpty() == false)
- {
- var db = new dsMSSQLTableAdapters.vJobReportForUserTableAdapter();// EEEntitiesJobreport();
- var sd = DateTime.Now.ToString("yyyy-MM-01");
- var ed = DateTime.Now.ToShortDateString();
- var rows = db.GetByDate(FCOMMON.info.Login.gcode, FCOMMON.info.Login.no, sd, ed);
- //vJobReportForUser.AsNoTracking().Where(t => t.gcode == FCOMMON.info.Login.gcode && t.id == FCOMMON.info.Login.no && t.pdate.CompareTo(sd) >= 0 && t.pdate.CompareTo(ed) <= 1).OrderByDescending(t => t.pdate);
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
-
- tbody.AppendLine($"| {item.pdate.Substring(5)} | ");
- tbody.AppendLine($"{item.ww} | ");
- tbody.AppendLine($"{item.name} | ");
-
- if (item.status == "진행 중" || item.status.EndsWith("%"))
- tbody.AppendLine($"{item.status} | ");
- else
- tbody.AppendLine($"{item.status} | ");
-
- tbody.AppendLine($"{item.type} | ");
- tbody.AppendLine($"{item.projectName} | ");
- tbody.AppendLine($"{item.hrs} | ");
- tbody.AppendLine($"{item.ot} | ");
-
- tbody.AppendLine("");
- tbody.AppendLine(item.description);
- tbody.AppendLine(" | ");
-
- tbody.AppendLine("
");
- }
- }
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 1 | ");
- tbody.AppendLine("자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage Find()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- if (searchkey.isEmpty() == false)
- {
- var db = new dsMSSQLTableAdapters.vJobReportForUserTableAdapter();// EEEntitiesJobreport();
- var sd = DateTime.Now.ToShortDateString();
- var rows = db.GetByToday(FCOMMON.info.Login.gcode, sd);//.vJobReportForUser.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.pdate.CompareTo(sd) == 0).OrderBy(t => t.name);
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
- tbody.AppendLine($"| {item.pdate} | ");
- tbody.AppendLine($"{item.status} | ");
- tbody.AppendLine($"{item.name} | ");
- tbody.AppendLine($"{item.projectName} | ");
- tbody.AppendLine($"{item.hrs} | ");
- tbody.AppendLine($"{item.ot} | ");
- tbody.AppendLine($"{item.description} | ");
-
-
- if (item.description.Length > 10)
- tbody.AppendLine($"{item.description.Substring(0, 10)}... | ");
- else
- tbody.AppendLine($"{item.description} | ");
- tbody.AppendLine("
");
- }
- }
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 1 | ");
- tbody.AppendLine("자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- // 직접 파일을 읽어서 반환
- var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "Jobreport", "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 = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage GetJobDetail(int id)
- {
- try
- {
- // 특정 업무일지의 전체 정보 조회
- string connectionString = Properties.Settings.Default.gwcs;
-
- using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
- {
- connection.Open();
-
- string selectSql = @"
- SELECT idx, pdate, gcode, uid as id, '' as name, '' as process, type, '' as svalue,
- hrs, ot, requestpart, '' as package, '' as userProcess, status, projectName,
- description, '' as ww, otStart, otEnd, ot as ot2, '' as otReason,
- '' as grade, '' as indate, '' as outdate, pidx
- FROM JobReport WITH (NOLOCK)
- WHERE gcode = @gcode AND uid = @uid AND idx = @idx";
-
- using (var command = new System.Data.SqlClient.SqlCommand(selectSql, connection))
- {
- command.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- command.Parameters.AddWithValue("@uid", FCOMMON.info.Login.no);
- command.Parameters.AddWithValue("@idx", id);
-
- using (var reader = command.ExecuteReader())
- {
- if (reader.Read())
- {
- var item = new
- {
- idx = reader["idx"],
- pdate = reader["pdate"],
- gcode = reader["gcode"],
- id = reader["id"],
- name = reader["name"],
- process = reader["process"],
- type = reader["type"],
- svalue = reader["svalue"],
- hrs = reader["hrs"],
- ot = reader["ot"],
- requestpart = reader["requestpart"],
- package = reader["package"],
- userProcess = reader["userProcess"],
- status = reader["status"],
- projectName = reader["projectName"],
- description = reader["description"], // 전체 내용
- ww = reader["ww"],
- otStart = reader["otStart"],
- otEnd = reader["otEnd"],
- ot2 = reader["ot2"],
- otReason = reader["otReason"],
- grade = reader["grade"],
- indate = reader["indate"],
- outdate = reader["outdate"],
- pidx = reader["pidx"]
- };
-
- // JSON 형태로 변환
- decimal hrs = 0;
- decimal ot = 0;
- int idx = 0;
- int pidx = 0;
-
- try { hrs = Convert.ToDecimal(item.hrs); } catch { hrs = 0; }
- try { ot = Convert.ToDecimal(item.ot); } catch { ot = 0; }
- try { idx = Convert.ToInt32(item.idx); } catch { idx = 0; }
- try { pidx = Convert.ToInt32(item.pidx); } catch { pidx = 0; }
-
- var desc = EscapeJsonString(item.description?.ToString() ?? ""); // 전체 내용
- var pdate = EscapeJsonString(item.pdate?.ToString() ?? "");
- var status = EscapeJsonString(item.status?.ToString() ?? "");
- var type = EscapeJsonString(item.type?.ToString() ?? "");
- var projectName = EscapeJsonString(item.projectName?.ToString() ?? "");
- var requestpart = EscapeJsonString(item.requestpart?.ToString() ?? "");
- var otStart = EscapeJsonString(item.otStart?.ToString() ?? "");
- var otEnd = EscapeJsonString(item.otEnd?.ToString() ?? "");
-
- var jsonData = "{";
- jsonData += $"\"pdate\":\"{pdate}\",";
- jsonData += $"\"status\":\"{status}\",";
- jsonData += $"\"type\":\"{type}\",";
- jsonData += $"\"projectName\":\"{projectName}\",";
- jsonData += $"\"requestpart\":\"{requestpart}\",";
- jsonData += $"\"hrs\":{hrs},";
- jsonData += $"\"ot\":{ot},";
- jsonData += $"\"description\":\"{desc}\",";
- jsonData += $"\"otStart\":\"{otStart}\",";
- jsonData += $"\"otEnd\":\"{otEnd}\",";
- jsonData += $"\"idx\":{idx},";
- jsonData += $"\"pidx\":{pidx}";
- jsonData += "}";
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- jsonData,
- System.Text.Encoding.UTF8,
- "application/json")
- };
-
- return resp;
- }
- }
- }
- }
-
- // 데이터를 찾을 수 없는 경우
- var errorResp = new HttpResponseMessage()
- {
- Content = new StringContent(
- "{\"error\":\"데이터를 찾을 수 없습니다.\"}",
- System.Text.Encoding.UTF8,
- "application/json")
- };
- return errorResp;
- }
- catch (Exception ex)
- {
- var errorResp = new HttpResponseMessage()
- {
- Content = new StringContent(
- $"{{\"error\":\"{ex.Message}\"}}",
- System.Text.Encoding.UTF8,
- "application/json")
- };
- return errorResp;
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetUsers()
- {
- try
- {
- string connectionString = Properties.Settings.Default.gwcs;
- var users = new List();
-
- using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
- {
- connection.Open();
-
- string selectSql = @"
- SELECT name, id, processs
- FROM vGroupUser
- WHERE gcode = @gcode AND useJobReport = 1 AND useUserState = 1
- ORDER BY name";
-
- using (var command = new System.Data.SqlClient.SqlCommand(selectSql, connection))
- {
- command.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
-
- using (var reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- users.Add(new
- {
- name = reader["name"],
- id = reader["id"],
- process = reader["processs"]
- });
- }
- }
- }
- }
-
- // 디버깅 로그 추가
- System.Diagnostics.Debug.WriteLine($"GetUsers: Found {users.Count} users for gcode {FCOMMON.info.Login.gcode}");
-
- // JSON 형태로 변환
- var jsonData = "[";
- bool first = true;
-
- foreach (var user in users)
- {
- if (!first) jsonData += ",";
- first = false;
-
- var name = EscapeJsonString(user.name?.ToString() ?? "");
- var id = EscapeJsonString(user.id?.ToString() ?? "");
- var process = EscapeJsonString(user.process?.ToString() ?? "");
-
- jsonData += "{";
- jsonData += $"\"name\":\"{name}\",";
- jsonData += $"\"id\":\"{id}\",";
- jsonData += $"\"process\":\"{process}\"";
- jsonData += "}";
- }
- jsonData += "]";
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- jsonData,
- System.Text.Encoding.UTF8,
- "application/json")
- };
-
- return resp;
- }
- catch (Exception ex)
- {
- var errorResp = new HttpResponseMessage()
- {
- Content = new StringContent(
- $"{{\"error\":\"{ex.Message}\"}}",
- System.Text.Encoding.UTF8,
- "application/json")
- };
- return errorResp;
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetJobData()
- {
- try
- {
- var gets = Request.GetQueryNameValuePairs();
- var startDateParam = gets.Where(t => t.Key == "startDate").FirstOrDefault();
- var endDateParam = gets.Where(t => t.Key == "endDate").FirstOrDefault();
- var userParam = gets.Where(t => t.Key == "user").FirstOrDefault();
-
- var startDate = startDateParam.Key != null ? startDateParam.Value : null;
- var endDate = endDateParam.Key != null ? endDateParam.Value : null;
- var selectedUser = userParam.Key != null ? userParam.Value : null;
-
- // 날짜 파라미터 처리
- string sd, ed;
- if (!string.IsNullOrEmpty(startDate) && !string.IsNullOrEmpty(endDate))
- {
- sd = startDate;
- ed = endDate;
- }
- else
- {
- // 기본값: 오늘부터 -2주
- var now = DateTime.Now;
- var twoWeeksAgo = now.AddDays(-14);
- sd = twoWeeksAgo.ToShortDateString();
- ed = now.ToShortDateString();
- }
-
- // 직접 SQL로 데이터 조회
- string connectionString = Properties.Settings.Default.gwcs;
- var jobReports = new List();
-
- using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
- {
- connection.Open();
-
- string selectSql = @"
- SELECT idx, pdate, gcode, uid as id, '' as name, '' as process, type, '' as svalue,
- hrs, ot, requestpart, '' as package, '' as userProcess, status, projectName,
- description, '' as ww, otStart, otEnd, ot as ot2, '' as otReason,
- '' as grade, '' as indate, '' as outdate, pidx
- FROM JobReport WITH (NOLOCK)
- WHERE gcode = @gcode AND pdate BETWEEN @startDate AND @endDate";
-
- // 사용자 필터가 있으면 해당 사용자, 없으면 로그인한 사용자
- selectSql += " AND uid = @uid";
-
- selectSql += " ORDER BY pdate DESC";
-
- using (var command = new System.Data.SqlClient.SqlCommand(selectSql, connection))
- {
- command.Parameters.AddWithValue("@gcode", FCOMMON.info.Login.gcode);
- command.Parameters.AddWithValue("@uid", !string.IsNullOrEmpty(selectedUser) ? selectedUser : FCOMMON.info.Login.no);
- command.Parameters.AddWithValue("@startDate", sd);
- command.Parameters.AddWithValue("@endDate", ed);
-
- using (var reader = command.ExecuteReader())
- {
- while (reader.Read())
- {
- jobReports.Add(new
- {
- idx = reader["idx"],
- pdate = reader["pdate"],
- gcode = reader["gcode"],
- id = reader["id"],
- name = reader["name"],
- process = reader["process"],
- type = reader["type"],
- svalue = reader["svalue"],
- hrs = reader["hrs"],
- ot = reader["ot"],
- requestpart = reader["requestpart"],
- package = reader["package"],
- userProcess = reader["userProcess"],
- status = reader["status"],
- projectName = reader["projectName"],
- description = reader["description"],
- ww = reader["ww"],
- otStart = reader["otStart"],
- otEnd = reader["otEnd"],
- ot2 = reader["ot2"],
- otReason = reader["otReason"],
- grade = reader["grade"],
- indate = reader["indate"],
- outdate = reader["outdate"],
- pidx = reader["pidx"]
- });
- }
- }
- }
- }
-
- // JSON 형태로 변환
- var jsonData = "[";
- bool first = true;
-
- if (jobReports != null)
- {
- foreach (var item in jobReports)
- {
- if (!first) jsonData += ",";
- first = false;
-
- // DBNull 처리를 위한 안전한 변환
- decimal hrs = 0;
- decimal ot = 0;
- int idx = 0;
- int pidx = 0;
-
- try { hrs = Convert.ToDecimal(item.hrs); } catch { hrs = 0; }
- try { ot = Convert.ToDecimal(item.ot); } catch { ot = 0; }
- try { idx = Convert.ToInt32(item.idx); } catch { idx = 0; }
- try { pidx = Convert.ToInt32(item.pidx); } catch { pidx = 0; }
-
- // 안전한 JSON 문자열 이스케이프 처리 및 25자 제한
- var fullDesc = item.description?.ToString() ?? "";
- var desc = EscapeJsonString(fullDesc.Length > 25 ? fullDesc.Substring(0, 25) + "..." : fullDesc);
- var pdate = EscapeJsonString(item.pdate?.ToString() ?? "");
- var ww = EscapeJsonString(item.ww?.ToString() ?? "");
- var name = EscapeJsonString(item.name?.ToString() ?? "");
- var status = EscapeJsonString(item.status?.ToString() ?? "");
- var type = EscapeJsonString(item.type?.ToString() ?? "");
- var projectName = EscapeJsonString(item.projectName?.ToString() ?? "");
- var requestpart = EscapeJsonString(item.requestpart?.ToString() ?? "");
- var userProcess = EscapeJsonString(item.userProcess?.ToString() ?? "");
-
- jsonData += "{";
- jsonData += $"\"pdate\":\"{pdate}\",";
- jsonData += $"\"ww\":\"{ww}\",";
- jsonData += $"\"name\":\"{name}\",";
- jsonData += $"\"status\":\"{status}\",";
- jsonData += $"\"type\":\"{type}\",";
- jsonData += $"\"projectName\":\"{projectName}\",";
- jsonData += $"\"requestpart\":\"{requestpart}\",";
- jsonData += $"\"userProcess\":\"{userProcess}\",";
- jsonData += $"\"hrs\":{hrs},";
- jsonData += $"\"ot\":{ot},";
- jsonData += $"\"description\":\"{desc}\",";
- jsonData += $"\"idx\":{idx},";
- jsonData += $"\"pidx\":{pidx}";
- jsonData += "}";
- }
- }
- jsonData += "]";
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- jsonData,
- System.Text.Encoding.UTF8,
- "application/json")
- };
-
- return resp;
- }
- catch (Exception ex)
- {
- var errorResp = new HttpResponseMessage()
- {
- Content = new StringContent(
- $"{{\"error\":\"{ex.Message}\"}}",
- System.Text.Encoding.UTF8,
- "application/json")
- };
- return errorResp;
- }
- }
-
- private string EscapeJsonString(string input)
- {
- if (string.IsNullOrEmpty(input))
- return "";
-
- // 제어 문자 제거 (0x00-0x1F 범위)
- var cleanInput = System.Text.RegularExpressions.Regex.Replace(input, @"[\x00-\x08\x0B\x0C\x0E-\x1F]", "");
-
- return cleanInput
- .Replace("\\", "\\\\") // 백슬래시
- .Replace("\"", "\\\"") // 따옴표
- .Replace("\n", "\\n") // 개행
- .Replace("\r", "\\r") // 캐리지 리턴
- .Replace("\t", "\\t"); // 탭
- }
- }
-}
\ No newline at end of file
diff --git a/Project/Web/Controller/KuntaeController.cs b/Project/Web/Controller/KuntaeController.cs
deleted file mode 100644
index e05e8f0..0000000
--- a/Project/Web/Controller/KuntaeController.cs
+++ /dev/null
@@ -1,293 +0,0 @@
-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 KuntaeController : BaseController
- {
-
- [HttpGet]
- public HttpResponseMessage GetList(string sd = null, string ed = null)
- {
- var sql = string.Empty;
- sql = "select idx,gcode,uid,dbo.getUserName(uid) as uname,cate,sdate,edate,term,termdr,drtime,DrTimePMS,crtime,title,contents, tag, extcate,extidx, wuid,wdate" +
- " from Holyday" +
- " where gcode = @gcode" +
- " and uid = @uid" +
- " and sdate between @sd and @ed" +
- " order by wdate desc";
-
-
- 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);
- cmd.Parameters.AddWithValue("uid", FCOMMON.info.Login.no);
-
- // 날짜 파라미터가 없으면 기본값 사용 (현재 월)
- var startDate = !string.IsNullOrEmpty(sd) ? sd : DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd");
- var endDate = !string.IsNullOrEmpty(ed) ? ed : DateTime.Now.ToString("yyyy-MM-dd");
-
- cmd.Parameters.AddWithValue("sd", startDate);
- cmd.Parameters.AddWithValue("ed", endDate);
- 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", "kuntae", "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 = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpPost]
- public HttpResponseMessage Insert([FromBody] KuntaeModel model)
- {
- try
- {
- var sql = @"INSERT INTO Holyday (gcode, uid, cate, sdate, edate, term, termdr, drtime, DrTimePMS, crtime, title, contents, tag, extcate, extidx, wuid, wdate)
- VALUES (@gcode, @uid, @cate, @sdate, @edate, @term, @termdr, @drtime, @DrTimePMS, @crtime, @title, @contents, @tag, @extcate, @extidx, @wuid, @wdate)";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- cmd.Parameters.AddWithValue("uid", FCOMMON.info.Login.no);
- cmd.Parameters.AddWithValue("cate", (object)model.cate ?? DBNull.Value);
- cmd.Parameters.AddWithValue("sdate", model.sdate);
- cmd.Parameters.AddWithValue("edate", (object)model.edate ?? DBNull.Value);
- cmd.Parameters.AddWithValue("term", (object)model.term ?? DBNull.Value);
- cmd.Parameters.AddWithValue("termdr", (object)model.termdr ?? DBNull.Value);
- cmd.Parameters.AddWithValue("drtime", (object)model.drtime ?? DBNull.Value);
- cmd.Parameters.AddWithValue("DrTimePMS", (object)model.DrTimePMS ?? DBNull.Value);
- cmd.Parameters.AddWithValue("crtime", (object)model.crtime ?? DBNull.Value);
- cmd.Parameters.AddWithValue("title", (object)model.title ?? DBNull.Value);
- cmd.Parameters.AddWithValue("contents", (object)model.contents ?? DBNull.Value);
- cmd.Parameters.AddWithValue("tag", (object)model.tag ?? DBNull.Value);
- cmd.Parameters.AddWithValue("extcate", (object)model.extcate ?? DBNull.Value);
- cmd.Parameters.AddWithValue("extidx", (object)model.extidx ?? DBNull.Value);
- cmd.Parameters.AddWithValue("wuid", FCOMMON.info.Login.no);
- cmd.Parameters.AddWithValue("wdate", DateTime.Now);
-
- cn.Open();
- var result = cmd.ExecuteNonQuery();
- cn.Close();
- cmd.Dispose();
- cn.Dispose();
-
- var response = new { success = true, message = "근태가 추가되었습니다." };
- var json = JsonConvert.SerializeObject(response);
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
- };
- }
- catch (Exception ex)
- {
- var response = new { success = false, message = "근태 추가 중 오류가 발생했습니다: " + ex.Message };
- var json = JsonConvert.SerializeObject(response);
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
- };
- }
- }
-
- [HttpPut]
- public HttpResponseMessage Update([FromBody] KuntaeModel model)
- {
- try
- {
- var sql = @"UPDATE Holyday SET cate = @cate, sdate = @sdate, edate = @edate, term = @term, termdr = @termdr,
- drtime = @drtime, DrTimePMS = @DrTimePMS, crtime = @crtime, title = @title, contents = @contents,
- tag = @tag, extcate = @extcate, extidx = @extidx
- WHERE gcode = @gcode AND uid = @uid AND idx = @idx";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- cmd.Parameters.AddWithValue("uid", FCOMMON.info.Login.no);
- cmd.Parameters.AddWithValue("cate", (object)model.cate ?? DBNull.Value);
- cmd.Parameters.AddWithValue("sdate", model.sdate);
- cmd.Parameters.AddWithValue("edate", (object)model.edate ?? DBNull.Value);
- cmd.Parameters.AddWithValue("term", (object)model.term ?? DBNull.Value);
- cmd.Parameters.AddWithValue("termdr", (object)model.termdr ?? DBNull.Value);
- cmd.Parameters.AddWithValue("drtime", (object)model.drtime ?? DBNull.Value);
- cmd.Parameters.AddWithValue("DrTimePMS", (object)model.DrTimePMS ?? DBNull.Value);
- cmd.Parameters.AddWithValue("crtime", (object)model.crtime ?? DBNull.Value);
- cmd.Parameters.AddWithValue("title", (object)model.title ?? DBNull.Value);
- cmd.Parameters.AddWithValue("contents", (object)model.contents ?? DBNull.Value);
- cmd.Parameters.AddWithValue("tag", (object)model.tag ?? DBNull.Value);
- cmd.Parameters.AddWithValue("extcate", (object)model.extcate ?? DBNull.Value);
- cmd.Parameters.AddWithValue("extidx", (object)model.extidx ?? DBNull.Value);
- cmd.Parameters.AddWithValue("idx", model.idx);
-
- cn.Open();
- var result = cmd.ExecuteNonQuery();
- cn.Close();
- cmd.Dispose();
- cn.Dispose();
-
- var response = new { success = true, message = "근태가 수정되었습니다." };
- var json = JsonConvert.SerializeObject(response);
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
- };
- }
- catch (Exception ex)
- {
- var response = new { success = false, message = "근태 수정 중 오류가 발생했습니다: " + ex.Message };
- var json = JsonConvert.SerializeObject(response);
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
- };
- }
- }
-
- [HttpDelete]
- public HttpResponseMessage Delete(string id)
- {
- try
- {
- var sql = "DELETE FROM Holyday WHERE gcode = @gcode AND uid = @uid AND idx = @idx";
-
- var cs = Properties.Settings.Default.gwcs;
- 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);
- cmd.Parameters.AddWithValue("uid", FCOMMON.info.Login.no);
- cmd.Parameters.AddWithValue("idx", id);
-
- cn.Open();
- var result = cmd.ExecuteNonQuery();
- cn.Close();
- cmd.Dispose();
- cn.Dispose();
-
- var response = new { success = true, message = "근태가 삭제되었습니다." };
- var json = JsonConvert.SerializeObject(response);
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
- };
- }
- catch (Exception ex)
- {
- var response = new { success = false, message = "근태 삭제 중 오류가 발생했습니다: " + ex.Message };
- var json = JsonConvert.SerializeObject(response);
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
- };
- }
- }
- }
-
- public class KuntaeModel
- {
- /*
- idx : 데이터고유번호
- gcode : 그룹코드(데이터 그룹간 식별)
- uid : 사원번호
- cate : 근태구분
- sdate : 시작일
- edate : 종료일
- term : 사용일
- termdr : 발생일
- drtime : 발생시간,
- crtime : 사용시간
- DrTimePMS : PMS등록시간
- title : 제목
- contents : 내용
- tag : 입력방식특이사항(clipboard=클립보드에서붙여넣었다)
- extcate : 외부에서생성된 경우 외부 출처
- extidx : 외부출처인경우 데이터고유번호
- wuid : 데이터기록자 사원번호
- wdate : 데이터를기록한일시
- */
-
- public int idx { get; set; } // 데이터고유번호
- public string gcode { get; set; } // 그룹코드(데이터 그룹간 식별)
- public string uid { get; set; } // 사원번호
- public string uname { get; set; } // 성명
- public string cate { get; set; } // 근태구분
- public string sdate { get; set; } // 시작일
- public string edate { get; set; } // 종료일
- public string term { get; set; } // 사용일
- public string termdr { get; set; } // 발생일
- public string drtime { get; set; } // 발생시간
- public string DrTimePMS { get; set; } // PMS등록시간
- public string crtime { get; set; } // 사용시간
- public string title { get; set; } // 제목
- public string contents { get; set; } // 내용
- public string tag { get; set; } // 입력방식특이사항
- public string extcate { get; set; } // 외부에서생성된 경우 외부 출처
- public string extidx { get; set; } // 외부출처인경우 데이터고유번호
- public string wuid { get; set; } // 데이터기록자 사원번호
- public string wdate { get; set; } // 데이터를기록한일시
- }
-}
-
-
-
diff --git a/Project/Web/Controller/ManualController.cs b/Project/Web/Controller/ManualController.cs
deleted file mode 100644
index db09e5f..0000000
--- a/Project/Web/Controller/ManualController.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-
-namespace Project.Web.Controllers
-{
- public class ManualController : BaseController
- {
- [HttpPost]
- public void Index([FromBody]string value)
- {
-
- }
-
- // PUT api/values/5
- public void Put(int id, [FromBody]string value)
- {
- }
-
- // DELETE api/values/5
- public void Delete(int id)
- {
-
- }
-
- [HttpGet]
- public HttpResponseMessage Page(string id)
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View($"\\Manual\\{id}");
-
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var contents = result.Content;
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var contents = result.Content;
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- }
-}
diff --git a/Project/Web/Controller/ProjectController.cs b/Project/Web/Controller/ProjectController.cs
deleted file mode 100644
index 527831b..0000000
--- a/Project/Web/Controller/ProjectController.cs
+++ /dev/null
@@ -1,408 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-using Newtonsoft.Json;
-using FCOMMON;
-using Project.Web.Model;
-
-namespace Project.Web.Controllers
-{
- public class ProjectController : BaseController
- {
- [HttpGet]
- public HttpResponseMessage Index()
- {
- var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "Project", "index.html");
- var contents = string.Empty;
-
- if (System.IO.File.Exists(filePath))
- {
- contents = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8);
- }
- else
- {
- contents = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage GetProjects(string status = "진행", string userFilter = "my")
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string currentUserName = FCOMMON.info.Login.nameK ?? "";
-
- var sql = @"
- SELECT idx, status as 상태,asset as 자산번호, model as 장비모델, serial as 시리얼번호, Priority as 우선순위,
- ReqSite as 요청국가, ReqPlant as 요청공장, ReqLine as 요청라인, ReqPackage as 요청부서패키지,
- reqstaff as 요청자, process as 프로젝트공정, sdate as 시작일,edate as 완료일,ddate as 만료일, odate as 출고일, name as 프로젝트명,
- dbo.getUserName( isnull(championid, userManager) ) as 프로젝트관리자,
- dbo.getUserName (isnull(designid, usermain)) as 설계담당,
- dbo.getUserName(isnull(epanelid, userhw2)) as 전장담당,
- dbo.getUserName(isnull(softwareid, usersub)) as 프로그램담당,
- crdue as 예산만기일, cramount as 예산,jasmin as 웹관리번호
- FROM Projects
- WHERE gcode = @gcode
- AND status = @status
- AND ISNULL(isdel, 0) = 0";
-
- // 사용자 필터 적용
- if (userFilter == "my" && !string.IsNullOrEmpty(currentUserName))
- {
- sql += @" AND (
- dbo.getUserName(ISNULL(championid, userManager)) LIKE @userName
- OR dbo.getUserName(ISNULL(designid, usermain)) LIKE @userName
- OR dbo.getUserName(ISNULL(epanelid, userhw2)) LIKE @userName
- OR dbo.getUserName(ISNULL(softwareid, usersub)) LIKE @userName
- )";
- }
-
- sql += " ORDER BY wdate DESC";
-
- var parameters = new
- {
- gcode = gcode,
- status = status,
- userName = userFilter == "my" ? "%" + currentUserName + "%" : ""
- };
-
- var projects = DBM.Query(sql, parameters);
-
- return CreateJsonResponse(new
- {
- Success = true,
- Data = projects,
- CurrentUser = currentUserName
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트 목록을 가져오는 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetProject(int id)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (id <= 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "유효하지 않은 프로젝트 ID입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
-
- var sql = @"
- SELECT idx, status as 상태,asset as 자산번호, model as 장비모델, serial as 시리얼번호, Priority as 우선순위,
-ReqSite as 요청국가, ReqPlant as 요청공장, ReqLine as 요청라인, ReqPackage as 요청부서패키지,
-reqstaff as 요청자, process as 프로젝트공정, sdate as 시작일,edate as 완료일,ddate as 만료일, odate as 출고일, name as 프로젝트명,
- dbo.getUserName( isnull(championid, userManager) ) as 프로젝트관리자,
- dbo.getUserName (isnull(designid, usermain)) as 설계담당,
- dbo.getUserName(isnull(epanelid, userhw2)) as 전장담당,
- dbo.getUserName(isnull(softwareid, usersub)) as 프로그램담당,
- crdue as 예산만기일, cramount as 예산,jasmin as 웹관리번호
- FROM Projects
- WHERE idx = @idx AND gcode = @gcode AND ISNULL(isdel, 0) = 0";
-
- var project = DBM.QuerySingleOrDefault(sql, new { idx = id, gcode = gcode });
-
- if (project == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트를 찾을 수 없습니다."
- });
- }
-
- return CreateJsonResponse(new
- {
- Success = true,
- Data = project
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트 조회 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpPost]
- public HttpResponseMessage CreateProject([FromBody] ProjectModel project)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (string.IsNullOrWhiteSpace(project.프로젝트명))
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트명을 입력해주세요."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string uid = FCOMMON.info.Login.no;
-
- var sql = @"
- INSERT INTO Projects (gcode, process, sdate, name, edate, ddate, odate, userManager, status, memo, wdate)
- VALUES (@gcode, @process, @sdate, @name, @edate, @ddate, @odate, @userManager, @status, @memo, GETDATE())";
-
- var parameters = new
- {
- gcode = gcode,
- process = project.프로젝트공정 ?? "",
- sdate = project.시작일,
- name = project.프로젝트명,
- edate = project.완료일,
- ddate = project.만료일,
- odate = project.출고일,
- userManager = project.프로젝트관리자 ?? "",
- status = project.상태 ?? "진행",
- memo = project.memo ?? ""
- };
-
- DBM.Execute(sql, parameters);
-
- return CreateJsonResponse(new
- {
- Success = true,
- Message = "프로젝트가 추가되었습니다."
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트 추가 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpPut]
- public HttpResponseMessage UpdateProject([FromBody] ProjectModel project)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (project.idx <= 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "유효하지 않은 프로젝트 ID입니다."
- });
- }
-
- if (string.IsNullOrWhiteSpace(project.프로젝트명))
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트명을 입력해주세요."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
-
- // 먼저 프로젝트가 존재하는지 확인
- var checkSql = "SELECT COUNT(*) FROM Projects WHERE idx = @idx AND gcode = @gcode AND ISNULL(isdel, 0) = 0";
- var count = DBM.QuerySingle(checkSql, new { idx = project.idx, gcode = gcode });
-
- if (count == 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "수정할 프로젝트를 찾을 수 없습니다."
- });
- }
-
- var sql = @"
- UPDATE Projects
- SET process = @process, sdate = @sdate, name = @name, edate = @edate,
- ddate = @ddate, odate = @odate, userManager = @userManager,
- status = @status, memo = @memo
- WHERE idx = @idx AND gcode = @gcode";
-
- var parameters = new
- {
- idx = project.idx,
- gcode = gcode,
- process = project.프로젝트공정 ?? "",
- sdate = project.시작일,
- name = project.프로젝트명,
- edate = project.완료일,
- ddate = project.만료일,
- odate = project.출고일,
- userManager = project.프로젝트관리자 ?? "",
- status = project.상태 ?? "진행",
- memo = project.memo ?? ""
- };
-
- DBM.Execute(sql, parameters);
-
- return CreateJsonResponse(new
- {
- Success = true,
- Message = "프로젝트가 수정되었습니다."
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트 수정 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpDelete]
- public HttpResponseMessage DeleteProject(int id)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (id <= 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "유효하지 않은 프로젝트 ID입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
-
- // 먼저 프로젝트가 존재하는지 확인
- var checkSql = "SELECT COUNT(*) FROM Projects WHERE idx = @idx AND gcode = @gcode AND ISNULL(isdel, 0) = 0";
- var count = DBM.QuerySingle(checkSql, new { idx = id, gcode = gcode });
-
- if (count == 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "삭제할 프로젝트를 찾을 수 없습니다."
- });
- }
-
- var sql = "UPDATE Projects SET isdel = 1 WHERE idx = @idx AND gcode = @gcode";
- DBM.Execute(sql, new { idx = id, gcode = gcode });
-
- return CreateJsonResponse(new
- {
- Success = true,
- Message = "프로젝트가 삭제되었습니다."
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "프로젝트 삭제 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- private object GetCurrentUser()
- {
- 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,
- DateFormatString = "yyyy-MM-dd HH:mm:ss"
- });
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(
- json,
- System.Text.Encoding.UTF8,
- "application/json")
- };
- }
- }
-}
diff --git a/Project/Web/Controller/PurchaseController.cs b/Project/Web/Controller/PurchaseController.cs
deleted file mode 100644
index 7d19919..0000000
--- a/Project/Web/Controller/PurchaseController.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-using System.Windows.Forms;
-
-namespace Project.Web.Controllers
-{
- public class PurchaseController : BaseController
- {
-
-
- // PUT api/values/5
- public void Put(int id, [FromBody] string value)
- {
- }
-
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
-
- [HttpGet]
- public string Test()
- {
- return "test";
- }
-
- [HttpGet]
- public HttpResponseMessage Find()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- if(searchkey.isEmpty()==false && searchkey != "%")
- {
- if (searchkey.StartsWith("%") == false) searchkey = "%" + searchkey;
- if (searchkey.EndsWith("%") == false) searchkey += "%";
- }
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- if (searchkey.isEmpty() == false)
- {
- var db = new dsMSSQLTableAdapters.vFindSIDTableAdapter();// EEEntitiesMain();
- var rows = db.GetData(searchkey);//.vFindSID.Where(t => t.sid.Contains(searchkey) || t.name.Contains(searchkey) || t.manu.Contains(searchkey) || t.model.Contains(searchkey));
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
- tbody.AppendLine($"| {item.Location} | ");
- tbody.AppendLine($"{item.sid} | ");
- tbody.AppendLine($"{item.name} | ");
- tbody.AppendLine($"{item.model} | ");
-
- if (item.IspriceNull())
- tbody.AppendLine($"-- | ");
- else
- {
- var price = (double)item.price / 1000.0;
-
- tbody.AppendLine($"{price.ToString("N0")} | ");
- }
-
-
- tbody.AppendLine($"{item.manu} | ");
- tbody.AppendLine($"{item.supply} | ");
-
- if (item.remark.Length > 10)
- tbody.AppendLine($"{item.remark.Substring(0, 10)}... | ");
- else
- tbody.AppendLine($"{item.remark} | ");
- tbody.AppendLine("
");
- }
- }
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 1 | ");
- tbody.AppendLine("자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
-
- var gets = Request.GetQueryNameValuePairs();// GetParameters(data);
-
-
- var key_search = gets.Where(t => t.Key == "search").FirstOrDefault();
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var searchkey = string.Empty;
- if (key_search.Key != null && key_search.Value.isEmpty() == false) searchkey = key_search.Value.Trim();
-
- var tbody = new System.Text.StringBuilder();
-
- //테이블데이터생성
- var itemcnt = 0;
- //if (searchkey.isEmpty() == false)
- //{
- var db = new dsMSSQLTableAdapters.vPurchaseTableAdapter();// EEEntitiesPurchase();
- var sd = DateTime.Now.ToString("yyyy-MM-01");
- var rows = db.GetAfter(FCOMMON.info.Login.gcode, sd);// .vPurchase.Where(t => t.gcode == FCOMMON.info.Login.gcode && t.pdate.CompareTo(sd) >= 0).OrderByDescending(t => t.pdate);
- itemcnt = rows.Count();
- foreach (var item in rows)
- {
- tbody.AppendLine("");
- tbody.AppendLine($"| {item.pdate.Substring(5)} | ");
-
- if (item.state == "---") tbody.AppendLine($"{item.state} | ");
- else if (item.state == "Received") tbody.AppendLine($"{item.state} | ");
- else tbody.AppendLine($"{item.state} | ");
-
- tbody.AppendLine($"{item.name} | ");
- tbody.AppendLine($"{item.sid} | ");
- tbody.AppendLine($"{item.pumname} | ");
-
- if (item.pumscale.Length > 10) tbody.AppendLine($"{item.pumscale.Substring(0, 10)}... | ");
- else tbody.AppendLine($"{item.pumscale} | ");
-
- tbody.AppendLine($"{item.pumqty} | ");
- tbody.AppendLine($"{item.pumprice} | ");
- tbody.AppendLine($"{item.pumamt} | ");
- tbody.AppendLine($"{item.supply} | ");
- if (item.project != null && item.project.Length > 10) tbody.AppendLine($"{item.project.Substring(0, 10)}... | ");
- else tbody.AppendLine($"{item.project} | ");
-
- if (item.bigo.Length > 10) tbody.AppendLine($"{item.bigo.Substring(0, 10)}... | ");
- else tbody.AppendLine($"{item.bigo} | ");
- tbody.AppendLine("
");
- }
- //}
-
- //아잍쳄이 없는경우
- if (itemcnt == 0)
- {
- tbody.AppendLine("");
- tbody.AppendLine("| 1 | ");
- tbody.AppendLine("자료가 없습니다 | ");
- tbody.AppendLine("
");
- }
-
-
- var contents = result.Content.Replace("{search}", searchkey);
- contents = contents.Replace("{tabledata}", tbody.ToString());
- contents = contents.Replace("{cnt}", itemcnt.ToString());
-
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- }
-}
diff --git a/Project/Web/Controller/ResourceController.cs b/Project/Web/Controller/ResourceController.cs
deleted file mode 100644
index 8767776..0000000
--- a/Project/Web/Controller/ResourceController.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using System.Web.Http;
-
-namespace Project.Web.Controllers
-{
- public class ResourceController : BaseController
- {
- //[HttpGet]
- //public HttpResponseMessage Index()
- //{
- // //로그인이 되어있지않다면 로그인을 가져온다
- // MethodResult result;
- // result = View(true);
-
- // var model = GetGlobalModel();
- // var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- // //기본값을 찾아서 없애줘야한다
- // var contents = result.Content;
-
- // //공용값 적용
- // ApplyCommonValue(ref contents);
-
- // //최종문자 적용
- // result.Content = contents;
-
- // var resp = new HttpResponseMessage()
- // {
- // Content = new StringContent(
- // result.Content,
- // System.Text.Encoding.UTF8,
- // "text/html")
- // };
-
- // return resp;
- //}
-
- [HttpGet]
- public HttpResponseMessage file()
- {
- var config = RequestContext.Configuration;
- var routeData = config.Routes.GetRouteData(Request).Values.ToList();
-
- var p_resource = routeData.Where(t => t.Key == "resource").FirstOrDefault();
- var p_path = routeData.Where(t => t.Key == "path").FirstOrDefault();
- var p_ext = routeData.Where(t => t.Key == "ext").FirstOrDefault();
- var p_subdir = routeData.Where(t => t.Key == "subdir").FirstOrDefault();
-
- var v_resource = string.Empty;
- var v_path = string.Empty;
- var v_ext = string.Empty;
- var v_subdir = string.Empty;
-
- if (p_resource.Key == "resource") v_resource = p_resource.Value.ToString();
- if (p_path.Key == "path") v_path = p_path.Value.ToString();
- if (p_ext.Key == "ext") v_ext = p_ext.Value.ToString();
- if (p_subdir.Key == "subdir") v_subdir = p_subdir.Value.ToString();
-
- //var file_ext = routeData[0].Value.ToString();
- //var name_resource = routeData[1].Value.ToString() + "." + file_ext;
- //var name_action = routeData[3].Value.ToString();
-
- Boolean isBinary = true;
-
-
- string content_type = "text/plain";
-
- if (v_ext == "json")
- {
- isBinary = false;
- content_type = "application/json";
- }
- else if(v_ext == "vue")
- {
- isBinary = false;
- content_type = "application/js";
- }
- else if (v_ext == "js")
- {
- isBinary = false;
- content_type = "application/js";
- }
- else if (v_ext == "css")
- {
- isBinary = false;
- content_type = "text/css";
- }
- else if (v_ext == "csv")
- {
- isBinary = false;
- content_type = "text/csv";
- }
- else if (v_ext == "ico")
- {
- isBinary = true;
- content_type = "image/x-icon";
- }
- else if(v_ext == "ttf" || v_ext == "otf")
- {
- isBinary = true;
- content_type = "application/octet-stream";
- }
-
- HttpContent resultContent = null;
-
- if (v_resource.isEmpty() && v_ext.isEmpty())
- {
- v_resource = "index";
- v_ext = "html";
- isBinary = false;
- content_type = "text/html";
- }
-
-
-
- var file = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "View", v_path, v_subdir, v_resource + "." + v_ext);
-
- if (isBinary)
- {
-
- if (System.IO.File.Exists(file))
- {
- var buffer = System.IO.File.ReadAllBytes(file);
- resultContent = new ByteArrayContent(buffer);
- Console.WriteLine(">>File(B) : " + file);
- }
- else Console.WriteLine("no resouoir file " + file);
-
- }
- else
- {
- if (System.IO.File.Exists(file))
- {
-
- var buffer = System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8);
- resultContent = new StringContent(buffer, System.Text.Encoding.UTF8, content_type);
- Console.WriteLine(">>File(S) : " + file);
- }
- else Console.WriteLine("no resouoir file " + file);
- }
-
-
- return new HttpResponseMessage()
- {
- Content = resultContent
- };
-
- }
- }
-}
diff --git a/Project/Web/Controller/ResultController.cs b/Project/Web/Controller/ResultController.cs
deleted file mode 100644
index bbdc2a5..0000000
--- a/Project/Web/Controller/ResultController.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-
-namespace Project.Web.Controllers
-{
- public class ResultController : BaseController
- {
- [HttpPost]
- public void Index([FromBody]string value)
- {
-
- }
-
- // PUT api/values/5
- public void Put(int id, [FromBody]string value)
- {
- }
-
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
-
- [HttpGet]
- public string Test()
- {
- return "test";
- }
-
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var contents = result.Content;
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- }
-}
diff --git a/Project/Web/Controller/SettingController.cs b/Project/Web/Controller/SettingController.cs
deleted file mode 100644
index 021616d..0000000
--- a/Project/Web/Controller/SettingController.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-
-namespace Project.Web.Controllers
-{
- public class SettingController : BaseController
- {
- [HttpPost]
- public void Index([FromBody]string value)
- {
-
- }
-
- // PUT api/values/5
- public void Put(int id, [FromBody]string value)
- {
- }
-
- // DELETE api/values/5
- public void Delete(int id)
- {
- }
-
- [HttpGet]
- public string Test()
- {
- return "test";
- }
-
- [HttpGet]
- public HttpResponseMessage Index()
- {
- //로그인이 되어있지않다면 로그인을 가져온다
- MethodResult result;
- result = View();
-
- var model = GetGlobalModel();
- var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
-
- //기본값을 찾아서 없애줘야한다
- var contents = result.Content;
-
- //공용값 적용
- ApplyCommonValue(ref contents);
-
- //최종문자 적용
- result.Content = contents;
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- result.Content,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- }
-}
diff --git a/Project/Web/Controller/TodoController.cs b/Project/Web/Controller/TodoController.cs
deleted file mode 100644
index b56161e..0000000
--- a/Project/Web/Controller/TodoController.cs
+++ /dev/null
@@ -1,439 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http;
-using System.Web.Http;
-using Newtonsoft.Json;
-using FCOMMON;
-using Project.Web.Model;
-
-namespace Project.Web.Controllers
-{
- public class TodoController : BaseController
- {
- [HttpGet]
- public HttpResponseMessage Index()
- {
- var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web", "wwwroot", "Todo", "index.html");
- var contents = string.Empty;
-
- if (System.IO.File.Exists(filePath))
- {
- contents = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8);
- }
- else
- {
- contents = "404 - File Not Found
The requested file was not found: " + filePath + "
";
- }
-
- ApplyCommonValue(ref contents);
-
- var resp = new HttpResponseMessage()
- {
- Content = new StringContent(
- contents,
- System.Text.Encoding.UTF8,
- "text/html")
- };
-
- return resp;
- }
-
- [HttpGet]
- public HttpResponseMessage GetTodos()
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string uid = FCOMMON.info.Login.no;
-
- var sql = @"SELECT * FROM EETGW_Todo WHERE gcode = @gcode AND uid = @uid
- ORDER BY
- CASE
- WHEN ISNULL(status,'0') = '1' THEN 1 -- 진행
- WHEN ISNULL(status,'0') = '0' THEN 2 -- 대기
- WHEN ISNULL(status,'0') = '3' THEN 3 -- 보류
- WHEN ISNULL(status,'0') = '5' THEN 4 -- 완료
- WHEN ISNULL(status,'0') = '2' THEN 5 -- 취소
- ELSE 6
- END, flag DESC,
- ISNULL(seqno, 0) DESC,
- expire ASC";
- var todos = DBM.Query(sql, new { gcode = gcode, uid = uid });
-
- return CreateJsonResponse(new
- {
- Success = true,
- Data = todos
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "Todo 목록을 가져오는 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetUrgentTodos()
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string uid = FCOMMON.info.Login.no;
-
- var sql = @"
- SELECT * FROM EETGW_Todo
- WHERE gcode = @gcode AND uid = @uid
- and isnull(status,'0') not in ('2','3','5')
- ORDER BY flag DESC, seqno DESC, expire ASC, wdate ASC";
-
- var todos = DBM.Query(sql, new { gcode = gcode, uid = uid });
-
- return CreateJsonResponse(new
- {
- Success = true,
- Data = todos
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "급한 Todo 목록을 가져오는 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpPost]
- public HttpResponseMessage CreateTodo([FromBody] TodoModel todo)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (string.IsNullOrEmpty(todo.remark))
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일 내용은 필수입니다."
- });
- }
-
- todo.gcode = FCOMMON.info.Login.gcode;
- todo.uid = FCOMMON.info.Login.no;
- todo.wuid = FCOMMON.info.Login.no;
- todo.wdate = DateTime.Now;
-
- if (todo.seqno == null) todo.seqno = 0;
- if (todo.flag == null) todo.flag = false;
- if (todo.status == '\0') todo.status = '0';
-
- // 새로 생성할 때 완료 상태면 완료일 설정
- DateTime? okdateValue = null;
- if (todo.status == '5')
- {
- okdateValue = DateTime.Now;
- }
-
- var sql = @"
- INSERT INTO EETGW_Todo (gcode, uid, title, remark, flag, expire, seqno, request, status, okdate, wuid, wdate)
- VALUES (@gcode, @uid, @title, @remark, @flag, @expire, @seqno, @request, @status, @okdate, @wuid, @wdate);
- SELECT SCOPE_IDENTITY();";
-
- var newId = DBM.QuerySingle(sql, new
- {
- gcode = todo.gcode,
- uid = todo.uid,
- title = todo.title,
- remark = todo.remark,
- flag = todo.flag,
- expire = todo.expire,
- seqno = todo.seqno,
- request = todo.request,
- status = todo.status,
- okdate = okdateValue,
- wuid = todo.wuid,
- wdate = todo.wdate
- });
-
- return CreateJsonResponse(new
- {
- Success = true,
- Message = "할일이 추가되었습니다.",
- Data = new { idx = newId }
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일 추가 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpPut]
- public HttpResponseMessage UpdateTodo([FromBody] TodoModel todo)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (todo.idx <= 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "유효하지 않은 Todo ID입니다."
- });
- }
-
- if (string.IsNullOrEmpty(todo.remark))
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일 내용은 필수입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string uid = FCOMMON.info.Login.no;
-
- // 상태가 완료('5')로 변경되고 아직 완료일이 설정되지 않은 경우 완료일 설정
- DateTime? okdateValue = null;
- if (todo.status == '5')
- {
- // 기존 완료일이 있는지 확인
- var existingTodo = DBM.QuerySingleOrDefault(
- "SELECT okdate FROM EETGW_Todo WHERE idx = @idx AND gcode = @gcode AND uid = @uid",
- new { idx = todo.idx, gcode = gcode, uid = uid });
-
- if (existingTodo?.okdate == null)
- {
- okdateValue = DateTime.Now;
- }
- }
-
- var sql = @"
- UPDATE EETGW_Todo
- SET title = @title, remark = @remark, flag = @flag, expire = @expire, seqno = @seqno, request = @request, status = @status, okdate = @okdate
- WHERE idx = @idx AND gcode = @gcode AND uid = @uid";
-
- var affectedRows = DBM.Execute(sql, new
- {
- title = todo.title,
- remark = todo.remark,
- flag = todo.flag ?? false,
- expire = todo.expire,
- seqno = todo.seqno ?? 0,
- request = todo.request,
- status = todo.status == '\0' ? '0' : todo.status,
- okdate = okdateValue,
- idx = todo.idx,
- gcode = gcode,
- uid = uid
- });
-
- if (affectedRows == 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "수정할 할일을 찾을 수 없습니다."
- });
- }
-
- return CreateJsonResponse(new
- {
- Success = true,
- Message = "할일이 수정되었습니다."
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일 수정 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpDelete]
- public HttpResponseMessage DeleteTodo(int id)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (id <= 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "유효하지 않은 Todo ID입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string uid = FCOMMON.info.Login.no;
-
- var sql = "DELETE FROM EETGW_Todo WHERE idx = @idx AND gcode = @gcode AND uid = @uid";
- var affectedRows = DBM.Execute(sql, new { idx = id, gcode = gcode, uid = uid });
-
- if (affectedRows == 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "삭제할 할일을 찾을 수 없습니다."
- });
- }
-
- return CreateJsonResponse(new
- {
- Success = true,
- Message = "할일이 삭제되었습니다."
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일 삭제 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- [HttpGet]
- public HttpResponseMessage GetTodo(int id)
- {
- try
- {
- var currentUser = GetCurrentUser();
- if (currentUser == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "로그인되지 않은 상태입니다."
- });
- }
-
- if (id <= 0)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "유효하지 않은 Todo ID입니다."
- });
- }
-
- string gcode = FCOMMON.info.Login.gcode;
- string uid = FCOMMON.info.Login.no;
-
- var sql = "SELECT * FROM EETGW_Todo WHERE idx = @idx AND gcode = @gcode AND uid = @uid";
- var todo = DBM.QuerySingleOrDefault(sql, new { idx = id, gcode = gcode, uid = uid });
-
- if (todo == null)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일을 찾을 수 없습니다."
- });
- }
-
- return CreateJsonResponse(new
- {
- Success = true,
- Data = todo
- });
- }
- catch (Exception ex)
- {
- return CreateJsonResponse(new
- {
- Success = false,
- Message = "할일 조회 중 오류가 발생했습니다: " + ex.Message
- });
- }
- }
-
- private object GetCurrentUser()
- {
- 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,
- DateFormatString = "yyyy-MM-dd HH:mm:ss"
- });
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(
- json,
- System.Text.Encoding.UTF8,
- "application/json")
- };
- }
- }
-}
diff --git a/Project/Web/Startup.cs b/Project/Web/Startup.cs
index 24c845e..26c3ffe 100644
--- a/Project/Web/Startup.cs
+++ b/Project/Web/Startup.cs
@@ -16,7 +16,44 @@ namespace Project.OWIN
{
public void Configuration(IAppBuilder app)
{
- // Configure Web API for Self-Host
+ app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
+
+ // 정적 파일 서빙을 가장 먼저 설정 (다른 모든 미들웨어보다 우선)
+ var staticFileOptions = new FileServerOptions
+ {
+ EnableDefaultFiles = true,
+ DefaultFilesOptions = { DefaultFileNames = { "index.html" } },
+ FileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("Web/wwwroot"),
+ RequestPath = Microsoft.Owin.PathString.Empty
+ };
+ app.UseFileServer(staticFileOptions);
+
+ // 캐시 방지 미들웨어 (정적 파일이 처리되지 않은 경우에만 적용)
+ app.Use(async (context, next) =>
+ {
+ var path = context.Request.Path.Value;
+
+ if (path.EndsWith(".js") ||
+ path.EndsWith(".css") ||
+ path.EndsWith(".jsx") ||
+ path.EndsWith(".tsx") ||
+ path.EndsWith(".html"))
+ {
+ context.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
+ context.Response.Headers["Pragma"] = "no-cache";
+ context.Response.Headers["Expires"] = "0";
+ }
+
+ // JSX/TSX 파일을 JavaScript로 처리
+ if (path.EndsWith(".jsx") || path.EndsWith(".tsx"))
+ {
+ context.Response.ContentType = "application/javascript";
+ }
+
+ await next();
+ });
+
+ // Configure Web API for Self-Host (정적 파일 후에 설정)
HttpConfiguration config = new HttpConfiguration();
//라우팅 설정
@@ -41,31 +78,8 @@ namespace Project.OWIN
// 파일 업로드 설정
config.Formatters.Remove(config.Formatters.XmlFormatter);
- app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(config);
- // 캐시 방지 미들웨어 추가 (정적 파일 서빙 전에 적용)
- app.Use(async (context, next) =>
- {
- if (context.Request.Path.Value.EndsWith(".js") || context.Request.Path.Value.EndsWith(".css"))
- {
- context.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
- context.Response.Headers["Pragma"] = "no-cache";
- context.Response.Headers["Expires"] = "0";
- }
- await next();
- });
-
- // 정적 파일 서빙 설정
- var options = new FileServerOptions
- {
- EnableDefaultFiles = true,
- DefaultFilesOptions = { DefaultFileNames = { "index.html" } },
- FileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("Web/wwwroot")
- };
-
- app.UseFileServer(options);
-
//appBuilder.UseFileServer(new FileServerOptions
//{
// RequestPath = new PathString(string.Empty),
diff --git a/Project/Web/wwwroot/Common.html b/Project/Web/wwwroot/Common.html
index ea9b45d..f5550aa 100644
--- a/Project/Web/wwwroot/Common.html
+++ b/Project/Web/wwwroot/Common.html
@@ -298,12 +298,11 @@
+
+
+
+