|
@@ -658,6 +658,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
if (teacher.id.Equals(id))
|
|
|
{
|
|
|
+ var bindData = scsso.data.ToObject<ScBindData>();
|
|
|
//var bind = teacher.binds.Find(x => x.source.Equals($"{scsso.Webid}") && x.userid.Equals($"{scsso.tid}"));
|
|
|
var bind = teacher.binds.Find(x => x.userid.Equals($"{scsso.tid}"));
|
|
|
if (bind == null)
|
|
@@ -669,7 +670,7 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
{
|
|
|
bind.username=scsso.username;
|
|
|
bind.account=scsso.account;
|
|
|
- var bindData = scsso.data.ToObject<ScBindData>();
|
|
|
+
|
|
|
bool isnew = true;
|
|
|
for (int index = 0; index < bind.data.Count; index++)
|
|
|
{
|
|
@@ -689,91 +690,10 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
bindData.username=scsso.username;
|
|
|
bindData.account = scsso.account;
|
|
|
}
|
|
|
- if (teacher.schools.IsNotEmpty())
|
|
|
- {
|
|
|
- foreach (var school in teacher.schools)
|
|
|
- {
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(school.schoolId))
|
|
|
- {
|
|
|
- if (school.status.Equals("join")) {
|
|
|
- StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
|
|
|
- List<GroupList> yxtrain = new List<GroupList>();
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryText.ToString(),
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school.schoolId}") }))
|
|
|
- {
|
|
|
- yxtrain.Add(item);
|
|
|
- }
|
|
|
- if (yxtrain.IsNotEmpty())
|
|
|
- {
|
|
|
- var meber = yxtrain.SelectMany(x => x.members).Where(y => y.id.Equals(teacher.id));
|
|
|
- //不在研修名单
|
|
|
- if (meber == null || meber.Count() <= 0)
|
|
|
- {
|
|
|
- yxtrain[0].members.Add(new Member { id = teacher.id, type = 1 });
|
|
|
- await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GroupList groupList = new GroupList()
|
|
|
- {
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- code = $"GroupList-{school.schoolId}",
|
|
|
- creatorId = teacher.id,
|
|
|
- type = "yxtrain",
|
|
|
- year = DateTimeOffset.UtcNow.Year,
|
|
|
- members = new List<Member> { new Member { id = teacher.id, type = 1 } },
|
|
|
- scope = "school",
|
|
|
- school = school.schoolId,
|
|
|
- name = "研修名单",
|
|
|
- pk = "GroupList",
|
|
|
- ttl = -1
|
|
|
- };
|
|
|
- await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
|
|
|
- }
|
|
|
- }
|
|
|
- Azure.Response response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(teacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
- if (response.Status != 200)
|
|
|
- {
|
|
|
- SchoolTeacher schoolTeacher = new SchoolTeacher
|
|
|
- {
|
|
|
- id = teacher.id,
|
|
|
- code = $"Teacher-{school.schoolId}",
|
|
|
- pk = "Teacher",
|
|
|
- name = teacher.name,
|
|
|
- picture = teacher.picture,
|
|
|
- size = 0,
|
|
|
- roles = new List<string> { "teacher" },
|
|
|
- permissions = new List<string>(),
|
|
|
- status = school.status,
|
|
|
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
- ttl = -1
|
|
|
- };
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(schoolTeacher, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
- }
|
|
|
- else {
|
|
|
- JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
- SchoolTeacher schoolTeacher = document.RootElement.ToObject<SchoolTeacher>();
|
|
|
- schoolTeacher.status = school.status;
|
|
|
- schoolTeacher.pk = "Teacher";
|
|
|
- schoolTeacher.name = teacher.name;
|
|
|
- schoolTeacher.picture = teacher.picture;
|
|
|
- if (schoolTeacher.roles.IsEmpty() || !schoolTeacher.roles.Contains("teacher"))
|
|
|
- {
|
|
|
- schoolTeacher.roles = new List<string> { "teacher" };
|
|
|
- }
|
|
|
- schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty() ? schoolTeacher.permissions : new List<string>();
|
|
|
- schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
- schoolTeacher.ttl = -1;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
- await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
}
|
|
|
+ await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
+ await ThirdService.GetScTeacher(bindData, teacher, _azureStorage, _azureCosmos, _serviceBus, _configuration, _dingDing);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -802,13 +722,15 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
size = 1,
|
|
|
defaultSchool = null,
|
|
|
schools = new List<Teacher.TeacherSchool>(),
|
|
|
- binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}", /*source = $"{scsso.Webid}",*/ type = type } }
|
|
|
+ binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind {username= scsso.username,account= scsso.account, data = new List<string> { scsso.data }, userid = $"{scsso.tid}", /*source = $"{scsso.Webid}",*/ type = type } }
|
|
|
};
|
|
|
var container = _azureStorage.GetBlobContainerClient(id);
|
|
|
await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
|
|
|
+
|
|
|
teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
|
|
|
|
|
|
ScBindData bindData = scsso.data.ToObject<ScBindData>();
|
|
|
+ await ThirdService.GetScTeacher(bindData, teacher, _azureStorage, _azureCosmos, _serviceBus, _configuration, _dingDing);
|
|
|
if (bindData != null)
|
|
|
{
|
|
|
bindData.userid = scsso.tid;
|
|
@@ -819,7 +741,6 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
else {
|
|
|
await _azureStorage.UploadFileByContainer("teammodelos", scsso.data.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
catch (Exception ex) {
|
|
|
await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败:\n{sso.ToJsonString()},{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
@@ -846,6 +767,9 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 动态地址路由。"config":"scsyxpt","path":"sc{pjx/jinniu}"
|
|
|
/// </summary>
|
|
@@ -961,6 +885,8 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
|
|
|
var location = _option.Location;
|
|
|
TmdidImplicit implicit_token = await _coreAPIHttpService.Implicit(
|
|
@@ -977,6 +903,8 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
await _dingDing.SendBotMsg($"OS,隐式登录获得信息为空:{_option.Location}-\n{scsso.ToJsonString()} \npath:{path}\n{implicit_token.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
|
return Redirect(rurl.Append($"?status=1").ToString());
|
|
|
}
|
|
|
+ //处理自动加入学校,加入培训名单
|
|
|
+ await ThirdService.GetScTeacher(bindData, teacher, _azureStorage, _azureCosmos, _serviceBus, _configuration, _dingDing);
|
|
|
var bind = teacher.binds.Find(x => x.userid.Equals(sso.tid));
|
|
|
//var bind = teacher.binds.Find(x => x.userid.Equals(sso.tid) && x.source.Equals(sso.Webid));
|
|
|
if (bind != null)
|
|
@@ -996,84 +924,6 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
}
|
|
|
bind.username = TeacherName;
|
|
|
bind.account = Account;
|
|
|
- if (teacher.schools.IsNotEmpty()) {
|
|
|
- foreach (var school in teacher.schools) {
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(school.schoolId) ) {
|
|
|
- if (school.status.Equals("join")) {
|
|
|
- StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
|
|
|
- List<GroupList> yxtrain = new List<GroupList>();
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryText.ToString(),
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school.schoolId}") }))
|
|
|
- {
|
|
|
- yxtrain.Add(item);
|
|
|
- }
|
|
|
- if (yxtrain.IsNotEmpty())
|
|
|
- {
|
|
|
- var meber = yxtrain.SelectMany(x => x.members).Where(y => y.id.Equals(teacher.id));
|
|
|
- //不在研修名单
|
|
|
- if (meber == null || meber.Count() <= 0)
|
|
|
- {
|
|
|
- yxtrain[0].members.Add(new Member { id = teacher.id, type = 1 });
|
|
|
- await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GroupList groupList = new GroupList()
|
|
|
- {
|
|
|
- id = Guid.NewGuid().ToString(),
|
|
|
- code = $"GroupList-{school.schoolId}",
|
|
|
- creatorId = teacher.id,
|
|
|
- type = "yxtrain",
|
|
|
- year = DateTimeOffset.UtcNow.Year,
|
|
|
- members = new List<Member> { new Member { id = teacher.id, type = 1 } },
|
|
|
- scope = "school",
|
|
|
- school = school.schoolId,
|
|
|
- name = "研修名单",
|
|
|
- pk = "GroupList",
|
|
|
- ttl = -1
|
|
|
- };
|
|
|
- await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus);
|
|
|
- }
|
|
|
- }
|
|
|
- Azure.Response response= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(teacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
- if (response.Status != 200) {
|
|
|
- SchoolTeacher schoolTeacher = new SchoolTeacher
|
|
|
- {
|
|
|
- id = teacher.id,
|
|
|
- code = $"Teacher-{school.schoolId}",
|
|
|
- pk= "Teacher",
|
|
|
- name=teacher.name,
|
|
|
- picture= teacher.picture,
|
|
|
- size=0,
|
|
|
- roles=new List<string> { "teacher" },
|
|
|
- permissions= new List<string>(),
|
|
|
- status=school.status,
|
|
|
- createTime=DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
- ttl=-1
|
|
|
- };
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync(schoolTeacher, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
- SchoolTeacher schoolTeacher = document.RootElement.ToObject<SchoolTeacher>();
|
|
|
- schoolTeacher.status =school.status;
|
|
|
- schoolTeacher.pk = "Teacher";
|
|
|
- schoolTeacher.name = teacher.name;
|
|
|
- schoolTeacher.picture = teacher.picture;
|
|
|
- if (schoolTeacher.roles.IsEmpty() ||! schoolTeacher.roles.Contains("teacher")) {
|
|
|
- schoolTeacher.roles = new List<string> { "teacher" };
|
|
|
- }
|
|
|
- schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty()? schoolTeacher.permissions: new List<string>();
|
|
|
- schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
- schoolTeacher.ttl = -1;
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{school.schoolId}"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
}
|
|
|
try
|
|
@@ -1092,11 +942,9 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
//绑定失效
|
|
|
if (teacher.binds.IsNotEmpty())
|
|
|
{
|
|
|
- // teacher.binds.RemoveAll(x => x.userid.Equals(sso.tid) && x.source.Equals(sso.Webid));
|
|
|
teacher.binds.RemoveAll(x => x.userid.Equals(sso.tid) );
|
|
|
await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
|
|
|
}
|
|
|
- // string enurl = HttpUtility.UrlEncode(rurl.Append($"status=4¶m={sso.ToJsonString()}&type={type}&bindurl=sc/bind").ToString());
|
|
|
string enurl = $"status=4¶m={HttpUtility.UrlEncode(sso.ToJsonString(),Encoding.UTF8)}&type={type}&bindurl=sc/bind";
|
|
|
return Redirect(rurl.Append($"?{enurl}").ToString());
|
|
|
}
|
|
@@ -1106,7 +954,5 @@ namespace TEAMModelOS.Controllers.Third
|
|
|
return Redirect(rurl.Append($"?status=1").ToString());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|