using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.Text; using System.Threading.Tasks; using Winsoft.GOV.Framework; namespace Winsoft.GOV.WCF { public class Host { private static ServiceHost adapter; public static bool Start() { try { adapter = new ServiceHost(typeof(PowerMettersService)); adapter.Open(); FunLib.Log("Winsoft.GOV.WCF started!"); return true; } catch (Exception ex) { FunLib.Log("Start Service failed:{0}" + ex.ToString()); return false; } } public static void Stop() { try { if (adapter != null) { adapter.Close(); adapter = null; } } catch (Exception ex) { FunLib.Log("Stop Service failed:{0}" + ex.ToString()); } } private static void Log(string msg) { System.Console.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString()); System.Console.WriteLine(":{0}", msg); } } }