|
@@ -5,6 +5,9 @@ using System.Text;
|
|
|
using System.Xml;
|
|
|
using System.IO;
|
|
|
using System.Text.RegularExpressions;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Net.Http;
|
|
|
+using Newtonsoft.Json;
|
|
|
|
|
|
namespace spgen
|
|
|
{
|
|
@@ -186,6 +189,19 @@ namespace spgen
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static void ReadEntityInfoFromServer(List<String> InfoArr)
|
|
|
+ {
|
|
|
+ entityDic.Clear();
|
|
|
+
|
|
|
+ Regex reg = new Regex("^(.+)=.+0x(.+)$");
|
|
|
+ foreach (string line in InfoArr)
|
|
|
+ {
|
|
|
+ Match match = reg.Match(line);
|
|
|
+ if (match.Success && !entityDic.ContainsKey(match.Groups[1].Value))
|
|
|
+ entityDic.Add(match.Groups[1].Value, match.Groups[2].Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public static Entity Load(string xmlfile)
|
|
|
{
|
|
@@ -530,8 +546,76 @@ namespace spgen
|
|
|
Console.WriteLine("\tUsage: spgen.exe <entity>.xml\n");
|
|
|
}
|
|
|
|
|
|
+ public class ShellInfo
|
|
|
+ {
|
|
|
+ public string module { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+
|
|
|
+ public string value { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ static async Task PostRequestAsync()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 构造请求数据
|
|
|
+ var requestData = "{\"terminal_no\": \"7555980178\"}";
|
|
|
+ var content = new StringContent(requestData, Encoding.UTF8, "application/json");
|
|
|
+
|
|
|
+ // 创建 HttpClient 实例
|
|
|
+ using (var httpClient = new HttpClient())
|
|
|
+ {
|
|
|
+ // 设置请求的 URL
|
|
|
+ var requestUrl = "http://centerconfig.paasst.cmbchina.cn/api/unify/config/query";
|
|
|
+
|
|
|
+ // 发送 POST 请求
|
|
|
+ var response = await httpClient.PostAsync(requestUrl, content);
|
|
|
+
|
|
|
+ // 检查响应是否成功
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+ // 读取响应内容
|
|
|
+ var responseContent = await response.Content.ReadAsStringAsync();
|
|
|
+
|
|
|
+ dynamic jsonObject = JsonConvert.DeserializeObject(responseContent);
|
|
|
+
|
|
|
+ dynamic dataObj = JsonConvert.DeserializeObject(jsonObject.data.ToString());
|
|
|
+
|
|
|
+ dynamic shellObj = JsonConvert.DeserializeObject(dataObj.shell_config_dto.ToString());
|
|
|
+
|
|
|
+
|
|
|
+ List<ShellInfo> infos = JsonConvert.DeserializeObject<List<ShellInfo>>(shellObj.config.ToString());
|
|
|
+
|
|
|
+
|
|
|
+ List<String> entityArr = new List<string>();
|
|
|
+
|
|
|
+ foreach (var it in infos)
|
|
|
+ {
|
|
|
+ if (it.module == "Entity")
|
|
|
+ {
|
|
|
+ String cur = it.name + "=" + it.value;
|
|
|
+ entityArr.Insert(0, cur);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ entityArr.Insert(0, "VtmLoader=1,mod_VtmLoader,0x10F");
|
|
|
+ Entity.ReadEntityInfoFromServer(entityArr);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Console.WriteLine($"Error: {response.StatusCode}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine($"Exception: {ex.ToString()}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// spgen.exe print_entity.xml
|
|
|
- static void Main(string[] args)
|
|
|
+ static async Task Main(string[] args)
|
|
|
{
|
|
|
if (args.Length != 1 && args.Length != 2)
|
|
|
{
|
|
@@ -539,12 +623,9 @@ namespace spgen
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String shellIniPath = "shell.ini";
|
|
|
- if (args.Length == 2)
|
|
|
- shellIniPath = args[1];
|
|
|
try
|
|
|
{
|
|
|
- Entity.ReadEntityInfoFromShellIni(shellIniPath);
|
|
|
+ await PostRequestAsync();
|
|
|
string xmlfile = System.IO.Path.Combine(Environment.CurrentDirectory, args[0]);
|
|
|
Entity entity = Entity.Load(xmlfile);
|
|
|
|