spc-kiosk-pb/Kiosk/Popup/SPC.Kiosk.Popup.Model/Functions.cs

166 lines
5.5 KiB
C#
Raw Normal View History

2019-06-16 05:12:09 +00:00

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using SPC.Kiosk.Common;
namespace SPC.Kiosk.Popup.Model
{
/// <summary>
/// Popup 사용 공통 기능
/// </summary>
public static class Functions
{
/// <summary>
/// Name with Encript Character
/// </summary>
/// <param name="_name"></param>
/// <returns></returns>
public static string GetEncriptName(this string _name)
{
string result = _name;
try
{
switch (_name.Length)
{
case 1:
result = _name;
break;
case 2:
result = _name.Substring(0, 1) + "*";
break;
case 3:
result = _name.Substring(0, 1) + "*" + _name.Substring(2, 1);
break;
case 4:
result = _name.Substring(0, 1) + "*" + _name.Substring(2, 2);
break;
case 5:
result = _name.Substring(0, 1) + "**" + _name.Substring(3, 2);
break;
default:
var names = _name.Trim().Replace(" ", " ").Split(' ');
int i = 0;
result = string.Empty;
foreach (var aName in names)
{
if (i.Equals(1))
{
result += string.Empty.PadRight(aName.Length, '*');
}
else
{
result += aName;
}
i++;
}
break;
}
}
catch
{
result = _name;
}
return result;
}
/// <summary>
/// Card Number With Encript Character
/// </summary>
/// <param name="_cardNo"></param>
/// <returns></returns>
public static string GetEncriptCardNo(this string _cardNo)
{
string result = _cardNo;
try
{
switch (_cardNo.Length)
{
case 14:
result = string.Format("{0}-{1}{2}-{3}-{4}"
, _cardNo.Substring(0, 4)
, _cardNo.Substring(4, 2)
, "**"
, "****"
, "**");
break;
case 15:
result = string.Format("{0}-{1}{2}-{3}-{4}{5}"
, _cardNo.Substring(0, 4)
, _cardNo.Substring(4, 2)
, "**"
, "****"
, "**"
, _cardNo.Substring(14, 1));
break;
case 16:
result = string.Format("{0}-{1}{2}-{3}-{4}{5}"
, _cardNo.Substring(0, 4)
, _cardNo.Substring(4, 2)
, "**"
, "****"
, "**"
, _cardNo.Substring(14, 2));
break;
}
}
catch
{
result = _cardNo;
}
return result;
}
/// <summary>
/// Get Mobile Company Name by Type
/// </summary>
/// <param name="_companyType"></param>
/// <returns></returns>
public static List<M_Language> GetMobileCompanyName(this MobileCompanyType _companyType)
{
List<M_Language> result = null;
try
{
switch (_companyType)
{
case MobileCompanyType.KT_Mobile:
result = new List<M_Language>
{
new M_Language
{
Type=SupportLanguageType.ko,
LanguageData = "KT"
}
};
break;
case MobileCompanyType.SK_Telecom:
result = new List<M_Language>
{
new M_Language
{
Type=SupportLanguageType.ko,
LanguageData = "SK Telecom"
}
};
break;
case MobileCompanyType.LG_Uplus:
result = new List<M_Language>
{
new M_Language
{
Type=SupportLanguageType.ko,
LanguageData = "LG U+"
},
};
break;
}
}
catch
{
result = null;
}
return result;
}
}
}