Browse Source

[WHAT] 展覽查詢優化,增加註解

Dev
berlin-tzen 2 years ago
parent
commit
486cdc1728
  1. 450
      EuroTran/EasyBL.WEBAPP/ShowEasy/ExhibMaintain_QryService.cs
  2. 24
      EuroTran/EasyBL.WEBAPP/ShowEasy/ExhibitionService.cs

450
EuroTran/EasyBL.WEBAPP/ShowEasy/ExhibMaintain_QryService.cs

@ -461,12 +461,13 @@ namespace EasyBL.WEBAPP.SYS
var sLanguageID = _fetchString(i_crm, @"LanguageID"); var sLanguageID = _fetchString(i_crm, @"LanguageID");
if (string.IsNullOrEmpty(sLanguageID)) {
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE; sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
} }
saShowStatus = am_qry.FindAllByIDsAsDictionary(sLanguageID, i_crm.ORIGID, sArgumentClassID).Values.ToList(); saShowStatus = am_qry.FindAllByIDsAsDictionary(sLanguageID, i_crm.ORIGID, sArgumentClassID).Values.ToList();
rm = new SuccessResponseMessage(null, i_crm); rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saShowStatus); rm.DATA.Add(BLWording.REL, saShowStatus);
} while (false); } while (false);
@ -497,11 +498,13 @@ namespace EasyBL.WEBAPP.SYS
/// </summary> /// </summary>
/// <param name="i_crm"></param> /// <param name="i_crm"></param>
/// <returns></returns> /// <returns></returns>
public Dictionary<string, StatusDTO> QueryShowStatusDic(string sLanguageID) {
public Dictionary<string, StatusDTO> QueryShowStatusDic(string sLanguageID)
{
Dictionary<string, StatusDTO> rsResult = new Dictionary<string, StatusDTO>(); Dictionary<string, StatusDTO> rsResult = new Dictionary<string, StatusDTO>();
if (string.IsNullOrEmpty(sLanguageID)) {
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE; sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
} }
@ -510,9 +513,11 @@ namespace EasyBL.WEBAPP.SYS
var rsExhibitionStatusList = QueryAllDetailExhibitionAsDictionary(sLanguageID).Values.ToList().Where(w => !string.IsNullOrEmpty(w.Status)).Select(s => s.Status); var rsExhibitionStatusList = QueryAllDetailExhibitionAsDictionary(sLanguageID).Values.ToList().Where(w => !string.IsNullOrEmpty(w.Status)).Select(s => s.Status);
foreach (var sStatus in rsExhibitionStatusList) {
foreach (var sStatus in rsExhibitionStatusList)
{
if (StatusDic.ContainsKey(sStatus)) {
if (StatusDic.ContainsKey(sStatus))
{
StatusDTO rsStatus = new StatusDTO(); StatusDTO rsStatus = new StatusDTO();
rsStatus.Key = sStatus; rsStatus.Key = sStatus;
@ -525,7 +530,7 @@ namespace EasyBL.WEBAPP.SYS
} }
return rsResult; return rsResult;
} }
#endregion 展覽管理(Dictionary 查詢展覽狀態) #endregion 展覽管理(Dictionary 查詢展覽狀態)
@ -555,13 +560,23 @@ namespace EasyBL.WEBAPP.SYS
var sArgumentClassID = "Frequency"; var sArgumentClassID = "Frequency";
saFrequency = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
.Where(t1 => t1.ArgumentClassID == sArgumentClassID)
.ToList();
var sLanguageID = _fetchString(i_crm, @"LanguageID");
if (string.IsNullOrEmpty(sLanguageID)) {
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
var sOrgID = i_crm.ORIGID;
if (string.IsNullOrEmpty(sOrgID)) {
sOrgID = WebAppGlobalConstWord.TG_ORGID;
}
saFrequency = am_qry.FindAllByIDsAsDictionary(sLanguageID, sOrgID, sArgumentClassID).Values.ToList();
rm = new SuccessResponseMessage(null, i_crm); rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saFrequency); rm.DATA.Add(BLWording.REL, saFrequency);
} while (false); } while (false);
} }
catch (Exception ex) catch (Exception ex)
@ -583,7 +598,10 @@ namespace EasyBL.WEBAPP.SYS
#endregion 展覽管理(List 查詢展覽週期選單) #endregion 展覽管理(List 查詢展覽週期選單)
public List<CategoryDicDTO> QueryCategoryFilterList(string sLanguageID) {
#region 展覽管理(List 查詢展覽階層類別)
public List<CategoryDicDTO> QueryCategoryFilterList(string sLanguageID)
{
string sMsg = null; string sMsg = null;
@ -606,17 +624,20 @@ namespace EasyBL.WEBAPP.SYS
var rsCategoryDic = cm_qry.FindAllByIDsAsDictionary(sCategoryType, sLanguageID); var rsCategoryDic = cm_qry.FindAllByIDsAsDictionary(sCategoryType, sLanguageID);
foreach (var Exhibition in rsExhibitionList) {
foreach (var Exhibition in rsExhibitionList)
{
// MainCategory // MainCategory
var sMainCategoryIDs = Exhibition.MainCategoryIDs; var sMainCategoryIDs = Exhibition.MainCategoryIDs;
var MainCategoryIDList = new List<string>(); var MainCategoryIDList = new List<string>();
if (!string.IsNullOrEmpty(sMainCategoryIDs)) {
if (!string.IsNullOrEmpty(sMainCategoryIDs))
{
MainCategoryIDList = JsonConvert.DeserializeObject<List<string>>(sMainCategoryIDs); MainCategoryIDList = JsonConvert.DeserializeObject<List<string>>(sMainCategoryIDs);
} }
foreach (var sMainCategoryID in MainCategoryIDList) {
foreach (var sMainCategoryID in MainCategoryIDList)
{
var rsCategory = rsCategoryDic[sMainCategoryID]; var rsCategory = rsCategoryDic[sMainCategoryID];
CategoryDicDTO MainCategory = new CategoryDicDTO(); CategoryDicDTO MainCategory = new CategoryDicDTO();
@ -634,21 +655,26 @@ namespace EasyBL.WEBAPP.SYS
SubCategoryIDList = JsonConvert.DeserializeObject<List<string>>(sSubCategoryIDs); SubCategoryIDList = JsonConvert.DeserializeObject<List<string>>(sSubCategoryIDs);
} }
foreach (var SubCategoryID in SubCategoryIDList) {
foreach (var SubCategoryID in SubCategoryIDList)
{
var rsCategory = rsCategoryDic[SubCategoryID]; var rsCategory = rsCategoryDic[SubCategoryID];
var ParentIDList = new List<string>(); var ParentIDList = new List<string>();
if (rsCategory != null) {
if (rsCategory != null)
{
if (!string.IsNullOrEmpty(rsCategory.ParentIDs)) {
if (!string.IsNullOrEmpty(rsCategory.ParentIDs))
{
ParentIDList = JsonConvert.DeserializeObject<List<string>>(rsCategory.ParentIDs); ParentIDList = JsonConvert.DeserializeObject<List<string>>(rsCategory.ParentIDs);
foreach (var ParentID in ParentIDList) {
foreach (var ParentID in ParentIDList)
{
if (rsResult.ContainsKey(ParentID)) {
if (rsResult.ContainsKey(ParentID))
{
CategoryDTO SubCategory = new CategoryDTO(); CategoryDTO SubCategory = new CategoryDTO();
SubCategory.CategoryID = rsCategory.CategoryID; SubCategory.CategoryID = rsCategory.CategoryID;
@ -657,11 +683,11 @@ namespace EasyBL.WEBAPP.SYS
rsResult[ParentID].SubCategoryDic[SubCategory.CategoryID] = SubCategory; rsResult[ParentID].SubCategoryDic[SubCategory.CategoryID] = SubCategory;
} }
} }
} }
} }
} }
@ -669,7 +695,8 @@ namespace EasyBL.WEBAPP.SYS
} }
// Categories to list // Categories to list
foreach (KeyValuePair<string, CategoryDicDTO> MainCategory in rsResult) {
foreach (KeyValuePair<string, CategoryDicDTO> MainCategory in rsResult)
{
var MainCategoryID = MainCategory.Key; var MainCategoryID = MainCategory.Key;
rsResult[MainCategoryID].SubCategoryList = rsResult[MainCategoryID].SubCategoryDic.Values.ToList(); rsResult[MainCategoryID].SubCategoryList = rsResult[MainCategoryID].SubCategoryDic.Values.ToList();
@ -682,16 +709,17 @@ namespace EasyBL.WEBAPP.SYS
{ {
sMsg = Util.GetLastExceptionMsg(ex); sMsg = Util.GetLastExceptionMsg(ex);
} }
finally
{
}
return rsResult.Values.ToList(); return rsResult.Values.ToList();
} }
public Dictionary<string, View_CMS_Exhibition> FindAllByIDsAsDictionary(string sLanguageID) {
#endregion 展覽管理(List 查詢展覽階層類別)
#region 展覽管理(Dictionary 以ID查詢所有展覽)
public Dictionary<string, View_CMS_Exhibition> FindAllByIDsAsDictionary(string sLanguageID)
{
var db = SugarBase.GetIntance(); var db = SugarBase.GetIntance();
string sMsg = null; string sMsg = null;
@ -719,7 +747,8 @@ namespace EasyBL.WEBAPP.SYS
}) })
.ToList(); .ToList();
foreach (var Exhibition in saDataList) {
foreach (var Exhibition in saDataList)
{
saDataDict[Exhibition.ExhibitionID] = Exhibition; saDataDict[Exhibition.ExhibitionID] = Exhibition;
} }
@ -734,15 +763,21 @@ namespace EasyBL.WEBAPP.SYS
return saDataDict; return saDataDict;
} }
#endregion 展覽管理(Dictionary 以ID查詢所有展覽)
#region 展覽管理(List 查詢所有展覽列表卡片)
public List<ExhibitionCardDTO> QueryExhibitionCard( public List<ExhibitionCardDTO> QueryExhibitionCard(
string sLanguageID,
string sLanguageID,
List<string> RegionIDs, List<string> RegionIDs,
List<string> CountryIDs, List<string> CountryIDs,
List<string> CityIDs, List<string> CityIDs,
List<string> MainCategoryIDs, List<string> MainCategoryIDs,
List<string> SubCategoryIDs, List<string> SubCategoryIDs,
List<string> Status, List<string> Status,
List<string> sDate) {
List<string> sDate,
string sSortType)
{
List<ExhibitionCardDTO> rsResult = new List<ExhibitionCardDTO>(); List<ExhibitionCardDTO> rsResult = new List<ExhibitionCardDTO>();
@ -753,11 +788,12 @@ namespace EasyBL.WEBAPP.SYS
{ {
do do
{ {
if (string.IsNullOrEmpty(sLanguageID)) {
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE; sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
} }
var rsExhibitionList = FindAllByIDsAsDictionary(sLanguageID).Values.ToList();
var rsExhibitionList = QueryAllDetailExhibitionAsDictionary(sLanguageID).Values.ToList();
if (MainCategoryIDs.Count > 0) if (MainCategoryIDs.Count > 0)
{ {
@ -769,183 +805,94 @@ namespace EasyBL.WEBAPP.SYS
rsExhibitionList = FilterBySubCategoryIDs(rsExhibitionList, SubCategoryIDs); rsExhibitionList = FilterBySubCategoryIDs(rsExhibitionList, SubCategoryIDs);
} }
var Cards = rsExhibitionList
.Select(t1 => new ExhibitionCardDTO
{
ExhibitionID = t1.ExhibitionID,
IsRecommend = t1.IsRecommend,
Logo = t1.Logo,
AbbreviatedName = t1.AbbreviatedName,
ExhibitionName = t1.ExhibitionName,
})
.ToList();
var CardDic = new Dictionary<string, ExhibitionCardDTO>();
foreach (var Card in Cards) {
CardDic[Card.ExhibitionID] = Card;
}
CardDic = SetCardCategory(CardDic, rsExhibitionList, sLanguageID);
CardDic = SetCardInfo(CardDic, rsExhibitionList, sLanguageID);
if (Status.Count > 0) if (Status.Count > 0)
{ {
CardDic = FilterByStatus(CardDic, Status);
rsExhibitionList = FilterByStatus(rsExhibitionList, Status);
} }
if (RegionIDs.Count > 0 || CountryIDs.Count > 0 || CityIDs.Count > 0) if (RegionIDs.Count > 0 || CountryIDs.Count > 0 || CityIDs.Count > 0)
{ {
CardDic = FilterByLocationIDs(CardDic, RegionIDs, CountryIDs, CityIDs);
rsExhibitionList = FilterByLocationIDs(rsExhibitionList, RegionIDs, CountryIDs, CityIDs);
} }
if (sDate.Count > 0) if (sDate.Count > 0)
{ {
CardDic = FilterByDate(CardDic, sDate);
rsExhibitionList = FilterByDate(rsExhibitionList, sDate);
} }
rsResult = CardDic.Values.ToList();
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
}
finally
{
}
return rsResult;
}
public Dictionary<string, ExhibitionCardDTO> SetCardCategory(Dictionary<string, ExhibitionCardDTO> Cards, List<View_CMS_Exhibition> ExhibitionList, string sLanguageID) {
ExhibMainCategoryMaintain_QryService emcm_qry = new ExhibMainCategoryMaintain_QryService();
ExhibSubCategoryMaintain_QryService escm_qry = new ExhibSubCategoryMaintain_QryService();
var MainCategoryDic = emcm_qry.QueryExhibMainCategoryAsDictionary(sLanguageID);
var SubCategoryDic = escm_qry.QueryExhibSubCategoryAsDictionary(sLanguageID);
var Cards = rsExhibitionList
.Select(t1 => new ExhibitionCardDTO
{
foreach (var Exhibition in ExhibitionList) {
ExhibitionID = t1.ExhibitionID,
AbbreviatedName = t1.AbbreviatedName,
ExhibitionName = t1.ExhibitionName,
MainCategoryList = t1.MainCategories,
SubCategoryList = t1.SubCategories,
Logo = t1.Logo,
if (!string.IsNullOrEmpty(Exhibition.MainCategoryIDs)) {
StartDate = t1.StartDate,
EndDate = t1.EndDate,
ExhibStatus = t1.Status,
Intro = t1.Intro,
IsRecommend = t1.IsRecommend,
ExhibitorCount = t1.ExhibitorCount,
VisitorCount = t1.VisitorCount
var rsMainCategoryIDs = JsonConvert.DeserializeObject<List<string>>(Exhibition.MainCategoryIDs);
})
.ToList();
foreach (var MainCategoryID in rsMainCategoryIDs) {
if (!string.IsNullOrEmpty(sSortType))
{
if (MainCategoryDic[MainCategoryID] != null) {
Cards[Exhibition.ExhibitionID].MainCategoryList.Add(MainCategoryDic[MainCategoryID]);
if (sSortType == "Recommended")
{
Cards = Cards.OrderByDescending(o => o.IsRecommend).ToList();
} }
}
}
if (!string.IsNullOrEmpty(Exhibition.SubCategoryIDs))
{
var rsSubCategoryIDs = JsonConvert.DeserializeObject<List<string>>(Exhibition.SubCategoryIDs);
if (sSortType == "ShowDate")
{
Cards = Cards.OrderByDescending(o => o.StartDate.ToString()).ToList();
}
foreach (var SubCategoryID in rsSubCategoryIDs)
{
if (sSortType == "ExhibitorCount")
{
Cards = Cards.OrderByDescending(o => o.ExhibitorCount).ToList();
}
if (SubCategoryDic[SubCategoryID] != null)
if (sSortType == "VisitorCount")
{ {
Cards[Exhibition.ExhibitionID].SubCategoryList.Add(SubCategoryDic[SubCategoryID]);
Cards = Cards.OrderByDescending(o => o.VisitorCount).ToList();
} }
} }
}
return Cards;
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
} }
return Cards;
return rsResult;
} }
public Dictionary<string, ExhibitionCardDTO> SetCardInfo(Dictionary<string, ExhibitionCardDTO> Cards, List<View_CMS_Exhibition> ExhibitionList, string sLanguageID) {
ExhibInfoMaintain_QryService eim_qry = new ExhibInfoMaintain_QryService();
FileMaintain_QryService fm_qry = new FileMaintain_QryService();
ExhibStatMaintain_QryService esm_qry = new ExhibStatMaintain_QryService();
var rsInfoLocationDic = eim_qry.FindAllLocationByIDsAsDictionary(sLanguageID, "", "");
foreach (var Exhibition in ExhibitionList) {
var Info = eim_qry.FindAllByIDsAsDictionary(sLanguageID, Exhibition.ExhibitionID).Values.FirstOrDefault();
#endregion 展覽管理(List 查詢所有展覽列表卡片)
var LogoFile = fm_qry.FindAllByIDsAsDictionary(Exhibition.Logo).Values.FirstOrDefault();
Cards[Exhibition.ExhibitionID].Logo = "";
if (LogoFile != null) {
var Server = Common.ConfigGetValue("", "ida:RedirectUri");
Cards[Exhibition.ExhibitionID].Logo = Server +"/"+ LogoFile.FilePath.Replace("\\", "/");
}
#region 展覽管理(List 以主類別過濾)
if (Info != null) {
var Stat = esm_qry.FindAllByIDsAsDictionary(Exhibition.ExhibitionID, Info.Year).Values.FirstOrDefault();
Cards[Exhibition.ExhibitionID].ExhibStatus = Info.Status;
Cards[Exhibition.ExhibitionID].Intro = Info.Intro;
Cards[Exhibition.ExhibitionID].StartDate = Info.StartDate;
Cards[Exhibition.ExhibitionID].EndDate = Info.EndDate;
Cards[Exhibition.ExhibitionID].IsFavorite = "";
Cards[Exhibition.ExhibitionID].ExhibitorCount = 0;
Cards[Exhibition.ExhibitionID].VisitorCount = 0;
if (Stat != null) {
Cards[Exhibition.ExhibitionID].ExhibitorCount = Stat.ExhibitorCount;
Cards[Exhibition.ExhibitionID].VisitorCount = Stat.VisitorCount;
}
LocationDTO Location = new LocationDTO();
if (rsInfoLocationDic.ContainsKey(Info.ExhibitionInfoID)) {
Location = rsInfoLocationDic[Info.ExhibitionInfoID];
}
Cards[Exhibition.ExhibitionID].RegionID = Location.Region.RegionID;
Cards[Exhibition.ExhibitionID].RegionName = Location.Region.RegionName;
Cards[Exhibition.ExhibitionID].CountryID = Location.Country.CountryID;
Cards[Exhibition.ExhibitionID].CountryName = Location.Country.CountryName;
Cards[Exhibition.ExhibitionID].CityID = Location.City.CityID;
Cards[Exhibition.ExhibitionID].CityName = Location.City.CityName;
}
}
return Cards;
}
public List<View_CMS_Exhibition> FilterByMainCategoryIDs(List<View_CMS_Exhibition> ExhibitionList, List<string> MainCategoryIDs)
public List<ExhibitionDTO> FilterByMainCategoryIDs(List<ExhibitionDTO> ExhibitionList, List<string> MainCategoryIDs)
{ {
var ExhibitionDic = new Dictionary<string, View_CMS_Exhibition>();
var ExhibitionDic = new Dictionary<string, ExhibitionDTO>();
foreach (var Exhibition in ExhibitionList) foreach (var Exhibition in ExhibitionList)
{ {
var rsMainCategoryIDs = JsonConvert.DeserializeObject<List<string>>(Exhibition.MainCategoryIDs);
var rsMainCategoryIDs = Exhibition.MainCategories.Select(s => s.CategoryID).ToList();
bool hasMatch = rsMainCategoryIDs.Intersect(MainCategoryIDs).Any(); bool hasMatch = rsMainCategoryIDs.Intersect(MainCategoryIDs).Any();
@ -960,15 +907,18 @@ namespace EasyBL.WEBAPP.SYS
return ExhibitionDic.Values.ToList(); return ExhibitionDic.Values.ToList();
} }
public List<View_CMS_Exhibition> FilterBySubCategoryIDs(List<View_CMS_Exhibition> ExhibitionList, List<string> SubCategoryIDs)
#endregion 展覽管理(List 以主類別過濾)
#region 展覽管理(List 以子類別過濾)
public List<ExhibitionDTO> FilterBySubCategoryIDs(List<ExhibitionDTO> ExhibitionList, List<string> SubCategoryIDs)
{ {
var ExhibitionDic = new Dictionary<string, View_CMS_Exhibition>();
var ExhibitionDic = new Dictionary<string, ExhibitionDTO>();
foreach (var Exhibition in ExhibitionList) foreach (var Exhibition in ExhibitionList)
{ {
var rsSubCategoryIDs = JsonConvert.DeserializeObject<List<string>>(Exhibition.SubCategoryIDs);
var rsSubCategoryIDs = Exhibition.SubCategories.Select(s => s.CategoryID).ToList();
bool hasMatch = rsSubCategoryIDs.Intersect(SubCategoryIDs).Any(); bool hasMatch = rsSubCategoryIDs.Intersect(SubCategoryIDs).Any();
@ -983,17 +933,20 @@ namespace EasyBL.WEBAPP.SYS
return ExhibitionDic.Values.ToList(); return ExhibitionDic.Values.ToList();
} }
public Dictionary<string, ExhibitionCardDTO> FilterByLocationIDs(Dictionary<string, ExhibitionCardDTO> Cards, List<string> RegionIDs, List<string> CountryIDs, List<string> CityIDs)
#endregion 展覽管理(List 以子類別過濾)
#region 展覽管理(List 以位址過濾)
public List<ExhibitionDTO> FilterByLocationIDs(List<ExhibitionDTO> ExhibitionList, List<string> RegionIDs, List<string> CountryIDs, List<string> CityIDs)
{ {
var ExhibitionDic = new Dictionary<string, ExhibitionCardDTO>();
var ExhibitionDic = new Dictionary<string, ExhibitionDTO>();
foreach (var Exhibition in Cards.Values)
foreach (var Exhibition in ExhibitionList)
{ {
bool hasRegionMatch = RegionIDs.Contains(Exhibition.RegionID);
bool hasCountryMatch = CountryIDs.Contains(Exhibition.CountryID);
bool hasCityMatch = CityIDs.Contains(Exhibition.CityID);
bool hasRegionMatch = RegionIDs.Contains(Exhibition.Region.RegionID);
bool hasCountryMatch = CountryIDs.Contains(Exhibition.Country.CountryID);
bool hasCityMatch = CityIDs.Contains(Exhibition.City.CityID);
if (hasRegionMatch && !ExhibitionDic.ContainsKey(Exhibition.ExhibitionID)) if (hasRegionMatch && !ExhibitionDic.ContainsKey(Exhibition.ExhibitionID))
{ {
@ -1015,19 +968,22 @@ namespace EasyBL.WEBAPP.SYS
} }
return ExhibitionDic;
return ExhibitionDic.Values.ToList();
} }
public Dictionary<string, ExhibitionCardDTO> FilterByStatus(Dictionary<string, ExhibitionCardDTO> Cards, List<string> Status)
#endregion 展覽管理(List 以位址過濾)
#region 展覽管理(List 以狀態過濾)
public List<ExhibitionDTO> FilterByStatus(List<ExhibitionDTO> ExhibitionList, List<string> Status)
{ {
var ExhibitionDic = new Dictionary<string, ExhibitionCardDTO>();
var ExhibitionDic = new Dictionary<string, ExhibitionDTO>();
foreach (var Exhibition in Cards.Values)
foreach (var Exhibition in ExhibitionList)
{ {
var rsStatus = Exhibition.ExhibStatus;
var rsStatus = Exhibition.Status;
bool hasMatch = Status.Contains(rsStatus); bool hasMatch = Status.Contains(rsStatus);
@ -1039,37 +995,41 @@ namespace EasyBL.WEBAPP.SYS
} }
return ExhibitionDic;
return ExhibitionDic.Values.ToList();
} }
public Dictionary<string, ExhibitionCardDTO> FilterByDate(Dictionary<string, ExhibitionCardDTO> Cards, List<string> sDate)
#endregion 展覽管理(List 以狀態過濾)
#region 展覽管理(List 以日期過濾)
public List<ExhibitionDTO> FilterByDate(List<ExhibitionDTO> ExhibitionList, List<string> sDate)
{ {
var rsCards = new Dictionary<string, ExhibitionCardDTO>();
var rsCards = new Dictionary<string, ExhibitionDTO>();
var sStartDate = DateTime.ParseExact(sDate[0], "yyyy-MM-dd", CultureInfo.InvariantCulture); var sStartDate = DateTime.ParseExact(sDate[0], "yyyy-MM-dd", CultureInfo.InvariantCulture);
var sEndDate = DateTime.Now; var sEndDate = DateTime.Now;
if (sDate.Count == 2) {
if (sDate.Count == 2)
{
sEndDate = DateTime.ParseExact(sDate[1], "yyyy-MM-dd", CultureInfo.InvariantCulture); sEndDate = DateTime.ParseExact(sDate[1], "yyyy-MM-dd", CultureInfo.InvariantCulture);
} }
var rsCardList = Cards.Values.Where(w => w.StartDate >= sStartDate && w.StartDate <= sEndDate);
var rsExhibitionList = ExhibitionList.Where(w => w.StartDate >= sStartDate && w.StartDate <= sEndDate);
foreach (var Card in rsCardList) {
rsCards[Card.ExhibitionID] = Card;
}
return rsExhibitionList.ToList();
}
return rsCards;
#endregion 展覽管理(List 以日期過濾)
}
#region 展覽管理(List 查詢展覽階層位址)
public List<RegionDicDTO> QueryLocationFilterList(string sLanguageID)
{
public List<RegionDicDTO> QueryLocationFilterList(string sLanguageID) {
string sMsg = null;
ExhibInfoMaintain_QryService eim_qry = new ExhibInfoMaintain_QryService(); ExhibInfoMaintain_QryService eim_qry = new ExhibInfoMaintain_QryService();
@ -1077,7 +1037,6 @@ namespace EasyBL.WEBAPP.SYS
List<RegionDicDTO> rsRegionList = new List<RegionDicDTO>(); List<RegionDicDTO> rsRegionList = new List<RegionDicDTO>();
var db = SugarBase.GetIntance();
try try
{ {
do do
@ -1089,7 +1048,8 @@ namespace EasyBL.WEBAPP.SYS
var saDataList = eim_qry.FindAllLocationByIDsAsDictionary(sLanguageID, "", "").Values; var saDataList = eim_qry.FindAllLocationByIDsAsDictionary(sLanguageID, "", "").Values;
foreach (var Location in saDataList) {
foreach (var Location in saDataList)
{
RegionDicDTO Region = new RegionDicDTO(); RegionDicDTO Region = new RegionDicDTO();
Region.RegionID = Location.Region.RegionID; Region.RegionID = Location.Region.RegionID;
@ -1147,14 +1107,20 @@ namespace EasyBL.WEBAPP.SYS
} }
catch (Exception ex) catch (Exception ex)
{ {
sMsg = Util.GetLastExceptionMsg(ex);
} }
return rsRegionList; return rsRegionList;
} }
public List<View_CMS_Exhibition> QueryPopularExhibitionList(string sLanguageID, int iCount) {
#endregion 展覽管理(List 查詢展覽階層位址)
#region 展覽管理(List 查詢熱門展覽)
public List<View_CMS_Exhibition> QueryPopularExhibitionList(string sLanguageID, int iCount)
{
string sMsg = "";
List<View_CMS_Exhibition> rsExhibition = new List<View_CMS_Exhibition>(); List<View_CMS_Exhibition> rsExhibition = new List<View_CMS_Exhibition>();
@ -1169,7 +1135,8 @@ namespace EasyBL.WEBAPP.SYS
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE; sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
} }
if (iCount <= 0) {
if (iCount <= 0)
{
iCount = WebAppGlobalConstWord.TOP_LIMIT; iCount = WebAppGlobalConstWord.TOP_LIMIT;
} }
@ -1193,14 +1160,20 @@ namespace EasyBL.WEBAPP.SYS
} }
catch (Exception ex) catch (Exception ex)
{ {
sMsg = Util.GetLastExceptionMsg(ex);
} }
return rsExhibition; return rsExhibition;
} }
public List<CountryDTO> QueryPopularCountry(string sLanguageID, int iCount) {
#endregion 展覽管理(List 查詢熱門展覽)
#region 展覽管理(List 查詢熱門國家)
public List<CountryDTO> QueryPopularCountry(string sLanguageID, int iCount)
{
string sMsg = "";
List<CountryDTO> rsCountryList = new List<CountryDTO>(); List<CountryDTO> rsCountryList = new List<CountryDTO>();
@ -1235,7 +1208,8 @@ namespace EasyBL.WEBAPP.SYS
var Dic = new Dictionary<string, string>(); var Dic = new Dictionary<string, string>();
if (!CountryExhibDic.ContainsKey(Location.Country.CountryID)) {
if (!CountryExhibDic.ContainsKey(Location.Country.CountryID))
{
CountryExhibDic[Location.Country.CountryID] = Dic; CountryExhibDic[Location.Country.CountryID] = Dic;
} }
@ -1258,7 +1232,8 @@ namespace EasyBL.WEBAPP.SYS
CountryDTO Country = new CountryDTO(); CountryDTO Country = new CountryDTO();
if (CountryDic.ContainsKey(CountryID)) {
if (CountryDic.ContainsKey(CountryID))
{
Country.CountryID = CountryDic[CountryID].CountryID; Country.CountryID = CountryDic[CountryID].CountryID;
Country.CountryName = CountryDic[CountryID].CountryName; Country.CountryName = CountryDic[CountryID].CountryName;
@ -1275,13 +1250,16 @@ namespace EasyBL.WEBAPP.SYS
} }
catch (Exception ex) catch (Exception ex)
{ {
sMsg = Util.GetLastExceptionMsg(ex);
} }
return rsCountryList; return rsCountryList;
} }
#endregion 展覽管理(List 查詢熱門國家)
#region 展覽管理(List 查詢熱門類別)
public List<CategoryDicDTO> QueryPopularCategory(string sLanguageID, int iCount) public List<CategoryDicDTO> QueryPopularCategory(string sLanguageID, int iCount)
{ {
@ -1315,9 +1293,11 @@ namespace EasyBL.WEBAPP.SYS
var MainCategoryIDList = JsonConvert.DeserializeObject<List<string>>(Exhibition.MainCategoryIDs); var MainCategoryIDList = JsonConvert.DeserializeObject<List<string>>(Exhibition.MainCategoryIDs);
foreach (var MainCategoryID in MainCategoryIDList) {
foreach (var MainCategoryID in MainCategoryIDList)
{
if (!CategoryExhibDic.ContainsKey(MainCategoryID)) {
if (!CategoryExhibDic.ContainsKey(MainCategoryID))
{
CategoryExhibDic[MainCategoryID] = Dic; CategoryExhibDic[MainCategoryID] = Dic;
} }
@ -1364,7 +1344,11 @@ namespace EasyBL.WEBAPP.SYS
} }
public Dictionary<string, ExhibitionDTO> QueryAllDetailExhibitionAsDictionary(string sLanguageID) {
#endregion 展覽管理(List 查詢熱門類別)
#region 展覽管理(Dictionary 查詢所有詳細展覽)
public Dictionary<string, ExhibitionDTO> QueryAllDetailExhibitionAsDictionary(string sLanguageID)
{
Dictionary<string, ExhibitionDTO> rsResult = new Dictionary<string, ExhibitionDTO>(); Dictionary<string, ExhibitionDTO> rsResult = new Dictionary<string, ExhibitionDTO>();
@ -1388,9 +1372,10 @@ namespace EasyBL.WEBAPP.SYS
ExhibStatMaintain_QryService esm_qry = new ExhibStatMaintain_QryService(); ExhibStatMaintain_QryService esm_qry = new ExhibStatMaintain_QryService();
ExhibMediaMaintain_QryService emm_qry = new ExhibMediaMaintain_QryService(); ExhibMediaMaintain_QryService emm_qry = new ExhibMediaMaintain_QryService();
foreach (var Exhibition in ExhibitionList) {
foreach (var Exhibition in ExhibitionList)
{
ExhibitionDTO rsExhibition = new ExhibitionDTO(); ExhibitionDTO rsExhibition = new ExhibitionDTO();
@ -1457,7 +1442,8 @@ namespace EasyBL.WEBAPP.SYS
} }
// set ExhibInfo // set ExhibInfo
if (ExhibInfo != null) {
if (ExhibInfo != null)
{
Location = eim_qry.FindAllLocationByIDsAsDictionary(sLanguageID, ExhibInfo.Year, Exhibition.ExhibitionID).Values.FirstOrDefault(); Location = eim_qry.FindAllLocationByIDsAsDictionary(sLanguageID, ExhibInfo.Year, Exhibition.ExhibitionID).Values.FirstOrDefault();
@ -1529,7 +1515,8 @@ namespace EasyBL.WEBAPP.SYS
// set Media Link // set Media Link
var MediaFileList = emm_qry.FindAllByIDsAsDictionary(rsExhibition.ExhibitionID, "").Values.ToList(); var MediaFileList = emm_qry.FindAllByIDsAsDictionary(rsExhibition.ExhibitionID, "").Values.ToList();
foreach (var File in MediaFileList) {
foreach (var File in MediaFileList)
{
VideoDTO Video = new VideoDTO(); VideoDTO Video = new VideoDTO();
Video.VideoLink = File.Link; Video.VideoLink = File.Link;
@ -1541,7 +1528,8 @@ namespace EasyBL.WEBAPP.SYS
// set Image Files // set Image Files
var ImageFileList = fm_qry.FindAllByIDsAsDictionary(rsExhibition.ExhibitionID).Values.ToList(); var ImageFileList = fm_qry.FindAllByIDsAsDictionary(rsExhibition.ExhibitionID).Values.ToList();
foreach (var File in ImageFileList) {
foreach (var File in ImageFileList)
{
ImageDTO Image = new ImageDTO(); ImageDTO Image = new ImageDTO();
Image.ImageLink = Server + "/" + File.FilePath.Replace("\\", "/"); Image.ImageLink = Server + "/" + File.FilePath.Replace("\\", "/");
@ -1558,7 +1546,11 @@ namespace EasyBL.WEBAPP.SYS
return rsResult; return rsResult;
} }
public ExhibitionDTO QueryOneDetailExhibition(string sLanguageID, string sExhibitionID) {
#endregion 展覽管理(Dictionary 查詢所有詳細展覽)
#region 展覽管理(ExhibitionDTO 查詢單一詳細展覽)
public ExhibitionDTO QueryOneDetailExhibition(string sLanguageID, string sExhibitionID)
{
var rsExhibition = QueryAllDetailExhibitionAsDictionary(sLanguageID) var rsExhibition = QueryAllDetailExhibitionAsDictionary(sLanguageID)
.Values.ToList() .Values.ToList()
@ -1569,31 +1561,40 @@ namespace EasyBL.WEBAPP.SYS
} }
public List<CategoryExhibitionDTO> QueryCategoryExhibition(string sLanguageID, List<string> IncludeCountryIDs, List<string> ExcludeCountryIDs) {
#endregion 展覽管理(ExhibitionDTO 查詢單一詳細展覽)
#region 展覽管理(List 查詢階層主類別展覽)
public List<CategoryExhibitionDTO> QueryCategoryExhibition(string sLanguageID, List<string> IncludeCountryIDs, List<string> ExcludeCountryIDs)
{
Dictionary<string, CategoryExhibitionDTO> rsResult = new Dictionary<string, CategoryExhibitionDTO>(); Dictionary<string, CategoryExhibitionDTO> rsResult = new Dictionary<string, CategoryExhibitionDTO>();
if (string.IsNullOrEmpty(sLanguageID)) {
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE; sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
} }
var rsExhibitionList = QueryAllDetailExhibitionAsDictionary(sLanguageID).Values.Where(w => w.MainCategories.Count > 0); var rsExhibitionList = QueryAllDetailExhibitionAsDictionary(sLanguageID).Values.Where(w => w.MainCategories.Count > 0);
if (IncludeCountryIDs.Count > 0) {
if (IncludeCountryIDs.Count > 0)
{
rsExhibitionList = rsExhibitionList.Where(w => IncludeCountryIDs.Contains(w.Country.CountryID)); rsExhibitionList = rsExhibitionList.Where(w => IncludeCountryIDs.Contains(w.Country.CountryID));
} }
if (ExcludeCountryIDs.Count > 0) {
if (ExcludeCountryIDs.Count > 0)
{
rsExhibitionList = rsExhibitionList.Where(w => !ExcludeCountryIDs.Contains(w.Country.CountryID)); rsExhibitionList = rsExhibitionList.Where(w => !ExcludeCountryIDs.Contains(w.Country.CountryID));
} }
foreach (var Exhibition in rsExhibitionList) {
foreach (var Exhibition in rsExhibitionList)
{
List<CategoryDTO> MainCategoryList = Exhibition.MainCategories; List<CategoryDTO> MainCategoryList = Exhibition.MainCategories;
ExhibitionDTO ExhibDTO = new ExhibitionDTO(); ExhibitionDTO ExhibDTO = new ExhibitionDTO();
foreach (var MainCategory in MainCategoryList) {
foreach (var MainCategory in MainCategoryList)
{
CategoryExhibitionDTO rsCategoryExhibition = new CategoryExhibitionDTO(); CategoryExhibitionDTO rsCategoryExhibition = new CategoryExhibitionDTO();
@ -1608,7 +1609,8 @@ namespace EasyBL.WEBAPP.SYS
} }
foreach (KeyValuePair<string, CategoryExhibitionDTO> CM in rsResult) {
foreach (KeyValuePair<string, CategoryExhibitionDTO> CM in rsResult)
{
var sCategoryID = CM.Key; var sCategoryID = CM.Key;
@ -1617,9 +1619,11 @@ namespace EasyBL.WEBAPP.SYS
} }
return rsResult.Values.ToList(); return rsResult.Values.ToList();
} }
#endregion 展覽管理(List 查詢階層主類別展覽)
} }

24
EuroTran/EasyBL.WEBAPP/ShowEasy/ExhibitionService.cs

@ -389,30 +389,8 @@ namespace EasyBL.WEBAPP.SYS
} }
ExhibMaintain_QryService em_qry = new ExhibMaintain_QryService(); ExhibMaintain_QryService em_qry = new ExhibMaintain_QryService();
var rsResult = em_qry.QueryExhibitionCard(sLanguageID, RegionIDs, CountryIDs, CityIDs, MainCategoryIDs, SubCategoryIDs, Status, Date);
if (!string.IsNullOrEmpty(SortType)) {
if (SortType == "Recommended")
{
rsResult = rsResult.OrderByDescending(o => o.IsRecommend).ToList();
}
if (SortType == "ShowDate") {
rsResult = rsResult.OrderByDescending(o => o.StartDate.ToString()).ToList();
}
if (SortType == "ExhibitorCount")
{
rsResult = rsResult.OrderByDescending(o => o.ExhibitorCount).ToList();
}
if (SortType == "VisitorCount")
{
rsResult = rsResult.OrderByDescending(o => o.VisitorCount).ToList();
}
}
var rsResult = em_qry.QueryExhibitionCard(sLanguageID, RegionIDs, CountryIDs, CityIDs, MainCategoryIDs, SubCategoryIDs, Status, Date, SortType);
//返回token信息 //返回token信息
srm = new SuccessResponseMessage(null, null); srm = new SuccessResponseMessage(null, null);

Loading…
Cancel
Save