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.

584 lines
26 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using Entity.ViewModels;
  4. using SqlSugar;
  5. using SqlSugar.Base;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Web;
  9. namespace EasyBL.WEBSITE.Com
  10. {
  11. public class ComService : ServiceBase
  12. {
  13. #region 獲取組織信息
  14. /// <summary>
  15. /// 獲取組織信息
  16. /// </summary>
  17. /// <param name="i_crm"></param>
  18. /// <returns></returns>
  19. public ResponseMessage GetOrgInfo(RequestMessage i_crm)
  20. {
  21. ResponseMessage rm = null;
  22. string sMsg = null;
  23. var db = SugarBase.DB;
  24. try
  25. {
  26. do
  27. {
  28. var sdb = new SimpleClient<OTB_SYS_Organization>(db);
  29. var oOrg = sdb.GetById(i_crm.ORIGID);
  30. rm = new SuccessResponseMessage(null, i_crm);
  31. rm.DATA.Add(BLWording.REL, oOrg);
  32. } while (false);
  33. }
  34. catch (Exception ex)
  35. {
  36. sMsg = Util.GetLastExceptionMsg(ex);
  37. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetOrgInfo(獲取組織信息)", "", "", "");
  38. }
  39. finally
  40. {
  41. if (null != sMsg)
  42. {
  43. rm = new ErrorResponseMessage(sMsg, i_crm);
  44. }
  45. }
  46. return rm;
  47. }
  48. #endregion 獲取組織信息
  49. #region 官網設定(分頁查詢)
  50. /// <summary>
  51. /// 官網設定(分頁查詢)
  52. /// </summary>
  53. /// <param name="i_crm"></param>
  54. /// <returns></returns>
  55. public ResponseMessage GetWebSiteSettingPage(RequestMessage i_crm)
  56. {
  57. ResponseMessage rm = null;
  58. string sMsg = null;
  59. var db = SugarBase.GetIntance();
  60. try
  61. {
  62. do
  63. {
  64. var pml = new PageModel
  65. {
  66. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  67. PageSize = _fetchInt(i_crm, @"pageSize")
  68. };
  69. var iPageCount = 0;
  70. var sSetType = _fetchString(i_crm, @"SetType");
  71. var sLangId = _fetchString(i_crm, @"LangId");
  72. var sParentId = _fetchString(i_crm, @"ParentId");
  73. var bOnlyParent = _fetchBool(i_crm, @"OnlyParent");
  74. pml.DataList = db.Queryable<OTB_WSM_WebSiteSetting, OTB_SYS_Files, OTB_SYS_Files, OTB_SYS_Files>((t1, t2, t3, t4) =>
  75. new object[] {
  76. JoinType.Left, t1.OrgID == t2.OrgID && t1.IconId == t2.ParentID,
  77. JoinType.Left, t1.OrgID == t3.OrgID && t1.SubIconId == t3.ParentID,
  78. JoinType.Left, t1.OrgID == t4.OrgID && t1.CoverId == t4.ParentID
  79. })
  80. .Where((t1, t2, t3, t4) => t1.OrgID == i_crm.ORIGID && t1.SetType == sSetType && t1.LangId == i_crm.LANG && t1.Active)
  81. .WhereIF(!string.IsNullOrEmpty(sParentId), (t1, t2, t3, t4) => t1.ParentId == sParentId)
  82. .WhereIF(bOnlyParent, (t1, t2, t3, t4) => !SqlFunc.HasValue(t1.ParentId))
  83. .Select((t1, t2, t3, t4) => new View_WSM_WebSiteSetting
  84. {
  85. Guid = SqlFunc.GetSelfAndAutoFill(t1.Guid),
  86. IconFileName = t2.FileName,
  87. IconFilePath = t2.FilePath,
  88. SubIconFileName = t3.FileName,
  89. SubIconFilePath = t3.FilePath,
  90. CoverFileName = t4.FileName,
  91. CoverPath = t4.FilePath
  92. })
  93. .OrderBy("t1.ParentId,t1.OrderByValue", "asc")
  94. .ToPageList(pml.PageIndex, pml.PageSize, ref iPageCount);
  95. pml.Total = iPageCount;
  96. rm = new SuccessResponseMessage(null, i_crm);
  97. rm.DATA.Add(BLWording.REL, pml);
  98. } while (false);
  99. }
  100. catch (Exception ex)
  101. {
  102. sMsg = Util.GetLastExceptionMsg(ex);
  103. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetWebSiteSettingPage(官網設定(分頁查詢))", "", "", "");
  104. }
  105. finally
  106. {
  107. if (null != sMsg)
  108. {
  109. rm = new ErrorResponseMessage(sMsg, i_crm);
  110. }
  111. }
  112. return rm;
  113. }
  114. #endregion 官網設定(分頁查詢)
  115. #region 官網設定(多筆)
  116. /// <summary>
  117. /// 官網設定(多筆)
  118. /// </summary>
  119. /// <param name="i_crm"></param>
  120. /// <returns></returns>
  121. public ResponseMessage GetWebSiteSetting(RequestMessage i_crm)
  122. {
  123. ResponseMessage rm = null;
  124. string sMsg = null;
  125. var db = SugarBase.GetIntance();
  126. try
  127. {
  128. do
  129. {
  130. var sSetType = _fetchString(i_crm, @"SetType");
  131. var sLangId = _fetchString(i_crm, @"LangId");
  132. var sParentId = _fetchString(i_crm, @"ParentId");
  133. var bHasChild = _fetchBool(i_crm, @"HasChild");
  134. var bSingle = _fetchBool(i_crm, @"Single");
  135. var saWebSiteSetting = db.Queryable<OTB_WSM_WebSiteSetting, OTB_SYS_Files, OTB_SYS_Files, OTB_SYS_Files>((t1, t2, t3, t4) =>
  136. new object[] {
  137. JoinType.Left, t1.OrgID == t2.OrgID && t1.IconId == t2.ParentID,
  138. JoinType.Left, t1.OrgID == t3.OrgID && t1.SubIconId == t3.ParentID,
  139. JoinType.Left, t1.OrgID == t4.OrgID && t1.CoverId == t4.ParentID
  140. })
  141. .Where((t1, t2, t3, t4) => t1.OrgID == i_crm.ORIGID && t1.SetType == sSetType && t1.LangId == sLangId && t1.Active)
  142. .WhereIF(!bSingle && !string.IsNullOrEmpty(sParentId), (t1, t2, t3, t4) => t1.ParentId == sParentId)
  143. .WhereIF(!bSingle && string.IsNullOrEmpty(sParentId), (t1, t2, t3, t4) => !SqlFunc.HasValue(t1.ParentId))
  144. .WhereIF(bSingle, (t1, t2, t3, t4) => t1.Guid == sParentId)
  145. .Select((t1, t2, t3, t4) => new View_WSM_WebSiteSetting
  146. {
  147. Guid = SqlFunc.GetSelfAndAutoFill(t1.Guid),
  148. IconFileName = t2.FileName,
  149. IconFilePath = t2.FilePath,
  150. SubIconFileName = t3.FileName,
  151. SubIconFilePath = t3.FilePath,
  152. CoverFileName = t4.FileName,
  153. CoverPath = t4.FilePath
  154. })
  155. .OrderBy("t1.ParentId,t1.OrderByValue", "asc")
  156. .ToList();
  157. if (bHasChild)
  158. {
  159. var saWebSiteSetting_Child = db.Queryable<OTB_WSM_WebSiteSetting, OTB_SYS_Files, OTB_SYS_Files, OTB_SYS_Files>((t1, t2, t3, t4) =>
  160. new object[] {
  161. JoinType.Left, t1.OrgID == t2.OrgID && t1.IconId == t2.ParentID,
  162. JoinType.Left, t1.OrgID == t3.OrgID && t1.SubIconId == t3.ParentID,
  163. JoinType.Left, t1.OrgID == t4.OrgID && t1.CoverId == t4.ParentID
  164. })
  165. .Where((t1, t2, t3, t4) => t1.OrgID == i_crm.ORIGID && t1.SetType == sSetType && t1.LangId == sLangId && t1.Active && SqlFunc.HasValue(t1.ParentId))
  166. .Select((t1, t2, t3, t4) => new View_WSM_WebSiteSetting
  167. {
  168. Guid = SqlFunc.GetSelfAndAutoFill(t1.Guid),
  169. IconFileName = t2.FileName,
  170. IconFilePath = t2.FilePath,
  171. SubIconFileName = t3.FileName,
  172. SubIconFilePath = t3.FilePath,
  173. CoverFileName = t4.FileName,
  174. CoverPath = t4.FilePath
  175. })
  176. .OrderBy(t1 => t1.OrderByValue)
  177. .ToList();
  178. foreach (var setting in saWebSiteSetting)
  179. {
  180. setting.Infos = saWebSiteSetting_Child.FindAll(x => x.ParentId == setting.Guid);
  181. }
  182. }
  183. rm = new SuccessResponseMessage(null, i_crm);
  184. if (bSingle)
  185. {
  186. rm.DATA.Add(BLWording.REL, saWebSiteSetting[0]);
  187. }
  188. else
  189. {
  190. rm.DATA.Add(BLWording.REL, saWebSiteSetting);
  191. }
  192. } while (false);
  193. }
  194. catch (Exception ex)
  195. {
  196. sMsg = Util.GetLastExceptionMsg(ex);
  197. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetWebSiteSetting(官網設定(多筆))", "", "", "");
  198. }
  199. finally
  200. {
  201. if (null != sMsg)
  202. {
  203. rm = new ErrorResponseMessage(sMsg, i_crm);
  204. }
  205. }
  206. return rm;
  207. }
  208. #endregion 官網設定(多筆)
  209. #region 獲取最新消息分頁資料
  210. /// <summary>
  211. /// 獲取最新消息分頁資料
  212. /// </summary>
  213. /// <param name="i_crm"></param>
  214. /// <returns></returns>
  215. public ResponseMessage GetNewsPage(RequestMessage i_crm)
  216. {
  217. ResponseMessage rm = null;
  218. string sMsg = null;
  219. var db = SugarBase.DB;
  220. try
  221. {
  222. do
  223. {
  224. var pml = new PageModel
  225. {
  226. PageIndex = _fetchInt(i_crm, "pageIndex"),
  227. PageSize = _fetchInt(i_crm, "pageSize")
  228. };
  229. var iPageCount = 0;
  230. var sNewsType = _fetchString(i_crm, "NewsType");
  231. pml.DataList = db.Queryable<OTB_WSM_News, OTB_SYS_Files>((t1, t2) =>
  232. new object[] {
  233. JoinType.Left,t1.OrgID==t2.OrgID && t1.News_Pic==t2.ParentID
  234. })
  235. .OrderBy((t1) => t1.OrderByValue)
  236. .Where((t1) => t1.OrgID == i_crm.ORIGID && t1.News_Type == sNewsType && t1.News_Show == "Y" && t1.News_LanguageType == i_crm.LANG)
  237. .Select((t1, t2) => new { t1.SN, t1.News_Title, t1.CreateDate, t1.NewsContent, News_PicPath = t2.FilePath })
  238. .ToPageList(pml.PageIndex, pml.PageSize, ref iPageCount);
  239. pml.Total = iPageCount;
  240. rm = new SuccessResponseMessage(null, i_crm);
  241. rm.DATA.Add(BLWording.REL, pml);
  242. } while (false);
  243. }
  244. catch (Exception ex)
  245. {
  246. sMsg = Util.GetLastExceptionMsg(ex);
  247. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetNewsPage(獲取最新消息分頁資料)", "", "", "");
  248. }
  249. finally
  250. {
  251. if (null != sMsg)
  252. {
  253. rm = new ErrorResponseMessage(sMsg, i_crm);
  254. }
  255. }
  256. return rm;
  257. }
  258. #endregion 獲取最新消息分頁資料
  259. #region 獲取展覽資訊分頁資料
  260. /// <summary>
  261. /// 獲取展覽資訊分頁資料
  262. /// </summary>
  263. /// <param name="i_crm"></param>
  264. /// <returns></returns>
  265. public ResponseMessage GetExhibitionPage(RequestMessage i_crm)
  266. {
  267. ResponseMessage rm = null;
  268. string sMsg = null;
  269. var db = SugarBase.DB;
  270. try
  271. {
  272. do
  273. {
  274. var pml = new PageModel
  275. {
  276. PageIndex = _fetchInt(i_crm, "pageIndex"),
  277. PageSize = _fetchInt(i_crm, "pageSize")
  278. };
  279. var iPageCount = 0;
  280. var sIsShowWebSim = _fetchString(i_crm, "IsShowWebSim");
  281. var bTop = _fetchBool(i_crm, "Top");
  282. var sKeyWords = _fetchString(i_crm, "KeyWords");
  283. var sArea = _fetchString(i_crm, "Area");
  284. var sDateStart = _fetchString(i_crm, "DateStart");
  285. var sDateEnd = _fetchString(i_crm, "DateEnd");
  286. var sNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
  287. pml.DataList = db.Queryable<OTB_OPM_Exhibition, OTB_SYS_Files, OTB_SYS_Arguments, OTB_SYS_Arguments>((t1, t2, t3, t4) => new object[] {
  288. JoinType.Left,t1.OrgID == t2.OrgID && t1.LogoFileId == t2.ParentID,
  289. JoinType.Left,t1.OrgID == t3.OrgID && t1.ExhibitionAddress == t3.ArgumentID && t3.ArgumentClassID == "Area" && t3.LevelOfArgument == 2,
  290. JoinType.Left,t1.OrgID == t4.OrgID && t1.State == t4.ArgumentID && t4.ArgumentClassID == "Area" && t4.LevelOfArgument == 1})
  291. .OrderBy((t1, t2) => t1.ExhibitionDateStart, OrderByType.Asc)
  292. .Where((t1, t2) => t1.OrgID == i_crm.ORIGID && t1.IsShowWebSite == "Y" && t1.Effective == "Y")
  293. //.WhereIF(!string.IsNullOrEmpty(sIsShowWebSim), (t1) => t1.OrgID == i_crm.ORIGID && t1.IsShowWebSim == "Y")
  294. .WhereIF(bTop, (t1) => t1.ExhibitionDateEnd >= DateTime.Now.Date)
  295. .WhereIF(!string.IsNullOrEmpty(sKeyWords), (t1) => (t1.Exhibitioname_TW.Contains(sKeyWords) || t1.Exhibitioname_EN.Contains(sKeyWords)))
  296. .WhereIF(!string.IsNullOrEmpty(sArea), (t1) => t1.State == sArea)
  297. .WhereIF(!string.IsNullOrEmpty(sDateStart) && string.IsNullOrEmpty(sDateEnd), (t1) => t1.ExhibitionDateEnd >= SqlFunc.ToDate(sDateStart))
  298. .WhereIF(!string.IsNullOrEmpty(sDateEnd) && string.IsNullOrEmpty(sDateStart), (t1) => t1.ExhibitionDateStart <= SqlFunc.ToDate(sDateEnd))
  299. .WhereIF(!string.IsNullOrEmpty(sDateStart) && !string.IsNullOrEmpty(sDateEnd), (t1) => t1.ExhibitionDateStart <= SqlFunc.ToDate(sDateEnd) && t1.ExhibitionDateEnd >= SqlFunc.ToDate(sDateStart))
  300. .Select((t1, t2, t3, t4) => new
  301. {
  302. t1.SN,
  303. t1.State,
  304. t1.ExhibitionAddress,
  305. t1.Exhibitioname_TW,
  306. t1.Exhibitioname_EN,
  307. t1.ExhibitionDateStart,
  308. t1.ExhibitionDateEnd,
  309. ExhibitionAddressName = t3.ArgumentValue,
  310. StateName = t4.ArgumentValue,
  311. ExhibitionAddressName_EN = t3.ArgumentValue_EN,
  312. StateName_EN = t4.ArgumentValue_EN,
  313. LogoFilePath = t2.FilePath
  314. }).ToPageList(pml.PageIndex, pml.PageSize, ref iPageCount);
  315. pml.Total = iPageCount;
  316. rm = new SuccessResponseMessage(null, i_crm);
  317. rm.DATA.Add(BLWording.REL, pml);
  318. } while (false);
  319. }
  320. catch (Exception ex)
  321. {
  322. sMsg = Util.GetLastExceptionMsg(ex);
  323. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetExhibitionPage(獲取展覽資訊分頁資料)", "", "", "");
  324. }
  325. finally
  326. {
  327. if (null != sMsg)
  328. {
  329. rm = new ErrorResponseMessage(sMsg, i_crm);
  330. }
  331. }
  332. return rm;
  333. }
  334. #endregion 獲取展覽資訊分頁資料
  335. #region 獲取最新消息分明細
  336. /// <summary>
  337. /// 獲取最新消息分明細
  338. /// </summary>
  339. /// <param name="i_crm"></param>
  340. /// <returns></returns>
  341. public ResponseMessage GetNewsInfo(RequestMessage i_crm)
  342. {
  343. ResponseMessage rm = null;
  344. string sMsg = null;
  345. var db = SugarBase.GetIntance();
  346. try
  347. {
  348. do
  349. {
  350. var iId = _fetchInt(i_crm, "Id");
  351. var bIncludeFiles = _fetchBool(i_crm, "IncludeFiles");
  352. var saNews = db.Queryable<OTB_WSM_News>().Where(x => x.OrgID == i_crm.ORIGID && x.SN == iId).ToList();
  353. rm = new SuccessResponseMessage(null, i_crm);
  354. rm.DATA.Add(BLWording.REL, saNews);
  355. if (bIncludeFiles && saNews.Count > 0)
  356. {
  357. var saFiles = db.Queryable<OTB_SYS_Files>().Where(x => x.OrgID == i_crm.ORIGID && x.ParentID == saNews[0].PicShowId).ToList();
  358. rm.DATA.Add("files", saFiles);
  359. }
  360. } while (false);
  361. }
  362. catch (Exception ex)
  363. {
  364. sMsg = Util.GetLastExceptionMsg(ex);
  365. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetNewsInfo(獲取最新消息分明細)", "", "", "");
  366. }
  367. finally
  368. {
  369. if (null != sMsg)
  370. {
  371. rm = new ErrorResponseMessage(sMsg, i_crm);
  372. }
  373. }
  374. return rm;
  375. }
  376. #endregion 獲取最新消息分明細
  377. #region 客戶寄送郵件
  378. /// <summary>
  379. /// 客戶寄送郵件
  380. /// </summary>
  381. /// <param name="i_crm"></param>
  382. /// <returns></returns>
  383. public ResponseMessage SendMail(RequestMessage i_crm)
  384. {
  385. ResponseMessage rm = null;
  386. string sMsg = null;
  387. var bSend = false;
  388. var db = SugarBase.GetIntance();
  389. try
  390. {
  391. do
  392. {
  393. var sFlag = _fetchString(i_crm, "flag");
  394. var sCaptcha = "";
  395. if (HttpContext.Current.Session[BLWording.CAPTCHA + sFlag] != null)
  396. {
  397. sCaptcha = HttpContext.Current.Session[BLWording.CAPTCHA + sFlag].ToString();
  398. }
  399. var sValidcode = _fetchString(i_crm, "validcode");
  400. if (sCaptcha != sValidcode)
  401. {
  402. sMsg = "驗證碼錯誤";
  403. break;
  404. }
  405. var oWebSiteMailLog = new OTB_WSM_WebSiteMailLog
  406. {
  407. OrgID = i_crm.ORIGID,
  408. Type = _fetchString(i_crm, "type"),
  409. Ucomp = _fetchString(i_crm, "ucomp"),
  410. Uname = _fetchString(i_crm, "uname"),
  411. Utel = _fetchString(i_crm, "utel"),
  412. Uemail = _fetchString(i_crm, "uemail"),
  413. Title = _fetchString(i_crm, "utitle"),
  414. Content = _fetchString(i_crm, "umailcontent"),
  415. CreateDate = DateTime.Now,
  416. ModifyDate = DateTime.Now
  417. };
  418. var sCusCommentsEmail = Common.GetSystemSetting(db, i_crm.ORIGID, "CusCommentsEmail");
  419. //獲取Email郵件格式
  420. var oEmailTempl = db.Queryable<OTB_SYS_Email>().Single(it => it.OrgID == i_crm.ORIGID && it.EmailID == "CusComments");
  421. if (oEmailTempl != null)
  422. {
  423. //寄信開始
  424. var sEmailBody = oEmailTempl.BodyHtml.Replace("{{:ucomp}}", oWebSiteMailLog.Ucomp)
  425. .Replace("{{:uname}}", oWebSiteMailLog.Uname)
  426. .Replace("{{:uemail}}", oWebSiteMailLog.Uemail)
  427. .Replace("{{:utel}}", oWebSiteMailLog.Utel)
  428. .Replace("{{:utitle}}", oWebSiteMailLog.Title)
  429. .Replace("{{:umailcontent}}", oWebSiteMailLog.Content);
  430. var oEmail = new Emails();
  431. var saEmailTo = new List<EmailTo>(); //收件人
  432. var oEmailTo = new EmailTo
  433. {
  434. ToUserID = sCusCommentsEmail,
  435. ToUserName = sCusCommentsEmail,
  436. ToEmail = sCusCommentsEmail,
  437. Type = "to"
  438. };
  439. saEmailTo.Add(oEmailTo);
  440. oEmail.FromUserName = "系統郵件";//取fonfig
  441. oEmail.Title = oWebSiteMailLog.Type == null ? oEmailTempl.EmailSubject : (oWebSiteMailLog.Type == "C" ? "一般詢問" : "線上詢價");//取fonfig
  442. oEmail.EmailBody = sEmailBody;
  443. oEmail.IsCCSelf = false;
  444. oEmail.Attachments = null;
  445. oEmail.EmailTo = saEmailTo;
  446. bSend = new MailService(i_crm.ORIGID, true).MailFactory(oEmail, out sMsg);
  447. if (bSend || oWebSiteMailLog.Content.IndexOf("***TEST***") > -1)
  448. {
  449. db.Insertable(oWebSiteMailLog).ExecuteCommand();
  450. }
  451. }
  452. rm = new SuccessResponseMessage(null, i_crm);
  453. rm.DATA.Add(BLWording.REL, bSend);
  454. } while (false);
  455. }
  456. catch (Exception ex)
  457. {
  458. sMsg = Util.GetLastExceptionMsg(ex);
  459. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WebSite.TE.ComService", "客戶寄送郵件", nameof(SendMail), "", "", "");
  460. }
  461. finally
  462. {
  463. if (null != sMsg)
  464. {
  465. rm = new ErrorResponseMessage(sMsg, i_crm);
  466. }
  467. }
  468. return rm;
  469. }
  470. #endregion 客戶寄送郵件
  471. #region 依據展覽獲取展覽報價規則
  472. /// <summary>
  473. /// 依據展覽獲取展覽報價規則
  474. /// </summary>
  475. /// <param name="i_crm"></param>
  476. /// <returns></returns>
  477. public ResponseMessage GetExhibitionRules(RequestMessage i_crm)
  478. {
  479. ResponseMessage rm = null;
  480. string sMsg = null;
  481. var db = SugarBase.GetIntance();
  482. try
  483. {
  484. do
  485. {
  486. var iId = _fetchInt(i_crm, "Id");
  487. var oRules = db.Queryable<OTB_WSM_ExhibitionRules, OTB_OPM_Exhibition, OTB_SYS_Arguments>((t1, t2, t3) => t1.OrgID == t2.OrgID && t1.Guid == t2.CostRulesId && t1.OrgID == t3.OrgID && t1.Currency == t3.ArgumentID && t3.ArgumentClassID == "Currency")
  488. .Where((t1, t2) => t2.SN == iId)
  489. .Select((t1, t2, t3) => new View_WSM_ExhibitionRules
  490. {
  491. Guid = t1.Guid,
  492. FileId_EN = t1.FileId_EN,
  493. Title = t1.Title,
  494. CostRules = t1.CostRules,
  495. PackingPrice = t1.PackingPrice,
  496. FeedingPrice = t1.FeedingPrice,
  497. StoragePrice = t1.StoragePrice,
  498. FeedingRequiredMinCBM = t1.FeedingRequiredMinCBM,
  499. FeedingMinMode = t1.FeedingMinMode,
  500. PackingRequiredMinCBM = t1.PackingRequiredMinCBM,
  501. PackingMinMode = t1.PackingMinMode,
  502. CostInstruction = t1.CostInstruction,
  503. CostInstruction_EN = t1.CostInstruction_EN,
  504. IsMerge = t1.IsMerge,
  505. Memo = t1.Memo,
  506. ServiceInstruction = t1.ServiceInstruction,
  507. ServiceInstruction_EN = t1.ServiceInstruction_EN,
  508. Currency = t1.Currency,
  509. CurrencyName = t3.ArgumentValue,
  510. CurrencyName_EN = t3.ArgumentValue_EN,
  511. }).Single();
  512. var saFiles = new List<OTB_SYS_Files>();
  513. if (i_crm.LANG == "en")
  514. {
  515. saFiles = db.Queryable<OTB_SYS_Files>().OrderBy(x => x.OrderByValue).Where(x => x.ParentID == oRules.FileId_EN).ToList();
  516. }
  517. else
  518. {
  519. saFiles = db.Queryable<OTB_SYS_Files>().OrderBy(x => x.OrderByValue).Where(x => x.ParentID == oRules.Guid).ToList();
  520. }
  521. oRules.Files = saFiles;
  522. rm = new SuccessResponseMessage(null, i_crm);
  523. rm.DATA.Add(BLWording.REL, oRules);
  524. } while (false);
  525. }
  526. catch (Exception ex)
  527. {
  528. sMsg = Util.GetLastExceptionMsg(ex);
  529. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, "EasyBL.WEBSITE.Com.ComService", "", "GetExhibitionRules(依據展覽獲取展覽報價規則)", "", "", "");
  530. }
  531. finally
  532. {
  533. if (null != sMsg)
  534. {
  535. rm = new ErrorResponseMessage(sMsg, i_crm);
  536. }
  537. }
  538. return rm;
  539. }
  540. #endregion 依據展覽獲取展覽報價規則
  541. }
  542. }