|
@@ -1,18 +1,18 @@
|
|
|
-using Newtonsoft.Json;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
using SAGA.DotNetUtils.Http;
|
|
|
using SAGA.MBI.Common;
|
|
|
-using SAGA.Models;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
+using SAGA.MBI.RequestData;
|
|
|
+using SAGA.DotNetUtils.Extend;
|
|
|
|
|
|
namespace SAGA.GplotRelationComputerManage
|
|
|
{
|
|
|
public class RelationBll
|
|
|
{
|
|
|
+ private const string MaxTime = "29000101000000";
|
|
|
#region 地址相关
|
|
|
/// <summary>
|
|
|
/// 获取基础地址
|
|
@@ -20,7 +20,7 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
/// <returns></returns>
|
|
|
public string GetBaseUrl()
|
|
|
{
|
|
|
- return $"{ MBIConst.DataPlatformLocalHost}data - platform - 3 / relation / ";
|
|
|
+ return $"{ MBIConst.DataPlatformLocalHost}data-platform-3/relation/";
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取密码相关地址字符串
|
|
@@ -48,12 +48,14 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
var periods = new JArray();
|
|
|
var timeObject = new JObject();
|
|
|
timeObject.Add("begin_time", beginTime);
|
|
|
- timeObject.Add("end_time", "29000101000000");
|
|
|
- jObject.Add("periods", periods);
|
|
|
- //string postData = $"{{\"graph_type\":\"{graphType}\",\"periods\":[{{\"begin_time\":\"{begin_time}\",\"end_time\":\"29000101000000\"}}]}}";
|
|
|
+ timeObject.Add("end_time", MaxTime);
|
|
|
+ periods.Add(timeObject);
|
|
|
+ jObject.Add("periods", periods);
|
|
|
RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
|
|
|
-
|
|
|
- return restClient.GetRequest().GetValue("graph_id");
|
|
|
+ string strResult = restClient.GetRequest();
|
|
|
+ string graphId = null; ;
|
|
|
+ RequestResultUtil.HandlerResult(strResult, (obj) => graphId = obj.GetValueEx("graph_id"));
|
|
|
+ return graphId;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -69,12 +71,16 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
JObject jObject = new JObject();
|
|
|
JObject criteria = new JObject();
|
|
|
jObject.Add("criteria", criteria);
|
|
|
- criteria.Add("jObjectValue", graphType);
|
|
|
- //string postData = $"{{\"graph_type\":\"{graphType}\"}}";
|
|
|
- //postData = $"{{\"criteria\":{{\"graph_type\":\"{graphType}\"}}}}";
|
|
|
+ criteria.Add("graph_type", graphType);
|
|
|
RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
|
|
|
- GraphInstance instance = new GraphInstance();
|
|
|
- var result = restClient.GetRequest();
|
|
|
+ GraphInstance instance =null;
|
|
|
+ var strResult = restClient.GetRequest();
|
|
|
+ RequestResultUtil.HandlerResult(strResult, (obj) =>
|
|
|
+ {
|
|
|
+ var listStr = obj["Content"].ToString();
|
|
|
+ var list = JsonConvert.DeserializeObject<List<GraphInstance>>(listStr);
|
|
|
+ instance = list.FirstOrDefault();
|
|
|
+ });
|
|
|
return instance;
|
|
|
}
|
|
|
|
|
@@ -83,10 +89,10 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
/// 修改之前的图实例时间,然后创建新的,20171123)
|
|
|
/// </summary>
|
|
|
/// <param name="graphId">图类型</param>
|
|
|
- /// <param name="statrDateTime"></param>
|
|
|
- /// <param name="endDateTime"></param>
|
|
|
+ /// <param name="biginTime"></param>
|
|
|
+ /// <param name="endTime"></param>
|
|
|
/// <returns></returns>
|
|
|
- public string UpdateGraphInstance(string graphId, string biginTime, string endTime)
|
|
|
+ public bool UpdateGraphInstance(string graphId, string biginTime, string endTime)
|
|
|
{
|
|
|
var baseUrl = GetBaseUrl();
|
|
|
var password = GetPasswordQuerry();
|
|
@@ -102,12 +108,11 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
set.Add("periods", periods);
|
|
|
var timeObject = new JObject();
|
|
|
timeObject.Add("begin_time", biginTime);
|
|
|
- timeObject.Add("end_time", "endTime");
|
|
|
-
|
|
|
- //string postData = $"{{\"criteria\":{{\"graph_id\":\"{graphId}\"}},\"set\":{{\"periods\":[{{\"begin_time\":\"{statrDateTime}\",\"end_time\":\"{endDateTime}\"}}]}}}}";
|
|
|
+ timeObject.Add("end_time", endTime);
|
|
|
+ periods.Add(timeObject);
|
|
|
RestClient restClient = new RestClient(url, HttpVerb.POST, jObject.ToString());
|
|
|
-
|
|
|
- return restClient.GetRequest().GetValue("graph_id");
|
|
|
+ var strResult = restClient.GetRequest();
|
|
|
+ return RequestResultUtil.HandlerResult(strResult);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -131,9 +136,9 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
/// <summary>
|
|
|
/// 创建关系数据
|
|
|
/// </summary>
|
|
|
- /// <param name="criteria">关系数据</param>
|
|
|
+ /// <param name="items">关系数据</param>
|
|
|
/// <returns></returns>
|
|
|
- public bool CreateRelations(List<GraphRelationItem> items)
|
|
|
+ public bool CreateRelations(List<GraphRelationItem> items)
|
|
|
{
|
|
|
var baseUrl = GetBaseUrl();
|
|
|
var password = GetPasswordQuerry();
|
|
@@ -152,9 +157,8 @@ namespace SAGA.GplotRelationComputerManage
|
|
|
}
|
|
|
JObject jobject = new JObject();
|
|
|
jobject.Add("criterias", JArray.FromObject(useItems));
|
|
|
- RestClient restClient1 = new RestClient(url, HttpVerb.POST, JsonConvert.SerializeObject(jobject).ToString());
|
|
|
- var result =restClient1.GetRequest().IsSuccess();
|
|
|
- return result;
|
|
|
+ RestClient restClient1 = new RestClient(url, HttpVerb.POST, jobject.ToString());
|
|
|
+ return RequestResultUtil.HandlerResult(restClient1.GetRequest()); ;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|