12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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);
- }
- }
- }
|