|
@@ -195,7 +195,6 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
//分区键
|
|
|
string partitionCode = "copyAbility-mark";
|
|
|
-
|
|
|
if (!string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}"))
|
|
|
{
|
|
|
//查询要复制区域的能力标准点
|
|
@@ -203,30 +202,30 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.blob))
|
|
|
{
|
|
|
- item.blob = item.blob.Replace($"{oldStandard}", $"{standard}");
|
|
|
+ item.blob = item.blob.Replace($"/{oldStandard}/", $"/{standard}/");
|
|
|
};
|
|
|
|
|
|
item.standard = $"{standard}";
|
|
|
item.code = $"Ability-{standard}";
|
|
|
item.school = $"{standard}";
|
|
|
|
|
|
- ////添加区能力标准点
|
|
|
- //abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
|
|
|
+ //添加区能力标准点
|
|
|
+ abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
|
|
|
|
|
|
}
|
|
|
- //if (abilities.Count < 256)
|
|
|
- //{
|
|
|
- // await Task.WhenAll(abilities);
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // int pages = (abilities.Count + 255) / 256;
|
|
|
- // for(int i = 0; i < pages; i++)
|
|
|
- // {
|
|
|
- // List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
|
|
|
- // await Task.WhenAll(tempAbility);
|
|
|
- // }
|
|
|
- //}
|
|
|
+ if (abilities.Count < 256)
|
|
|
+ {
|
|
|
+ await Task.WhenAll(abilities);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int pages = (abilities.Count + 255) / 256;
|
|
|
+ for (int i = 0; i < pages; i++)
|
|
|
+ {
|
|
|
+ List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
|
|
|
+ await Task.WhenAll(tempAbility);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//微能力点
|
|
|
await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{oldStandard}") }))
|
|
@@ -241,7 +240,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty($"{rnode.link}"))
|
|
|
{
|
|
|
- rnode.link = rnode.link.Replace($"{oldStandard}", $"{standard}");
|
|
|
+ rnode.link = rnode.link.Replace($"/{oldStandard}/", $"/{standard}/");
|
|
|
}
|
|
|
rnodes.Add(rnode);
|
|
|
}
|
|
@@ -255,22 +254,14 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
atask.standard = $"{standard}";
|
|
|
atask.codeval = $"{standard}";
|
|
|
|
|
|
- ////添加区能力标准点中的节点
|
|
|
+ //添加区能力标准点中的节点
|
|
|
//abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}")));
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}"));
|
|
|
}
|
|
|
-
|
|
|
- //if (abilityTasks.Count <= 256)
|
|
|
- //{
|
|
|
- // await Task.WhenAll(abilityTasks);
|
|
|
- //}
|
|
|
- //else
|
|
|
+ //for (int i = 0; i < abilityTasks.Count; i++)
|
|
|
//{
|
|
|
- // int pages = (abilityTasks.Count + 255) / 256;
|
|
|
- // for (int i = 0; i < pages; i++)
|
|
|
- // {
|
|
|
- // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip((i) * 256).Take(256).ToList();
|
|
|
- // await Task.WhenAll(tempAbilityTasks);
|
|
|
- // }
|
|
|
+ // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip(i).Take(1).ToList();
|
|
|
+ // await Task.WhenAll(tempAbilityTasks);
|
|
|
//}
|
|
|
|
|
|
//新政策文件
|
|
@@ -278,7 +269,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
standardFile.standard = $"{standard}";
|
|
|
standardFile.id = areaId;
|
|
|
- //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
|
|
|
}
|
|
|
|
|
|
//新的区域设置
|
|
@@ -286,7 +277,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
areaSetting.accessConfig = null;
|
|
|
areaSetting.id = areaId;
|
|
|
- //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
|
|
|
}
|
|
|
|
|
|
//执行复制操作
|
|
@@ -301,7 +292,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
|
|
|
messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
|
|
|
var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
|
|
|
|
|
|
//发送消息实体
|
|
|
Notification notification = new Notification
|
|
@@ -321,7 +312,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
var location = _option.Location;
|
|
|
await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //站内发送消息
|
|
|
|
|
|
- return Ok(new { state = 200, });
|
|
|
+ return Ok(new { state = 200, area = addArea });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -337,30 +328,30 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.blob))
|
|
|
{
|
|
|
- item.blob = item.blob.Replace($"{area.standard}", $"{standard}");
|
|
|
+ item.blob = item.blob.Replace($"/{area.standard}/", $"/{standard}/");
|
|
|
};
|
|
|
|
|
|
item.standard = $"{standard}";
|
|
|
item.code = $"Ability-{standard}";
|
|
|
item.school = $"{standard}";
|
|
|
|
|
|
- ////添加区能力标准点
|
|
|
- //abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
|
|
|
+ //添加区能力标准点
|
|
|
+ abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{standard}")));
|
|
|
}
|
|
|
|
|
|
- //if (abilities.Count < 256)
|
|
|
- //{
|
|
|
- // await Task.WhenAll(abilities);
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // int pages = (abilities.Count + 255) / 256;
|
|
|
- // for (int i = 0; i < pages; i++)
|
|
|
- // {
|
|
|
- // List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
|
|
|
- // await Task.WhenAll(tempAbility);
|
|
|
- // }
|
|
|
- //}
|
|
|
+ if (abilities.Count < 256)
|
|
|
+ {
|
|
|
+ await Task.WhenAll(abilities);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int pages = (abilities.Count + 255) / 256;
|
|
|
+ for (int i = 0; i < pages; i++)
|
|
|
+ {
|
|
|
+ List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
|
|
|
+ await Task.WhenAll(tempAbility);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//微能力点
|
|
|
await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
|
|
@@ -375,7 +366,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty($"{rnode.link}"))
|
|
|
{
|
|
|
- rnode.link = rnode.link.Replace($"{area.standard}", $"{standard}");
|
|
|
+ rnode.link = rnode.link.Replace($"/{area.standard}/", $"/{standard}/");
|
|
|
}
|
|
|
rnodes.Add(rnode);
|
|
|
}
|
|
@@ -391,20 +382,12 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
////添加区能力标准点中的节点
|
|
|
//abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}")));
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{standard}"));
|
|
|
}
|
|
|
-
|
|
|
- //if (abilityTasks.Count <= 256)
|
|
|
+ //for (int i = 0; i < abilityTasks.Count; i++)
|
|
|
//{
|
|
|
- // await Task.WhenAll(abilityTasks);
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // int pages = (abilityTasks.Count + 255) / 256;
|
|
|
- // for (int i = 0; i < pages; i++)
|
|
|
- // {
|
|
|
- // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip((i) * 256).Take(256).ToList();
|
|
|
- // await Task.WhenAll(tempAbilityTasks);
|
|
|
- // }
|
|
|
+ // List<Task<ItemResponse<AbilityTask>>> tempAbilityTasks = abilityTasks.Skip(i).Take(1).ToList();
|
|
|
+ // await Task.WhenAll(tempAbilityTasks);
|
|
|
//}
|
|
|
|
|
|
//新政策文件
|
|
@@ -412,7 +395,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
standardFile.standard = $"{standard}";
|
|
|
standardFile.id = areaId;
|
|
|
- //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(standardFile, new PartitionKey($"StandardFile"));
|
|
|
}
|
|
|
|
|
|
//新的区域设置
|
|
@@ -420,7 +403,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
areaSetting.accessConfig = null;
|
|
|
areaSetting.id = areaId;
|
|
|
- //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(areaSetting, new PartitionKey($"AreaSetting"));
|
|
|
}
|
|
|
|
|
|
//执行复制操作
|
|
@@ -435,7 +418,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
|
|
|
messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
|
|
|
var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
|
- //await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile); //执行复制操作
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile); //执行复制操作
|
|
|
|
|
|
//发送消息实体
|
|
|
Notification notification = new Notification
|
|
@@ -455,9 +438,9 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
var location = _option.Location;
|
|
|
await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //发送站内发送消息
|
|
|
|
|
|
- return Ok(new { state = 201 });
|
|
|
+ return Ok(new { state = 200, area });
|
|
|
}
|
|
|
- else return Ok(new { state = 202, message = "未找到默认能力点!" });
|
|
|
+ else return Ok(new { state = 201, message = "未找到默认能力点!" });
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -490,7 +473,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
List<string> abilityIds = new List<string>(); //册别的ID集合
|
|
|
|
|
|
//查询册别信息
|
|
|
- await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
|
|
|
+ await foreach (var tempAbility in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Ability>(queryText: $"select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{_oldStandard}") }))
|
|
|
{
|
|
|
abilityIds.Add(tempAbility.id); //查询出来册别ID添加册别ID集合
|
|
|
}
|
|
@@ -501,7 +484,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
}
|
|
|
|
|
|
List<string> abilityTaskIds = new List<string>(); //章节ID集合
|
|
|
- foreach (var abilityId in abilityIds)
|
|
|
+ foreach (var abilityId in abilityIds)
|
|
|
{
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c where c.abilityId='{abilityId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_oldStandard}") }))
|
|
|
{
|
|
@@ -509,7 +492,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
}
|
|
|
}
|
|
|
//删除章节
|
|
|
- if (abilityTaskIds.IsNotEmpty())
|
|
|
+ if (abilityTaskIds.IsNotEmpty())
|
|
|
{
|
|
|
//var sresponse = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").DeleteItemsStreamAsync(abilityTaskIds, $"AbilityTask-{_oldStandard}");
|
|
|
}
|
|
@@ -527,7 +510,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(item.blob))
|
|
|
{
|
|
|
- item.blob = item.blob.Replace($"{_newStandard}", $"{_oldStandard}");
|
|
|
+ item.blob = item.blob.Replace($"/{_newStandard}/", $"/{_oldStandard}/");
|
|
|
};
|
|
|
|
|
|
item.standard = $"{_oldStandard}";
|
|
@@ -538,10 +521,20 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
////添加区能力标准点
|
|
|
//abilities.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(item, new PartitionKey($"Ability-{_oldStandard}")));
|
|
|
}
|
|
|
- //if (abilities.IsNotEmpty())
|
|
|
+
|
|
|
+ //if (abilities.Count < 256)
|
|
|
//{
|
|
|
// await Task.WhenAll(abilities);
|
|
|
//}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // int pages = (abilities.Count + 255) / 256;
|
|
|
+ // for (int i = 0; i < pages; i++)
|
|
|
+ // {
|
|
|
+ // List<Task<ItemResponse<Ability>>> tempAbility = abilities.Skip((i) * 256).Take(256).ToList();
|
|
|
+ // await Task.WhenAll(tempAbility);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
//微能力点
|
|
|
await foreach (var atask in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AbilityTask>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilityTask-{_newStandard}") }))
|
|
@@ -556,7 +549,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty($"{rnode.link}"))
|
|
|
{
|
|
|
- rnode.link = rnode.link.Replace($"{_newStandard}", $"{_oldStandard}");
|
|
|
+ rnode.link = rnode.link.Replace($"/{_newStandard}/", $"/{_oldStandard}/");
|
|
|
}
|
|
|
rnodes.Add(rnode);
|
|
|
}
|
|
@@ -573,11 +566,22 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
|
|
|
////添加区能力标准点中的节点
|
|
|
//abilityTasks.Add(cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}")));
|
|
|
+ //await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").CreateItemAsync(atask, new PartitionKey($"AbilityTask-{_oldStandard}"));
|
|
|
}
|
|
|
- //if (abilities.IsNotEmpty())
|
|
|
+
|
|
|
+ //if (abilityTasks.Count <= 256)
|
|
|
//{
|
|
|
// await Task.WhenAll(abilityTasks);
|
|
|
//}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // int pages = (abilityTasks.Count + 255) / 256;
|
|
|
+ // for (int i = 0; i < pages; i++)
|
|
|
+ // {
|
|
|
+ // List<Task<ItemResponse<AbilityTask>>> itemAbilityTask = abilityTasks.Skip((i) * 256).Take(256).ToList();
|
|
|
+ // await Task.WhenAll(itemAbilityTask);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
//新政策文件
|
|
|
await foreach (StandardFile standardFile in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<StandardFile>(queryText: $"select value(c) from c where c.id='{_newId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StandardFile") }))
|
|
@@ -634,7 +638,7 @@ namespace TEAMModeBI.Controllers.BISchool
|
|
|
var location = _option.Location;
|
|
|
await _notificationService.SendNotification(clientID, clientSecret, location, url, notification); //发送站内发送消息
|
|
|
|
|
|
- return Ok(new { state = 200, abilityIds, abilityTaskIds, abilities1, abilityTasks1, abilityTasks,areaSettings });
|
|
|
+ return Ok(new { state = 200, abilityIds, abilityTaskIds, abilities1, abilityTasks1, standardFiles, areaSettings });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|