using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; using System.Diagnostics; using System.Runtime.InteropServices; using System.Net; using System.ServiceModel; using SiaSun.LMS.Interface; using System.ServiceProcess; namespace SiaSun.LMS.WCFHost { /// /// Program /// public static class MainApp { //本机地址 public static IPAddress[] _IPAddressList; //应用程序路径 public static string _APP_PATH; //服务地址 public static string _BaseUrl; //语言 public static string _Language; public static MAIN mainForm = null; #region ------业务接口定义 public static SiaSun.LMS.Interface.I_BaseService _I_BaseService = new SiaSun.LMS.Implement.S_BaseService(); public static SiaSun.LMS.Interface.I_SystemService _I_SystemService = new SiaSun.LMS.Implement.S_SystemService(); public static SiaSun.LMS.Interface.I_FlowService _I_FlowService = new SiaSun.LMS.Implement.S_FlowService(); public static SiaSun.LMS.Interface.I_PlanService _I_PlanService = new SiaSun.LMS.Implement.S_PlanService(); public static SiaSun.LMS.Interface.I_ManageService _I_ManageService = new SiaSun.LMS.Implement.S_ManageService(); public static SiaSun.LMS.Interface.I_StorageService _I_StorageService = new SiaSun.LMS.Implement.S_StorageService(); public static SiaSun.LMS.Interface.I_CellService _I_CellService = new SiaSun.LMS.Implement.S_CellService(); public static SiaSun.LMS.Interface.I_LEDService _I_LedService = new SiaSun.LMS.Implement.S_LEDService(); /// /// 基础服务类 /// //public static SiaSun.LMS.Interface.I_BaseService _I_BaseService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/BaseService")); } //} ///// ///// 系统类 ///// //public static SiaSun.LMS.Interface.I_SystemService _I_SystemService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/SystemService")); } //} ///// ///// 状态流程类 ///// //public static SiaSun.LMS.Interface.I_FlowService _I_FlowService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/FlowService")); } //} ///// ///// 计划类 ///// //public static SiaSun.LMS.Interface.I_PlanService _I_PlanService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/PlanService")); } //} ///// ///// 任务类 ///// //public static SiaSun.LMS.Interface.I_ManageService _I_ManageService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/ManageService")); } //} ///// ///// 库存存储类 ///// //public static SiaSun.LMS.Interface.I_StorageService _I_StorageService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/StorageService")); } //} ///// ///// 仓储货位类 ///// //public static SiaSun.LMS.Interface.I_CellService _I_CellService //{ // get { return SiaSun.LMS.Common.WCFHelper.Create(string.Format(_BaseUrl + "/CellService")); } //} #endregion /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { //获得语言 _Language = SiaSun.LMS.Common.AppSettings.GetValue("Language"); //获得服务地址 _BaseUrl = SiaSun.LMS.Common.StringUtil.GetConfig("SiaSunSrvUrl"); //获得执行程序的路径 _APP_PATH = AppDomain.CurrentDomain.BaseDirectory; //获得IP地址 _IPAddressList = Dns.GetHostAddresses(Dns.GetHostName()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //add by yangjian //ServiceHost clientAccessPolicy = new ServiceHost(typeof(SiaSun.LMS.Implement.S_ClientAccessPolicy)); //clientAccessPolicy.Open(); using (Process p = SiaSun.LMS.Common.SingleInstance.GetRunningInstance()) { if (p != null) //已经有应用程序副本执行 { System.Windows.Forms.MessageBox.Show("请检查程序是否已经隐藏在后台运行!", "系统提示"); //SiaSun.LMS.Common.SingleInstance.HandleRunningInstance(p); p.Dispose(); } else { mainForm = new MAIN(); Application.Run(mainForm); } } } } }