ldj/winform/service/PrintServiceForm.cs

102 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Base;
//using DeiNiu.wms.Logical;
using DeiNiu.wms.Data;
using DevExpress.XtraGrid.Columns;
using System.Threading;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraEditors.DXErrorProvider;
using DeiNiu.wms.Data.Model;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DeiNiu.Utils;
using System.ServiceModel;
namespace DeiNiu.wms.win
{
public partial class PrintServiceForm : BasicRibbonForm
{
private ServiceHost host = null;
string svrUrl = WmsConstants.LIGHT_SVR_ADDRESS;
string wmsUrl = "";
string postUrl = "";
delegate void showStatus();
public PrintServiceForm()
{
InitializeComponent();
initialControls();
// loadData();
}
#region initialControls
private void initialControls()
{
}
#endregion
void startHost()
{
// lbStatus.Text = "服务启动失败";
try
{
/*
wmsUrl = System.Configuration.ConfigurationManager.AppSettings["WMSuri"];
Uri baseAddress = new Uri(svrUrl);
LightService service = new LightService();
service.lightOd += this.lightByOrder;
// service.lightUp += this.lightUp;
host = new ServiceHost(service, baseAddress);
// elelab.DNLights.lightOffEvent += testPicked;
WebHttpBinding binding = new WebHttpBinding();
ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(ILightService), binding, baseAddress);
WebHttpBehavior httpBehavior = new WebHttpBehavior();
endpoint.Behaviors.Add(httpBehavior);
host.Opened += delegate
{
// addLog("服务已启动");
if (InvokeRequired)
{
this.Invoke(new showStatus(delegate()
{
lbStatus.Text = "服务已启动";
lbUrl.Text = "亮灯服务地址:" + svrUrl; ;
}));
}
else
{
lbStatus.Text = "服务已启动";
lbUrl.Text = "亮灯服务地址:" + svrUrl;
}
};
host.Open();
* */
}
catch (Exception e)
{
// addLog("启动服务失败: " + e.Message);
MessageBox.Show("启动服务失败: " + e.Message);
}
}
}
}