😎新增manage创建流程服务

This commit is contained in:
bairubing 2024-11-05 09:35:12 +08:00
parent 623e2326bf
commit 9d299f48de

View File

@ -257,6 +257,55 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
}; };
return errorResponse; return errorResponse;
} }
}
/// <summary>
/// 创建流程
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<ManageResponse> CreateProcess(CreateProjectInput input)
{
// 获取 SolidWorksManage 地址
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
// 拼接接口地址
string url = $"{apiUrl}/api/PropertyCard/CreateProcess";
//获取token
var token = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageAuthorization);
// 将参数对象序列化为 JSON 字符串
string jsonParameters = JsonConvert.SerializeObject(input);
// 设置请求内容
var content = new StringContent(jsonParameters, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Remove("Authorization");
// 添加 Authorization 到请求头
client.DefaultRequestHeaders.Add("Authorization", token);
// 发送 POST 请求
HttpResponseMessage response = await client.PostAsync(url, content);
// 处理响应
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
// 解析 JSON 数据
var result = JsonConvert.DeserializeObject<ManageResponse>(responseBody);
return result;
}
else
{
string responseBody = await response.Content.ReadAsStringAsync();
var errorResponse = new ManageResponse()
{
Success = false,
Message = responseBody,
Data = "",
CustomAction = "",
CustomAttributes = ""
};
return errorResponse;
}
} }
/// <summary> /// <summary>