|
@@ -42,6 +42,7 @@ using TEAMModelOS.SDK.DI.IPIP;
|
|
|
using Azure;
|
|
|
using Microsoft.AspNetCore.Http.HttpResults;
|
|
|
using System.Net;
|
|
|
+using System.Dynamic;
|
|
|
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BICommon
|
|
@@ -455,14 +456,14 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
//取得ID帳號中所有的歸戶學校ID
|
|
|
List<string> coreSchIds = new List<string>();
|
|
|
Dictionary<string, List<string>> schTmidDic = new Dictionary<string, List<string>>(); //學校ID > TMID 字典
|
|
|
- string sqlEx = "SELECT c.id, c.schoolCode, c.schoolCodeW FROM c WHERE IS_DEFINED(c.schoolCode) AND NOT IS_NULL(c.schoolCode) AND IS_DEFINED(c.schoolCodeW) AND NOT IS_NULL(c.schoolCodeW)";
|
|
|
- if (hasMail) sqlEx += " AND IS_DEFINED(c.mail) AND NOT IS_NULL(c.mail) ";
|
|
|
+ string sqlEx = "SELECT c.id, c.schoolCode, c.schoolCodeW FROM c WHERE ((IS_DEFINED(c.schoolCode) AND NOT IS_NULL(c.schoolCode)) OR (IS_DEFINED(c.schoolCodeW) AND NOT IS_NULL(c.schoolCodeW)))";
|
|
|
+ if (hasMail) sqlEx += " AND (IS_DEFINED(c.mail) AND NOT IS_NULL(c.mail)) ";
|
|
|
await foreach (var item in cosmosClientCsv2.GetContainer("Core", "ID2").GetItemQueryIteratorSql<JsonElement>(queryText: sqlEx, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"base-ex") }))
|
|
|
{
|
|
|
string tmid = item.GetProperty("id").ToString();
|
|
|
- string shortCode = (item.TryGetProperty("shortCode", out JsonElement _shortCode)) ? _shortCode.ToString() : string.Empty;
|
|
|
+ string schoolCode = (item.TryGetProperty("schoolCode", out JsonElement _schoolCode)) ? _schoolCode.ToString() : string.Empty;
|
|
|
string schoolCodeW = (item.TryGetProperty("schoolCodeW", out JsonElement _schoolCodeW)) ? _schoolCodeW.ToString() : string.Empty;
|
|
|
- string schId = (!string.IsNullOrWhiteSpace(shortCode)) ? shortCode : (!string.IsNullOrWhiteSpace(schoolCodeW)) ? schoolCodeW : string.Empty;
|
|
|
+ string schId = (!string.IsNullOrWhiteSpace(schoolCode)) ? schoolCode : (!string.IsNullOrWhiteSpace(schoolCodeW)) ? schoolCodeW : string.Empty;
|
|
|
if (!string.IsNullOrWhiteSpace(schId))
|
|
|
{
|
|
|
if(!coreSchIds.Contains(schId)) coreSchIds.Add(schId);
|
|
@@ -1484,14 +1485,14 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
List<string> coreSchIds = new List<string>();
|
|
|
Dictionary<string, List<string>> schTmidDic = new Dictionary<string, List<string>>(); //學校ID > TMID 字典
|
|
|
//取得有歸戶的所有TMID
|
|
|
- string sqlEx = "SELECT c.id, c.schoolCode, c.schoolCodeW FROM c WHERE IS_DEFINED(c.schoolCode) AND NOT IS_NULL(c.schoolCode) AND IS_DEFINED(c.schoolCodeW) AND NOT IS_NULL(c.schoolCodeW)";
|
|
|
- if (hasMail) sqlEx += " AND IS_DEFINED(c.mail) AND NOT IS_NULL(c.mail) ";
|
|
|
+ string sqlEx = "SELECT c.id, c.schoolCode, c.schoolCodeW FROM c WHERE ((IS_DEFINED(c.schoolCode) AND NOT IS_NULL(c.schoolCode)) OR (IS_DEFINED(c.schoolCodeW) AND NOT IS_NULL(c.schoolCodeW)))";
|
|
|
+ if (hasMail) sqlEx += " AND (IS_DEFINED(c.mail) AND NOT IS_NULL(c.mail)) ";
|
|
|
await foreach (var item in cosmosClientCsv2.GetContainer("Core", "ID2").GetItemQueryIteratorSql<JsonElement>(queryText: sqlEx, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"base-ex") }))
|
|
|
{
|
|
|
string tmid = item.GetProperty("id").ToString();
|
|
|
- string shortCode = (item.TryGetProperty("shortCode", out JsonElement _shortCode)) ? _shortCode.ToString() : string.Empty;
|
|
|
+ string schoolCode = (item.TryGetProperty("schoolCode", out JsonElement _schoolCode)) ? _schoolCode.ToString() : string.Empty;
|
|
|
string schoolCodeW = (item.TryGetProperty("schoolCodeW", out JsonElement _schoolCodeW)) ? _schoolCodeW.ToString() : string.Empty;
|
|
|
- string schId = (!string.IsNullOrWhiteSpace(shortCode)) ? shortCode : (!string.IsNullOrWhiteSpace(schoolCodeW)) ? schoolCodeW : string.Empty;
|
|
|
+ string schId = (!string.IsNullOrWhiteSpace(schoolCode)) ? schoolCode : (!string.IsNullOrWhiteSpace(schoolCodeW)) ? schoolCodeW : string.Empty;
|
|
|
if (!string.IsNullOrWhiteSpace(schId))
|
|
|
{
|
|
|
if (!coreSchIds.Contains(schId)) coreSchIds.Add(schId);
|
|
@@ -1652,13 +1653,12 @@ namespace TEAMModelBI.Controllers.BICommon
|
|
|
|
|
|
private async Task CallSendMailApiAsync(string email, string subject, string title, string body, string template, string image)
|
|
|
{
|
|
|
- object mailVars = new
|
|
|
- {
|
|
|
- sub = subject,
|
|
|
- title = title,
|
|
|
- body = body,
|
|
|
- image = image
|
|
|
- };
|
|
|
+ dynamic mailVars = new ExpandoObject();
|
|
|
+ mailVars.sub = subject;
|
|
|
+ mailVars.title = title;
|
|
|
+ mailVars.body = body;
|
|
|
+ if (!string.IsNullOrWhiteSpace(image))
|
|
|
+ mailVars.image = image;
|
|
|
await _coreAPIHttpService.SendMail(new Dictionary<string, object> { { "to", email }, { "tid", template }, { "vars", mailVars } }, _option.Location, _configuration);
|
|
|
}
|
|
|
|