2024-02-01 18:32:23 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ServiceModel;
|
2024-02-02 17:10:15 +08:00
|
|
|
|
using System.ServiceModel.Channels;
|
2024-02-01 18:32:23 +08:00
|
|
|
|
|
2024-02-01 19:05:50 +08:00
|
|
|
|
namespace MECF.Framework.Common.MultiProcess.ProcessCenter
|
2024-02-01 18:32:23 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
|
|
|
|
|
public class MultiProcessService : IMultiProcessService
|
|
|
|
|
{
|
|
|
|
|
public bool CanEnterProcessIdleNow(string sicMachineName, string pmName, out string result)
|
|
|
|
|
{
|
|
|
|
|
return MULTIPROCESS.CanEnterProcessIdleNow(sicMachineName, pmName, out result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanEnterProcessNow(string sicMachineName, string pmName, out string result)
|
|
|
|
|
{
|
|
|
|
|
return MULTIPROCESS.CanEnterProcessNow(sicMachineName, pmName, out result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<string> QueryAllProcessInformation()
|
|
|
|
|
{
|
|
|
|
|
return MULTIPROCESS.QueryAllProcessInformation();
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-02 16:17:07 +08:00
|
|
|
|
public string QueryMyProcessInformation(string sicMachineName, string pmName)
|
|
|
|
|
{
|
|
|
|
|
return MULTIPROCESS.QueryMyProcessInformation(sicMachineName, pmName);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-01 18:32:23 +08:00
|
|
|
|
public bool UpdateChamberState(string sicMachineName, string pmName, string state)
|
|
|
|
|
{
|
2024-02-02 17:10:15 +08:00
|
|
|
|
return MULTIPROCESS.UpdateChamberState(GetClientInformation(sicMachineName, pmName), sicMachineName, pmName, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetClientInformation(string sicMachineName, string pmName)
|
|
|
|
|
{
|
|
|
|
|
//提供方法执行的上下文环境
|
|
|
|
|
OperationContext context = OperationContext.Current;
|
|
|
|
|
//获取传进的消息属性
|
|
|
|
|
MessageProperties properties = context.IncomingMessageProperties;
|
|
|
|
|
//获取消息发送的远程终结点IP和端口
|
|
|
|
|
RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
|
|
|
|
|
|
|
|
|
|
return $"{sicMachineName} {pmName}; {endpoint.Address}";
|
2024-02-01 18:32:23 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|