LogicHelper.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Infrastructure;
  2. using LitJson;
  3. using Services;
  4. namespace Util
  5. {
  6. public class LogicHelper
  7. {
  8. public static void GetLogicJsonData(int projectId)
  9. {
  10. var logicProjectService = App.GetService<ILogicProjectService>();
  11. var logicProject = logicProjectService.GetById(projectId);
  12. if(logicProject == null)
  13. {
  14. return;
  15. }
  16. string jsonData = logicProject.setData;
  17. if(string.IsNullOrEmpty(jsonData))
  18. {
  19. return;
  20. }
  21. JsonData jsonDataObj = JsonMapper.ToObject(jsonData);
  22. JsonData nodes = jsonDataObj["nodes"]; // 节点数据
  23. foreach(JsonData node in nodes)
  24. {
  25. JsonData id = node["id"];
  26. JsonData type = node["type"];
  27. }
  28. Dictionary<string, string> nodeDict = new Dictionary<string, string>();
  29. JsonData edges = jsonDataObj["edges"]; // 边数据
  30. foreach(JsonData edge in edges)
  31. {
  32. JsonData source = edge["source"];
  33. JsonData target = edge["target"];
  34. nodeDict.Add(source.ToString(), target.ToString());
  35. }
  36. }
  37. }
  38. }