宜昌华友原料库管理软件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.7 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.ServiceModel;
using SSLMS.Service;
using SSLMS.IService;
using System.ServiceModel.Description;
namespace SSLMS.Host
{
public partial class IO : ServiceBase
{
ServiceHost shBase;
ServiceHost shB;
ServiceHost shST;
ServiceHost shWF;
ServiceHost shSAP;
ServiceHost shIO;
public IO()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
// TODO: 在此处添加代码以启动服务。
try
{
this.IOeventLog.WriteEntry("The service sh_Base starting.");
shBase = new ServiceHost(typeof(S_Base), new Uri(string.Format(Program._BaseUrl + "/Base")));
shBase.AddServiceEndpoint(typeof(I_Base), new WSHttpBinding(SecurityMode.None), "");
ServiceMetadataBehavior smbBase = new ServiceMetadataBehavior();
smbBase.HttpGetEnabled = true;
shBase.Description.Behaviors.Add(smbBase);
shBase.Open();
this.IOeventLog.WriteEntry("The service sh_Base is ready.");
this.IOeventLog.WriteEntry("The service sh_B starting.");
shB = new ServiceHost(typeof(S_B), new Uri(string.Format(Program._BaseUrl + "/B")));
shB.AddServiceEndpoint(typeof(I_B), new WSHttpBinding(SecurityMode.None), "");
ServiceMetadataBehavior smbB = new ServiceMetadataBehavior();
smbB.HttpGetEnabled = true;
shB.Description.Behaviors.Add(smbB);
shB.Open();
this.IOeventLog.WriteEntry("The service sh_B is ready.");
this.IOeventLog.WriteEntry("The service sh_IO starting.");
shIO = new ServiceHost(typeof(S_IO), new Uri(string.Format(Program._BaseUrl + "/IO")));
shIO.AddServiceEndpoint(typeof(I_IO), new WSHttpBinding(SecurityMode.None), "");
ServiceMetadataBehavior smbIO = new ServiceMetadataBehavior();
smbIO.HttpGetEnabled = true;
shIO.Description.Behaviors.Add(smbIO);
shIO.Open();
this.IOeventLog.WriteEntry("The service sh_IO is ready.");
this.IOeventLog.WriteEntry("The service sh_ST starting.");
shST = new ServiceHost(typeof(S_ST), new Uri(string.Format(Program._BaseUrl + "/ST")));
shST.AddServiceEndpoint(typeof(I_ST), new WSHttpBinding(SecurityMode.None), "");
ServiceMetadataBehavior smbST = new ServiceMetadataBehavior();
smbST.HttpGetEnabled = true;
shST.Description.Behaviors.Add(smbST);
shST.Open();
this.IOeventLog.WriteEntry("The service sh_ST is ready.", EventLogEntryType.Error);
this.IOeventLog.WriteEntry("The service sh_WF starting.");
shWF = new ServiceHost(typeof(S_WF), new Uri(string.Format(Program._BaseUrl + "/WF")));
shWF.AddServiceEndpoint(typeof(I_WF), new WSHttpBinding(SecurityMode.None), "");
ServiceMetadataBehavior smbWF = new ServiceMetadataBehavior();
smbWF.HttpGetEnabled = true;
shWF.Description.Behaviors.Add(smbWF);
shWF.Open();
this.IOeventLog.WriteEntry("The service sh_WF is ready.", EventLogEntryType.Error);
this.IOeventLog.WriteEntry("The service sh_SAP starting.");
shSAP = new ServiceHost(typeof(S_SAP), new Uri(string.Format(Program._BaseUrl + "/SAP")));
shSAP.AddServiceEndpoint(typeof(I_SAP), new WSHttpBinding(SecurityMode.None), "");
ServiceMetadataBehavior smbSAP = new ServiceMetadataBehavior();
smbSAP.HttpGetEnabled = true;
shSAP.Description.Behaviors.Add(smbSAP);
shSAP.Open();
this.IOeventLog.WriteEntry("The service sh_WF is ready.", EventLogEntryType.Error);
}
catch (CommunicationException ce)
{
this.IOeventLog.WriteEntry(string.Format("An exception occurred: {0}", ce.Message));
}
}
protected override void OnStop()
{
// TODO: 在此处添加代码以执行停止服务所需的关闭操作。
this.shBase.Close();
this. shB.Close();
this.shIO.Close();
this. shST.Close();
this. shWF.Close();
this. shSAP.Close();
}
}
}