|
@@ -10,28 +10,30 @@ using TEAMModelOS.SDK.Context.Exception;
|
|
|
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
using TEAMModelOS.SDK.Module.AzureTable.Interfaces;
|
|
|
+using TEAMModelOS.Service.Core.Implements;
|
|
|
using TEAMModelOS.Service.Syllabus.Interfaces;
|
|
|
|
|
|
namespace TEAMModelOS.Service.Syllabus.Implements
|
|
|
{
|
|
|
- public class SyllabusService : ISyllabusService
|
|
|
+ public class SyllabusService : BaseService, ISyllabusService
|
|
|
{
|
|
|
|
|
|
- private readonly IAzureTableDBRepository _azureTableDBRepository;
|
|
|
- public SyllabusService(IAzureTableDBRepository azureTableDBRepository) {
|
|
|
- _azureTableDBRepository = azureTableDBRepository;
|
|
|
- }
|
|
|
+ //private readonly IAzureTableDBRepository _azureTableDBRepository;
|
|
|
+ //public SyllabusService(IAzureTableDBRepository azureTableDBRepository) {
|
|
|
+ // _azureTableDBRepository = azureTableDBRepository;
|
|
|
+ //}
|
|
|
|
|
|
|
|
|
- public async Task<List<SyllabusTree>> SaveOrUpdateAll(List<SyllabusTree> trees)
|
|
|
+ public async Task<List<SyllabusTree>> SaveOrUpdateAll(List<SyllabusTree> trees ,string lang )
|
|
|
{
|
|
|
List<SyllabusTree> nodes = new List<SyllabusTree>();
|
|
|
TreeToList(trees, nodes);
|
|
|
List<SyllabusNode> nods = MessagePackHelper.JsonToObject<List<SyllabusNode>>(MessagePackHelper.ObjectToJson(nodes));
|
|
|
- await _azureTableDBRepository.SaveOrUpdateAll<SyllabusNode>(nods);
|
|
|
+ nods.ForEach(m => { m.PartitionKey = lang; });
|
|
|
+ await SaveOrUpdateAll<SyllabusNode>(nods);
|
|
|
List<SyllabusTree> treess = ListToTree(nods);
|
|
|
return treess;
|
|
|
- // return Task.Factory.StartNew(() => { return treess; });
|
|
|
+ // return Task.Factory.StartNew(() => { return treess; });
|
|
|
}
|
|
|
|
|
|
public List<SyllabusTree> TreeToList(List<SyllabusTree> trees, List<SyllabusTree> nodes)
|
|
@@ -47,33 +49,36 @@ namespace TEAMModelOS.Service.Syllabus.Implements
|
|
|
return nodes;
|
|
|
}
|
|
|
|
|
|
- private List<SyllabusTree> ListToTree(List<SyllabusNode> noes)
|
|
|
+ public async Task<List<SyllabusTree>> FindSyllabusTreeByDict(Dictionary<string, object> dict)
|
|
|
+ {
|
|
|
+ List<SyllabusNode> syllabusNodes = await FindListByDict<SyllabusNode>(dict);
|
|
|
+ return ListToTree(syllabusNodes);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<SyllabusTree> ListToTree(List<SyllabusNode> noes)
|
|
|
{
|
|
|
List<SyllabusTree> list = MessagePackHelper.JsonToObject<List<SyllabusTree>>(MessagePackHelper.ObjectToJson(noes));
|
|
|
-
|
|
|
var lookup = list.ToDictionary(n => n.RowKey, n => n);
|
|
|
return GetChild(list, lookup);
|
|
|
}
|
|
|
|
|
|
- public List<SyllabusTree> GetChild(List<SyllabusTree> list ,Dictionary<string , SyllabusTree> dict) {
|
|
|
+ public List<SyllabusTree> GetChild(List<SyllabusTree> list, Dictionary<string, SyllabusTree> dict)
|
|
|
+ {
|
|
|
List<SyllabusTree> trees = new List<SyllabusTree>();
|
|
|
- foreach (SyllabusTree node in list) {
|
|
|
- bool flag= dict.TryGetValue(node.Pid, out SyllabusTree syllabus);
|
|
|
+ foreach (SyllabusTree node in list)
|
|
|
+ {
|
|
|
+ bool flag = dict.TryGetValue(node.Pid, out SyllabusTree syllabus);
|
|
|
if (flag && syllabus != null)
|
|
|
{
|
|
|
syllabus.Children.Add(node);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
trees.Add(node);
|
|
|
}
|
|
|
}
|
|
|
- return trees;
|
|
|
+ return trees;
|
|
|
}
|
|
|
|
|
|
- public async Task<SyllabusNode> SaveOrUpdate(SyllabusNode node )
|
|
|
- {
|
|
|
-
|
|
|
- return await _azureTableDBRepository.SaveOrUpdate<SyllabusNode>(node);
|
|
|
- }
|
|
|
}
|
|
|
}
|