firts commit

This commit is contained in:
2025-10-24 10:25:29 +09:00
commit ec77d8bc29
49 changed files with 134191 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
using System;
using System.Data;
using System.Linq;
using KART_API.Dto;
using KART_API.Utils;
namespace KART_API.Services
{
public class URIService
{
static readonly log4net.ILog logger = log4net.LogManager.GetLogger(typeof(URIService));
/// <summary>
/// 단축 URL 반환
/// </summary>
/// <param name="realURI">실제 URL</param>
/// <returns>단축 URL</returns>
public static string GetURIKey(string realURI, int mode, string skey, string projectTitle, string okey)
{
string returnString = string.Empty;
MSDAL msdal = new MSDAL();
var connection = msdal.ConnectReport();
try
{
DataTable urlKeyTable = msdal.GetDataTable("select * from REPORT_URL with(nolock) where REAL_URL = '" + realURI + "' and SKEY ='"+ skey + "' and URL_OWNER ='" + okey + "' and IS_PAGE_ONLY="+mode, connection);
if (urlKeyTable.Rows.Count > 0)
{
returnString = urlKeyTable.Rows[0]["URL_KEY"].ToString();
}
else
{
DataTable urlKeysTable = msdal.GetDataTable("select URL_KEY from REPORT_URL with(nolock) ", connection);
string randomString = string.Empty;
do
{
randomString = Common.GetRandomString();
}
while (urlKeysTable.AsEnumerable().Where(dr => dr.Field<string>("URL_KEY") == randomString).ToList().Count > 0);
//while ((from DataRow dr in urlKeysTable.Rows where dr.Field<string>("URL_KEY") == randomString select dr).ToList().Count > 0);
string insertString = "insert into REPORT_URL(URL_KEY, REAL_URL, IS_PAGE_ONLY, SKEY, PROJECT_TITLE, URL_OWNER, LANDING_CNT) values ('" + randomString + "','" + realURI + "'," + mode + ",'" + skey + "','" + projectTitle + "','" + okey + "', 0)";
msdal.ExecuteSQL(insertString, connection);
returnString = randomString;
}
}
catch (Exception ex)
{
logger.Fatal("URI" + " > " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message);
}
finally
{
msdal.Disconnect(connection);
}
return returnString;
}
/// <summary>
/// 실제 URL 반환
/// </summary>
/// <param name="urlKey">단축 URL의 Key값</param>
/// <param name="isCount">카운트 Update 여부</param>
/// <returns>실제 URL</returns>
public static DataTable GetRealURL(string urlKey, bool isCount)
{
DataTable urlTable = new DataTable();
MSDAL msdal = new MSDAL();
var connection = msdal.ConnectReport();
try
{
urlTable = GetUriInfo(urlKey);
if (urlTable.Rows.Count > 0)
{
if (isCount)
{
string insertString = "update a set a.LANDING_CNT = a.LANDING_CNT + 1 from REPORT_URL a where URL_KEY = '" + urlKey + "'";
msdal.ExecuteSQL(insertString, connection);
}
}
}
catch (Exception ex)
{
logger.Fatal("URI" + " > " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message);
}
finally
{
msdal.Disconnect(connection);
}
return urlTable;
}
public static DataTable GetUriInfo(string urlKey)
{
DataTable uriInfo = new DataTable();
MSDAL msdal = new MSDAL();
var connection = msdal.ConnectReport();
try
{
uriInfo = msdal.GetDataTable("SELECT [URL_KEY],[REAL_URL],[IS_PAGE_ONLY],[SKEY], '' as [VER],[PROJECT_TITLE],[URL_OWNER] FROM REPORT_URL WHERE [URL_KEY] collate Korean_Wansung_CS_AS = '" + urlKey + "'", connection);
if (uriInfo.Rows.Count > 0)
{
projectCodeInfo projectCodeInfo = new projectCodeInfo(uriInfo.Rows[0]["SKEY"].ToString());
Common.SetEnableDataTableForEdit(ref uriInfo,0);
uriInfo.Columns["VER"].MaxLength = 50;
uriInfo.Rows[0]["VER"] = projectCodeInfo.ver;
}
}
catch (Exception ex)
{
logger.Fatal("URI" + " > " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message);
}
finally
{
msdal.Disconnect(connection);
}
return uriInfo;
}
}
}