| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.ServiceModel;
- using System.Text;
- using System.Threading.Tasks;
- namespace Winsoft.GOV.WCF
- {
- public class Host
- {
- private static ServiceHost adapter;
- public static bool Start()
- {
- try
- {
- adapter = new ServiceHost(typeof(PowerMettersService));
- adapter.Open();
- Log("Winsoft.GOV.WCF started!");
- return true;
- }
- catch (Exception ex)
- {
- Log("Start Service failed:{0}" + ex.ToString());
- return false;
- }
- }
- public static void Stop()
- {
- try
- {
- if (adapter != null)
- {
- adapter.Close();
- adapter = null;
- }
- }
- catch (Exception ex)
- {
- 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);
- }
- }
- }
|