Program.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.ServiceModel;
  5. using System.ServiceModel.Description;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using log4net;
  9. namespace GDNXFD.WcfHost
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. ILog logger = LogManager.GetLogger("AppLog");
  16. try
  17. {
  18. logger.Info("日志写入测试");
  19. //以配置文件方式配置终结点
  20. ServiceHost host = new ServiceHost(typeof(GDNXFD.WcfService.AlertService));
  21. host.Open();
  22. ServiceHost host2 = new ServiceHost(typeof(GDNXFD.WcfService.AdviceService));
  23. host2.Open();
  24. ServiceHost host3 = new ServiceHost(typeof(GDNXFD.WcfService.DefectBillService));
  25. host3.Open();
  26. ServiceHost host4 = new ServiceHost(typeof(GDNXFD.WcfService.FaultInfoService));
  27. host4.Open();
  28. }
  29. catch (Exception ex)
  30. {
  31. Console.WriteLine("创建ServiceHost出现异常");
  32. logger.Info(ex.Message);
  33. }
  34. Console.WriteLine("WCF服务启动成功......");
  35. //int i = 0;
  36. //foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
  37. //{
  38. // i++;
  39. // Console.WriteLine("终结点序号:{0},终结点名称:{1},终结点地址:{2},终结点绑定:{3}{4}", i, endpoint.Name, endpoint.Address, endpoint.Binding, Environment.NewLine);
  40. //}
  41. try
  42. {
  43. Console.WriteLine("线程启动......");
  44. GDNXFD.WcfService.AdviceWorker.Instance.Start();
  45. }
  46. catch (Exception ex)
  47. {
  48. //logger.Info(ex.Message);
  49. }
  50. while (true)
  51. {
  52. Console.Read();
  53. }
  54. }
  55. }
  56. }