更新 SolidWorks 管理相关常量和逻辑
在 `ConfigConst.cs` 中添加 `SolidWorksManageApiUrlNew` 和 `SolidWorksManageAuthorizationNew` 常量。 修改多个类的截止时间为 `2025年8月31日`。 新增 `RefreshManageToKenNew` 类以刷新新版 Manage Token。 在 `OaOpenInterfaceService.cs` 中统一字段类型为 `CreateProjectField`。 添加 `CreateProcessInput` 和 `CreateProcessField` 类以处理创建流程的输入数据。 在 `SolidWorksManageService.cs` 中新增获取新版 token 的方法,并更新相关 API 地址和授权信息。 移除 `index.vue` 中的调试用 `console.log` 语句。
This commit is contained in:
parent
29d6d6109b
commit
6a1234444e
@ -174,4 +174,14 @@ public class ConfigConst
|
|||||||
/// SolidWorksManage授权
|
/// SolidWorksManage授权
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SolidWorksManageAuthorization = "SolidWorksManage_Authorization";
|
public const string SolidWorksManageAuthorization = "SolidWorksManage_Authorization";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SolidWorksManage New地址
|
||||||
|
/// </summary>
|
||||||
|
public const string SolidWorksManageApiUrlNew = "SolidWorksManage_ApiUrlNew";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SolidWorksManage New授权
|
||||||
|
/// </summary>
|
||||||
|
public const string SolidWorksManageAuthorizationNew = "SolidWorksManage_AuthorizationNew";
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public class SyncProductDesignBomToSap : IJob
|
|||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||||
|
|
||||||
|
|
||||||
DateTime cutoffTime = new DateTime(2025, 6, 30, 20, 0, 0);
|
DateTime cutoffTime = new DateTime(2025, 8, 31, 20, 0, 0);
|
||||||
if (startTime > cutoffTime)
|
if (startTime > cutoffTime)
|
||||||
{
|
{
|
||||||
// 创建一个Random类的实例
|
// 创建一个Random类的实例
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class SyncProductDesignMaterialToSap : IJob
|
|||||||
//var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
//var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||||
|
|
||||||
DateTime cutoffTime = new DateTime(2025, 6, 30, 20, 0, 0);
|
DateTime cutoffTime = new DateTime(2025, 8, 31, 20, 0, 0);
|
||||||
if (startTime > cutoffTime)
|
if (startTime > cutoffTime)
|
||||||
{
|
{
|
||||||
// 创建一个Random类的实例
|
// 创建一个Random类的实例
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public class SyncProductDesignProcessRouteToSap : IJob
|
|||||||
//var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
//var sysEnumService = serviceScope.ServiceProvider.GetRequiredService<SysEnumService>();
|
||||||
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("启威星 1.94.4.74").CopyNew();
|
||||||
|
|
||||||
DateTime cutoffTime = new DateTime(2025, 6, 30, 20, 0, 0);
|
DateTime cutoffTime = new DateTime(2025, 8, 31, 20, 0, 0);
|
||||||
if (startTime > cutoffTime)
|
if (startTime > cutoffTime)
|
||||||
{
|
{
|
||||||
// 创建一个Random类的实例
|
// 创建一个Random类的实例
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||||
|
//
|
||||||
|
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||||
|
//
|
||||||
|
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||||
|
|
||||||
|
using Furion.Schedule;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Vistar.Application.Entity;
|
||||||
|
|
||||||
|
namespace Vistar.Application.Job.SolidWorksManage;
|
||||||
|
[JobDetail("job_RefreshManageToKenNew", Description = "刷新新版ManageToKen", GroupName = "default", Concurrent = false)]
|
||||||
|
[PeriodHours(6, TriggerId = "trigger_RefreshManageToKenNew", Description = "刷新新版ManageToKen", RunOnStart = false)]
|
||||||
|
public class RefreshManageToKenNew : IJob
|
||||||
|
{
|
||||||
|
private readonly IServiceScopeFactory _scopeFactory;
|
||||||
|
public SolidWorksManageService.SolidWorksManageService _solidWorksManage;
|
||||||
|
public RefreshManageToKenNew(IServiceScopeFactory scopeFactory, SolidWorksManageService.SolidWorksManageService solidWorksManage)
|
||||||
|
{
|
||||||
|
_scopeFactory = scopeFactory;
|
||||||
|
_solidWorksManage = solidWorksManage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
DateTime startTime = DateTime.Now;
|
||||||
|
using var serviceScope = _scopeFactory.CreateScope();
|
||||||
|
var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().AsTenant().GetConnectionScope("1300000000001").CopyNew();
|
||||||
|
var outputs = await _solidWorksManage.AuthenticateNew();
|
||||||
|
var json = JsonConvert.SerializeObject(outputs);
|
||||||
|
string output = json;
|
||||||
|
var elapsedMilliseconds = (DateTime.Now - startTime).TotalMilliseconds;
|
||||||
|
|
||||||
|
db.CopyNew().Insertable<ScheduledTaskLog>(new
|
||||||
|
{
|
||||||
|
TaskName = "刷新新版ManageToKen",
|
||||||
|
LogDateTime = DateTime.Now,
|
||||||
|
ReturnResult = output,
|
||||||
|
Elapsed = elapsedMilliseconds.ToLong()
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -99,38 +99,38 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
if (clientExists == false)
|
if (clientExists == false)
|
||||||
{
|
{
|
||||||
var fieldList = new List<Field>();
|
var fieldList = new List<CreateProjectField>();
|
||||||
if (input.fld004503 != null)
|
if (input.fld004503 != null)
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld004503", value = input.fld004503.ToString() });
|
fieldList.Add(new CreateProjectField { key = "fld004503", value = input.fld004503.ToString() });
|
||||||
}
|
}
|
||||||
if (input.fld004503 != null)
|
if (input.fld004503 != null)
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld004504", value = input.fld004504.ToString() });
|
fieldList.Add(new CreateProjectField { key = "fld004504", value = input.fld004504.ToString() });
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldList.Add(new Field { key = "fld004684", value = input.fld004684 });
|
fieldList.Add(new CreateProjectField { key = "fld004684", value = input.fld004684 });
|
||||||
fieldList.Add(new Field { key = "_System_objNBS", value = input._System_objNBS });
|
fieldList.Add(new CreateProjectField { key = "_System_objNBS", value = input._System_objNBS });
|
||||||
fieldList.Add(new Field { key = "_System_objDescription", value = input._System_objDescription });
|
fieldList.Add(new CreateProjectField { key = "_System_objDescription", value = input._System_objDescription });
|
||||||
fieldList.Add(new Field { key = "fld004728", value = input.fld004728 });
|
fieldList.Add(new CreateProjectField { key = "fld004728", value = input.fld004728 });
|
||||||
fieldList.Add(new Field { key = "fld005299", value = input.fld005299 });
|
fieldList.Add(new CreateProjectField { key = "fld005299", value = input.fld005299 });
|
||||||
fieldList.Add(new Field { key = "fld005300", value = input.fld005300 });
|
fieldList.Add(new CreateProjectField { key = "fld005300", value = input.fld005300 });
|
||||||
fieldList.Add(new Field { key = "fld005281", value = "SET" });
|
fieldList.Add(new CreateProjectField { key = "fld005281", value = "SET" });
|
||||||
fieldList.Add(new Field { key = "fld004521", value = "M" });
|
fieldList.Add(new CreateProjectField { key = "fld004521", value = "M" });
|
||||||
fieldList.Add(new Field { key = "fld004519", value = "FERT" });
|
fieldList.Add(new CreateProjectField { key = "fld004519", value = "FERT" });
|
||||||
fieldList.Add(new Field { key = "fld004522", value = "1000" });
|
fieldList.Add(new CreateProjectField { key = "fld004522", value = "1000" });
|
||||||
fieldList.Add(new Field { key = "fld004928", value = "E" });
|
fieldList.Add(new CreateProjectField { key = "fld004928", value = "E" });
|
||||||
fieldList.Add(new Field { key = "fld004935", value = "X" });
|
fieldList.Add(new CreateProjectField { key = "fld004935", value = "X" });
|
||||||
fieldList.Add(new Field { key = "fld004510", value = "A" });
|
fieldList.Add(new CreateProjectField { key = "fld004510", value = "A" });
|
||||||
fieldList.Add(new Field { key = "fld004514", value = "A" });
|
fieldList.Add(new CreateProjectField { key = "fld004514", value = "A" });
|
||||||
fieldList.Add(new Field { key = "fld004517", value = "A" });
|
fieldList.Add(new CreateProjectField { key = "fld004517", value = "A" });
|
||||||
fieldList.Add(new Field { key = "fld005753", value = "OA" });
|
fieldList.Add(new CreateProjectField { key = "fld005753", value = "OA" });
|
||||||
|
|
||||||
var fieldGroupValue = await _fieldGroupDefaultRep.AsQueryable().Where(x => x.GroupObjid == input.object_id).ToListAsync();
|
var fieldGroupValue = await _fieldGroupDefaultRep.AsQueryable().Where(x => x.GroupObjid == input.object_id).ToListAsync();
|
||||||
|
|
||||||
for (int i = 0; i < fieldGroupValue.Count; i++)
|
for (int i = 0; i < fieldGroupValue.Count; i++)
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld00" + fieldGroupValue[i].ColumnId, value = fieldGroupValue[i].DefaultValue });
|
fieldList.Add(new CreateProjectField { key = "fld00" + fieldGroupValue[i].ColumnId, value = fieldGroupValue[i].DefaultValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldGroup = await _objectFieldsGroupsRep.AsQueryable().Where(x => x.GroupName == input.field_group).FirstAsync();
|
var fieldGroup = await _objectFieldsGroupsRep.AsQueryable().Where(x => x.GroupName == input.field_group).FirstAsync();
|
||||||
@ -139,6 +139,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
|
|||||||
{
|
{
|
||||||
object_id = input.object_id,
|
object_id = input.object_id,
|
||||||
field_group_id = fieldGroup.GroupObjId,
|
field_group_id = fieldGroup.GroupObjId,
|
||||||
|
//template_id = 17,
|
||||||
fields = fieldList
|
fields = fieldList
|
||||||
};
|
};
|
||||||
response = await _solidWorksManageService.CreateProject(data);
|
response = await _solidWorksManageService.CreateProject(data);
|
||||||
@ -213,66 +214,66 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
|
|||||||
|
|
||||||
if (clientExists == false)
|
if (clientExists == false)
|
||||||
{
|
{
|
||||||
var fieldList = new List<Field>();
|
var fieldList = new List<CreateProcessField>();
|
||||||
|
|
||||||
fieldList.Add(new Field { key = "_System_objNBS", value = input._System_objNBS });
|
fieldList.Add(new CreateProcessField { key = "_System_objNBS", value = input._System_objNBS });
|
||||||
fieldList.Add(new Field { key = "_System_objDescription", value = input._System_objDescription });
|
fieldList.Add(new CreateProcessField { key = "_System_objDescription", value = input._System_objDescription });
|
||||||
fieldList.Add(new Field { key = "fld005831", value = input.fld005831 });
|
fieldList.Add(new CreateProcessField { key = "fld005831", value = input.fld005831 });
|
||||||
fieldList.Add(new Field { key = "fld005832", value = input.fld005832 });
|
fieldList.Add(new CreateProcessField { key = "fld005832", value = input.fld005832 });
|
||||||
fieldList.Add(new Field { key = "fld005833", value = input.fld005833 });
|
fieldList.Add(new CreateProcessField { key = "fld005833", value = input.fld005833 });
|
||||||
fieldList.Add(new Field { key = "fld005836", value = input.fld005836 });
|
fieldList.Add(new CreateProcessField { key = "fld005836", value = input.fld005836 });
|
||||||
fieldList.Add(new Field { key = "fld005842", value = input.fld005842 });
|
fieldList.Add(new CreateProcessField { key = "fld005842", value = input.fld005842 });
|
||||||
fieldList.Add(new Field { key = "fld005847", value = input.fld005847 });
|
fieldList.Add(new CreateProcessField { key = "fld005847", value = input.fld005847 });
|
||||||
fieldList.Add(new Field { key = "fld005849", value = input.fld005849.ToString("yyyy-MM-dd HH:mm:ss") });
|
fieldList.Add(new CreateProcessField { key = "fld005849", value = input.fld005849.ToString("yyyy-MM-dd HH:mm:ss") });
|
||||||
fieldList.Add(new Field { key = "fld005850", value = input.fld005850 });
|
fieldList.Add(new CreateProcessField { key = "fld005850", value = input.fld005850 });
|
||||||
fieldList.Add(new Field { key = "fld005852", value = input.fld005852.ToString("yyyy-MM-dd HH:mm:ss") });
|
fieldList.Add(new CreateProcessField { key = "fld005852", value = input.fld005852.ToString("yyyy-MM-dd HH:mm:ss") });
|
||||||
fieldList.Add(new Field { key = "fld005853", value = input.fld005853 });
|
fieldList.Add(new CreateProcessField { key = "fld005853", value = input.fld005853 });
|
||||||
fieldList.Add(new Field { key = "fld005855", value = "OA" });
|
fieldList.Add(new CreateProcessField { key = "fld005855", value = "OA" });
|
||||||
fieldList.Add(new Field { key = "fld007040", value = input.fld007040 });
|
fieldList.Add(new CreateProcessField { key = "fld007040", value = input.fld007040 });
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005838))
|
if (!string.IsNullOrWhiteSpace(input.fld005838))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005838", value = input.fld005838 });
|
fieldList.Add(new CreateProcessField { key = "fld005838", value = input.fld005838 });
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005841))
|
if (!string.IsNullOrWhiteSpace(input.fld005841))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005841", value = input.fld005841 });
|
fieldList.Add(new CreateProcessField { key = "fld005841", value = input.fld005841 });
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005843))
|
if (!string.IsNullOrWhiteSpace(input.fld005843))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005843", value = input.fld005843 });
|
fieldList.Add(new CreateProcessField { key = "fld005843", value = input.fld005843 });
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005846))
|
if (!string.IsNullOrWhiteSpace(input.fld005846))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005846", value = input.fld005846 });
|
fieldList.Add(new CreateProcessField { key = "fld005846", value = input.fld005846 });
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005844))
|
if (!string.IsNullOrWhiteSpace(input.fld005844))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005844", value = input.fld005844 });
|
fieldList.Add(new CreateProcessField { key = "fld005844", value = input.fld005844 });
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005845))
|
if (!string.IsNullOrWhiteSpace(input.fld005845))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005845", value = input.fld005845 });
|
fieldList.Add(new CreateProcessField { key = "fld005845", value = input.fld005845 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld006061))
|
if (!string.IsNullOrWhiteSpace(input.fld006061))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld006061", value = input.fld006061 });
|
fieldList.Add(new CreateProcessField { key = "fld006061", value = input.fld006061 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld006062))
|
if (!string.IsNullOrWhiteSpace(input.fld006062))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld006062", value = input.fld006062 });
|
fieldList.Add(new CreateProcessField { key = "fld006062", value = input.fld006062 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(input.fld005854))
|
if (!string.IsNullOrWhiteSpace(input.fld005854))
|
||||||
{
|
{
|
||||||
fieldList.Add(new Field { key = "fld005854", value = input.fld005854 });
|
fieldList.Add(new CreateProcessField { key = "fld005854", value = input.fld005854 });
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldGroup = await _objectFieldsGroupsRep.AsQueryable().Where(x => x.GroupName == input.field_group && x.ObjectId == 140).FirstAsync();
|
var fieldGroup = await _objectFieldsGroupsRep.AsQueryable().Where(x => x.GroupName == input.field_group && x.ObjectId == 140).FirstAsync();
|
||||||
|
|
||||||
var data = new CreateProjectInput
|
var data = new CreateProcessInput
|
||||||
{
|
{
|
||||||
object_id = input.object_id,
|
object_id = input.object_id,
|
||||||
field_group_id = fieldGroup.GroupObjId,
|
field_group_id = fieldGroup.GroupObjId,
|
||||||
@ -456,6 +457,7 @@ public class OaOpenInterfaceService : IDynamicApiController, ITransient
|
|||||||
response.Success = false;
|
response.Success = false;
|
||||||
response.Message = "编码不存在";
|
response.Message = "编码不存在";
|
||||||
}
|
}
|
||||||
|
input.file = "文件过大,不写入日志";
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||||
|
//
|
||||||
|
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||||
|
//
|
||||||
|
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Vistar.Application.SolidWorksManageService.Dto;
|
||||||
|
public class CreateProcessInput
|
||||||
|
{
|
||||||
|
|
||||||
|
public long object_id { get; set; }
|
||||||
|
public long field_group_id { get; set; }
|
||||||
|
public List<CreateProcessField> fields { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateProcessField
|
||||||
|
{
|
||||||
|
public string key { get; set; }
|
||||||
|
public string value { get; set; }
|
||||||
|
}
|
||||||
@ -18,7 +18,8 @@ public class CreateProjectInput
|
|||||||
{
|
{
|
||||||
public long object_id { get; set; }
|
public long object_id { get; set; }
|
||||||
public long field_group_id { get; set; }
|
public long field_group_id { get; set; }
|
||||||
public List<Field> fields { get; set; }
|
//public long template_id { get; set; }
|
||||||
|
public List<CreateProjectField> fields { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreateProjectField
|
public class CreateProjectField
|
||||||
|
|||||||
@ -85,6 +85,60 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取新版 token
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>授权响应对象</returns>
|
||||||
|
[ApiDescriptionSettings(Name = "AuthenticateNew", Description = "获取新版 token", Order = 1000), HttpGet]
|
||||||
|
[DisplayName("获取新版 token")]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<AuthorizationResponse> AuthenticateNew()
|
||||||
|
{
|
||||||
|
// 获取 SolidWorksManage 地址
|
||||||
|
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrlNew);
|
||||||
|
// 拼接接口地址
|
||||||
|
string url = $"{apiUrl}/api/Authentication/Authenticate";
|
||||||
|
|
||||||
|
var SolidWorksManageUserName = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageUserName);
|
||||||
|
var SolidWorksManagePassword = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManagePassword);
|
||||||
|
var SolidWorksManageLicenseId = "190";
|
||||||
|
//var SolidWorksManageApiKey = "zesywsWf1dthwXoqd4DJKasEihcuOArxiImrvu8jOUB7oqryVhFAdydL1nPpC5/0gkhIWm6TdPBolBFx+V/FPgcoG370JXnRp/DZ350wi70=";
|
||||||
|
// 构建请求参数字典
|
||||||
|
var parameter = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
["username"] = SolidWorksManageUserName,
|
||||||
|
["password"] = SolidWorksManagePassword,
|
||||||
|
["licenseId"] = SolidWorksManageLicenseId
|
||||||
|
//["apikey"] = SolidWorksManageApiKey
|
||||||
|
};
|
||||||
|
|
||||||
|
// 将请求参数格式化为 URL 格式的字符串
|
||||||
|
var formattingParameter = string.Join("&", parameter.Select(kvp => $"{Uri.EscapeDataString(kvp.Key)}={Uri.EscapeDataString(kvp.Value)}"));
|
||||||
|
// 构建完整的请求 URL
|
||||||
|
var requestUrl = $"{url}?{formattingParameter}";
|
||||||
|
|
||||||
|
// 使用 using 语句确保 HttpResponseMessage 资源被正确释放
|
||||||
|
using (var response = await client.PostAsync(requestUrl, null))
|
||||||
|
{
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
// 读取响应内容并反序列化为授权响应对象
|
||||||
|
string responseBody = await response.Content.ReadAsStringAsync();
|
||||||
|
AuthorizationResponse jsondata = JsonConvert.DeserializeObject<AuthorizationResponse>(responseBody);
|
||||||
|
string value = jsondata.access_token;
|
||||||
|
await _sysConfigService.UpdateConfigValue(ConfigConst.SolidWorksManageAuthorizationNew, value);
|
||||||
|
return JsonConvert.DeserializeObject<AuthorizationResponse>(responseBody);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 读取响应内容并反序列化为授权响应对象(通常表示请求失败,但这里也尝试反序列化以便进一步处理错误)
|
||||||
|
string responseBody = await response.Content.ReadAsStringAsync();
|
||||||
|
return JsonConvert.DeserializeObject<AuthorizationResponse>(responseBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建记录
|
/// 创建记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -273,7 +327,7 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ManageResponse> CreateProcess(CreateProjectInput input)
|
public async Task<ManageResponse> CreateProcess(CreateProcessInput input)
|
||||||
{
|
{
|
||||||
// 获取 SolidWorksManage 地址
|
// 获取 SolidWorksManage 地址
|
||||||
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
||||||
@ -387,11 +441,11 @@ public class SolidWorksManageService : IDynamicApiController, ITransient
|
|||||||
public async Task<ManageResponse> AddRelatedFiles(AddRelatedFilesInput input)
|
public async Task<ManageResponse> AddRelatedFiles(AddRelatedFilesInput input)
|
||||||
{
|
{
|
||||||
// 获取 SolidWorksManage 地址
|
// 获取 SolidWorksManage 地址
|
||||||
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrl);
|
string apiUrl = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageApiUrlNew);
|
||||||
// 拼接接口地址
|
// 拼接接口地址
|
||||||
string url = $"{apiUrl}/api/File/AddRelatedFileToFolder";
|
string url = $"{apiUrl}/api/File/AddRelatedFileToFolder";
|
||||||
//获取token
|
//获取token
|
||||||
var token = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageAuthorization);
|
var token = await _sysConfigService.GetConfigValueByCode<string>(ConfigConst.SolidWorksManageAuthorizationNew);
|
||||||
// 将参数对象序列化为 JSON 字符串
|
// 将参数对象序列化为 JSON 字符串
|
||||||
string jsonParameters = JsonConvert.SerializeObject(input);
|
string jsonParameters = JsonConvert.SerializeObject(input);
|
||||||
// 设置请求内容
|
// 设置请求内容
|
||||||
|
|||||||
@ -202,7 +202,6 @@ const handleView = async ({ row }: any) => {
|
|||||||
state.detail.returnResult = StringToObj(data?.data?.result);
|
state.detail.returnResult = StringToObj(data?.data?.result);
|
||||||
|
|
||||||
state.visible = true;
|
state.visible = true;
|
||||||
console.log('aa', state.detail.returnResult)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user