116 lines
3.5 KiB
C#
116 lines
3.5 KiB
C#
using System.Data;
|
|
using System.Data.SqlTypes;
|
|
using KART_API.Utils;
|
|
|
|
namespace KART_API.Services
|
|
{
|
|
public class UserService
|
|
{
|
|
static readonly log4net.ILog logger = log4net.LogManager.GetLogger(typeof(UserService));
|
|
|
|
/// <summary>
|
|
/// Login
|
|
/// </summary>
|
|
/// <param name="userEmail">ID</param>
|
|
/// <param name="userPW">PW</param>
|
|
/// <returns>User 정보</returns>
|
|
public DataTable userLogin(string userEmail, string userPW)
|
|
{
|
|
MSDAL msdal = new MSDAL();
|
|
var connection = msdal.ConnectIntra();
|
|
|
|
string sqlString = " select p_no, p_user_mail as mail, p_name as member_name, p_depart_now + p_team_now as team, '' as member_redirect ";
|
|
sqlString += " , CASE WHEN p_depart_now + p_team_now='M101' AND p_job_now = '02' THEN 1 ELSE 2 END as is_kri ";
|
|
sqlString += " from project2.dbo.V_PERSON ";
|
|
sqlString += " where p_resign = '0' and p_pass_new is not null ";
|
|
sqlString += " and (p_user_mail = '" + userEmail + "' or p_user_mail = '" + userEmail + "@kric.com') and p_pass_new COLLATE Korean_Wansung_CS_AS = '" + userPW + "'";
|
|
|
|
DataTable resultTable = msdal.GetDataTable(sqlString, connection);
|
|
msdal.Disconnect(connection);
|
|
|
|
if (resultTable.Rows.Count < 1)
|
|
{
|
|
connection = msdal.ConnectReport();
|
|
sqlString = " SELECT 99999999 as p_no, member_mail as mail, member_name as member_name, 'CLIENT' as team, member_redirect, is_kri ";
|
|
sqlString += " FROM REPORT_MEMBER ";
|
|
sqlString += " where is_use = 1 and member_mail = '" + userEmail + "' and member_pw = '" + userPW + "' ";
|
|
|
|
resultTable = msdal.GetDataTable(sqlString, connection);
|
|
msdal.Disconnect(connection);
|
|
}
|
|
|
|
return resultTable;
|
|
}
|
|
|
|
public bool isKricSystem(string systemString)
|
|
{
|
|
bool isKricSystem = false;
|
|
|
|
MSDAL dal = new MSDAL();
|
|
var connection = dal.ConnectReport();
|
|
try
|
|
{
|
|
DataTable resultTable = dal.GetDataTable($"SELECT * FROM REPORT_EXTERNAL_SYS WHERE system_key = '{systemString}' and is_use = 1", connection);
|
|
isKricSystem = resultTable.Rows.Count > 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.Fatal(this.GetType().Name + " > " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
dal.Disconnect(connection);
|
|
}
|
|
|
|
return isKricSystem;
|
|
}
|
|
|
|
public static string userNumber(string userEmail)
|
|
{
|
|
string userNumber = "";
|
|
if (Common.IsNumeric(userEmail))
|
|
{
|
|
userNumber = userEmail;
|
|
}
|
|
else
|
|
{
|
|
MSDAL msdal = new MSDAL();
|
|
var connection = msdal.ConnectIntra();
|
|
|
|
string sqlString = " select p_no ";
|
|
sqlString += " from project2.dbo.V_PERSON ";
|
|
sqlString += " where p_resign = '0' and p_pass_new is not null ";
|
|
sqlString += " and (p_user_mail = '" + userEmail + "' or p_user_mail = '" + userEmail + "@kric.com')";
|
|
|
|
DataTable resultTable = msdal.GetDataTable(sqlString, connection);
|
|
msdal.Disconnect(connection);
|
|
|
|
if (resultTable.Rows.Count > 0)
|
|
{
|
|
userNumber = resultTable.Rows[0][0].ToString();
|
|
}
|
|
}
|
|
|
|
return userNumber;
|
|
}
|
|
|
|
public static string getDinIDs()
|
|
{
|
|
string returnString = string.Empty;
|
|
|
|
MSDAL msdal = new MSDAL();
|
|
var connection = msdal.ConnectIntra();
|
|
|
|
DataTable resultTable = msdal.GetDataTable("SELECT STRING_AGG(''''+p_user_mail+'''',',') as DinIDs FROM [project2].[dbo].[person] WHERE p_depart_now='S' and p_team_now in ('101','201')", connection);
|
|
msdal.Disconnect(connection);
|
|
|
|
if(resultTable.Rows.Count > 0)
|
|
{
|
|
returnString = resultTable.Rows[0][0].ToString();
|
|
}
|
|
|
|
return returnString;
|
|
}
|
|
}
|
|
}
|