You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

2091 lines
84 KiB

using EasyBL.WebApi.Message;
using EasyBL.WEBAPP.SYS;
using Entity.ShowEasyDtos;
using Entity.Sugar;
using Entity.ViewModels;
using Newtonsoft.Json;
using SqlSugar;
using SqlSugar.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace EasyBL.WEBAPP.ShowEasy
{
public class ONSiteMaintain_QryService : ServiceBase
{
#region 服務管理(分頁查詢)
/// <summary>
/// 服務管理(分頁查詢)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryPage(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var pml = new PageModel
{
PageIndex = _fetchInt(i_crm, @"pageIndex"),
PageSize = _fetchInt(i_crm, @"pageSize")
};
var iPageCount = 0;
var sSortField = _fetchString(i_crm, @"sortField");
var sSortOrder = _fetchString(i_crm, @"sortOrder");
var sLangID = _fetchString(i_crm, @"LangID");
var sEffective = _fetchString(i_crm, @"Effective");
var iSupplierID = _fetchString(i_crm, @"SupplierID");
var iSubCategory = _fetchInt(i_crm, @"SubCategory");
var sLaunchDateS = _fetchString(i_crm, @"LaunchDateS");
var sLaunchDateE = _fetchString(i_crm, @"LaunchDateE");
//var sKeyWord = _fetchString(i_crm, @"KeyWord");
var bExcel = _fetchBool(i_crm, @"Excel");
//var sExcelType = _fetchString(i_crm, @"ExcelType");
var rLaunchDateS = new DateTime();
var rLaunchDateE = new DateTime();
if (!string.IsNullOrEmpty(sLaunchDateS))
{
rLaunchDateS = SqlFunc.ToDate(sLaunchDateS);
}
if (!string.IsNullOrEmpty(sLaunchDateE))
{
rLaunchDateE = SqlFunc.ToDate(sLaunchDateE).AddDays(1);
}
pml.DataList = db.Queryable<SETB_PDT_ONSiteBaseInfo, SETB_SCM_Supplier>
((t1, t2) =>
new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.SupplierID == t2.SupplierID && t1.LangID == t2.LangType
}
)
.Where((t1, t2) => t1.OrgID == i_crm.ORIGID)//, t3
.WhereIF(!string.IsNullOrEmpty(sLangID), (t1) => t1.LangID == sLangID)
.WhereIF(!string.IsNullOrEmpty(sEffective), (t1) => sEffective.Contains(t1.Effective))
.WhereIF(!string.IsNullOrEmpty(iSupplierID), (t1) => t1.SupplierID == iSupplierID)
.Select((t1, t2) => new View_PDT_ServiceBaseInfo//, t3
{
OrgID = t1.OrgID,
ServiceID = t1.ServiceID,
ServiceName = t1.ServiceName,
LangID = t1.LangID,
LaunchDateS = t1.LaunchDateS,
LaunchDateE = t1.LaunchDateE,
Effective = t1.Effective,
SupplierName = t2.CompanyName,
})
//.MergeTable()
.OrderBy(sSortField, sSortOrder)
.ToPageList(pml.PageIndex, bExcel ? 100000 : pml.PageSize, ref iPageCount);
pml.Total = iPageCount;
rm = new SuccessResponseMessage(null, i_crm);
if (bExcel)
{
var sFileName = "";
var oHeader = new Dictionary<string, string>();
var listMerge = new List<Dictionary<string, int>>();
var dicAlain = new Dictionary<string, string>();
var dt_new = new DataTable();
var saCustomers1 = pml.DataList;
var saCustomers = pml.DataList as List<View_PDT_ServiceBaseInfo>;
sFileName = "標準品基本資料";
oHeader = new Dictionary<string, string>
{
{ "RowIndex", "項次" },
{ "ServiceName", "服務名稱" },
{ "SupplierName", "供應商" },
{ "LaunchDateS", "上架開始日期" },
{ "LaunchDateE", "上架結束日期" }
};
dt_new.Columns.Add("RowIndex");
dt_new.Columns.Add("ServiceName");
dt_new.Columns.Add("SupplierName");
dt_new.Columns.Add("LaunchDateS");
dt_new.Columns.Add("LaunchDateE");
foreach (var customer in saCustomers)
{
var row_new = dt_new.NewRow();
row_new["RowIndex"] = customer.RowIndex;
row_new["ServiceName"] = customer.ServiceName;
row_new["SupplierName"] = customer.SupplierName;
row_new["LaunchDateS"] = Convert.ToDateTime(customer.LaunchDateS).ToString("yyyy/MM/dd");
row_new["LaunchDateE"] = Convert.ToDateTime(customer.LaunchDateE).ToString("yyyy/MM/dd");
dt_new.Rows.Add(row_new);
}
//dicAlain = ExcelService.GetExportAlain(oHeader, "CustomerNO,UniCode,Telephone,FAX,CreateUser,CreateUserName,CreateDate,IsAudit");
var bOk = new ExcelService().CreateExcelByTb(dt_new, out string sPath, oHeader, dicAlain, listMerge, sFileName);
rm.DATA.Add(BLWording.REL, sPath);
}
else
{
rm.DATA.Add(BLWording.REL, pml);
}
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryPage(服務管理(分頁查詢))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 服務管理(分頁查詢)
#region 其他訂單問題(分頁查詢)
/// <summary>
/// 其他訂單問題(分頁查詢)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryOrderQuestion(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sLangID = _fetchString(i_crm, @"LangID");
var iServiceID = _fetchString(i_crm, @"ServiceID");
var saServiceByOrderQuestion = db.Queryable<SETB_PDT_ServiceByOrderQuestion, SETB_SAL_Survey, OTB_SYS_Arguments>
((t1, t2, t3) =>
new object[] {
JoinType.Left, t1.QuestionID == t2.SurveyID ,
JoinType.Left, t2.AnswerType == t3.ArgumentID && t3.ArgumentClassID == "AnswerType"
}
)
.Where((t1) => t1.LangID == sLangID && t1.ServiceID == iServiceID)
.Where((t1) => t1.PlanID == null && t1.AddFlag == null)
.Select((t1, t2, t3) => new View_PDT_ServiceByOrderQuestion
{
ServiceID = t1.ServiceID,
QuestionID = t1.QuestionID,
RequiredFlag = t1.RequiredFlag,
LangID = t1.LangID,
SurveyName = t2.SurveyName,
Answer = t3.ArgumentValue
})
.OrderBy(t1 => t1.QuestionID)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saServiceByOrderQuestion);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryPage(其他訂單問題(分頁查詢))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 服務管理(分頁查詢)
#region 區域列表(分頁查詢)
/// <summary>
/// 區域列表(分頁查詢)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryRegionList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sLangID = _fetchString(i_crm, @"LangID");
var saRegionAll = db.Queryable<SETB_SYS_Region>().Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
.WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LangType == sLangID)
.Select(x => new View_UTL_RegionAll
{
id = "A" + x.RegionID.ToString(),
parent = "0",
text = x.RegionName,
name = x.RegionName
})
.OrderBy(x => x.id)
.ToList();
var saCountryAll = db.Queryable<SETB_SYS_Country>().Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
.WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LangType == sLangID)
.Select(x => new View_UTL_RegionAll
{
id = "B" + x.CountryID.ToString(),
parent = "A" + x.RegionID.ToString(),
text = x.CountryName,
name = x.CountryName
})
.OrderBy(x => x.parent)
.ToList();
var saCityAll = db.Queryable<SETB_UTL_City>().Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
.WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LangType == sLangID)
.Select(x => new View_UTL_RegionAll
{
id = "C" + x.CityID.ToString(),
parent = "B" + x.CountryID.ToString(),
text = x.CityName,
name = x.CityName
})
.OrderBy(x => x.id)
.ToList();
saRegionAll.AddRange(saCountryAll);
saRegionAll.AddRange(saCityAll);
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saRegionAll);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryPage(其他訂單問題(分頁查詢))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 服務管理(分頁查詢)
#region 方案問題(分頁查詢)
/// <summary>
/// 方案問題(分頁查詢)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryPlanList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sLangID = _fetchString(i_crm, @"LangID");
var iServiceID = _fetchString(i_crm, @"ServiceID");
var saServiceByOrderQuestion = db.Queryable<SETB_PDT_ONSiteItem, OTB_SYS_Arguments>
((t1, t2) =>
new object[] {
JoinType.Left, t1.ItemType == t2.ArgumentID && t2.ArgumentClassID == "ServiceItem" ,
}
)
.Where((t1, t2) => t1.LangID == sLangID && t1.ServiceID == iServiceID && t1.OrgID== i_crm.ORIGID).
Select((t1, t2) => new
{
t1.Guid,
t1.ItemType,
PlanFlag = "Y"
,
ItemName=t2.ArgumentValue,
t1.CreateDate
}).OrderBy(t1 => t1.CreateDate).ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saServiceByOrderQuestion);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryPage(服務管理(分頁查詢))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 服務管理(分頁查詢)
#region 問題列表(分頁查詢)
/// <summary>
/// 服務管理(分頁查詢)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryQuestion(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sSurveyType = _fetchString(i_crm, @"SurveyType");
var sCategoryID = _fetchString(i_crm, @"CategoryID");
var saQuestion = db.Queryable<SETB_SAL_Survey, OTB_SYS_Arguments, OTB_SYS_Arguments>
((t1, t2, t3) =>
new object[] {
JoinType.Left, t1.AnswerType == t2.ArgumentID && t2.ArgumentClassID == "AnswerType" ,
JoinType.Left, t1.SurveyType == t3.ArgumentID && t3.ArgumentClassID == "SurveyType"
}
)
.Where(t1 => t1.OrgID == i_crm.ORIGID && t1.DelStatus != "Y")
.WhereIF(!string.IsNullOrEmpty(sSurveyType), (t1) => t1.SurveyType == sSurveyType)
.WhereIF(!string.IsNullOrEmpty(sCategoryID), t1 => t1.CategoryID == sCategoryID)
.Select((t1, t2, t3) => new View_SAL_Survey
{
SurveyID = SqlFunc.GetSelfAndAutoFill(t1.SurveyID),
SurveyName = t1.SurveyName,
AnswerTypeName = t2.ArgumentValue,
SurveyTypeName = t3.ArgumentValue
}).OrderBy(t1 => t1.CreateDate).ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saQuestion);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryPage(服務管理(分頁查詢))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 服務管理(分頁查詢)
#region 供應商列表(多筆)
/// <summary>
/// 供應商列表(多筆)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QuerySupplierList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sLangID = _fetchString(i_crm, @"LangID");
var saSupplierc = db.Queryable<SETB_SCM_Supplier>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y")
.WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LangType == sLangID)
.OrderBy(x => x.CreateDate)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saSupplierc);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QuerySupplierList(供應商列表(多筆))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 供應商列表(多筆)
#region 供應商聯絡人列表(多筆)
/// <summary>
/// 供應商聯絡人列表(多筆)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QuerySupplierContactorList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sSupplierID = _fetchString(i_crm, @"SupplierID");
var sLangID = _fetchString(i_crm, @"LangID");
var saSupplierc = db.Queryable<SETB_SCM_SupplierContactor>()
.Where(x => x.OrgID == i_crm.ORIGID)
.WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LangType == sLangID)
.WhereIF(!string.IsNullOrEmpty(sSupplierID), x => x.SupplierID == sSupplierID)
//.OrderBy(x => x.ContacterName)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saSupplierc);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QuerySupplierContactorList(供應商列表(多筆))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 供應商列表(多筆)
#region 服務子類別列表(多筆)
/// <summary>
/// 服務子類別列表(多筆)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QuerySubCategoryList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sLangID = _fetchString(i_crm, @"LangID");
var saArgumentClass = db.Queryable<SETB_SYS_Category>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N" && x.CategoryType == "Service" && x.ParentIDs != "" && x.ParentIDs != null)
.WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LanguageID == sLangID)
.OrderBy(x => x.OrderByValue)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saArgumentClass);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QuerySubCategoryList(服務子類別列表(多筆))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 參數類別(多筆)
#region 幣別列表(多筆)
/// <summary>
/// 幣別列表(多筆)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryCurrencyList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
// var sLangID = _fetchString(i_crm, @"LangID");
var saArgumentClass = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N" && x.ArgumentClassID == "Currency")
// .WhereIF(!string.IsNullOrEmpty(sLangID), x => x.LanguageID == sLangID)
.OrderBy(x => x.OrderByValue)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saArgumentClass);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryCurrencyList(幣別列表(多筆))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 參數類別(多筆)
#region 展會列表(多筆)
/// <summary>
/// 展會列表(多筆)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryExhibitionList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sLangID = _fetchString(i_crm, @"LangID");
var sMainCategoryID = _fetchString(i_crm, @"MainCategoryID");
var sSubCategoryID = _fetchString(i_crm, @"SubCategoryID");
var sExhibitionName = _fetchString(i_crm, @"ExhibitionName");
var saQuestion = db.Queryable<SETB_CMS_Exhibition>()
.Where(x => x.OrgID == i_crm.ORIGID && x.DelStatus != "Y" && x.Effective == "Y" && x.LanguageID == sLangID)
.WhereIF(!string.IsNullOrEmpty(sMainCategoryID), x => x.MainCategoryIDs.Contains(sMainCategoryID))
.WhereIF(!string.IsNullOrEmpty(sSubCategoryID), x => x.SubCategoryIDs.Contains(sSubCategoryID))
.WhereIF(!string.IsNullOrEmpty(sExhibitionName), x => x.ExhibitionName.Contains(sExhibitionName))
.Select(t1 => new SETB_CMS_Exhibition
{
ExhibitionID = t1.ExhibitionID,
ExhibitionNo = t1.ExhibitionNo,
ExhibitionName = t1.ExhibitionName,
AbbreviatedName = t1.AbbreviatedName
}).OrderBy(t1 => t1.OrderByValue).ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saQuestion);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QuerySupplierList(供應商列表(多筆))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 供應商列表(多筆)
#region 展覽主類別管理 (List 展覽主類別查詢)
public ResponseMessage QueryExhibCategoryList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sCategoryType = "Exhibition";
var sLanguageID = _fetchString(i_crm, @"LanguageID");
var sIsMainCategory = _fetchString(i_crm, @"IsMainCategory");
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
//var sIsMainCategory = "Y";
var saCategory = db.Queryable<SETB_SYS_Category>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" && x.DelStatus == "N")
.Where(t1 => t1.LanguageID == sLanguageID)
.Where(x => x.CategoryType == sCategoryType)
.Where(x => x.IsMainCategory == sIsMainCategory)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saCategory);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryExhibCategoryList 展覽類別管理 (List 展覽類別查詢)", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 展覽主類別管理 (List 展覽主類別查詢)
#region 以項目當作搜尋條件
/// <summary>
/// 報價設定管理(查詢筆數)
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryServiceQSList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var sQuotationType = _fetchString(i_crm, @"QuotationType");
var sLangType = _fetchString(i_crm, @"LangType");
var saCountry = db.Queryable<SETB_PDT_ServiceQS>()
//搜尋條件
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y" )
.WhereIF(!string.IsNullOrEmpty(sQuotationType), x => x.QuotationType == sQuotationType)
.WhereIF(!string.IsNullOrEmpty(sLangType), x => x.LangID == sLangType)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saCountry);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceMaintain_QryService), "", "QueryList(城市類別管理(查詢筆數))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 以國家當作搜尋條件
#region 卡車車型信息
/// <summary>
/// 卡車車型信息
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
public ResponseMessage QueryTruckInfoList(RequestMessage i_crm)
{
ResponseMessage rm = null;
string sMsg = null;
var db = SugarBase.GetIntance();
try
{
do
{
var saArgumentClass = db.Queryable<SETB_PDT_ServiceTruckInfo>()
.Where(x => x.OrgID == i_crm.ORIGID && x.Effective == "Y")
.OrderBy(x => x.MaxWeight)
.ToList();
rm = new SuccessResponseMessage(null, i_crm);
rm.DATA.Add(BLWording.REL, saArgumentClass);
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(ServiceQSMaintain_QryService), "", "QueryTruckInfoList(卡車車型信息(多筆))", "", "", "");
}
finally
{
if (null != sMsg)
{
rm = new ErrorResponseMessage(sMsg, i_crm);
}
}
return rm;
}
#endregion 參數類別(多筆)
//所有服務Api
public List<ServiceCategoryDTO> QueryAllCategoryFilterList(string sLanguageID)
{
string sMsg = null;
var rsResult = new Dictionary<string, ServiceCategoryDTO>();
var sCategoryType = WebAppGlobalConstWord.CATEGORYSERVICETYPE;//Service
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
var db = SugarBase.GetIntance();
try
{
do
{
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
var rsCategoryDic = new Dictionary<string, SETB_SYS_Category>();
var saCategoryList = db.Queryable<SETB_SYS_Category>()
.Where(t1 => t1.CategoryType == sCategoryType)
.Where(t1 => t1.LanguageID == sLanguageID)
.Where(t1 => t1.Effective == "Y" )
.Where(t1 => t1.DelStatus == "N")
.Where(t1 => t1.OrgID == sORIGID)
.ToList();
foreach (var Category in saCategoryList)
{
rsCategoryDic[Category.CategoryID] = Category;
if (Category.IsMainCategory == "Y") {
//主類別
var MainCategory = rsCategoryDic[Category.CategoryID];
var MainCategoryDTO = new ServiceCategoryDTO();
MainCategoryDTO.CategoryID = MainCategory.CategoryID;
MainCategoryDTO.CategoryName = MainCategory.CategoryName;
rsResult[MainCategoryDTO.CategoryID] = MainCategoryDTO;
}
}
var lstSubCategoryList = saCategoryList.Where(x => x.IsMainCategory == "N").ToList();
foreach (var SubCategoryModel in lstSubCategoryList)
{
if (rsCategoryDic.ContainsKey(SubCategoryModel.CategoryID))
{
var SubCategory = rsCategoryDic[SubCategoryModel.CategoryID];
var ParentIDs = SubCategory.ParentIDs;
if (!string.IsNullOrEmpty(ParentIDs))
{
var ParentIDList = JsonConvert.DeserializeObject<List<string>>(ParentIDs);
foreach (var ParentID in ParentIDList)
{
var SubCategoryDTO = new ServiceCategoryDTO();
SubCategoryDTO.CategoryID = SubCategory.CategoryID;
SubCategoryDTO.CategoryName = SubCategory.CategoryName;
rsResult[ParentID].SubCategoryDic[SubCategoryDTO.CategoryID] = SubCategoryDTO;
}
}
}
}
foreach (var Category in rsResult.Values.ToList())
{
rsResult[Category.CategoryID].SubCategoryList = rsResult[Category.CategoryID].SubCategoryDic.Values.ToList();
rsResult[Category.CategoryID].SubCategoryDic = null;
}
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
}
finally
{
}
return rsResult.Values.ToList();
}
//服務主列表服務類別Api
public List<ServiceCategoryDTO> QueryCategoryFilterList(string sLanguageID)
{
string sMsg = null;
var rsResult = new Dictionary<string, ServiceCategoryDTO>();
var sCategoryType = WebAppGlobalConstWord.CATEGORYSERVICETYPE;//Service
var db = SugarBase.GetIntance();
try
{
do
{
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
//查詢出所有的服務類別
var rsCategoryDic = new Dictionary<string, SETB_SYS_Category>();
var saCategoryList = db.Queryable<SETB_SYS_Category>()
.Where(t1 => t1.CategoryType == sCategoryType)
.Where(t1 => t1.LanguageID == sLanguageID)
.Where(t1 => t1.Effective == "Y")
.Where(t1 => t1.DelStatus == "N")
.ToList();
foreach (var Category in saCategoryList)
{
rsCategoryDic[Category.CategoryID] = Category;
}
var rsExhibitionList = QueryAllONSiteList(sLanguageID);
foreach (var Exhibition in rsExhibitionList)
{
var sMainCategoryIDs = Exhibition.MainCategoryIDs;
if (!string.IsNullOrEmpty(sMainCategoryIDs))
{
var MainCategoryList = JsonConvert.DeserializeObject<List<string>>(sMainCategoryIDs);
foreach (var MainCategoryID in MainCategoryList)
{
if (rsCategoryDic.ContainsKey(MainCategoryID))
{
var MainCategory = rsCategoryDic[MainCategoryID];
var MainCategoryDTO = new ServiceCategoryDTO();
MainCategoryDTO.CategoryID = MainCategory.CategoryID;
MainCategoryDTO.CategoryName = MainCategory.CategoryName;
rsResult[MainCategoryDTO.CategoryID] = MainCategoryDTO;
}
}
}
}
foreach (var Exhibition in rsExhibitionList)
{
var sSubCategoryIDs = Exhibition.SubCategoryID;
if (!string.IsNullOrEmpty(sSubCategoryIDs))
{
var SubCategoryList = JsonConvert.DeserializeObject<List<string>>(sSubCategoryIDs);
foreach (var SubCategoryID in SubCategoryList)
{
if (rsCategoryDic.ContainsKey(SubCategoryID))
{
var SubCategory = rsCategoryDic[SubCategoryID];
var ParentIDs = SubCategory.ParentIDs;
if (!string.IsNullOrEmpty(ParentIDs))
{
var ParentIDList = JsonConvert.DeserializeObject<List<string>>(ParentIDs);
foreach (var ParentID in ParentIDList)
{
var SubCategoryDTO = new ServiceCategoryDTO();
SubCategoryDTO.CategoryID = SubCategory.CategoryID;
SubCategoryDTO.CategoryName = SubCategory.CategoryName;
rsResult[ParentID].SubCategoryDic[SubCategoryDTO.CategoryID] = SubCategoryDTO;
}
}
}
}
}
}
foreach (var Category in rsResult.Values.ToList())
{
rsResult[Category.CategoryID].SubCategoryList = rsResult[Category.CategoryID].SubCategoryDic.Values.ToList();
rsResult[Category.CategoryID].SubCategoryDic = null;
}
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
}
finally
{
}
return rsResult.Values.ToList();
}
//取得所有Onsite服務的服務子類別與主類別
public List<View_PDT_ONSiteBaseInfo> QueryAllONSiteList(string sLanguageID)
{
List<View_PDT_ONSiteBaseInfo> saDataList = new List<View_PDT_ONSiteBaseInfo>();
var db = SugarBase.GetIntance();
try
{
do
{
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
saDataList = db.Queryable<SETB_PDT_ONSiteBaseInfo, SETB_SYS_Category>((t1, t2) =>
new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.LangID == t2.LanguageID && t1.SubCategoryID.Contains(t2.CategoryID)
}
)
.Where((t1, t2) => t1.Effective == "Y")
.WhereIF(!string.IsNullOrEmpty(sLanguageID), t1 => t1.LangID == sLanguageID)
.Select((t1, t2) => new View_PDT_ONSiteBaseInfo
{
ServiceID = SqlFunc.GetSelfAndAutoFill(t1.ServiceID),
SubCategoryID=t1.SubCategoryID,
MainCategoryIDs =t2.ParentIDs
})
.ToList();
return saDataList;
} while (false);
}
catch (Exception ex)
{
}
return saDataList;
}
//取得全部位置
public List<ServiceRegionDTO> AllQueryLocationFilterList(string sLanguageID)
{
ExhibInfoMaintain_QryService eim_qry = new ExhibInfoMaintain_QryService();
List<ServiceRegionDTO> saLocationList = new List<ServiceRegionDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
var saDataList = db.Queryable<SETB_UTL_City, SETB_SYS_Country, SETB_SYS_Region>((t1, t2, t3) => new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.CountryID == t2.CountryID && t1.LangType == t2.LangType,
JoinType.Left, t1.OrgID == t3.OrgID && t2.RegionID == t3.RegionID && t1.LangType == t3.LangType
})
.Where((t1, t2, t3) => t1.OrgID == sORIGID && t1.DelStatus != "Y" && t1.Effective == "Y" && t1.LangType== sLanguageID)
.Select((t1, t2, t3) => new View_UTL_City
{
CityID = SqlFunc.GetSelfAndAutoFill(t1.CityID),
CountryID = t2.CountryID,
CountryName = t2.CountryName,
RegionID = t3.RegionID,
RegionName = t3.RegionName
}).OrderBy(t3 => t3.OrderByValue).ToList();
Dictionary<string, ServiceRegionDTO> RegionDic = new Dictionary<string, ServiceRegionDTO>();
foreach (var Location in saDataList)
{
ServiceRegionDTO Region = new ServiceRegionDTO();
Region.RegionID = Location.RegionID;
Region.RegionName = Location.RegionName;
if (!RegionDic.ContainsKey(Location.RegionID))
{
//包含洲
RegionDic.Add(Location.RegionID, Region);
}
ServiceCountryDTO Country = new ServiceCountryDTO();
Country.CountryID = Location.CountryID;
Country.CountryName = Location.CountryName;
if (!RegionDic[Location.RegionID].CountryDic.ContainsKey(Location.CountryID))
{
//包含國家
RegionDic[Location.RegionID].CountryDic.Add(Location.CountryID, Country);
}
CityDTO City = new CityDTO();
City.CityID = Location.CityID;
City.CityName = Location.CityName;
RegionDic[Location.RegionID].CountryDic[Location.CountryID].CityDic.Add(Location.CityID,City);
}
foreach (var Region in RegionDic.Values)
{
foreach (var Country in Region.CountryDic.Values)
{
foreach (var City in Country.CityDic.Values)
{
if (Country.CityList == null)
{
Country.CityList = new List<CityDTO>();
}
Country.CityList.Add(City);
}
if (Region.CountryList == null)
{
Region.CountryList = new List<ServiceCountryDTO>();
}
Country.CityDic = null;
Region.CountryList.Add(Country);
}
Region.CountryDic = null;
saLocationList.Add(Region);
}
return saLocationList;
} while (false);
}
catch (Exception ex)
{
}
return saLocationList;
}
//取得所有Onsite服務的位置
public List<ServiceRegionDTO> QueryLocationFilterList(string sLanguageID)
{
ExhibInfoMaintain_QryService eim_qry = new ExhibInfoMaintain_QryService();
List<ServiceRegionDTO> saLocationList = new List<ServiceRegionDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
if (string.IsNullOrEmpty(sLanguageID))
{
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
//
var saDataList = db.Queryable<SETB_PDT_ONSiteBaseInfo, SETB_UTL_City, SETB_SYS_Country, SETB_SYS_Region>((t1, t2, t3,t4) => new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.LangID == t2.LangType && t1.SuitPlace.Contains(t2.CityID),
JoinType.Left, t2.OrgID == t3.OrgID && t2.CountryID == t3.CountryID && t2.LangType == t3.LangType,
JoinType.Left, t2.OrgID == t4.OrgID && t3.RegionID == t4.RegionID && t2.LangType == t4.LangType
})
.Where((t1, t2, t3,t4) => t1.OrgID == sORIGID && t1.LangID == sLanguageID && t2.DelStatus != "Y" && t2.Effective == "Y" )
.Select((t1, t2, t3, t4) => new View_UTL_City
{
CityID = t2.CityID,
CityName=t2.CityName,
CountryID = t3.CountryID,
CountryName = t3.CountryName,
RegionID = t4.RegionID,
RegionName = t4.RegionName
}).OrderBy(t4 => t4.OrderByValue).ToList();
Dictionary<string, ServiceRegionDTO> RegionDic = new Dictionary<string, ServiceRegionDTO>();
foreach (var Location in saDataList)
{
ServiceRegionDTO Region = new ServiceRegionDTO();
Region.RegionID = Location.RegionID;
Region.RegionName = Location.RegionName;
if (!RegionDic.ContainsKey(Location.RegionID))
{
//包含洲
RegionDic.Add(Location.RegionID, Region);
}
ServiceCountryDTO Country = new ServiceCountryDTO();
Country.CountryID = Location.CountryID;
Country.CountryName = Location.CountryName;
if (!RegionDic[Location.RegionID].CountryDic.ContainsKey(Location.CountryID))
{
//包含國家
RegionDic[Location.RegionID].CountryDic.Add(Location.CountryID, Country);
}
CityDTO City = new CityDTO();
City.CityID = Location.CityID;
City.CityName = Location.CityName;
RegionDic[Location.RegionID].CountryDic[Location.CountryID].CityDic.Add(Location.CityID, City);
}
foreach (var Region in RegionDic.Values)
{
foreach (var Country in Region.CountryDic.Values)
{
foreach (var City in Country.CityDic.Values)
{
if (Country.CityList == null)
{
Country.CityList = new List<CityDTO>();
}
Country.CityList.Add(City);
}
if (Region.CountryList == null)
{
Region.CountryList = new List<ServiceCountryDTO>();
}
Country.CityDic = null;
Region.CountryList.Add(Country);
}
Region.CountryDic = null;
saLocationList.Add(Region);
}
return saLocationList;
} while (false);
}
catch (Exception ex)
{
}
return saLocationList;
}
//輪播圖片
public List<FileDTO> QueryBannerFileList(string sLanguageID, string sServiceID)
{
List<FileDTO> saFilePath = new List<FileDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
string requestUrl = Common.ConfigGetValue("", "ida:RedirectUri");
var objONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteBaseInfo>()
//搜尋條件
.Where(x => x.OrgID == sORIGID && x.ServiceID == sServiceID && x.LangID == sLanguageID)
.Single();
if (objONSiteBaseInfo != null && !string.IsNullOrEmpty(objONSiteBaseInfo.BannerFile)) {
saFilePath = db.Queryable<OTB_SYS_Files>()
.Where(x => x.ParentID == objONSiteBaseInfo.BannerFile && x.OrgID== sORIGID)
.Select(x => new FileDTO
{
FileID=x.FileID,
FileName=x.FileName,
FilePath=x.FilePath
})
.ToList();
if (saFilePath != null && saFilePath.Count > 0) {
foreach (var FileModel in saFilePath)
{
FileModel.FilePath = requestUrl + "/" + FileModel.FilePath.Replace("\\", "/");
}
}
}
return saFilePath;
} while (false);
}
catch (Exception ex)
{
}
return saFilePath;
}
//包裝類型
public List<ArgumentDTO> GetPackingTypes(string sLanguageID)
{
List<ArgumentDTO> saPackingTypes = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
saPackingTypes = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == sORIGID && x.Effective == "Y" && x.DelStatus == "N" && x.ArgumentClassID == "PackingType")
.Select(x => new ArgumentDTO
{
ArgumentID = x.ArgumentID,
ArgumentValue = x.ArgumentValue,
OrderByValue = x.OrderByValue
})
.OrderBy(x=>x.OrderByValue)
.ToList();
return saPackingTypes;
} while (false);
}
catch (Exception ex)
{
}
return saPackingTypes;
}
//領取地城市
public List<ArgumentDTO> GetTW(string sLanguageID)
{
List<ArgumentDTO> saTW = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
saTW = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == sORIGID && x.Effective == "Y" && x.DelStatus == "N" && x.ArgumentClassID == "TW")
.Select(x => new ArgumentDTO
{
ArgumentID = x.ArgumentID,
ArgumentValue = x.ArgumentValue,
OrderByValue = x.OrderByValue
})
.OrderBy(x => x.OrderByValue)
.ToList();
return saTW;
} while (false);
}
catch (Exception ex)
{
}
return saTW;
}
//服務項目
public List<ArgumentDTO> GetServiceItems(string sLanguageID, string sServiceID)
{
List<ArgumentDTO> saServiceItem = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
saServiceItem = db.Queryable<SETB_PDT_ONSiteItem, OTB_SYS_Arguments>((t1, t2) =>
new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.ItemType == t2.ArgumentID && t2.ArgumentClassID=="ServiceItem"
} )
.Where((t1, t2) => t1.Effective == "Y" && t1.LangID== sLanguageID && t1.OrgID== sORIGID && t1.ServiceID== sServiceID && t2.ArgumentClassID== "ServiceItem")
.Select((t1, t2) => new ArgumentDTO
{
ArgumentID =t1.Guid,
ItemType=t1.ItemType,
ArgumentValue = t2.ArgumentValue
})
.ToList();
return saServiceItem;
} while (false);
}
catch (Exception ex)
{
}
return saServiceItem;
}
//展覽年份
public List<ArgumentDTO> GetExtensionYears(string sLanguageID, string sServiceID)
{
List<ArgumentDTO> saExhibitionYear = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
var objONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteBaseInfo>()
//搜尋條件
.Where(x => x.OrgID == sORIGID && x.ServiceID == sServiceID && x.LangID == sLanguageID)
.Single();
if (objONSiteBaseInfo.ExhibitionID != "[]" && objONSiteBaseInfo.ExhibitionID != "")
{
saExhibitionYear = db.Queryable<SETB_CMS_Exhibition_Info>()
.Where((t1) => t1.LanguageID == sLanguageID && t1.OrgID== sORIGID && objONSiteBaseInfo.ExhibitionID.Contains(t1.ExhibitionID))
.Select((t1) => new ArgumentDTO
{
ArgumentID=t1.Year,
ArgumentValue=t1.Year
})
.OrderBy(x=>x.ArgumentID)
.ToList();
}
return saExhibitionYear;
} while (false);
}
catch (Exception ex)
{
}
return saExhibitionYear;
}
//展覽月份
public List<ArgumentDTO> GetExtensionMonths(string sLanguageID)
{
List<ArgumentDTO> saPackingTypes = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
saPackingTypes = db.Queryable<OTB_SYS_Arguments>()
.Where(x => x.OrgID == sORIGID && x.Effective == "Y" && x.DelStatus == "N" && x.ArgumentClassID == "ExtensionMonth")
.Select(x => new ArgumentDTO
{
ArgumentID = x.ArgumentID,
ArgumentValue = x.ArgumentValue,
OrderByValue = x.OrderByValue
})
.OrderBy(x => x.OrderByValue)
.ToList();
return saPackingTypes;
} while (false);
}
catch (Exception ex)
{
}
return saPackingTypes;
}
//展覽列表
public List<ArgumentDTO> QueryExhibitions(string sLanguageID, string sServiceID)
{
List<ArgumentDTO> saExhibition = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
var objONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteBaseInfo>()
//搜尋條件
.Where(x => x.OrgID == sORIGID && x.ServiceID == sServiceID && x.LangID== sLanguageID)
.Single();
if (objONSiteBaseInfo.ExhibitionID != "[]" && objONSiteBaseInfo.ExhibitionID != "")
{
saExhibition = db.Queryable<SETB_CMS_Exhibition>
()
.Where((t1) => t1.LanguageID == sLanguageID && objONSiteBaseInfo.ExhibitionID.Contains(t1.ExhibitionID))
.Select((t1) => new ArgumentDTO
{
ArgumentID=t1.ExhibitionID,
ArgumentValue = t1.ExhibitionName
})
.ToList();
}
return saExhibition;
} while (false);
}
catch (Exception ex)
{
}
return saExhibition;
}
//服務詳情
public ONSiteBaseInfoDTO GetOneOnsiteServiceInfo(string sLanguageID, string sServiceID)
{
ONSiteBaseInfoDTO objONSiteBaseInfo = new ONSiteBaseInfoDTO();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
objONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteBaseInfo,OTB_SYS_Arguments, OTB_SYS_Arguments,SETB_SCM_Supplier>((t1, t2,t3, t4) =>
new object[] {
JoinType.Left, t1.OrgID == t2.OrgID && t1.ConfirmDays == t2.ArgumentID && t2.ArgumentClassID=="OrderConfirmDays",
JoinType.Left, t1.OrgID == t3.OrgID && t1.CurrencyID == t3.ArgumentID && t3.ArgumentClassID=="Currency",
JoinType.Left, t1.OrgID == t4.OrgID && t1.SupplierID == t4.SupplierID && t1.LangID == t4.LangType
}
)
//搜尋條件
.Where((t1) => t1.OrgID == sORIGID && t1.ServiceID == sServiceID && t1.LangID == sLanguageID)
.Select((t1, t2, t3,t4) => new ONSiteBaseInfoDTO
{
ServiceID = t1.ServiceID,
ServiceNo=t1.ServiceNo,
ServiceName=t1.ServiceName,
ConfirmDays=t2.ArgumentValue,
ExhibitionID=t1.ExhibitionID,
CancelPolicy=t1.CancelPolicy,
Features=t1.Features,
Details=t1.Details,
MinPrice=t1.MinPrice,
CurrencyID=t1.CurrencyID,
CurrencyName=t3.ArgumentValue,
ExpenseDescription ="",
SupplierName=t4.CompanyName,
SupplierLogo=t4.LogoFile,
PreviewFile=t1.PreviewFile
}).Single();
//常見問題
var lstFQA = db.Queryable<SETB_PDT_ServiceByFQA>()
.Where(x => x.ServiceID == sServiceID && x.LangID == sLanguageID && x.Answer!="" && x.Question!="")
.OrderBy(x => x.CreateDate)
.Select(x => new FQADTO {
Question= x.Question,
Answer=x.Answer
})
.ToList();
objONSiteBaseInfo.FQAs = lstFQA;
//適用地區
var saSuitPlace = db.Queryable<SETB_PDT_ServiceBySuitPlace, SETB_SYS_Region, SETB_SYS_Country, SETB_UTL_City>
((t1, t2, t3, t4) =>
new object[] {
JoinType.Left, t1.RegionID == t2.RegionID && t1.LangID== t2.LangType ,
JoinType.Left, t1.CountryID == t3.CountryID && t1.LangID== t3.LangType ,
JoinType.Left, t1.CityID == t4.CityID && t1.LangID== t4.LangType
}
)
.Where((t1) => t1.LangID == sLanguageID && t1.ServiceID == sServiceID)
.Select((t1, t2, t3, t4) => new View_PDT_ServiceBySuitPlace
{
ServiceID = t1.ServiceID,
LangID = t1.LangID,
Guid = t1.Guid,
RegionID = t1.RegionID,
CountryID = t1.CountryID,
CityID = t1.CityID,
Name = SqlFunc.IsNull(SqlFunc.IsNull(t2.RegionName, t3.CountryName), t4.CityName)
})
.OrderBy(t1 => t1.RegionID)
.ToList();
var sSuitPlace = "";
if (saSuitPlace.Count > 0)
{
foreach (var SuitPlace in saSuitPlace)
{
sSuitPlace += SuitPlace.Name + ",";
}
objONSiteBaseInfo.SuitPlaces = sSuitPlace;
}
//適用展會
if (objONSiteBaseInfo.ExhibitionID != "[]" && objONSiteBaseInfo.ExhibitionID != "")
{
var saExhibition = db.Queryable<SETB_CMS_Exhibition>
()
.Where((t1) => t1.LanguageID == sLanguageID && objONSiteBaseInfo.ExhibitionID.Contains(t1.ExhibitionID))
.Select((t1) => new SETB_CMS_Exhibition
{
ExhibitionName = t1.ExhibitionName
})
.ToList();
var sExhibitionName = "";
if (saExhibition.Count > 0)
{
foreach (var Exhibition in saExhibition)
{
sExhibitionName += Exhibition.ExhibitionName + ",";
}
objONSiteBaseInfo.ExhibitionNames = sExhibitionName;
}
}
//服務領取地
var saServiceByOther = db.Queryable<SETB_PDT_ServiceByOther, SETB_SYS_Region, SETB_SYS_Country, SETB_UTL_City>
((t1, t2, t3, t4) =>
new object[] {
JoinType.Left, t1.CityID == t2.RegionID && t1.LangID== t2.LangType ,
JoinType.Left, t1.CityID == t3.CountryID && t1.LangID== t3.LangType ,
JoinType.Left, t1.CityID == t4.CityID && t1.LangID== t4.LangType ,
}
)
.Where((t1) => t1.LangID == sLanguageID && t1.ServiceID == sServiceID)
.Select((t1, t2, t3, t4) => new View_PDT_ServiceByOther
{
ServiceID = t1.ServiceID,
LangID = t1.LangID,
Guid = t1.Guid,
CityID = t1.CityID,
Address = t1.Address,
CusTitle = t1.CusTitle,
CityName = SqlFunc.IsNull(SqlFunc.IsNull(t2.RegionName, t3.CountryName), t4.CityName)
})
.OrderBy(t1 => t1.CreateDate)
.ToList();
var sReceivinPlaces = "";
if (saServiceByOther.Count > 0)
{
foreach (var ServiceByOther in saServiceByOther)
{
sReceivinPlaces += ServiceByOther.CityName + ",";
}
objONSiteBaseInfo.ReceivinPlaces = sReceivinPlaces;
}
string requestUrl = Common.ConfigGetValue("", "ida:RedirectUri");
if (!string.IsNullOrEmpty(objONSiteBaseInfo.SupplierLogo)) {
var oFilePath = db.Queryable<OTB_SYS_Files>()
.Where(x => x.ParentID == objONSiteBaseInfo.SupplierLogo && x.OrgID == sORIGID)
.Select(x => new FileDTO
{
FileID = x.FileID,
FileName = x.FileName,
FilePath = x.FilePath
})
.Single();
if (oFilePath != null)
{
objONSiteBaseInfo.SupplierLogo = requestUrl + "/" + oFilePath.FilePath.Replace("\\", "/");
}
}
if (!string.IsNullOrEmpty(objONSiteBaseInfo.PreviewFile))
{
var oFilePath = db.Queryable<OTB_SYS_Files>()
.Where(x => x.ParentID == objONSiteBaseInfo.PreviewFile && x.OrgID == sORIGID)
.Select(x => new FileDTO
{
FileID = x.FileID,
FileName = x.FileName,
FilePath = x.FilePath
})
.Single();
if (oFilePath != null)
{
objONSiteBaseInfo.PreviewFile = requestUrl + "/" + oFilePath.FilePath.Replace("\\", "/");
}
}
return objONSiteBaseInfo;
} while (false);
}
catch (Exception ex)
{
}
return objONSiteBaseInfo;
}
//服務費用List
public List<ONSiteItemDTO> GetOneOnsiteItem(string sLanguageID, string sServiceID)
{
List<ONSiteItemDTO> saONSiteItem = new List<ONSiteItemDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
saONSiteItem = db.Queryable<SETB_PDT_ONSiteItem, OTB_SYS_Arguments>
((t1, t2) =>
new object[] {
JoinType.Left, t1.ItemType == t2.ArgumentID && t2.ArgumentClassID == "ServiceItem" ,
}
)
.Where((t1, t2) => t1.LangID == sLanguageID && t1.ServiceID == sServiceID && t1.OrgID == sORIGID).
Select((t1, t2) => new ONSiteItemDTO
{
Guid=t1.Guid,
ItemType=t1.ItemType,
ItemName = t2.ArgumentValue,
ExpensesMemo=t1.ExpensesMemo,
EscortFreeCityID=t1.EscortFreeCityID,
CreateDate=t1.CreateDate
}).OrderBy(t1 => t1.CreateDate).ToList();
foreach (var objONSiteItem in saONSiteItem) {
if (objONSiteItem.ItemType == WebAppGlobalConstWord.STACKER)
{
//堆高機
var lstServiceCostRules = db.Queryable<SETB_PDT_ServiceCostRules>()
.Where(x => x.QSID == objONSiteItem.Guid)
.OrderBy(x => x.Weight_Min)
.Select(x => new ServiceCostRulesDTO { Guid = x.Guid, Weight_Min = x.Weight_Min, Weight_Max = x.Weight_Max, Price = x.Price, PricingMode = x.PricingMode, Memo = x.Memo, CreateDate = x.CreateDate })
.ToList();
int i = 1;
foreach (var ServiceCostRules in lstServiceCostRules)
{
ServiceCostRules.Index = i;
i++;
}
objONSiteItem.StackerCostRules = lstServiceCostRules;
objONSiteItem.TruckCostRules = null;
objONSiteItem.TruckHolidayPay = null;
objONSiteItem.TruckMarkupByModel = null;
objONSiteItem.OtherCostRules = null;
objONSiteItem.TruckEscortCostRules = null;
}
else if (objONSiteItem.ItemType == WebAppGlobalConstWord.TRUCK)
{
objONSiteItem.StackerCostRules = null;
objONSiteItem.OtherCostRules = null;
//卡車費用表
var lstServiceTruckCostRules = db.Queryable<SETB_PDT_ServiceTruckCostRules>()
.Where(x => x.QSID == objONSiteItem.Guid)
.Select(x => new ServiceTruckCostRulesDTO { TruckID = x.TruckID, CityID = x.CityID, Price = x.Price })
.ToList();
objONSiteItem.TruckCostRules = lstServiceTruckCostRules;
//假日加班費
var lstTruckHolidayPay = db.Queryable<SETB_PDT_ServiceTruckOtherCost>()
.Where(x => x.QSID == objONSiteItem.Guid && x.Type == "1")
.Select(x => new ServiceTruckOtherCostDTO { TruckID = x.TruckID, Price = x.Price })
.ToList();
objONSiteItem.TruckHolidayPay = lstTruckHolidayPay;
//車型加價
var lstTruckMarkupByModel = db.Queryable<SETB_PDT_ServiceTruckOtherCost>()
.Where(x => x.QSID == objONSiteItem.Guid && x.Type == "2")
.Select(x => new ServiceTruckOtherCostDTO { TruckID = x.TruckID, Price = x.Price })
.ToList();
objONSiteItem.TruckMarkupByModel = lstTruckMarkupByModel;
//卡車押車費用表
if (objONSiteItem.EscortFreeCityID != null) {
var lstTruckEscortCostRules = db.Queryable<SETB_PDT_ServiceTruckCostRules>()
.Where(x => x.QSID == objONSiteItem.Guid && x.CityID == objONSiteItem.EscortFreeCityID)
.Select(x => new ServiceTruckCostRulesDTO { TruckID = x.TruckID, CityID = x.CityID, Price = x.Price })
.ToList();
objONSiteItem.TruckEscortCostRules = lstTruckEscortCostRules;
}
}
else
{
//其他 非堆高機和卡車
objONSiteItem.TruckCostRules = null;
objONSiteItem.TruckHolidayPay = null;
objONSiteItem.TruckMarkupByModel = null;
objONSiteItem.StackerCostRules = null;
objONSiteItem.TruckEscortCostRules = null;
var lstONSiteOtherCostRules = db.Queryable<SETB_PDT_ONSiteOtherCostRules>()
.Where( x => x.ONSiteItemID == objONSiteItem.Guid)
.Select(x => new ONSiteOtherCostRulesDTO { Guid = x.Guid, PricingMode = x.PricingMode, Price = x.Price, InterbankPrice = x.InterbankPrice, Unit_Min = x.Unit_Min })
.ToList();
if (lstONSiteOtherCostRules.Count > 0) {
objONSiteItem.OtherCostRules = lstONSiteOtherCostRules;
var ONSiteOtherCostRulesDTOModel = lstONSiteOtherCostRules[0];
objONSiteItem.CostRuleText = string.Format("新台幣{0}元/立方米 (最低按 {1} 立方米計算)(以{2})(含稅)", int.Parse(ONSiteOtherCostRulesDTOModel.Price.ToString()).ToString("#,###"), ONSiteOtherCostRulesDTOModel.Unit_Min, (ONSiteOtherCostRulesDTOModel.PricingMode=="N"? "單件計min": "全部貨量計min")) ;
}
}
}
return saONSiteItem;
} while (false);
}
catch (Exception ex)
{
}
return saONSiteItem;
}
//卡車類型
public List<SETB_PDT_ServiceTruckInfo> GetTruckTypes(string sLanguageID)
{
List<SETB_PDT_ServiceTruckInfo> saPackingTypes = new List<SETB_PDT_ServiceTruckInfo>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
saPackingTypes = db.Queryable<SETB_PDT_ServiceTruckInfo>()
.Where(x => x.OrgID == sORIGID && x.Effective == "Y" )
.OrderBy(x => x.GoodsHeight)
.ToList();
return saPackingTypes;
} while (false);
}
catch (Exception ex)
{
}
return saPackingTypes;
}
//訂單問題List
public List<OrderQuestionDTO> GetOrderQuestions(string sLanguageID, string sServiceID)
{
List<OrderQuestionDTO> saServiceByOrderQuestion = new List<OrderQuestionDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
saServiceByOrderQuestion = db.Queryable<SETB_PDT_ServiceByOrderQuestion, SETB_SAL_Survey, OTB_SYS_Arguments>
((t1, t2, t3) =>
new object[] {
JoinType.Left, t1.QuestionID == t2.SurveyID ,
JoinType.Left, t2.AnswerType == t3.ArgumentID && t3.ArgumentClassID == "AnswerType"
}
)
.Where((t1) => t1.LangID == sLanguageID && t1.ServiceID == sServiceID)
.Where((t1) => t1.PlanID == null && t1.AddFlag == null)
.Select((t1, t2, t3) => new OrderQuestionDTO
{
ServiceID = t1.ServiceID,
QuestionID = t1.QuestionID,
RequiredFlag = t1.RequiredFlag,
LangID = t1.LangID,
SurveyName = t2.SurveyName,
Answer = t3.ArgumentValue,
AnswerType = t2.AnswerType
})
.OrderBy(t1 => t1.QuestionID)
.ToList();
return saServiceByOrderQuestion;
} while (false);
}
catch (Exception ex)
{
}
return saServiceByOrderQuestion;
}
//服務支付方式
public List<ArgumentDTO> GetPayTypes(string sLanguageID, string sServiceID)
{
List<ArgumentDTO> saPayTypes = new List<ArgumentDTO>();
var db = SugarBase.GetIntance();
try
{
do
{
var sORIGID = WebAppGlobalConstWord.TG_ORGID;
var objONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteBaseInfo>()
//搜尋條件
.Where(x => x.OrgID == sORIGID && x.ServiceID == sServiceID && x.LangID == sLanguageID)
.Single();
if (objONSiteBaseInfo != null && !string.IsNullOrEmpty(objONSiteBaseInfo.PayType))
{
if (objONSiteBaseInfo.PayType.Contains("1")) {
saPayTypes.Add(new ArgumentDTO() { ArgumentID = "1", ArgumentValue = "信用卡付款" });
}
if (objONSiteBaseInfo.PayType.Contains("2"))
{
saPayTypes.Add(new ArgumentDTO() { ArgumentID = "2", ArgumentValue = "銀行匯款" });
}
if (objONSiteBaseInfo.PayType.Contains("3"))
{
saPayTypes.Add(new ArgumentDTO() { ArgumentID = "3", ArgumentValue = "現場付款" });
}
saPayTypes = saPayTypes.OrderBy(x => x.ArgumentID).ToList();
}
return saPayTypes;
} while (false);
}
catch (Exception ex)
{
}
return saPayTypes;
}
//QueryALLOnSiteServiceAsDic
public Dictionary<string, View_PDT_ONSiteBaseInfo> FindAllByIDsAsDictionary(string sLanguageID, string ServiceID)
{
string sMsg = null;
var db = SugarBase.GetIntance();
Dictionary<string, View_PDT_ONSiteBaseInfo> saServiceDic = new Dictionary<string, View_PDT_ONSiteBaseInfo>();
try
{
do
{
if (string.IsNullOrEmpty(sLanguageID)) {
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
}
var saServiceList = db.Queryable<SETB_PDT_ONSiteBaseInfo>()
.Where(t1 => t1.Effective == "Y")
.Where(t1 => t1.LangID == sLanguageID)
.WhereIF(!string.IsNullOrEmpty(ServiceID), t1 => t1.ServiceID == ServiceID)
.Select((t1) => new View_PDT_ONSiteBaseInfo
{
ServiceID = SqlFunc.GetSelfAndAutoFill(t1.ServiceID)
})
.ToList();
foreach (var service in saServiceList)
{
saServiceDic[service.ServiceID] = service;
}
return saServiceDic;
} while (false);
}
catch (Exception ex)
{
sMsg = Util.GetLastExceptionMsg(ex);
}
return saServiceDic;
}
public Dictionary<string, View_PDT_ONSiteBaseInfo> FindAllDetailByIDsAsDictionary(string sLanguageID, string ServiceID) {
var OnSiteServiceDic = FindAllByIDsAsDictionary(sLanguageID, ServiceID);
SupplierMaintain_QryService sm_qry = new SupplierMaintain_QryService();
var SupplierDic = sm_qry.FindAllByIDsAsDictionary(sLanguageID);
foreach (var OnSiteService in OnSiteServiceDic.Values) {
if (!string.IsNullOrEmpty(OnSiteService.SupplierID)) {
if (SupplierDic.ContainsKey(OnSiteService.SupplierID)) {
var rsSupplier = SupplierDic[OnSiteService.SupplierID];
OnSiteServiceDic[OnSiteService.ServiceID].SupplierName = rsSupplier.CompanyName;
}
}
}
return OnSiteServiceDic;
}
}
}