821 lines
37 KiB
C#
821 lines
37 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Runtime.InteropServices;
|
|
|
|
using Cosmos.BaseFrame;
|
|
using Cosmos.UserFrame;
|
|
using Cosmos.ServiceProvider;
|
|
using Cosmos.Common;
|
|
using Cosmos.Service;
|
|
using Cosmos.CommonManager;
|
|
using System.Threading;
|
|
using SPC.Kiosk.Common;
|
|
using SPC.Kiosk.PB.Model;
|
|
|
|
namespace SPC.Kiosk.DataHelper
|
|
{
|
|
public class CommonDataHelper : IDisposable
|
|
{
|
|
#region [ Members ]
|
|
private SManager sManager = null; // 이 객체를 통해 업무 Service 호출
|
|
private StateServer StateObject = null; // StateObject : StateServer Object (객체)
|
|
private PosStatus m_cPosStatus = null; // 기본정보 참조
|
|
private TranStatus m_cTrnStatus = null; // 거래정보 참조
|
|
protected IDataCommonUs m_cDataCommon = null;
|
|
/// <summary>
|
|
/// POS 초기화 필요 유무
|
|
/// </summary>
|
|
public bool NeedInitModule { get; set; }
|
|
#endregion Members
|
|
|
|
#region [ Ctor & Dispose ]
|
|
/// <summary>
|
|
/// Ctor
|
|
/// </summary>
|
|
public CommonDataHelper()
|
|
{
|
|
sManager = new SManager();
|
|
StateObject = (StateServer)StateServer.GetInstance();
|
|
if (!NeedInitModule)
|
|
{
|
|
m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보
|
|
m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보
|
|
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Dispose
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
sManager = null; // 이 객체를 통해 업무 Service 호출
|
|
StateObject = null; // StateObject : StateServer Object (객체)
|
|
m_cPosStatus = null; // 기본정보 참조
|
|
m_cTrnStatus = null; // 거래정보 참조
|
|
m_cDataCommon = null;
|
|
}
|
|
#endregion Ctor & Dispose
|
|
|
|
#region [ Methods ]
|
|
/// <summary>
|
|
/// Set Common Language Data
|
|
/// </summary>
|
|
public void SetCommonLanguage()
|
|
{
|
|
try
|
|
{
|
|
if (NeedInitModule) return;
|
|
var getLanguageData = m_cDataCommon.Select_NHS_LANG_MSG("COMMON");//m_cDataCommon.Select_NHS_LANG_MSG("COMMON");
|
|
if (getLanguageData is DataTable)
|
|
{
|
|
foreach (var aLanguageData in getLanguageData.Rows)
|
|
{
|
|
if (aLanguageData is DataRow aRow)
|
|
{
|
|
var languageCode = aRow["LANG_MESSAGE_CD"] is null ? string.Empty : aRow["LANG_MESSAGE_CD"].ToString();
|
|
var languageType = SupportLanguageType.ko;
|
|
if (!(aRow["LANG_CD"] is null) && aRow["LANG_CD"].ToString().Length > 2)
|
|
{
|
|
try
|
|
{
|
|
languageType = (SupportLanguageType)Enum.Parse(typeof(SupportLanguageType), aRow["LANG_CD"].ToString().Substring(0, 2));
|
|
}
|
|
catch
|
|
{
|
|
|
|
languageType = SupportLanguageType.ko;
|
|
}
|
|
}
|
|
var languageData = aRow["LANG_MESSAGE"] is null ? string.Empty : aRow["LANG_MESSAGE"].ToString();
|
|
Languages.SetMessage(languageCode, languageType, languageData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "SetCommonLanguage()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Get Language Data
|
|
/// _gubunCD
|
|
/// 상품/제품 = "PROD" Item
|
|
/// 카데고리 = "CATE" Category
|
|
/// 옵션 = "OPTN" Option
|
|
/// 옵션그룹 = "OPTNGRP" Option Group
|
|
/// </summary>
|
|
/// <param name="_gubunCD"></param>
|
|
/// <param name="_messageCD"></param>
|
|
/// <returns></returns>
|
|
public List<M_Language> GetLaguageData(string _gubunCD, string _messageCD)
|
|
{
|
|
if (NeedInitModule) return null;
|
|
List<M_Language> result = new List<M_Language>();
|
|
try
|
|
{
|
|
var getLanguageData = m_cDataCommon.Select_NHS_LANG_MSG(_gubunCD, _messageCD);
|
|
if (getLanguageData is DataTable && getLanguageData.Rows.Count > 0)
|
|
{
|
|
foreach (var aLanguageData in getLanguageData.Rows)
|
|
{
|
|
if (aLanguageData is DataRow aRow)
|
|
{
|
|
var languageCode = aRow["LANG_MESSAGE_CD"] is null ? string.Empty : aRow["LANG_MESSAGE_CD"].ToString();
|
|
var languageType = SupportLanguageType.ko;
|
|
if (!(aRow["LANG_CD"] is null) && aRow["LANG_CD"].ToString().Length > 2)
|
|
{
|
|
try
|
|
{
|
|
languageType = (SupportLanguageType)Enum.Parse(typeof(SupportLanguageType), aRow["LANG_CD"].ToString().Substring(0, 2));
|
|
}
|
|
catch
|
|
{
|
|
|
|
languageType = SupportLanguageType.ko;
|
|
}
|
|
}
|
|
var languageData = aRow["LANG_MESSAGE"] is null ? string.Empty : aRow["LANG_MESSAGE"].ToString();
|
|
var dataFinded = result.Where(r => r.Type.Equals(languageType)).FirstOrDefault();
|
|
if (dataFinded is M_Language)
|
|
{
|
|
dataFinded.LanguageData = languageData;
|
|
}
|
|
else
|
|
{
|
|
var addDada = new M_Language
|
|
{
|
|
Type = languageType,
|
|
LanguageData = languageData
|
|
};
|
|
result.Add(addDada);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetLaguageData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = new List<M_Language>();
|
|
}
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// Get Into Data
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<M_IntroItems> GetIntroData(double _screenWidth)
|
|
{
|
|
if (NeedInitModule) return null;
|
|
List<M_IntroItems> result = null;
|
|
try
|
|
{
|
|
|
|
var getIntroItem = m_cDataCommon.Select_NHS_SCREEN();
|
|
if (getIntroItem is DataTable && getIntroItem.Rows.Count > 0)
|
|
{
|
|
result = new List<M_IntroItems>();
|
|
var screenRow = getIntroItem.Rows[0];
|
|
var screenCD = screenRow["SCREEN_CD"] is null ? string.Empty : screenRow["SCREEN_CD"].ToString();
|
|
if (!string.IsNullOrEmpty(screenCD))
|
|
{
|
|
var getFrames = m_cDataCommon.Select_NHS_SCREEN_LAYER_GROUPBY_FRAMECD(screenCD);
|
|
var stackWidth = _screenWidth;
|
|
if (getFrames.Rows.Count.Equals(2)) stackWidth = _screenWidth / 2;
|
|
var stackIndex = 0;
|
|
foreach (var getFramesItem in getFrames.Rows)
|
|
{
|
|
if (getFramesItem is DataRow aFrameRow)
|
|
{
|
|
|
|
var frameCD = aFrameRow["FRAME_CD"] is null ? string.Empty : aFrameRow["FRAME_CD"].ToString();
|
|
if (!string.IsNullOrEmpty(frameCD))
|
|
{
|
|
var getStackContents = GetStackContents(screenCD, frameCD);
|
|
var newIntroItems = new M_IntroItems
|
|
{
|
|
ItemsStack = stackIndex,
|
|
StackWidth = stackWidth,
|
|
StackContents = getStackContents
|
|
};
|
|
result.Add(newIntroItems);
|
|
stackIndex++;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetIntroData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private List<M_StackContents> GetStackContents(string _screenCD, string _frameCD)
|
|
{
|
|
List<M_StackContents> result = null;
|
|
try
|
|
{
|
|
var getScreenLayer = m_cDataCommon.Select_NHS_SCREEN_LAYER(_screenCD, _frameCD);
|
|
if (getScreenLayer is DataTable && getScreenLayer.Rows.Count > 0)
|
|
{
|
|
result = new List<M_StackContents>();
|
|
int setIndex = 0;
|
|
foreach (var aStackItem in getScreenLayer.Rows)
|
|
{
|
|
if (aStackItem is DataRow aRow)
|
|
{
|
|
var layerCD = aRow["LAYER_CD"] is null ? string.Empty : aRow["LAYER_CD"].ToString();
|
|
if (!string.IsNullOrEmpty(layerCD))
|
|
{
|
|
var mediaItems = GetMediaRollItems(_screenCD, _frameCD, layerCD);
|
|
var newStackItems = new M_StackContents
|
|
{
|
|
ItemsIndex = setIndex,
|
|
MediaRollItems = mediaItems,
|
|
};
|
|
result.Add(newStackItems);
|
|
setIndex++;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetStackContents()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private List<M_MediaRollItem> GetMediaRollItems(string _screenCD, string _frameCD, string _layerCD)
|
|
{
|
|
List<M_MediaRollItem> result = null;
|
|
try
|
|
{
|
|
var getScreenContents = m_cDataCommon.Select_NHS_SCREEN_CONTENTS(_screenCD, _frameCD, _layerCD);
|
|
if (getScreenContents is DataTable && getScreenContents.Rows.Count > 0)
|
|
{
|
|
result = new List<M_MediaRollItem>();
|
|
foreach (var aContents in getScreenContents.Rows)
|
|
{
|
|
if (aContents is DataRow aRow)
|
|
{
|
|
var fileType = aRow["FILE_MIME_TYPE"].ToString().Equals("PNG")
|
|
? MediaType.Image
|
|
: aRow["FILE_MIME_TYPE"].ToString().Equals("MP4")
|
|
? MediaType.VOD
|
|
: MediaType.None;
|
|
var linkType = aRow["LINK_YN"].ToString().Equals("1")
|
|
? IntroLinkType.Page
|
|
: aRow["LINK_YN"].ToString().Equals("2")
|
|
? IntroLinkType.Category
|
|
: aRow["LINK_YN"].ToString().Equals("3")
|
|
? IntroLinkType.ItemCode
|
|
: IntroLinkType.None;
|
|
var param1 = aRow["PRD_CATE_L"] is null ? string.Empty : aRow["PRD_CATE_L"].ToString();
|
|
var param2 = aRow["PRD_CATE_M"] is null ? string.Empty : aRow["PRD_CATE_M"].ToString();
|
|
var linkParameter = string.Empty;
|
|
switch (linkType)
|
|
{
|
|
case IntroLinkType.Page:
|
|
switch (param1)
|
|
{
|
|
case "0":
|
|
linkParameter = "FirstSelect";
|
|
break;
|
|
case "1":
|
|
linkParameter = "SensingPage";
|
|
break;
|
|
case "2":
|
|
linkParameter = "ItemPage";
|
|
break;
|
|
default:
|
|
linkParameter = "FirstSelect";
|
|
break;
|
|
}
|
|
break;
|
|
case IntroLinkType.Category:
|
|
linkParameter = string.Format("category&{0}&{1}", param1, param2);
|
|
break;
|
|
case IntroLinkType.ItemCode:
|
|
linkParameter = param1;
|
|
break;
|
|
|
|
}
|
|
var mediaPath = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString();
|
|
var runnigSeconds = aRow["PLAY_TIME"] is null ? 0 : double.Parse(aRow["PLAY_TIME"].ToString());
|
|
var startTime = aRow["DISPLAY_START_TIME"] is null ? string.Empty : aRow["DISPLAY_START_TIME"].ToString();
|
|
var endTime = aRow["DISPLAY_END_TIME"] is null ? string.Empty : aRow["DISPLAY_END_TIME"].ToString();
|
|
if (!startTime.Length.Equals(4)) startTime = string.Empty;
|
|
if (!endTime.Length.Equals(4)) startTime = string.Empty;
|
|
var newMediaItem = new M_MediaRollItem
|
|
{
|
|
Type = fileType,
|
|
MediaPath = ResourceManager.GetCDPimagePath(mediaPath),
|
|
LinkType = linkType,
|
|
LinkParameter = linkParameter,
|
|
RunnigSeconds = runnigSeconds,
|
|
StartTime = startTime.Equals(string.Empty)
|
|
? default(TimeSpan)
|
|
: new TimeSpan(int.Parse(startTime.Substring(0,2)), int.Parse(startTime.Substring(2, 2)), 0),
|
|
EndTime = endTime.Equals(string.Empty)
|
|
? default(TimeSpan)
|
|
: new TimeSpan(int.Parse(endTime.Substring(0, 2)), int.Parse(endTime.Substring(2, 2)), 59)
|
|
|
|
};
|
|
result.Add(newMediaItem);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetMediaRollItems()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Category Data
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<M_CategoryItems> GetCategoryData()
|
|
{
|
|
if (NeedInitModule) return null;
|
|
List<M_CategoryItems> result = null;
|
|
try
|
|
{
|
|
var getCategory1Items = m_cDataCommon.Select_NHS_PRD_CATE("0000");
|
|
if (getCategory1Items is DataTable)
|
|
{
|
|
result = new List<M_CategoryItems>();
|
|
int setIndex = 0;
|
|
foreach (var aCategoryItem in getCategory1Items.Rows)
|
|
{
|
|
if (aCategoryItem is DataRow aRow)
|
|
{
|
|
var category1Code = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString();
|
|
if (!result.Exists(r => r.Catalog1Item.Category1.Equals(category1Code)))
|
|
{
|
|
result.Add
|
|
(
|
|
new M_CategoryItems
|
|
{
|
|
Catalog1Item = new M_ItemData
|
|
{
|
|
Index = setIndex,
|
|
ItemCode = category1Code,
|
|
Category1 = category1Code,
|
|
},
|
|
Catalog2Items = GetCategory2Data(category1Code)
|
|
}
|
|
);
|
|
setIndex++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetCategoryData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// Get Category2 Data
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<M_ItemData> GetCategory2Data(string _category1Code)
|
|
{
|
|
if (NeedInitModule) return new List<M_ItemData>();
|
|
var result = new List<M_ItemData>();
|
|
try
|
|
{
|
|
var getCategory2Item = m_cDataCommon.Select_NHS_PRD_CATE(_category1Code);
|
|
if (getCategory2Item is DataTable)
|
|
{
|
|
int setIndex = 0;
|
|
foreach (var aCategoryItem in getCategory2Item.Rows)
|
|
{
|
|
if (aCategoryItem is DataRow aRow)
|
|
{
|
|
var category2Code = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString();
|
|
if (!result.Exists(r => r.Category2.Equals(category2Code)))
|
|
{
|
|
result.Add
|
|
(
|
|
new M_ItemData
|
|
{
|
|
Index = setIndex,
|
|
ItemCode = category2Code,
|
|
Category1 = _category1Code,
|
|
Category2 = category2Code,
|
|
}
|
|
);
|
|
setIndex++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetCategory2Data()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = new List<M_ItemData>();
|
|
}
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// Get Item Data
|
|
/// </summary>
|
|
/// <param name="_categoryItems"></param>
|
|
/// <returns></returns>
|
|
public List<M_ItemData> GetItemsData(string _itemcode = null, string _barcord = null)
|
|
{
|
|
if (NeedInitModule) return new List<M_ItemData>();
|
|
var result = new List<M_ItemData>();
|
|
try
|
|
{
|
|
var getItems = m_cDataCommon.Select_NHS_STOR_PRD_KEY(_itemcode, _barcord);
|
|
if (getItems is DataTable)
|
|
{
|
|
int setIndex = 0;
|
|
foreach (var aItem in getItems.Rows)
|
|
{
|
|
if (aItem is DataRow aRow)
|
|
{
|
|
var itemCode = aRow["ITEM_CD"] is null ? string.Empty : aRow["ITEM_CD"].ToString();
|
|
if (!result.Exists(r => r.ItemCode.Equals(itemCode)))
|
|
{
|
|
var category1 = aRow["PRD_CATE_UP_CD"] is null ? string.Empty : aRow["PRD_CATE_UP_CD"].ToString();
|
|
var category2 = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString();
|
|
var imageFile = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString();
|
|
var isOption = aRow["OPTN_YN"] is null ? false : aRow["OPTN_YN"].ToString().Equals("1");
|
|
var isSoldOut = aRow["SOLDOUT_YN"] is null ? false : aRow["SOLDOUT_YN"].ToString().Equals("1");
|
|
var itemPrice = aRow["SALES_PRC"] is null ? 0d : double.Parse(aRow["SALES_PRC"].ToString());
|
|
var option = isOption ? GetItemOption(itemCode) : null;
|
|
var badgeImages = GetBadgeImages(itemCode);
|
|
result.Add
|
|
(
|
|
new M_ItemData
|
|
{
|
|
Index = setIndex,
|
|
ItemCode = itemCode,
|
|
Category1 = category1,
|
|
Category2 = category2,
|
|
ImageFile = imageFile,
|
|
BadgeImages = badgeImages,
|
|
IsOption = isOption,
|
|
IsSoldOut = isSoldOut,
|
|
Price = itemPrice,
|
|
Option = option
|
|
}
|
|
);
|
|
setIndex++;
|
|
}
|
|
else
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetItemsData()", "Duplicate Item No", string.Format("{0} : {1}", itemCode, aRow["TOUCH_KEY_NM"].rDBToString()));
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetItemsData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = new List<M_ItemData>();
|
|
}
|
|
return result;
|
|
}
|
|
public M_ItemData GetBarcordItemsData(string _itemcode = null, string _barcord = null)
|
|
{
|
|
if (NeedInitModule) return null;
|
|
var result = new M_ItemData();
|
|
try
|
|
{
|
|
var getItems = m_cDataCommon.Select_NHS_PRD_MST(_barcord,_itemcode);
|
|
if (getItems is DataTable && getItems.Rows.Count > 0)
|
|
{
|
|
if (getItems.Rows[0] is DataRow aRow)
|
|
{
|
|
var itemCode = aRow["ITEM_CD"] is null ? string.Empty : aRow["ITEM_CD"].ToString();
|
|
var category2 = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString();
|
|
var imageFile = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString();
|
|
var itemPrice = aRow["TAKE_OUT_SALE_AMT"] is null ? 0d : double.Parse(aRow["TAKE_OUT_SALE_AMT"].ToString());
|
|
result = new M_ItemData
|
|
{
|
|
ItemCode = itemCode,
|
|
Category2 = category2,
|
|
ImageFile = imageFile,
|
|
Price = itemPrice,
|
|
};
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
result = null;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetBarcordItemsData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
private List<string> GetBadgeImages(string _itemCode)
|
|
{
|
|
List<string> result = null;
|
|
try
|
|
{
|
|
var getBadgeImages = m_cDataCommon.Select_NHS_STOR_PRD_TAG(_itemCode);
|
|
if (getBadgeImages is DataTable && getBadgeImages.Rows.Count > 0)
|
|
{
|
|
result = new List<string>();
|
|
|
|
int setIndex = 0;
|
|
foreach (var aItem in getBadgeImages.Rows)
|
|
{
|
|
if (aItem is DataRow aRow)
|
|
{
|
|
var badgeImage = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString();
|
|
if (!string.IsNullOrEmpty(badgeImage))
|
|
{
|
|
result.Add(badgeImage);
|
|
setIndex++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetBadgeImages()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Option Data
|
|
/// </summary>
|
|
/// <param name="_itemCode"></param>
|
|
/// <returns></returns>
|
|
public List<M_ItemOptionGroup> GetItemOption(string _itemCode)
|
|
{
|
|
if (NeedInitModule) return null;
|
|
List<M_ItemOptionGroup> result = null;
|
|
try
|
|
{
|
|
var getOptionGroup = m_cDataCommon.Select_NHS_PRD_OPTN(_itemCode);
|
|
if (getOptionGroup is DataTable && getOptionGroup.Rows.Count > 0 )
|
|
{
|
|
result = new List<M_ItemOptionGroup>();
|
|
|
|
int setIndex = 0;
|
|
foreach (var aItem in getOptionGroup.Rows)
|
|
{
|
|
if (aItem is DataRow aRow)
|
|
{
|
|
try
|
|
{
|
|
var optionGroupCode = aRow["ITEM_OPTN_GRP_CD"] is null ? string.Empty : aRow["ITEM_OPTN_GRP_CD"].ToString();
|
|
|
|
if (!result.Exists(r => r.Code.Equals(optionGroupCode)))
|
|
{
|
|
var getOptionGroupItem = m_cDataCommon.Select_NHS_PRD_OPTN_GRP(optionGroupCode);
|
|
if (getOptionGroupItem is DataTable && getOptionGroupItem.Rows.Count.Equals(1))
|
|
{
|
|
var optionGroupItem = getOptionGroupItem.Rows[0];
|
|
var selectMode = optionGroupItem["SEL_MTD"].ToString().Equals("S")
|
|
? OptionSelectMode.Single
|
|
: optionGroupItem["SEL_MTD"].ToString().Equals("M")
|
|
? OptionSelectMode.Multi
|
|
: OptionSelectMode.None;
|
|
var imageFile = optionGroupItem["FILE_NAME"] is null ? string.Empty : optionGroupItem["FILE_NAME"].ToString();
|
|
var isMustSelect = optionGroupItem["RQRD_YN"] is null ? false : optionGroupItem["RQRD_YN"].ToString().Equals("1");
|
|
result.Add
|
|
(
|
|
new M_ItemOptionGroup
|
|
{
|
|
Index = setIndex,
|
|
Code = optionGroupCode,
|
|
ImageFile = imageFile,
|
|
SelectMode = selectMode,
|
|
IsMustSelect = isMustSelect,
|
|
Name = GetLaguageData("OPTNGRP", optionGroupCode),
|
|
Options = GetOptions(optionGroupCode),
|
|
}
|
|
);
|
|
setIndex++;
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetItemOption()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// Get Option Group Data With Options Data
|
|
/// </summary>
|
|
/// <param name="_optionGroupCode"></param>
|
|
/// <returns></returns>
|
|
public List<M_ItemOption> GetOptions(string _optionGroupCode)
|
|
{
|
|
if (NeedInitModule) return null;
|
|
List<M_ItemOption> result = null;
|
|
try
|
|
{
|
|
var getOption = m_cDataCommon.Select_NHS_OPTN_MST(_optionGroupCode);
|
|
if (getOption is DataTable && getOption.Rows.Count > 0)
|
|
{
|
|
result = new List<M_ItemOption>();
|
|
int setIndex = 0;
|
|
foreach (var aItem in getOption.Rows)
|
|
{
|
|
if (aItem is DataRow aRow)
|
|
{
|
|
try
|
|
{
|
|
var optionCode = aRow["ITEM_OPTN_CD"] is null ? string.Empty : aRow["ITEM_OPTN_CD"].ToString();
|
|
if (!result.Exists(r => r.Code.Equals(optionCode)))
|
|
{
|
|
var kind = aRow["KIND"].ToString().Equals("DIS")
|
|
? OptionKind.Discount
|
|
: aRow["KIND"].ToString().Equals("BTN")
|
|
? OptionKind.Button
|
|
: aRow["KIND"].ToString().Equals("UPC")
|
|
? OptionKind.UpCharge
|
|
: aRow["KIND"].ToString().Equals("CNT")
|
|
? OptionKind.Count
|
|
: OptionKind.None;
|
|
var kindCode = aRow["KIND_CODE"] is null ? string.Empty : aRow["KIND_CODE"].ToString();
|
|
var amountMin = aRow["MIN_AMT"] is null ? 0 : int.Parse(aRow["MIN_AMT"].ToString());
|
|
var amountMax = aRow["MAX_AMT"] is null ? 0 : int.Parse(aRow["MAX_AMT"].ToString());
|
|
var amount = aRow["AMT"] is null ? 0d : double.Parse(aRow["AMT"].ToString());
|
|
result.Add
|
|
(
|
|
new M_ItemOption
|
|
{
|
|
Index = setIndex,
|
|
Code = optionCode,
|
|
Name = GetLaguageData("OPTN", optionCode),
|
|
SelectValue = 0d,
|
|
Kind = kind,
|
|
KindCode = kindCode,
|
|
Amount = amount,
|
|
AmountMin = amountMin,
|
|
AmountMax = amountMax
|
|
}
|
|
);
|
|
setIndex++;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetOptions()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
result = null;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Kiosk 에서 사용가능한 결재수단 사용여부를 조회 : 2019-06-10 - 1997fx11
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Dictionary<string, string> GetNhsFuncInfo()
|
|
{
|
|
var nhsFuncInfoType = new NhsFuncInfoType();
|
|
var dictionaryNhsFuncInfo = new Dictionary<string, string>();
|
|
|
|
try
|
|
{
|
|
var dt = m_cDataCommon.Select_NHS_FUNC_INFO();
|
|
|
|
if (dt != null)
|
|
{
|
|
//전체 const로 잡힌 필드를 돌며 DB에서 받아온 Key와 매칭
|
|
foreach (var item in nhsFuncInfoType.GetType().GetFields())
|
|
{
|
|
//DataTable에서 키와 일치하는 값을 찾아냄
|
|
var rowData = dt.Select($"FUNC_CD = {item.GetValue(item.Name)}").FirstOrDefault();
|
|
if (rowData != null)
|
|
{
|
|
//Dictionary에 키와 Use_Yn값을 추가
|
|
dictionaryNhsFuncInfo.Add(item.GetValue(item.Name)?.ToString(), rowData["USE_YN"]?.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetNhsFuncInfo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
}
|
|
|
|
return dictionaryNhsFuncInfo;
|
|
}
|
|
#endregion Methods
|
|
|
|
|
|
#region MyRegion
|
|
/// <summary>
|
|
/// 2019-03-19 - 1997fx11 : 구매고객 이력 호출
|
|
/// </summary>
|
|
/// <param name="_custCd"></param>
|
|
/// <returns></returns>
|
|
public string[] GetCustBuyHistory(string _custCd)
|
|
{
|
|
string[] aList = null;
|
|
string sToday = string.Empty;
|
|
|
|
try
|
|
{
|
|
var custNo = _custCd.Length >= 10 ? _custCd.Substring(0, 10) : string.Empty;
|
|
sToday = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
|
|
|
|
aList = string.IsNullOrEmpty(custNo) ? null : m_cDataCommon.Select_NHS_CUST_BUY_HIST(sToday, _custCd);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "GetCustBuyHistory()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
aList = null;
|
|
}
|
|
|
|
return aList;
|
|
}
|
|
//public int GetNewProduct(string _updateDate = )
|
|
//{
|
|
// int iRet = 0;
|
|
|
|
// try
|
|
// {
|
|
// iRet = m_cDataCommon.Get_NEW_PRODUCT_BY_IRT(_updateDate);
|
|
// }
|
|
// catch
|
|
// {
|
|
// iRet = -1;
|
|
// }
|
|
|
|
// return iRet;
|
|
//}
|
|
|
|
/// <summary>
|
|
/// 2019-05-30 - 1997fx11 : 알림톡 전송
|
|
/// </summary>
|
|
/// <param name="sPhoneNo"></param>
|
|
/// <param name="skorItemName"></param>
|
|
/// <param name="itemCount"></param>
|
|
public void Send_NoticeTalk(string sPhoneNo, string korItemName, string itemCount)
|
|
{
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(m_cPosStatus.Base.LastRcptBarcodeData))
|
|
{
|
|
var result = m_cDataCommon.Send_NoticeTalk(sPhoneNo, korItemName, itemCount);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonLog.ErrorLogWrite(this, "Send_NoticeTalk()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |