using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Diagnostics;
|
using System.Linq;
|
using System.ServiceModel;
|
using System.ServiceProcess;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using siemensSapService.orm;
|
|
namespace siemensSapService
|
{
|
public partial class Service1 : ServiceBase
|
{
|
#region 开启服务流程
|
//1.cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
|
//2.InstallUtil.exe E:\ximenzi\wms\siemensSapService\siemensSapService\bin\Debug\siemensSapService.exe 找到自己的服务地址
|
//启动服务 net start IWareCC
|
//停止服务 net stop IWareCC
|
//卸载服务 sc delete IWareCC
|
#endregion
|
public Service1()
|
{
|
InitializeComponent();
|
}
|
ServiceHost aspService;//声明WCF变量
|
protected override void OnStart(string[] args)
|
{
|
aspService = new ServiceHost(typeof(siemensSapService.wcf.sapWcf));
|
aspService.Open();//开启wcf服务
|
|
}
|
|
protected override void OnStop()
|
{
|
CloseWcf(aspService);//关闭WCF服务
|
|
}
|
|
|
|
///<summary>
|
///关闭WCF
|
///</summary>
|
///<param name="host">需要关闭的WCF</param>
|
private void CloseWcf(ServiceHost host)
|
{
|
if (host != null)
|
{
|
host.Close();
|
}
|
}
|
|
/// <summary>
|
/// 关闭线程
|
/// </summary>
|
/// <param name="thread">需要关闭的线程</param>
|
private void CloseThread(Thread thread)
|
{
|
if (thread != null)
|
{
|
thread.Abort();
|
}
|
|
}
|
|
}
|
}
|