|
|
@@ -207,7 +207,12 @@ namespace YSAI.Opc.ua.service
|
|
|
public override string LogHead => "[ OpcUaServiceOperate 操作 ]";
|
|
|
public override string ClassName => "OpcUaServiceOperate";
|
|
|
|
|
|
- public async Task<OperateResult> OnAsync()
|
|
|
+ public Task<OperateResult> OnAsync()
|
|
|
+ {
|
|
|
+ return Task.Run(() => On());
|
|
|
+ }
|
|
|
+
|
|
|
+ public OperateResult On()
|
|
|
{
|
|
|
//开始记录运行时间
|
|
|
RunTimeTool.Instance("OpcUaServiceOperate.On").StartRecord();
|
|
|
@@ -222,13 +227,13 @@ namespace YSAI.Opc.ua.service
|
|
|
AI.ConfigSectionName = "Opc.Ua.Service";
|
|
|
|
|
|
//加载应用程序配置
|
|
|
- ApplicationConfiguration config = await AI.LoadApplicationConfiguration(false);
|
|
|
+ ApplicationConfiguration config = AI.LoadApplicationConfiguration(false).Result;
|
|
|
if (!config.SecurityConfiguration.AutoAcceptUntrustedCertificates)
|
|
|
{
|
|
|
config.CertificateValidator.CertificateValidation += new CertificateValidationEventHandler(CertificateValidator_CertificateValidation);
|
|
|
}
|
|
|
//检查申请证书
|
|
|
- bool haveAppCertificate = await AI.CheckApplicationInstanceCertificate(false, 0);
|
|
|
+ bool haveAppCertificate = AI.CheckApplicationInstanceCertificate(false, 0).Result;
|
|
|
if (!haveAppCertificate)
|
|
|
{
|
|
|
return Break("On", false, "应用实例证书无效");
|
|
|
@@ -238,7 +243,7 @@ namespace YSAI.Opc.ua.service
|
|
|
|
|
|
|
|
|
//启动服务
|
|
|
- await AI.Start(service);
|
|
|
+ AI.StartAsService(service);
|
|
|
|
|
|
//打印信息
|
|
|
var endpoints = AI.Server.GetEndpoints().Select(e => e.EndpointUrl).Distinct();
|
|
|
@@ -271,11 +276,6 @@ namespace YSAI.Opc.ua.service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public OperateResult On()
|
|
|
- {
|
|
|
- return OnAsync().Result;
|
|
|
- }
|
|
|
-
|
|
|
public Task<OperateResult> OffAsync()
|
|
|
{
|
|
|
return Task.Run(() => Off());
|