Explorar el Código

消息解析(字典解析+查询服务任务生成)

singlese7en hace 2 años
padre
commit
6c3c7fb474
Se han modificado 100 ficheros con 6877 adiciones y 0 borrados
  1. 253 0
      HisClientReceiveToScan.sln
  2. 223 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADTHandler.cs
  3. 108 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A01_Handler.cs
  4. 95 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A02_Handler.cs
  5. 106 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A04_Handler.cs
  6. 106 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A05_Handler.cs
  7. 42 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/BizComponent_ADT.cs
  8. 148 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/MediII.Adapter.BizComponent.ADT.csproj
  9. 36 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/AssemblyInfo.cs
  10. 63 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Resources.Designer.cs
  11. 117 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Resources.resx
  12. 26 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Settings.Designer.cs
  13. 7 0
      IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Settings.settings
  14. 109 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/BaseBizComponent.cs
  15. 67 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/BizComponentFactory.cs
  16. 26 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/DefaultBizBehavior.cs
  17. 29 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/IBizBehavior.cs
  18. 18 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/IBizComponent.cs
  19. 115 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/MediII.Adapter.BizComponent.Base.csproj
  20. 36 0
      IL.BizComponent/MediII.Adapter.BizComponent.Base/Properties/AssemblyInfo.cs
  21. 71 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/BizComponent_MFN.cs
  22. 326 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFNBase.cs
  23. 130 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z2A_HisInfo.cs
  24. 118 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z2B_GY_KESHI.cs
  25. 301 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z2B_GY_KESHI_ZS.cs
  26. 285 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z3H_GY_YAOPINFL.cs
  27. 113 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/MediII.Adapter.BizComponent.MFN.csproj
  28. 36 0
      IL.BizComponent/MediII.Adapter.BizComponent.MFN/Properties/AssemblyInfo.cs
  29. 668 0
      IL.BizComponent/MediII.Adapter.BizComponent.PMU/BizComponent_PMU.cs
  30. 102 0
      IL.BizComponent/MediII.Adapter.BizComponent.PMU/MediII.Adapter.BizComponent.PMU.csproj
  31. 36 0
      IL.BizComponent/MediII.Adapter.BizComponent.PMU/Properties/AssemblyInfo.cs
  32. 20 0
      MediII.Adapter.MsgToScanServer/ApplictStatic.cs
  33. 100 0
      MediII.Adapter.MsgToScanServer/MediII.Adapter.MsgToScanServer.csproj
  34. 37 0
      MediII.Adapter.MsgToScanServer/MsgToScanServer.Designer.cs
  35. 105 0
      MediII.Adapter.MsgToScanServer/MsgToScanServer.cs
  36. 24 0
      MediII.Adapter.MsgToScanServer/Program.cs
  37. 59 0
      MediII.Adapter.MsgToScanServer/ProjectInstaller.Designer.cs
  38. 24 0
      MediII.Adapter.MsgToScanServer/ProjectInstaller.cs
  39. 129 0
      MediII.Adapter.MsgToScanServer/ProjectInstaller.resx
  40. 36 0
      MediII.Adapter.MsgToScanServer/Properties/AssemblyInfo.cs
  41. 149 0
      MediII.Adapter.MsgToScanServer/ServiceStatusPublishManager.cs
  42. 97 0
      MediII.Adapter.MsgToScanServer/app.config
  43. 13 0
      MediII.Adapter.ReceiveToScanModel/BaseEntity.cs
  44. 46 0
      MediII.Adapter.ReceiveToScanModel/HL7_MessageSetEntity.cs
  45. 107 0
      MediII.Adapter.ReceiveToScanModel/HL7_ReceiveEntity.cs
  46. 126 0
      MediII.Adapter.ReceiveToScanModel/HL7_ScanEntity.cs
  47. 66 0
      MediII.Adapter.ReceiveToScanModel/HL7_SendMessageEntity.cs
  48. 58 0
      MediII.Adapter.ReceiveToScanModel/MediII.Adapter.ReceiveToScanModel.csproj
  49. 36 0
      MediII.Adapter.ReceiveToScanModel/Properties/AssemblyInfo.cs
  50. 23 0
      MediII.Adapter.Scan.UE/DebugScanner.cs
  51. 207 0
      MediII.Adapter.Scan.UE/DefaultDBScanner.cs
  52. 23 0
      MediII.Adapter.Scan.UE/HL7_ADT_Scanner.cs
  53. 84 0
      MediII.Adapter.Scan.UE/HL7_Lock_Scanner.cs
  54. 23 0
      MediII.Adapter.Scan.UE/HL7_MFN_Scanner.cs
  55. 24 0
      MediII.Adapter.Scan.UE/HL7_PMU_Scanner.cs
  56. 85 0
      MediII.Adapter.Scan.UE/HL7_ReceiveEntity.cs
  57. 94 0
      MediII.Adapter.Scan.UE/HL7_TimeOut_Scanner.cs
  58. 114 0
      MediII.Adapter.Scan.UE/MediII.Adapter.BizComponent.UE.csproj
  59. 36 0
      MediII.Adapter.Scan.UE/Properties/AssemblyInfo.cs
  60. 11 0
      MediII.Adapter.Scan.UE/app.config
  61. 17 0
      MediII.Adapter.Scanner/App.Config
  62. 124 0
      MediII.Adapter.Scanner/DBScaner.cs
  63. 12 0
      MediII.Adapter.Scanner/Entity/BaseEntity.cs
  64. 45 0
      MediII.Adapter.Scanner/Entity/HL7_MessageSetEntity.cs
  65. 106 0
      MediII.Adapter.Scanner/MediII.Adapter.Scanner.csproj
  66. 14 0
      MediII.Adapter.Scanner/MessageItem.cs
  67. 36 0
      MediII.Adapter.Scanner/Properties/AssemblyInfo.cs
  68. 44 0
      MediII.Adapter.Scanner/ScanNormalTemplate.txt
  69. 58 0
      MediII.Adapter.Scanner/Scaner.cs
  70. 169 0
      MediII.Adapter.WinForm.Scan/MediII.Adapter.WinForm.Scanner.csproj
  71. 38 0
      MediII.Adapter.WinForm.Scan/Program.cs
  72. 36 0
      MediII.Adapter.WinForm.Scan/Properties/AssemblyInfo.cs
  73. 63 0
      MediII.Adapter.WinForm.Scan/Properties/Resources.Designer.cs
  74. 117 0
      MediII.Adapter.WinForm.Scan/Properties/Resources.resx
  75. 26 0
      MediII.Adapter.WinForm.Scan/Properties/Settings.Designer.cs
  76. 7 0
      MediII.Adapter.WinForm.Scan/Properties/Settings.settings
  77. 93 0
      MediII.Adapter.WinForm.Scan/app.config
  78. BIN
      MessageToScan/UE/Dapper.dll
  79. BIN
      MessageToScan/UE/IL.Common.dll
  80. BIN
      MessageToScan/UE/KC_HN_Tools.dll
  81. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.ADT.dll
  82. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.Base.dll
  83. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.MFN.dll
  84. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.OML.dll
  85. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.OMP.dll
  86. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.ORU.dll
  87. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.PMU.dll
  88. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.RAS.dll
  89. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.RDS.dll
  90. BIN
      MessageToScan/UE/MediII.Adapter.BizComponent.UE.dll
  91. BIN
      MessageToScan/UE/MediII.Adapter.ReceiveToSIModel.dll
  92. BIN
      MessageToScan/UE/MediII.Adapter.ReceiveToScanModel.dll
  93. BIN
      MessageToScan/UE/MediII.Adapter.Scan.Interface.dll
  94. BIN
      MessageToScan/UE/MediII.Adapter.Scanner.dll
  95. BIN
      MessageToScan/UE/MediII.Common.dll
  96. BIN
      MessageToScan/UE/Microsoft.Practices.EnterpriseLibrary.Common.dll
  97. BIN
      MessageToScan/UE/Microsoft.Practices.EnterpriseLibrary.Data.dll
  98. BIN
      MessageToScan/UE/Microsoft.Practices.EnterpriseLibrary.Logging.dll
  99. BIN
      MessageToScan/UE/Microsoft.Practices.ServiceLocation.dll
  100. BIN
      MessageToScan/UE/Microsoft.Practices.Unity.Interception.dll

+ 253 - 0
HisClientReceiveToScan.sln

@@ -0,0 +1,253 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.BizComponent.ADT", "IL.BizComponent\MediII.Adapter.BizComponent.ADT\MediII.Adapter.BizComponent.ADT.csproj", "{E634900C-0A19-4575-A0F7-BF5780AE20C3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.BizComponent.Base", "IL.BizComponent\MediII.Adapter.BizComponent.Base\MediII.Adapter.BizComponent.Base.csproj", "{619B1DBF-55B7-446B-AF40-852A6AB689A0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.ReceiveToScanModel", "MediII.Adapter.ReceiveToScanModel\MediII.Adapter.ReceiveToScanModel.csproj", "{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.BizComponent.UE", "MediII.Adapter.Scan.UE\MediII.Adapter.BizComponent.UE.csproj", "{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.WinForm.Scanner", "MediII.Adapter.WinForm.Scan\MediII.Adapter.WinForm.Scanner.csproj", "{5E125823-EC26-4F15-B178-48E8387C5F1A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sacnner", "Sacnner", "{13F2A33E-FD55-41A7-9288-18572D9E5130}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ORM", "ORM", "{0F0E79A2-AED1-4FD1-859B-A518FCB4BA31}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BizComponent", "BizComponent", "{092D7052-844E-4C0F-B6BB-D18B84FC7F99}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dll", "dll", "{746D4716-9F08-409E-9F3A-122F6F807E03}"
+	ProjectSection(SolutionItems) = preProject
+		..\dll\amqmdnet.dll = ..\dll\amqmdnet.dll
+		..\dll\amqmdunmanaged.dll = ..\dll\amqmdunmanaged.dll
+		..\dll\amqmdxcs.dll = ..\dll\amqmdxcs.dll
+		..\dll\AutoMapper.dll = ..\dll\AutoMapper.dll
+		..\dll\AutoMapper.xml = ..\dll\AutoMapper.xml
+		..\dll\ChnCharInfo.dll = ..\dll\ChnCharInfo.dll
+		..\dll\EFProviderWrapperToolkit.dll = ..\dll\EFProviderWrapperToolkit.dll
+		..\dll\EFTracingProvider.dll = ..\dll\EFTracingProvider.dll
+		..\dll\EntityFramework.dll = ..\dll\EntityFramework.dll
+		..\dll\IBM.XMS.dll = ..\dll\IBM.XMS.dll
+		..\dll\MediII.Adapter.BaseBiz.dll = ..\dll\MediII.Adapter.BaseBiz.dll
+		..\dll\MediII.Common.dll = ..\dll\MediII.Common.dll
+		..\dll\MediII.Common.MQAccess.dll = ..\dll\MediII.Common.MQAccess.dll
+		..\dll\MediII.Common.Processer.dll = ..\dll\MediII.Common.Processer.dll
+		..\dll\MediII.HL7.Mapping.dll = ..\dll\MediII.HL7.Mapping.dll
+		..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll = ..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll
+		..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll = ..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll
+		..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll = ..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll
+		..\dll\Microsoft.Practices.ServiceLocation.dll = ..\dll\Microsoft.Practices.ServiceLocation.dll
+		..\dll\Microsoft.Practices.Unity.Configuration.dll = ..\dll\Microsoft.Practices.Unity.Configuration.dll
+		..\dll\Microsoft.Practices.Unity.dll = ..\dll\Microsoft.Practices.Unity.dll
+		..\dll\Microsoft.Practices.Unity.Interception.Configuration.dll = ..\dll\Microsoft.Practices.Unity.Interception.Configuration.dll
+		..\dll\Microsoft.Practices.Unity.Interception.dll = ..\dll\Microsoft.Practices.Unity.Interception.dll
+		..\dll\NHapi.Base.dll = ..\dll\NHapi.Base.dll
+		..\dll\NHapi.Base.dll.config = ..\dll\NHapi.Base.dll.config
+		..\dll\NHapi.Model.V231.dll = ..\dll\NHapi.Model.V231.dll
+		..\dll\NHapi.Model.V24.dll = ..\dll\NHapi.Model.V24.dll
+		..\dll\NHapi.Model.V24.dll.VisualState.xml = ..\dll\NHapi.Model.V24.dll.VisualState.xml
+		..\dll\NHapi.Model.V24.XML = ..\dll\NHapi.Model.V24.XML
+		..\dll\NHapi.Model.V25.dll = ..\dll\NHapi.Model.V25.dll
+		..\dll\NHapi.Model.V251.dll = ..\dll\NHapi.Model.V251.dll
+	EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.Scan.Interface", "..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj", "{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IL.Common", "..\Public\IL.Common\IL.Common.csproj", "{F320951F-886B-4F99-A3FD-5686C0A97868}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.BizComponent.MFN", "IL.BizComponent\MediII.Adapter.BizComponent.MFN\MediII.Adapter.BizComponent.MFN.csproj", "{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.BizComponent.PMU", "IL.BizComponent\MediII.Adapter.BizComponent.PMU\MediII.Adapter.BizComponent.PMU.csproj", "{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.Scanner", "MediII.Adapter.Scanner\MediII.Adapter.Scanner.csproj", "{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediII.Adapter.MsgToScanServer", "MediII.Adapter.MsgToScanServer\MediII.Adapter.MsgToScanServer.csproj", "{76458091-5802-4284-8861-5F96360119FF}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8CBC27F7-4FA4-4B26-BBBC-A6D4CB6F5371}"
+	ProjectSection(SolutionItems) = preProject
+		README.md = README.md
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|Mixed Platforms = Debug|Mixed Platforms
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|Mixed Platforms = Release|Mixed Platforms
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|x86.ActiveCfg = Debug|x86
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Debug|x86.Build.0 = Debug|x86
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|Mixed Platforms.ActiveCfg = Release|x86
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|Mixed Platforms.Build.0 = Release|x86
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|x64.ActiveCfg = Release|Any CPU
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|x86.ActiveCfg = Release|x86
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3}.Release|x86.Build.0 = Release|x86
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Release|x64.ActiveCfg = Release|Any CPU
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0}.Release|x86.ActiveCfg = Release|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Release|x64.ActiveCfg = Release|Any CPU
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}.Release|x86.ActiveCfg = Release|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Release|x64.ActiveCfg = Release|Any CPU
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}.Release|x86.ActiveCfg = Release|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|x64.Build.0 = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Release|x64.ActiveCfg = Release|Any CPU
+		{5E125823-EC26-4F15-B178-48E8387C5F1A}.Release|x86.ActiveCfg = Release|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Release|x64.ActiveCfg = Release|Any CPU
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC}.Release|x86.ActiveCfg = Release|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Release|x64.ActiveCfg = Release|Any CPU
+		{F320951F-886B-4F99-A3FD-5686C0A97868}.Release|x86.ActiveCfg = Release|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Release|x64.ActiveCfg = Release|Any CPU
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}.Release|x86.ActiveCfg = Release|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Release|x64.ActiveCfg = Release|Any CPU
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}.Release|x86.ActiveCfg = Release|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Release|x64.ActiveCfg = Release|Any CPU
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}.Release|x86.ActiveCfg = Release|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Release|Any CPU.Build.0 = Release|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Release|x64.ActiveCfg = Release|Any CPU
+		{76458091-5802-4284-8861-5F96360119FF}.Release|x86.ActiveCfg = Release|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Release|Any CPU.Build.0 = Release|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Release|x64.ActiveCfg = Release|Any CPU
+		{FB0F3AD4-26BC-44D6-B4BB-88380A445C53}.Release|x86.ActiveCfg = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(NestedProjects) = preSolution
+		{619B1DBF-55B7-446B-AF40-852A6AB689A0} = {092D7052-844E-4C0F-B6BB-D18B84FC7F99}
+		{0786BB9F-0092-44A2-9CA0-263F5A0AA86E} = {092D7052-844E-4C0F-B6BB-D18B84FC7F99}
+		{E634900C-0A19-4575-A0F7-BF5780AE20C3} = {092D7052-844E-4C0F-B6BB-D18B84FC7F99}
+		{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1} = {092D7052-844E-4C0F-B6BB-D18B84FC7F99}
+		{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D} = {092D7052-844E-4C0F-B6BB-D18B84FC7F99}
+		{F182AC2B-A0D5-40D2-89AF-8D547606B6AC} = {0F0E79A2-AED1-4FD1-859B-A518FCB4BA31}
+		{4E8C6D0E-E696-4F02-812F-CEDD6FE3F6DC} = {13F2A33E-FD55-41A7-9288-18572D9E5130}
+		{0ADDDB14-B0F6-4D12-8025-5EC8124A511B} = {13F2A33E-FD55-41A7-9288-18572D9E5130}
+	EndGlobalSection
+	GlobalSection(SubversionScc) = preSolution
+		Svn-Managed = True
+		Manager = AnkhSVN - Subversion Support for Visual Studio
+	EndGlobalSection
+EndGlobal

+ 223 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADTHandler.cs

@@ -0,0 +1,223 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data;
+using System.Data.Common;
+using System.Transactions;
+using System.Text.RegularExpressions;
+using System.Management;
+using IL.Common;
+using MediII.Adapter.ReceiveToScanModel;
+
+namespace MediII.Adapter.BizComponent.ADT
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public abstract class ADTHandler
+    {
+        static readonly string SEDING_APPLICATION = System.Configuration.ConfigurationManager.AppSettings["SedingApplication"];
+        //数据库连接
+        protected Database ctx;
+        /// <summary>
+        /// 
+        /// </summary>
+        public ADTHandler()
+        {
+            DatabaseProviderFactory factory = new DatabaseProviderFactory();
+            ctx = factory.Create("HealthCare");
+        }
+
+        protected string GetZone(string value)
+        {
+            string sql = @"SELECT Zone FROM HealthCare.dbo.HisInfo WHERE HisZone = @HisZone";
+            var command1 = ctx.GetSqlStringCommand(sql.ToString());
+            ctx.AddInParameter(command1, "HisZone", System.Data.DbType.AnsiString, value);
+            DataTable dt = ctx.ExecuteDataSet(command1).Tables[0];
+            string ZONE = "";
+            if (dt.Rows.Count > 0)
+            {
+                ZONE = dt.Rows[0]["Zone"].ToString();
+            }
+            return ZONE;
+        }
+
+        /// <summary>
+        /// 根据事件类型获取不同的处理类
+        /// </summary>
+        /// <param name="evntType">消息类型</param>
+        /// <returns>ADTHandler的子类</returns>
+        public static ADTHandler GetHandler(string evntType)
+        {
+            try
+            {
+                switch (evntType)
+                {
+                    case "ADT^A01": return new ADT_A01_Handler();// 患者入院
+                    case "ADT^A02": return new ADT_A02_Handler();//患者位置转移:转科、转病区、转床
+                    case "ADT^A05": return new ADT_A05_Handler();//住院更新
+                    case "ADT^A04": return new ADT_A04_Handler();//住院患者                    
+                    //case "A08": return new ADT_A08_Handler();//患者信息修改:
+                    //case "A10": return new ADT_A10_Handler();//入科
+                    //case "A11": return new ADT_A11_Handler();//取消入院
+                    //case "A13": return new ADT_A13_Handler();//取消出院(ADT^A13)
+                    //case "A16": return new ADT_A16_Handler();//患者预出院
+                    //case "A25": return new ADT_A25_Handler();//患者取消预出院
+                    //case "A28": return new ADT_A28_Handler();//患者建档
+                    //case "A31": return new ADT_A31_Handler();//患者基本信息修改(ADT^A31) 
+                    //case "A29": return new ADT_A29_Handler();//删除婴儿信息(ADT^A29^ADT_A21)
+                    //case "A54": return new ADT_A54_Handler();//修改主治医生
+                    //case "A60": return new ADT_A60_Handler();//患者副作用信息修改
+
+
+
+
+                    default: throw new NotImplementedException();
+                }
+            }
+            catch (Exception ex)
+            {
+                LogHelper.LogError(ex, LogCatagories.General);
+                throw ex;
+            }
+
+        }
+
+
+
+        /// <summary>
+        /// 待实现的处理
+        /// </summary>
+        /// <param name="m">传入的消息结构</param>
+        /// <returns>ACK</returns>
+        public abstract void Handler(string m);
+
+        #region 获取字典信息
+        /// <summary>
+        /// 获取字典信息
+        /// </summary> 
+        /// <returns></returns>
+        protected DataTable GetDictionView(Database ctx, string viewName)
+        {
+            var ntb = new DataTable();
+            var sql = string.Format("SELECT  CodeID,CodeName,HisCodeID,MedCodeID FROM  HealthCare.dbo.[{0}]  WHERE IsDel=0", viewName);
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            ntb.Load(SqlDataAccess.ExecuteReader(ctx, cmd));
+            return ntb;
+        }
+
+
+        /// <summary>
+        /// 获取本地Zone
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="hisZone"></param>
+        /// <returns></returns>
+        protected string GetZone(Database ctx, string hisZone)
+        {
+            var sql = string.Format("SELECT top 1 Zone FROM HealthCare.dbo.HisInfo WHERE  HisZone='{0}'", hisZone);
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            var val = StrHelepr.Obj2StrTrim(SqlDataAccess.ExecuteScalar(ctx, cmd));
+            if (string.IsNullOrEmpty(val))
+            {
+                return hisZone;
+            }
+            return val;
+        }
+        #endregion
+
+        #region 取序列
+        ///<summary>
+        /// 取序列
+        /// </summary> 
+        protected string GetSeq(Database ctx, string seqName)
+        {
+            string sql = string.Format("SELECT NEXT VALUE FOR {0}", seqName);
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            object obj = SqlDataAccess.ExecuteScalar(ctx, cmd);
+            if (obj != null)
+                return obj.ToString();
+            else
+                return "0";
+        }
+        #endregion
+
+        #region 取服务器当前时间
+        /// <summary>
+        /// 获取当前时间
+        /// </summary> 
+        internal DateTime GetNow(Database ctx)
+        {
+
+            object obj = (DateTime)SqlDataAccess.ExecuteScalar(ctx, CommandType.Text, "select GETDATE()");
+            if (obj != null)
+                return Convert.ToDateTime(obj.ToString());
+            else
+                return DateTime.Now;
+        }
+
+        #endregion
+
+
+
+        /// <summary>
+        /// 添加床位日志
+        /// </summary>
+        /// <param name="ctx">数据库操作类</param>
+        /// <param name="visitNo"></param>
+        /// <param name="updateUser"></param>
+        /// <param name="OperateTypeInstr"></param>
+        /// <param name="remark"></param>
+        /// <param name="oldMsg"></param>
+        /// <param name="newMsg"></param>
+        protected void AddNewWardLog(Database ctx, string visitNo, string updateUser, string OperateTypeInstr, string remark, string oldMsg, string newMsg)
+        {
+            var sql = @" INSERT INTO HealthCare.dbo.Log_WardOperateLog( VisitNo ,  UpdateUser ,  UpdateDateTime ,   OperateTypeInstr , IP ,  Mac ,   Remark ,   OldContent ,   NewContent) VALUES( @VisitNo ,  @UpdateUser ,  GETDATE() ,   @OperateTypeInstr , @IP , @Mac ,   @Remark ,   @OldContent ,   @NewContent) ";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+
+            SqlDataAccess.AddInParameter(ctx, cmd, "VisitNo", DbType.AnsiString, visitNo);
+            SqlDataAccess.AddInParameter(ctx, cmd, "UpdateUser", DbType.AnsiString, updateUser);
+            SqlDataAccess.AddInParameter(ctx, cmd, "OperateTypeInstr", DbType.AnsiString, OperateTypeInstr);
+            SqlDataAccess.AddInParameter(ctx, cmd, "IP", DbType.AnsiString, NetHelper.GetIP());
+            SqlDataAccess.AddInParameter(ctx, cmd, "Mac", DbType.AnsiString, NetHelper.GetMacAddress());
+            SqlDataAccess.AddInParameter(ctx, cmd, "Remark", DbType.AnsiString, remark);
+            SqlDataAccess.AddInParameter(ctx, cmd, "OldContent", DbType.AnsiString, oldMsg);
+            SqlDataAccess.AddInParameter(ctx, cmd, "NewContent", DbType.AnsiString, newMsg);
+
+            SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+        }
+
+  
+
+
+
+
+
+
+
+        /// <summary>
+        /// 获取参数
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="key"></param>
+        /// <returns></returns>
+        protected string GetParam(Database ctx, string key)
+        {
+            try
+            {
+                var sql = string.Format("SELECT ParamValue FROM  HealthCare.dbo.SiteParamCtrl WHERE SiteNo='0000' AND ParamID='{0}' AND IsDel=0", key);
+                var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+                var obj = SqlDataAccess.ExecuteScalar(ctx, cmd);
+                return StrHelepr.Obj2StrTrim(obj);
+            }
+            catch (Exception ex)
+            {
+                IL.Common.LogHelper.LogError(string.Format("获取参数错误:{0}  {1}\r\n{2}", key, ex.Message, ex.StackTrace), LogCatagories.MQAccess);
+                return string.Empty;
+            }
+
+        }
+    }
+}

+ 108 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A01_Handler.cs

@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Transactions;
+using System.Data;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.ADT
+{
+    public class ADT_A01_Handler : ADTHandler
+    {
+        public override void Handler(string m)
+        {
+
+            //初始化
+            var rtnMsg = string.Empty;
+            var msgHead = string.Empty;
+            var msgBody = string.Empty;
+            var resultCode = string.Empty;
+            var result = string.Empty;
+            WebService server = new WebService();
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+            //读取配置的凭证号
+            var cert = System.Configuration.ConfigurationManager.AppSettings["cert"];
+            //读取就诊流水号
+            string visitNo = xmlHelper.XpathRead(m, "//*[@root='2.16.156.10011.2.5.1.9']", "extension");
+            var tmp=xmlHelper.XpathRead(m,"//*[name()='effectiveTime']");
+            var visitDate=tmp[0].LastChild.Attributes["value"].Value;
+            DateTime date = DateTime.ParseExact(visitDate, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
+
+            using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+
+                var isql = @"INSERT INTO HL7_Platform.dbo.HL7_Scan  (ID ,ChartNo,VisitNo,OtherNo1,OtherNo2,OtherNo3,OtherName ,  TaskType ,  TaskStatus ,  UpdateUser ,  UpdateTime,Reserve1) VALUES (@ID ,@ChartNo ,@VisitNo ,@OtherNo1 ,  @OtherNo2 ,@OtherNo3 ,@OtherName ,@TaskType ,@TaskStatus , @UpdateUser , GETDATE(),@Reserve1)";
+                //门诊处方单
+                var dcmd = ctx.DBGetSqlStringCommand(isql);
+                ctx.AddInParameter(dcmd, "id", System.Data.DbType.String, Guid.NewGuid().ToString("N"));
+                ctx.AddInParameter(dcmd, "ChartNo", System.Data.DbType.String, visitNo);
+                ctx.AddInParameter(dcmd, "VisitNo", System.Data.DbType.String, visitNo);
+                ctx.AddInParameter(dcmd, "OtherNo1", System.Data.DbType.String, date.ToString("yyyy-MM-dd HH:mm:ss"));
+                ctx.AddInParameter(dcmd, "OtherNo2", System.Data.DbType.String, "");
+                ctx.AddInParameter(dcmd, "OtherNo3", System.Data.DbType.String, "");
+                ctx.AddInParameter(dcmd, "OtherName", System.Data.DbType.String, "门诊处方单");
+                ctx.AddInParameter(dcmd, "TaskType", System.Data.DbType.String, "ADT^A01[B01]");
+                ctx.AddInParameter(dcmd, "TaskStatus", System.Data.DbType.Int32, 1);
+                ctx.AddInParameter(dcmd, "UpdateUser", System.Data.DbType.String, "9999");
+                ctx.AddInParameter(dcmd, "Reserve1", System.Data.DbType.String, "");
+                ctx.DBExecuteNonQuery(dcmd);
+
+                //门诊收费明细
+                var lcmd = ctx.DBGetSqlStringCommand(isql);
+                ctx.AddInParameter(lcmd, "id", System.Data.DbType.String, Guid.NewGuid().ToString("N"));
+                ctx.AddInParameter(lcmd, "ChartNo", System.Data.DbType.String, visitNo);
+                ctx.AddInParameter(lcmd, "VisitNo", System.Data.DbType.String, visitNo);
+                ctx.AddInParameter(lcmd, "OtherNo1", System.Data.DbType.String, date.ToString("yyyy-MM-dd HH:mm:ss"));
+                ctx.AddInParameter(lcmd, "OtherNo2", System.Data.DbType.String, "");
+                ctx.AddInParameter(lcmd, "OtherNo3", System.Data.DbType.String, "");
+                ctx.AddInParameter(lcmd, "OtherName", System.Data.DbType.String, "门诊收费明细");
+                ctx.AddInParameter(lcmd, "TaskType", System.Data.DbType.String, "ADT^A01[B02]");
+                ctx.AddInParameter(lcmd, "TaskStatus", System.Data.DbType.Int32, 1);
+                ctx.AddInParameter(lcmd, "UpdateUser", System.Data.DbType.String, "9999");
+                ctx.AddInParameter(lcmd, "Reserve1", System.Data.DbType.String, "");
+                ctx.DBExecuteNonQuery(lcmd);
+
+            }
+        }
+
+
+        public string GetDiagNo(string icdCode)
+        {
+            try
+            {
+                var sql = string.Format("SELECT DiagNo FROM HealthCare.dbo.Diag WHERE IcdCode='{0}'", icdCode);
+                var obj = ctx.DBExecuteScalar(CommandType.Text, sql);
+                var val = StrHelepr.Obj2StrTrim(obj);
+                if (string.IsNullOrWhiteSpace(val))
+                {
+                    val = icdCode;
+                }
+
+                return val;
+            }
+            catch (Exception ex)
+            {
+                IL.Common.LogHelper.LogError(string.Format("获取DiagNo错误:{0}  {1}\r\n{2}", icdCode, ex.Message, ex.StackTrace), LogCatagories.MQAccess);
+                return string.Empty;
+            }
+        }
+
+        public string GetBedNo(Database ctx, string roombed)
+        {
+            var sql = "SELECT Top 1 BedNo FROM HealthCare.dbo.Bed WHERE RoomBed=@RoomBed";
+            var cmd = ctx.DBGetSqlStringCommand(sql);
+            ctx.AddInParameter(cmd, "RoomBed", DbType.String, roombed);
+            var obj = StrHelepr.Obj2StrTrim(ctx.DBExecuteScalar(cmd));
+            if (string.IsNullOrWhiteSpace(obj))
+            {
+                obj = roombed;
+            }
+            return obj;
+
+        }
+    }
+
+
+}

+ 95 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A02_Handler.cs

@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Transactions;
+using MediII.Adapter.ReceiveToScanModel;
+using IL.Common;
+using System.Data.Common;
+using System.Data;
+
+namespace MediII.Adapter.BizComponent.ADT
+{
+    public class ADT_A02_Handler : ADTHandler
+    {
+        public override void Handler(string m)
+        {
+            #region 门诊就诊更新
+            //初始化
+            var rtnMsg = string.Empty;
+            var msgHead = string.Empty;
+            var msgBody = string.Empty;
+            var resultCode = string.Empty;
+            var result = string.Empty;
+            WebService server = new WebService();
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+            //读取配置的凭证号
+            var cert = System.Configuration.ConfigurationManager.AppSettings["cert"];
+            //读取就诊流水号
+            string visitNo = xmlHelper.XpathRead(m, "//*[@root='2.16.156.10011.2.5.1.9']", "extension");
+            var tmp = xmlHelper.XpathRead(m, "//*[name()='effectiveTime']");
+            var visitDate = tmp[0].LastChild.Attributes["value"].Value;
+            DateTime date = DateTime.ParseExact(visitDate, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
+            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+           {
+               #region 门诊就诊更新 
+
+               var isql = @"INSERT INTO HL7_Platform.dbo.HL7_Scan  (ID ,ChartNo,VisitNo,OtherNo1,OtherNo2,OtherNo3,OtherName ,  TaskType ,  TaskStatus ,  UpdateUser ,  UpdateTime,Reserve1) VALUES (@ID ,@ChartNo ,@VisitNo ,@OtherNo1 ,  @OtherNo2 ,@OtherNo3 ,@OtherName ,@TaskType ,@TaskStatus , @UpdateUser , GETDATE(),@Reserve1)";
+               //门诊处方单
+               var dcmd = ctx.DBGetSqlStringCommand(isql);
+               ctx.AddInParameter(dcmd, "id", System.Data.DbType.String, Guid.NewGuid().ToString("N"));
+               ctx.AddInParameter(dcmd, "ChartNo", System.Data.DbType.String, visitNo);
+               ctx.AddInParameter(dcmd, "VisitNo", System.Data.DbType.String, visitNo);
+               ctx.AddInParameter(dcmd, "OtherNo1", System.Data.DbType.String, date.ToString("yyyy-MM-dd HH:mm:ss"));
+               ctx.AddInParameter(dcmd, "OtherNo2", System.Data.DbType.String, "");
+               ctx.AddInParameter(dcmd, "OtherNo3", System.Data.DbType.String, "");
+               ctx.AddInParameter(dcmd, "OtherName", System.Data.DbType.String, "门诊处方单");
+               ctx.AddInParameter(dcmd, "TaskType", System.Data.DbType.String, "ADT^A02[B01]");
+               ctx.AddInParameter(dcmd, "TaskStatus", System.Data.DbType.Int32, 1);
+               ctx.AddInParameter(dcmd, "UpdateUser", System.Data.DbType.String, "9999");
+               ctx.AddInParameter(dcmd, "Reserve1", System.Data.DbType.String, "");
+               ctx.DBExecuteNonQuery(dcmd);
+        
+               #endregion
+               //门诊收费明细
+               var lcmd = ctx.DBGetSqlStringCommand(isql);
+               ctx.AddInParameter(lcmd, "id", System.Data.DbType.String, Guid.NewGuid().ToString("N"));
+               ctx.AddInParameter(lcmd, "ChartNo", System.Data.DbType.String, visitNo);
+               ctx.AddInParameter(lcmd, "VisitNo", System.Data.DbType.String, visitNo);
+               ctx.AddInParameter(lcmd, "OtherNo1", System.Data.DbType.String, date.ToString("yyyy-MM-dd HH:mm:ss"));
+               ctx.AddInParameter(lcmd, "OtherNo2", System.Data.DbType.String, "");
+               ctx.AddInParameter(lcmd, "OtherNo3", System.Data.DbType.String, "");
+               ctx.AddInParameter(lcmd, "OtherName", System.Data.DbType.String, "门诊收费明细");
+               ctx.AddInParameter(lcmd, "TaskType", System.Data.DbType.String, "ADT^A02[B02]");
+               ctx.AddInParameter(lcmd, "TaskStatus", System.Data.DbType.Int32, 1);
+               ctx.AddInParameter(lcmd, "UpdateUser", System.Data.DbType.String, "9999");
+               ctx.AddInParameter(lcmd, "Reserve1", System.Data.DbType.String, "");
+               ctx.DBExecuteNonQuery(lcmd);
+    
+               scope.Complete();
+            }
+            #endregion
+            
+
+        }
+
+        /// <summary>
+        /// 获取急诊病人床位
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="visitNo"></param>
+        /// <returns></returns>
+        private string GetDepartNo(Database ctx, string roomBed)
+        {
+
+            var sql = string.Format("SELECT top 1 DepartNo FROM dbo.Depart WHERE DepartCode='{0}' AND DepartType='99' AND IsDel=0", roomBed);
+            var dr = ctx.DBExecuteScalar(CommandType.Text, sql);
+            return StrHelepr.Obj2StrTrim(dr);
+        }
+
+
+
+    }
+}

+ 106 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A04_Handler.cs

@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Transactions;
+using System.Data;
+using System.Data.Common;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.ADT
+{
+    /// <summary>
+    /// 住院就诊记录
+    /// </summary>
+    public class ADT_A04_Handler : ADTHandler
+    {
+        public override void Handler(string m)
+        {
+            //初始化
+            var rtnMsg = string.Empty;
+            var msgHead = string.Empty;
+            var msgBody = string.Empty;
+            var resultCode = string.Empty;
+            var result = string.Empty;
+            WebService server = new WebService();
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+            //读取配置的凭证号
+            var cert = System.Configuration.ConfigurationManager.AppSettings["cert"];
+            //读取就诊流水号
+            string visitNo = xmlHelper.XpathRead(m, "//*[@root='2.16.156.10011.2.5.1.9']", "extension");
+            var tmp = xmlHelper.XpathRead(m, "//*[name()='effectiveTime']");
+            var visitDate = tmp[0].LastChild.Attributes["value"].Value;
+            DateTime date = DateTime.ParseExact(visitDate, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
+
+            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                var isql = @"INSERT INTO HL7_Platform.dbo.HL7_Scan  (ID ,ChartNo,VisitNo,OtherNo1,OtherNo2,OtherNo3,OtherName ,  TaskType ,  TaskStatus ,  UpdateUser ,  UpdateTime,Reserve1) VALUES (@ID ,@ChartNo ,@VisitNo ,@OtherNo1 ,  @OtherNo2 ,@OtherNo3 ,@OtherName ,@TaskType ,@TaskStatus , @UpdateUser , GETDATE(),@Reserve1)";
+                //住院就诊
+                var cmd = ctx.DBGetSqlStringCommand(isql);
+                SqlDataAccess.AddInParameter(ctx, cmd, "ID", DbType.AnsiString, Guid.NewGuid().ToString("N"));
+                SqlDataAccess.AddInParameter(ctx, cmd, "ChartNo", DbType.AnsiString, visitNo);
+                SqlDataAccess.AddInParameter(ctx, cmd, "VisitNo", DbType.AnsiString, visitNo);
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherNo1", DbType.AnsiString, date.ToString("yyyy-MM-dd HH:mm:ss"));
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherNo2", DbType.AnsiString, "");
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherNo3", DbType.AnsiString, "");
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherName", DbType.AnsiString, "住院就诊信息登记");
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskType", DbType.AnsiString, "ADT^A04[B01]");
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskStatus", DbType.Int32, 1);
+                SqlDataAccess.AddInParameter(ctx, cmd, "UpdateUser", DbType.AnsiString, "9999");
+                SqlDataAccess.AddInParameter(ctx, cmd, "Reserve1", DbType.AnsiString, "");
+                SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+
+                //ctx.AddInParameter(dcmd, "id", System.Data.DbType.String, Guid.NewGuid().ToString("N"));
+                //ctx.AddInParameter(dcmd, "ChartNo", System.Data.DbType.String, visitNo);
+                //ctx.AddInParameter(dcmd, "VisitNo", System.Data.DbType.String, visitNo);
+                //ctx.AddInParameter(dcmd, "OtherNo1", System.Data.DbType.String, date.ToString("yyyy-MM-dd HH:mm:ss"));
+                //ctx.AddInParameter(dcmd, "OtherNo2", System.Data.DbType.String, "");
+                //ctx.AddInParameter(dcmd, "OtherNo3", System.Data.DbType.String, "");
+                //ctx.AddInParameter(dcmd, "OtherName", System.Data.DbType.String, "门诊处方单");
+                //ctx.AddInParameter(dcmd, "TaskType", System.Data.DbType.String, "ADT^A01[B01]");
+                //ctx.AddInParameter(dcmd, "TaskStatus", System.Data.DbType.Int32, 1);
+                //ctx.AddInParameter(dcmd, "UpdateUser", System.Data.DbType.String, "9999");
+                //ctx.AddInParameter(dcmd, "Reserve1", System.Data.DbType.String, "");
+                //ctx.DBExecuteNonQuery(cmd);
+                
+               
+                scope.Complete(); 
+            }
+
+
+        }
+
+        /// <summary>
+        /// 获取门诊就诊次数
+        /// </summary> 
+        /// <returns></returns>
+        private int GetOutNumByChartNo(string chartNo)
+        {
+
+            string OutPatientSql = @"select count(1)	 
+                                             from HealthCare.dbo.OutPatient a, HealthCare.dbo.VisitRecord b	 
+                                             where a.VisitNo = b.VisitNo  AND b.ChartNo= @ChartNo  
+                                             AND a.VisitStatus<>'D'  ";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, OutPatientSql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ChartNo", DbType.AnsiString, chartNo);
+            return int.Parse(StrHelepr.Obj2StrTrim(SqlDataAccess.ExecuteScalar(ctx, cmd)));  //看诊次数 
+
+        }
+
+        /// <summary>
+        /// 获取急诊就诊次数
+        /// </summary> 
+        /// <returns></returns>
+        private int GetEmgNumByChartNo(string chartNo)
+        {
+            string EmgPatientSql = @"select count(1) from HealthCare.dbo.Emergency a, HealthCare.dbo.VisitRecord b	 
+                                             where a.VisitNo = b.VisitNo  
+                                             AND b.ChartNo= @ChartNo   AND a.VisitStatus<>'D'  ";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, EmgPatientSql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ChartNo", DbType.AnsiString, chartNo);
+            return int.Parse(StrHelepr.Obj2StrTrim(SqlDataAccess.ExecuteScalar(ctx, cmd)));   //看诊次数 
+
+        }
+
+    }
+}

+ 106 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/ADT_A05_Handler.cs

@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Transactions;
+using System.Data;
+using System.Data.Common;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.ADT
+{
+    /// <summary>
+    /// 住院就诊记录更新
+    /// </summary>
+    public class ADT_A05_Handler : ADTHandler
+    {
+        public override void Handler(string m)
+        {
+            //初始化
+            var rtnMsg = string.Empty;
+            var msgHead = string.Empty;
+            var msgBody = string.Empty;
+            var resultCode = string.Empty;
+            var result = string.Empty;
+            WebService server = new WebService();
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+            //读取配置的凭证号
+            var cert = System.Configuration.ConfigurationManager.AppSettings["cert"];
+            //读取就诊流水号
+            string visitNo = xmlHelper.XpathRead(m, "//*[@root='2.16.156.10011.2.5.1.9']", "extension");
+            var tmp = xmlHelper.XpathRead(m, "//*[name()='effectiveTime']");
+            var visitDate = tmp[0].LastChild.Attributes["value"].Value;
+            DateTime date = DateTime.ParseExact(visitDate, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
+
+            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                var isql = @"INSERT INTO HL7_Platform.dbo.HL7_Scan  (ID ,ChartNo,VisitNo,OtherNo1,OtherNo2,OtherNo3,OtherName ,  TaskType ,  TaskStatus ,  UpdateUser ,  UpdateTime,Reserve1) VALUES (@ID ,@ChartNo ,@VisitNo ,@OtherNo1 ,  @OtherNo2 ,@OtherNo3 ,@OtherName ,@TaskType ,@TaskStatus , @UpdateUser , GETDATE(),@Reserve1)";
+                //住院就诊
+                var cmd = ctx.DBGetSqlStringCommand(isql);
+                SqlDataAccess.AddInParameter(ctx, cmd, "ID", DbType.AnsiString, Guid.NewGuid().ToString("N"));
+                SqlDataAccess.AddInParameter(ctx, cmd, "ChartNo", DbType.AnsiString, visitNo);
+                SqlDataAccess.AddInParameter(ctx, cmd, "VisitNo", DbType.AnsiString, visitNo);
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherNo1", DbType.AnsiString, date.ToString("yyyy-MM-dd HH:mm:ss"));
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherNo2", DbType.AnsiString, "");
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherNo3", DbType.AnsiString, "");
+                SqlDataAccess.AddInParameter(ctx, cmd, "OtherName", DbType.AnsiString, "住院就诊信息更新");
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskType", DbType.AnsiString, "ADT^A04[B02]");
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskStatus", DbType.Int32, 1);
+                SqlDataAccess.AddInParameter(ctx, cmd, "UpdateUser", DbType.AnsiString, "9999");
+                SqlDataAccess.AddInParameter(ctx, cmd, "Reserve1", DbType.AnsiString, "");
+                SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+
+                //ctx.AddInParameter(dcmd, "id", System.Data.DbType.String, Guid.NewGuid().ToString("N"));
+                //ctx.AddInParameter(dcmd, "ChartNo", System.Data.DbType.String, visitNo);
+                //ctx.AddInParameter(dcmd, "VisitNo", System.Data.DbType.String, visitNo);
+                //ctx.AddInParameter(dcmd, "OtherNo1", System.Data.DbType.String, date.ToString("yyyy-MM-dd HH:mm:ss"));
+                //ctx.AddInParameter(dcmd, "OtherNo2", System.Data.DbType.String, "");
+                //ctx.AddInParameter(dcmd, "OtherNo3", System.Data.DbType.String, "");
+                //ctx.AddInParameter(dcmd, "OtherName", System.Data.DbType.String, "门诊处方单");
+                //ctx.AddInParameter(dcmd, "TaskType", System.Data.DbType.String, "ADT^A01[B01]");
+                //ctx.AddInParameter(dcmd, "TaskStatus", System.Data.DbType.Int32, 1);
+                //ctx.AddInParameter(dcmd, "UpdateUser", System.Data.DbType.String, "9999");
+                //ctx.AddInParameter(dcmd, "Reserve1", System.Data.DbType.String, "");
+                //ctx.DBExecuteNonQuery(cmd);
+                
+               
+                scope.Complete(); 
+            }
+
+
+        }
+
+        /// <summary>
+        /// 获取门诊就诊次数
+        /// </summary> 
+        /// <returns></returns>
+        private int GetOutNumByChartNo(string chartNo)
+        {
+
+            string OutPatientSql = @"select count(1)	 
+                                             from HealthCare.dbo.OutPatient a, HealthCare.dbo.VisitRecord b	 
+                                             where a.VisitNo = b.VisitNo  AND b.ChartNo= @ChartNo  
+                                             AND a.VisitStatus<>'D'  ";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, OutPatientSql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ChartNo", DbType.AnsiString, chartNo);
+            return int.Parse(StrHelepr.Obj2StrTrim(SqlDataAccess.ExecuteScalar(ctx, cmd)));  //看诊次数 
+
+        }
+
+        /// <summary>
+        /// 获取急诊就诊次数
+        /// </summary> 
+        /// <returns></returns>
+        private int GetEmgNumByChartNo(string chartNo)
+        {
+            string EmgPatientSql = @"select count(1) from HealthCare.dbo.Emergency a, HealthCare.dbo.VisitRecord b	 
+                                             where a.VisitNo = b.VisitNo  
+                                             AND b.ChartNo= @ChartNo   AND a.VisitStatus<>'D'  ";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, EmgPatientSql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ChartNo", DbType.AnsiString, chartNo);
+            return int.Parse(StrHelepr.Obj2StrTrim(SqlDataAccess.ExecuteScalar(ctx, cmd)));   //看诊次数 
+
+        }
+
+    }
+}

+ 42 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/BizComponent_ADT.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;  
+using MediII.Adapter.BizComponent.Base;
+
+namespace MediII.Adapter.BizComponent.ADT
+{
+    public class BizComponent_ADT : BaseBizComponent, IBizComponent
+    {
+        public override string DoProcess(string m,string msgType)
+        {
+            try
+            {
+                ADTHandler handler = ADTHandler.GetHandler(msgType);
+                try
+                {
+                    handler.Handler(m);
+                    return string.Empty;
+                }
+                catch (Exception ex)
+                {
+                    if (ex.InnerException == null)
+                    {
+                        return ex.Message;
+                    }
+                    else
+                    {
+                        return ex.Message + " InnerException:" + ex.InnerException.Message;
+                    }
+                } 
+            }
+            catch (Exception ex)
+            {
+                return ex.Message;
+            }
+             
+        }
+
+       
+    }
+}

+ 148 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/MediII.Adapter.BizComponent.ADT.csproj

@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{E634900C-0A19-4575-A0F7-BF5780AE20C3}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.BizComponent.ADT</RootNamespace>
+    <AssemblyName>MediII.Adapter.BizComponent.ADT</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\MediII.Adapter.WinForm.Scan\bin\Debug\UE\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <DebugSymbols>false</DebugSymbols>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
+    <DocumentationFile>
+    </DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <OutputPath>bin\Release\</OutputPath>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="SI.Common.SITask">
+      <HintPath>..\..\..\dll\SI.Common.SITask.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Management" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Transactions" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ADTHandler.cs" />
+    <Compile Include="ADT_A01_Handler.cs" />
+    <Compile Include="ADT_A02_Handler.cs" />
+    <Compile Include="ADT_A05_Handler.cs" />
+    <Compile Include="ADT_A04_Handler.cs" />
+    <Compile Include="BizComponent_ADT.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\MediII.Adapter.ReceiveToScanModel\MediII.Adapter.ReceiveToScanModel.csproj">
+      <Project>{f182ac2b-a0d5-40d2-89af-8d547606b6ac}</Project>
+      <Name>MediII.Adapter.ReceiveToSIModel</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.BizComponent.Base\MediII.Adapter.BizComponent.Base.csproj">
+      <Project>{619b1dbf-55b7-446b-af40-852a6ab689a0}</Project>
+      <Name>MediII.Adapter.BizComponent.Base</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScan\UE\
+Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScanServer\UE\</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MediII.Adapter.Winform.Tool.MQ")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MediII.Adapter.Winform.Tool.MQ")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("63a3c311-21ab-456d-acfa-37029f7be530")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 63 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Resources.Designer.cs

@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.18444
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MediII.Adapter.BizComponent.ADT.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   一个强类型的资源类,用于查找本地化的字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources() {
+        }
+        
+        /// <summary>
+        ///   返回此类使用的缓存的 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MediII.Adapter.BizComponent.ADT.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   使用此强类型资源类,为所有资源查找
+        ///   重写当前线程的 CurrentUICulture 属性。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 26 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Settings.Designer.cs

@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.18444
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MediII.Adapter.BizComponent.ADT.Properties {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+        
+        public static Settings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
IL.BizComponent/MediII.Adapter.BizComponent.ADT/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 109 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/BaseBizComponent.cs

@@ -0,0 +1,109 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MediII.Common;
+using System.ComponentModel.Composition;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data.Common;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.Base
+{
+    [Export]
+    public abstract class BaseBizComponent : IBizComponent
+    {
+
+        //数据库连接
+        protected Database ctx;
+        protected Database HealthCarectx;
+
+        static IBizBehavior BizBehavior { get; set; }
+
+        public BaseBizComponent()
+        {
+            DatabaseProviderFactory factory = new DatabaseProviderFactory();
+            ctx = factory.CreateDefault();
+            HealthCarectx = factory.Create("HealthCare");
+        }
+
+        static BaseBizComponent()
+        {
+            string bizBehavior = System.Configuration.ConfigurationManager.AppSettings["BizBehavior"];
+            if (string.IsNullOrEmpty(bizBehavior))
+            {
+                BizBehavior = new DefaultBizBehavior();
+            }
+            else
+            {
+                string[] ar = bizBehavior.Split(',');
+                string assemblyName = ar[0];
+                string typeName = ar[1];
+                try
+                {
+                    BizBehavior = Activator.CreateInstance(assemblyName, typeName).Unwrap() as IBizBehavior;
+                }
+                catch
+                {
+                    BizBehavior = new DefaultBizBehavior();
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// 处理消息
+        /// </summary>
+        /// <param name="message">解析后消息的抽象类型</param>
+        public abstract string DoProcess(string message,string msgType);
+
+        /// <summary>
+        ///实现处理的接口
+        /// </summary>
+        /// <param name="message">传入的消息字符</param>
+        /// <returns></returns>
+        public string Process(string message,string msgType)
+        {
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+            string messageID = xmlHelper.XpathRead(message, "//*[@root='2.16.156.10011.2.5.1.1']", "extension");
+            string guid = MediII.Common.GUIDHelper.NewGUID();
+            OnProcessing(guid, messageID, message, "HL7v3");
+            string ack = DoProcess(message,msgType);
+            OnProcessed(guid, "", ack, true);
+            return ack;
+        }
+
+        /// <summary>
+        /// 保存回复
+        /// </summary>
+        /// <param name="ack"></param>
+        private void OnProcessed(string id, string messageID, string ack, bool successed)
+        {
+            BizBehavior.AfterProcess(id, messageID, ack, successed);
+        }
+
+        /// <summary>
+        /// 保存接受信息
+        /// </summary>
+        /// <param name="message"></param>
+        private void OnProcessing(string id, string messageID, string message, string Version)
+        {
+            BizBehavior.BeforeProcess(id, messageID, message, Version);
+        }
+
+
+        #region 取DB服务器当前时间
+        public static DateTime GetNow(Database ctx)
+        {
+            DbCommand command = SqlDataAccess.GetSqlStringCommand(ctx, "SELECT  GETDATE() sysdate  ");
+            object obj = SqlDataAccess.ExecuteScalar(ctx, command);
+            if (obj != null)
+                return Convert.ToDateTime(obj.ToString());
+            else
+                return Convert.ToDateTime(null);
+        }
+        #endregion
+
+
+    }
+}

+ 67 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/BizComponentFactory.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MediII.Adapter.BizComponent.Base
+{
+    public static class BizComponentFactory
+    {
+        static readonly string HosiptalName;
+        static List<string> listNotExist = new List<string>();
+
+        static BizComponentFactory()
+        {
+            HosiptalName = System.Configuration.ConfigurationManager.AppSettings["HosiptalName"];
+        }
+
+        public static IBizComponent GetBizComponent(string messageName)
+        {
+
+            string assemblyName = string.Format("MediII.Adapter.BizComponent.{0}", messageName);
+            string typeName ;
+            //if (messageName == "ORM")
+            //{
+            //    int i = 10;
+            //}
+            if (string.IsNullOrEmpty(HosiptalName) || listNotExist.Contains(messageName))
+            {
+                typeName = string.Format("{0}.BizComponent_{1}", assemblyName, messageName);
+                try
+                {
+                   
+                    return Activator.CreateInstance(assemblyName, typeName).Unwrap() as IBizComponent;
+                     
+                }
+                catch(Exception ex)
+                {
+                    throw new Exception(string.Format("创建消息处理对象{0}失败", typeName));
+                }
+            }
+            else
+            {
+                typeName = string.Format("{0}.BizComponent_{1}_{2}", assemblyName, messageName, HosiptalName);
+
+                try
+                {
+                    return Activator.CreateInstance(assemblyName, typeName).Unwrap() as IBizComponent;
+                }
+                catch (TypeLoadException)
+                {
+                    typeName = string.Format("{0}.BizComponent_{1}", assemblyName, messageName);
+                    var bizComponet = Activator.CreateInstance(assemblyName, typeName).Unwrap() as IBizComponent;
+                    lock (listNotExist)
+                    {
+                        listNotExist.Add(messageName);
+                    }
+                    return bizComponet;
+                }
+                catch
+                {
+                    throw new Exception(string.Format("创建消息处理对象{0}失败", typeName));
+                }
+            }
+             
+        }
+    }
+}

+ 26 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/DefaultBizBehavior.cs

@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.ComponentModel.Composition;
+
+namespace MediII.Adapter.BizComponent.Base
+{
+    /// <summary>
+    /// 默认的实现,写日志
+    /// </summary>
+    public class DefaultBizBehavior:IBizBehavior
+    {
+        public void AfterProcess(string id,string messageID, string ack, bool successed)
+        {
+            string content = string.Format("消息:{0}已处理完毕,处理结果为:{1}\n\r回复消息为:{1}",messageID,successed,ack);
+            MediII.Common.LogHelper.LogDebug(content, Common.LogCatagories.BizBehavior);
+        }
+
+        public void BeforeProcess(string id, string messageID, string message, string Version)
+        {
+            string content = string.Format("消息:{0}已接收,内容为:{1}", messageID, message);
+            MediII.Common.LogHelper.LogDebug(content, Common.LogCatagories.BizBehavior);
+        }
+    }
+}

+ 29 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/IBizBehavior.cs

@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.ComponentModel.Composition;
+
+namespace MediII.Adapter.BizComponent.Base
+{
+    /// <summary>
+    /// Biz处理前后的行为
+    /// </summary>
+    public interface IBizBehavior
+    {
+        /// <summary>
+        /// 消息处理之后
+        /// </summary>
+        /// <param name="messageID">消息ID</param>
+        /// <param name="ack">回复信息</param>
+        /// <param name="successed">true成功 false失败</param>
+        void AfterProcess(string id,string messageID, string ack, bool successed);
+
+        /// <summary>
+        /// 消息处理之前
+        /// </summary>
+        /// <param name="messageID">消息ID</param>
+        /// <param name="message">消息</param>
+        void BeforeProcess(string id, string messageID, string message, string Version);
+    }
+}

+ 18 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/IBizComponent.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MediII.Adapter.BizComponent.Base
+{
+    public interface IBizComponent
+    { 
+        /// <summary>
+        /// 消息到达处理
+        /// </summary>
+        /// <param name="message">处理消息的抽象接口</param>
+        /// <param name="ackMessage">回复消息</param>
+        /// <returns>1 成功,0 失败</returns>
+        string Process(string message,string msgType);
+    }
+}

+ 115 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/MediII.Adapter.BizComponent.Base.csproj

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{619B1DBF-55B7-446B-AF40-852A6AB689A0}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.BizComponent.Base</RootNamespace>
+    <AssemblyName>MediII.Adapter.BizComponent.Base</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <DocumentationFile>
+    </DocumentationFile>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <PropertyGroup>
+    <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.ServiceLocation.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.Unity.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.Composition" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BaseBizComponent.cs" />
+    <Compile Include="BizComponentFactory.cs" />
+    <Compile Include="DefaultBizBehavior.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="IBizBehavior.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="IBizComponent.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScan\UE\
+Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScanServer\UE\</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
IL.BizComponent/MediII.Adapter.BizComponent.Base/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.BizComponent.Base")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("MediII.Adapter.BizComponent.Base")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("a05041ee-76a4-4b09-b57b-e872cb17b43b")]
+
+// 程序集的版本信息由下面四个值组成: 
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: 
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/BizComponent_MFN.cs

@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+//using MediII.Adapter.BaseBiz;
+using MediII.Common;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using MediII.Adapter.BizComponent.Base;
+
+namespace MediII.Adapter.BizComponent.MFN
+{
+    public class BizComponent_MFN : BaseBizComponent, IBizComponent
+    {
+        //数据库连接
+        protected Database ctx
+        {
+            get { return base.HealthCarectx; }
+        }
+
+        protected Database healthCarectx
+        {
+            get { return base.HealthCarectx; }
+        }
+        public override string DoProcess(string m,string msgType)
+        {
+            //只插入数据后续处理
+            //SyncInsert(m);
+
+            try
+            {
+
+                try
+                {
+                    //根据不同的类型再分开不同的类处理
+                    MFNBase processor = MFNBase.GetProcessor(msgType.Replace('^', '_'), ctx);//
+                    int result = processor.Process(m,msgType);
+                    return string.Empty;
+
+                    //string ack = SetACK(m, "ACK", mType, "ACK");
+                    //return ack;
+                }
+                catch (Exception ex)
+                {
+
+                    if (ex.InnerException == null)
+                    {
+                        return ex.Message;
+                    }
+                    else
+                    {
+                        return ex.Message + " InnerException:" + ex.InnerException.Message;
+                    }
+                }
+
+            }
+            catch (Exception ex)
+            {
+                //var tmp = ex.EntityValidationErrors.FirstOrDefault().ValidationErrors;
+                //string errString = "";
+                //foreach (var item in tmp)
+                //{
+                //    errString += item.ErrorMessage;
+                //}
+                //string ack = SetACK(m, "ACK", mType, "ACK", ex.EntityValidationErrors.ToString());
+                //throw new Exception(string.Format("{0}\r\n{1}", ex.EntityValidationErrors.ToString()));
+
+                return ex.Message;
+            }
+        }
+    }
+}

+ 326 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFNBase.cs

@@ -0,0 +1,326 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Common;
+using System.Linq;
+using System.Text;
+
+using Microsoft.Practices.EnterpriseLibrary.Data;
+//using MediII.Adapter.Model.UE;
+using IL.Common;
+using System.Data;
+
+namespace MediII.Adapter.BizComponent.MFN
+{
+    /// <summary>
+    /// MFN消息处理的基类
+    /// zengfan 2012-09-04
+    /// </summary>
+    public abstract class MFNBase
+    {
+        /// <summary>
+        /// 新增
+        /// </summary>
+        protected const string MAD = "MAD";
+
+        /// <summary>
+        /// 更新
+        /// </summary>
+        protected const string MUP = "MUP";
+
+        /// <summary>
+        /// 删除
+        /// </summary>
+        protected const string MDL = "MDL";
+
+        /// <summary>
+        /// 恢复
+        /// </summary>
+        protected const string MAC = "MAC";
+
+        /// <summary>
+        /// 消息处理,入库
+        /// </summary>
+        /// <param name="message">转化过的强类型消息</param>
+        /// <returns></returns>
+        public abstract int Process(string message,string msgType);
+
+        #region 根据不同类型初始化对应子类
+        /// <summary>
+        /// 根据不同类型初始化对应子类
+        /// </summary>
+        /// <param name="type">消息类型</param>
+        /// <returns></returns>
+        public static MFNBase GetProcessor(string type, Database ctx)
+        {
+            switch (type)
+            {
+                /*
+                 MFN_Z1A    MFN_Z1A
+                 MFN_Z1B    MFN_Z1B
+                 MFN_Z1C    MFN_Z1C
+                 MFN_Z1D    MFN_Z1D
+                 MFN_Z1E    MFN_Z1E
+                 MFN_Z1F    MFN_Z1F
+                 MFN_Z1G    MFN_Z1G
+                 MFN_Z1H    MFN_Z1H
+                 MFN_Z1I    MFN_Z1I
+                 MFN_Z3F    MFN_Z3F
+                 MFN_Z3I
+                 MFN_Z3J
+                 MFN_Z3K    
+                 MFN_Z3L
+                 MFN_Z3M    MFN_Z3M
+                 MFN_Z3N    MFN_Z3N
+                 MFN_Z4B    MFN_Z4B
+                 MFN_Z5F
+                 MFN_Z6C
+                 MFN_Z6D
+                 MFN_Z6E
+                 MFN_Z6G
+                 MFN_Z6H
+                 MFN_Z7B    MFN_Z7B
+                 MFN_Z7C    MFN_Z7C
+                 MFN_Z8B    MFN_Z8B
+                 MFN_Z8C    MFN_Z8C
+                 MFN_Z8D    MFN_Z8D
+                 */
+                case "MFN_Z1A":
+                //return new MFN_Z1H_V_Title(ctx);
+                //return new MFN_Z1G_dbo_PublicCode(ctx);
+                //return new MFN_Z8C_PublicCode(ctx);
+                case "MFN_Z1B":
+                case "MFN_Z1C":
+                case "MFN_Z1D":
+                case "MFN_Z1E":
+                case "MFN_Z1F":
+                case "MFN_Z1G":
+                    //return new MFN_Z1G_dbo_PublicCode(ctx);
+                case "MFN_Z1H":
+                    //return new MFN_Z1H_V_Title(ctx);
+                case "MFN_Z1I":
+                case "MFN_Z3F":
+                case "MFN_Z3M":
+                // case "MFN_Z3N":
+                case "MFN_Z4B":
+                case "MFN_Z7B":
+                case "MFN_Z7C":
+                case "MFN_Z8B":
+                case "MFN_Z8C":
+                    //return new MFN_Z8C_PublicCode(ctx);
+                //case "MFN_Z8D":
+                //    //return new MFN_Z1A_GY_DAIMA(ctx);
+                //case "MFN_Z2A":
+                //    //return new MFN_Z2A_GY_YUANQU(ctx);
+                case "MFN_Z2B":
+                    return new MFN_Z2B_GY_KESHI(ctx);
+                //case "MFN_Z2C":
+                //    return new MFN_Z2C_Depart(ctx); //   return new MFN_Z2C_GY_BINGQU(ctx);
+                //case "MFN_Z2D":
+                //    return new MFN_Z2D_GY_KESHIBQ(ctx);
+                //case "MFN_Z2E":
+                //    return new MFN_Z2E_GY_YILIAOZU1(ctx);
+                //case "MFN_Z2F":
+                //    return new MFN_Z2F_GY_YILIAOZU2(ctx);
+                //case "MFN_Z2G":
+                //    return new MFN_Z2G_bed(ctx); // return new MFN_Z2G_GY_CHANGWEIXX(ctx);
+                //case "MFN_Z2H":
+                //    return new MFN_Z2H_GY_ZHIGONGKSBG(ctx);
+                //case "MFN_Z2I":
+                //    return new MFN_Z2I_EmpLicense(ctx);
+                //case "MFN_Z2K":
+                //    return new MFN_Z2K_GY_CHANGWEIFU(ctx);
+                //case "MFN_Z2L":
+                //    return new MFN_Z2L_OpdRoomSet(ctx);                         //MFN_Z2L_WEIZHIXX(ctx);
+                ////case "MFN_Z3A":
+                ////    return new MFN_Z3A_GY_YAOPINXX(ctx);
+                ////case "MFN_Z3B":
+                ////    return new MFN_Z3B_GY_YAOPINCD(ctx);
+                //case "MFN_Z3C":
+                //    return new MFN_Z3C_DrugSet(ctx);                      //    return new MFN_Z3C_GY_YAOPINJG(ctx);
+                ////case "MFN_Z3D":
+                ////    return new MFN_Z3D_GY_YAOPINZBM(ctx);
+                //case "MFN_Z3E":
+                //    return new MFN_Z3E_GY_GEIYAOFS(ctx);
+                //case "MFN_Z3G":
+                //    return new MFN_Z3G_GY_PINCI(ctx);
+                ////case "MFN_Z3H":
+                ////    return new MFN_Z3H_GY_YAOPINFL(ctx);
+                //case "MFN_Z3I":
+                //    return new MFN_Z3I_GY_JIXING(ctx);
+                ////case "MFN_Z3J":
+                ////    return new MFN_Z3J_GY_ZHANGBULB(ctx);
+                //case "MFN_Z3K":
+                //    return new MFN_Z3K_YAOPINDLFL(ctx);
+                ////case "MFN_Z3L":
+                ////    return new MFN_Z3L_GY_YAOPINJZFL(ctx);
+                //case "MFN_Z3N":
+                //    return new MFN_Z3N_V_SkinAdvice(ctx);
+                ////case "MFN_Z3P":
+                ////    return new MFN_Z3P_GY_YAOPINDW(ctx);
+                ////case "MFN_Z3Q":
+                ////    return new MFN_Z3Q_GY_YAOPINMCGG(ctx);
+                //case "MFN_Z3R":
+                //    return new MFN_Z3R_DrugStock(ctx);//MFN_Z3R_GY_YAOPINKC(ctx);
+                //case "MFN_Z4A":
+                ////    return new MFN_Z4A_GY_JIBING(ctx);
+                //    return new MFN_Z4A_Diag(ctx);
+                //case "MFN_Z5A":
+                //    return new MFN_Z5A_GY_FEIYONGLB(ctx);
+                //case "MFN_Z5B":
+                //    return new MFN_Z5B_GY_FEIYONGXZ(ctx);
+                ////case "MFN_Z5C":
+                ////    return new MFN_Z5C_YB_BAOXIANLB(ctx);
+                //case "MFN_Z5D":
+                //    return new MFN_Z5D_MedCodeSet(ctx);  //MFN_Z5D_GY_SHOUFEIXM(ctx);
+                ////case "MFN_Z5E":
+                ////    return new MFN_Z5E_GY_HESUANXM(ctx);
+                //case "MFN_Z5F":
+                //    return new MFN_Z5F_GY_XIANGMULX(ctx);
+                //case "MFN_Z5I":
+                //    return new MFN_Z5I_MedCodeFee(ctx);
+                ////case "MFN_Z5G":
+                ////    return new MFN_Z5G_GY_GEIYAOFSJFXM(ctx);
+                //case "MFN_Z5H":
+                //    return new MFN_Z5H_MedCodeFee(ctx);
+                ////case "MFN_Z5I":
+                ////    return new MFN_Z5I_GY_JIANYANXMSF(ctx);
+                ////case "MFN_Z5J":
+                ////    return new MFN_Z5J_GY_JIJIADW(ctx);
+                ////case "MFN_Z5K":
+                ////    return new MFN_Z5K_YB_YIBAOYPDZ(ctx);
+                ////case "MFN_Z5L":
+                ////    return new MFN_Z5L_YB_JBDMDZ(ctx);
+                ////case "MFN_Z5M":
+                ////    return new MFN_Z5M_YB_ZLDMDZ(ctx);
+                //case "MFN_Z5N":
+                //    return new MFN_Z5N_GY_SHOUFEITCMX(ctx);
+                //case "MFN_Z6A":
+                //    return new MFN_Z6A_ModeCodeSet(ctx);
+                ////case "MFN_Z6B":
+                ////    return new MFN_Z6B_GY_JIANYANTCMX(ctx);
+                //case "MFN_Z6C":
+                //    return new MFN_Z6C_GY_CAIJIBW(ctx);
+                //case "MFN_Z6D":
+                //    return new MFN_Z6D_GY_JIANYANRQ(ctx);
+                //case "MFN_Z6E":
+                //    return new MFN_Z6E_MedViewTypeRef(ctx);
+                //case "MFN_Z6F":
+                //    return new MFN_Z6F_GY_YANGBENLX(ctx);
+                //case "MFN_Z6G":
+                //    return new MFN_Z6G_MedCodeSet(ctx);
+                ////case "MFN_Z6H":
+                ////    return new MFN_Z6H_GY_JIANCHALX(ctx);
+                //case "MFN_Z6I":
+                //    return new MFN_Z6I_MedViewTypeRef(ctx);
+                //case "MFN_Z6J":
+                //    return new  MFN_Z6J_MedCodeSetAndMedViewType(ctx);
+                //case "MFN_Z6K":
+                //    return new MFN_Z6K_MedCodeFee(ctx);
+                ////case "MFN_Z6L":
+                ////    return new MFN_Z6L_GY_JIANYANKDSYXMDY(ctx);
+                ////case "MFN_Z6M":
+                ////    return new MFN_Z6M_GY_JIANYANSYXM(ctx);
+                ////case "MFN_Z6N":
+                ////    return new MFN_Z6N_GY_JIANCHAXMYPSF(ctx);
+
+
+                //case "MFN_Z6O":
+                //    return new MFN_Z6O_TubeFee(ctx);
+
+                //case "MFN_Z8A":
+                //    return new MFN_Z8A_MedCodeSet(ctx);
+
+                //case "MFN_Z2M":
+                //    return new MFN_Z2M_EmpRight(ctx);
+                //case "MFN_Z7A":
+                //    return new MFN_Z7A_ModeCodeSet(ctx);
+                //case "MFN_Z7D":
+                //    return new MFN_Z7D_YZ_PAICHIYZ1(ctx);
+                //case "MFN_Z7E":
+                //    return new MFN_Z7E_YZ_PAICHIYZ2(ctx);
+                //case "MFN_Z7F":
+                //    return new MFN_Z7F_YZ_CHUANGWEIPXS(ctx);
+                ////Z7G(医嘱项目收费)定义多余
+                ////case "MFN_Z7G":
+                ////    return new MFN_Z7G_YIZHUXMSF(ctx);
+                //case "MFN_Z8A":
+                //    return new MFN_Z8A_SM_SHOUSHUMC(ctx);
+                default:
+                    throw new NotImplementedException();
+            }
+
+
+           
+        }
+        #endregion
+        //public static HealthCareContainer conn = new HealthCareContainer();
+        //public static IEnumerable<MedCodeSet> MCSList = conn.MedCodeSet.ToList();
+        #region 取序列
+        /// <summary>
+        /// 取序列
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="seqName"></param>
+        /// <returns></returns>
+        public static string GetSeq(Database ctx, string seqName)
+        {
+            //string sql = string.Format("select {0}.Nextval  from dual", seqName);//caowen
+            string sql = "SELECT NEXT VALUE FOR " + seqName;
+            DbCommand command = ctx.GetSqlStringCommand(sql);
+            object obj = ctx.ExecuteScalar(command);
+            if (obj != null)
+                return obj.ToString();
+            else
+                return "0";
+        }
+        #endregion
+
+        #region 获取表对应的顺序号
+        /// <summary>
+        /// 获取表对应的顺序号
+        /// </summary>
+        /// <param name="ctx"></param>
+        /// <param name="tableName"></param>
+        /// <returns></returns>
+        public static object GetSortNum(Database ctx, string tableName)
+        {
+            // "SELECT CONVERT(INT,MAX(UsageNo)) +1  FROM HealthCare.dbo.MedUsageSet WHERE UsageNo BETWEEN '1000' AND '7999'";
+            string sql = string.Format(@" SELECT CONVERT(INT,MAX(SeqNo)) +1 FROM {0} ", tableName);
+            // string sql = string.Format(@" SELECT COUNT(1)+1 FROM {0} ", tableName);
+            DbCommand command = ctx.GetSqlStringCommand(sql);
+            return ctx.ExecuteScalar(command);
+        }
+        #endregion
+
+        #region 获取输入码
+        /// <summary>
+        /// 获取输入码
+        /// </summary>
+        /// <param name="words">名称单词</param>
+        /// <param name="inputType">获取的输入码类型:0 拼音,1 五笔</param>
+        /// <returns></returns>
+        public static string GetInputCode(int inputType, string words)
+        {
+            words = inputType == 0 ? MediII.Common.InputCodeHelper.GetCode1(words) + "" : MediII.Common.InputCodeHelper.GetCode2(words) + "";
+            return words = words.Length > 10 ? words.Substring(0, 9) : words;
+        }
+        #endregion
+
+        #region 更新数据和字段(单个字段)
+        /// <summary>
+        /// 更新字段数据(单个字段)
+        /// </summary>
+        /// <param name="tableName">表名称</param>
+        /// <param name="columnName">列名</param>
+        /// <param name="columnValue">字段更新值</param>
+        /// <param name="conditions">条件</param>
+        /// <param name="ctx">数据库链接</param>
+        public static void UpdateCommonColumn(string tableName, string columnName, object columnValue, string conditions, Database ctx)
+        {
+            string updateSql = string.Format(@" UPDATE " + tableName + " SET " + columnName + " = " + columnValue + " WHERE " + conditions);
+            DbCommand command = ctx.GetSqlStringCommand(updateSql);
+            ctx.ExecuteNonQuery(command);
+        }
+        #endregion
+    }
+}

+ 130 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z2A_HisInfo.cs

@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NHapi.Model.V24.Message;
+using NHapi.Model.V24.Group;
+using NHapi.Model.V24.Segment;
+using System.Data.Common;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.MFN
+{
+   public class MFN_Z2A_HisInfo : MFNBase
+    {
+       private Database ctx = null;
+       public MFN_Z2A_HisInfo(Database dbCtx)
+        {
+            ctx = dbCtx;
+        }
+        public override int Process(NHapi.Base.Model.IMessage message)
+        {
+            
+            //取得消息类型 MAD新增 MUP更新 MDL删除 "MDC"作废 "MAC"恢复
+            string strMsgType;
+            
+            MFN_Z2A msg = message as MFN_Z2A;
+        
+            using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                for (int i = 0; i < msg.MFRepetitionsUsed; i++)
+                {
+                    MFN_Z2A_Nofification group = msg.GetMF(i);
+                    strMsgType = group.MFE.RecordLevelEventCode.Value;
+
+                    string pkid = group.Z2A.YuanQuId.Value;
+                    string qurysql = "select count(*) from HealthCare.dbo.HisInfo where Zone=@Zone";
+                    DbCommand command = ctx.GetSqlStringCommand(qurysql.ToString());
+                    ctx.AddInParameter(command, "Zone", System.Data.DbType.String, pkid);
+                    int counts = Convert.ToInt32(ctx.ExecuteScalar(command));
+                    if (counts == 0)
+                    {
+                        // 新增
+                        AddData(group, pkid);
+                    }
+                    else
+                    {
+                        
+                        if ("MUP" == strMsgType || "MAD" == strMsgType)
+                        {
+                            UpDateData(group, pkid);//修改
+                        }
+                        if ("MDL" == strMsgType)
+                        {
+                            #region 删除/作废
+                            //StringBuilder sql2 = new StringBuilder();
+                            //sql2.Append("update HealthCare.dbo.DrugStock set IsDelete=1  WHERE YaoPinKcID=@YaoPinKcID");
+                            //DbCommand command2 = ctx.GetSqlStringCommand(sql2.ToString());
+                            //ctx.AddInParameter(command2, "YaoPinKcID", System.Data.DbType.AnsiString, pkid);
+                            //ctx.ExecuteNonQuery(command2);
+                            #endregion
+                        }
+                    }
+                }
+                scope.Complete();
+            }
+            return 1;
+        }
+        private void AddData(MFN_Z2A_Nofification group, string pkid)
+        {
+            string sql = @"INSERT INTO HealthCare.dbo.HisInfo
+                                                          ( HospCode ,
+                                                            VAT ,
+                                                            HospName ,
+                                                            ShortName ,
+                                                            EngName ,
+                                                            Zone ,
+                                                            ZoneName ,
+                                                            Tel ,
+                                                            AdrArea ,
+                                                            AdrDesc ,
+                                                            EngAdrDesc ,
+                                                            EMail ,
+                                                            LicenseNo ,
+                                                            HasDelete ,
+                                                            UpdateUser ,
+                                                            UpdateTime ,
+                                                            HisZone
+                                                          )
+                                                  VALUES  ( @HospCode ,
+                                                            @VAT,
+                                                            @HospName ,
+                                                            @ShortName,
+                                                            @EngName ,
+                                                            @Zone ,
+                                                            @ZoneName ,
+                                                            @Tel ,
+                                                            @AdrArea,
+                                                            @AdrDesc ,
+                                                            @EngAdrDesc ,
+                                                            @EMail ,
+                                                            @LicenseNo ,
+                                                            @HasDelete ,
+                                                            @UpdateUser ,
+                                                            @UpdateTime ,
+                                                            @HisZone 
+                                                          )";
+            DbCommand cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SetEntity(group.Z2A, ctx, cmd);
+            SqlDataAccess.AddInParameter(ctx, cmd, "Zone", DbType.AnsiString, pkid);
+            SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+        }
+        private void UpDateData(MFN_Z2A_Nofification group, string pkid)
+        {
+        }
+        private void SetEntity(Z2A seg, Database ctx, DbCommand cmd)
+        {
+            SqlDataAccess.AddInParameter(ctx, cmd, "HospCode", DbType.AnsiString, seg.YuanQuBh.Value);
+            SqlDataAccess.AddInParameter(ctx, cmd, "VAT", DbType.AnsiString, seg.YuanQuBh.Value);
+            SqlDataAccess.AddInParameter(ctx, cmd, "HospName", DbType.AnsiString, seg.YuanQuMc.Value);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ShortName", DbType.AnsiString, seg.YiYuanJc.Value);
+            SqlDataAccess.AddInParameter(ctx, cmd, "HasDelete", DbType.Int16, seg.ZuoFeiBZ.Value=="1"? 1 : 0);
+
+            SqlDataAccess.AddInParameter(ctx, cmd, "UpdateUser", DbType.AnsiString, seg.XiuGaiRen.IDNumber.Value);//修改人
+            SqlDataAccess.AddInParameter(ctx, cmd, "UpdateTime", DbType.DateTime, seg.XiuGaiSJ.TimeOfAnEvent.GetAsDate());//修改时间
+        }
+    }
+}

+ 118 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z2B_GY_KESHI.cs

@@ -0,0 +1,118 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Data.Common;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data;
+using IL.Common;
+using System.Xml;
+//using MediII.Adapter.Model.UE;
+
+
+namespace MediII.Adapter.BizComponent.MFN
+{
+    /// <summary>
+    /// 公用科室
+    /// zengfan 2012-09-04
+    /// </summary>
+    /// <remarks></remarks>
+    public class MFN_Z2B_GY_KESHI : MFNBase
+    {
+        //数据库连接
+        //HealthCareContainer HealthCareContainer = new HealthCareContainer();
+        private Database ctx = null;
+        public MFN_Z2B_GY_KESHI(Database dbCtx)
+        {
+            ctx = dbCtx;
+        }
+        /// <summary>
+        /// 消息处理,入库
+        /// </summary>
+        /// <param name="message">转化过的强类型消息</param>
+        /// <returns></returns>
+        /// <remarks></remarks>
+        public override int Process(string message,string msgType)
+        {
+            string strMsgType;
+            using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                string sqlSel = "select count(*) from dbo.dic_department where id=@id";
+                OperateXmlUtil helper = new OperateXmlUtil();
+                string pkid = helper.XpathRead(message, "//*[@root='2.16.156.10011.1.26']", "extension");
+                DbCommand cmd = ctx.DBGetSqlStringCommand(sqlSel);
+                ctx.AddInParameter(cmd, "id", System.Data.DbType.String, pkid);
+                int counts = Convert.ToInt32(ctx.ExecuteScalar(cmd));
+                
+                if (counts == 0)
+                {
+                    string sql = @"insert into dbo.dic_department(id,
+                                                                name,
+									                            status,
+									                            search_code)
+							                            VALUES(@id,
+                                                                @name,
+									                            @status,
+									                            @search_code)";
+
+                    OperateXmlUtil xmlHelper = new OperateXmlUtil();
+                    DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
+                    Resolving(message, ctx, command);
+
+                    ctx.ExecuteNonQuery(command);
+                }
+                else
+                {
+                    string sql = "update dbo.dic_department set name=@name,search_code=@search_code where id=@id";
+                    OperateXmlUtil xmlHelper = new OperateXmlUtil();
+                    DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
+                    Resolving(message, ctx, command);
+
+                    ctx.ExecuteNonQuery(command);
+                }
+                scope.Complete();
+            }
+            return 1;
+        }
+
+
+        /// <summary>
+        /// 科室删除
+        /// </summary>
+        /// <param name="seg">传入资料</param>
+        /// <param name="HealthCareContainer">连线</param>
+        /// <param name="scope">交易</param>
+        public void Division_SyncDel(string pkid)
+        {
+            //string sql4 = "update HealthCare.dbo.Division set IsIss=1 where DivNo=@DivNo";
+            string sql4 = "delete from HealthCare.dbo.Division where DivNo=@DivNo";
+            DbCommand command4 = ctx.GetSqlStringCommand(sql4.ToString());
+            ctx.AddInParameter(command4, "DivNo", System.Data.DbType.AnsiString, pkid);
+            ctx.ExecuteNonQuery(command4);
+        }
+
+        public void Resolving(string Content, Database ctx, DbCommand command)
+        {
+            string value = string.Empty;
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+
+            value = xmlHelper.XpathRead(Content, "//*[@root='2.16.156.10011.1.26']", "extension");
+            ctx.AddInParameter(command, "id", System.Data.DbType.String, value);
+            var valueNode = xmlHelper.XpathRead(Content, "//*[name()='assignedPrincipalOrganization']").Item(0);
+
+            foreach (XmlNode xe in valueNode.ChildNodes)
+            {
+                if (xe.Name == "name")
+                {
+                    value = xe.LastChild.LastChild.Attributes["value"].Value;
+                    ctx.AddInParameter(command, "name", System.Data.DbType.String, value);
+                    value = xe.LastChild.LastChild.Attributes["code"].Value;
+                    ctx.AddInParameter(command, "search_code", System.Data.DbType.String, value);
+                    ctx.AddInParameter(command, "status", System.Data.DbType.String, "1");
+                    break;
+                }
+            }
+        }
+    }
+}

+ 301 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z2B_GY_KESHI_ZS.cs

@@ -0,0 +1,301 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NHapi.Model.V24.Message;
+using NHapi.Model.V24.Group;
+using NHapi.Model.V24.Segment;
+using System.Data.Common;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data;
+using IL.Common;
+//using MediII.Adapter.Model.UE;
+
+
+namespace MediII.Adapter.BizComponent.MFN
+{
+    /// <summary>
+    /// 公用科室
+    /// zengfan 2012-09-04
+    /// </summary>
+    /// <remarks></remarks>
+    public class MFN_Z2B_GY_KESHI_ZS : MFNBase
+    {
+        //数据库连接
+        //HealthCareContainer HealthCareContainer = new HealthCareContainer();
+        private Database ctx = null;
+        public MFN_Z2B_GY_KESHI_ZS(Database dbCtx)
+        {
+            ctx = dbCtx;
+        }
+        /// <summary>
+        /// 消息处理,入库
+        /// zengfan 2012-09-04
+        /// </summary>
+        /// <param name="message">转化过的强类型消息</param>
+        /// <returns></returns>
+        /// <remarks></remarks>
+        public override int Process(NHapi.Base.Model.IMessage message)
+        {
+            //IEnumerable<Employee> EmpList = HealthCareContainer.Employee;
+            //取得消息类型 MAD新增 MUP更新 MDL删除 "MDC"作废 "MAC"恢复
+            string strMsgType;
+
+            MFN_Z2B msg = message as MFN_Z2B;
+
+            using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                for (int i = 0; i < msg.MFRepetitionsUsed; i++)
+                {
+                    MFN_Z2B_Nofification group = msg.GetMF(i);
+                    strMsgType = group.MFE.RecordLevelEventCode.Value;
+                    //int KeShiLB;
+                    var pkid = StrHelepr.ObjToStrTrim(group.Z2B.KeShiId.Value);
+                        string qurysql = "select count(*) from HealthCare.dbo.Division where DivNo=@DivNo";
+                        DbCommand command = ctx.GetSqlStringCommand(qurysql.ToString());
+                        ctx.AddInParameter(command, "DivNo", System.Data.DbType.String, pkid);
+                        int counts = Convert.ToInt32(ctx.ExecuteScalar(command));
+                        if (counts == 0)
+                        {
+                            Division_SyncAdd(group, pkid);//增加
+                        }
+                        else
+                        {
+                            if ("MUP" == strMsgType || "MAD" == strMsgType)//修改
+                            {
+                                string sql2 = @"update HealthCare.dbo.Division 
+                                                set  DivName=@DivName,
+									                 DivEngName=@DivEngName,
+									                 DeptNo=@DeptNo,
+									                 UpdateUser=@UpdateUser,
+									                 UpdateTime=GETDATE(),
+									                 Keyword1=@Keyword1,
+									                 Keyword2=@Keyword2,
+									                 Keyword3=@Keyword3,
+									                 IsIss=@IsIss,
+									                 OpdUseType=@OpdUseType,
+									                 InpUseType=@InpUseType,
+                                                     Zone=@Zone,
+                                                     EmgUseType=@EmgUseType,
+                                                     DivCode=@DivCode,
+                                                     IsVirtual=@IsVirtual,
+                                                     IsConsultation=@IsConsultation,
+                                                     DivType=@DivType
+                                                where DivNo=@DivNo
+									                                                ";
+                                DbCommand command2 = ctx.GetSqlStringCommand(sql2.ToString());
+                                ctx.AddInParameter(command2, "DivNo", System.Data.DbType.AnsiString, pkid);
+                                SetDivisionEntity(group.Z2B, ctx, command2);
+                                ctx.ExecuteNonQuery(command2);
+                            }
+                            if ("MDL" == strMsgType)
+                            {
+                                Division_SyncDel(pkid);
+                            }
+                        }
+                }   
+                scope.Complete();
+            }
+            return 1;
+        }
+
+        /// <summary>
+        /// 科室新增
+        /// </summary> 
+        public void Division_SyncAdd(MFN_Z2B_Nofification group, string pkid)
+        {
+            string sql = @"insert into HealthCare.dbo.Division(DivNo,
+                                                                DivCode,
+									                            DivName,
+									                            DivEngName,
+									                            DeptNo,
+									                            IsVirtual,
+									                            IsConsultation,
+									                            DivType,
+									                            UpdateUser,
+									                            UpdateTime,
+									                            Keyword1,
+									                            Keyword2,
+									                            Keyword3,
+									                            IsIss,
+									                            OpdUseType,
+									                            InpUseType,
+									                            EmgUseType,
+                                                                 Zone)
+							                            VALUES(@DivNo,
+                                                                @DivCode,
+									                            @DivName,
+									                            @DivEngName,
+									                            @DeptNo,
+									                            @IsVirtual,
+									                            @IsConsultation,
+									                            @DivType,
+									                            @UpdateUser,
+									                            GETDATE(),
+									                            @Keyword1,
+									                            @Keyword2,
+									                            @Keyword3,
+									                            @IsIss,
+									                            @OpdUseType,
+									                            @InpUseType,
+									                            @EmgUseType,
+                                                                @Zone)";
+            DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
+            ctx.AddInParameter(command, "DivNo", System.Data.DbType.AnsiString, pkid);//部门代号
+            SetDivisionEntity(group.Z2B, ctx, command);
+            ctx.ExecuteNonQuery(command);
+        }
+        public void SetDivisionEntity(Z2B seg, Database ctx, DbCommand command)
+        {
+            //string sql = @"SELECT Zone FROM HealthCare.dbo.HisInfo WHERE HisZone = @HisZone";
+            //DbCommand command1 = ctx.GetSqlStringCommand(sql.ToString());
+            //ctx.AddInParameter(command1, "HisZone", System.Data.DbType.AnsiString, seg.YuanQu.Identifier.Value);
+            //DataTable dt = ctx.ExecuteDataSet(command1).Tables[0];
+            //string ZONE = "";
+            //if (dt.Rows.Count > 0)
+            //{
+            //    ZONE = dt.Rows[0]["Zone"].ToString();
+            //}
+
+            ctx.AddInParameter(command, "Zone", System.Data.DbType.AnsiString, GetZone(seg.YuanQu.Identifier.Value));
+
+            //ctx.AddInParameter(command, "keshiid", System.Data.DbType.AnsiString, seg.  KeShiId.Value);
+            ctx.AddInParameter(command, "DivCode", System.Data.DbType.AnsiString, seg.KeShiBm.Value);              //科别代码
+            ctx.AddInParameter(command, "DeptNo", System.Data.DbType.AnsiString, "");//seg.ShangJiKs.Identifier.Value);  //科别代号
+            ctx.AddInParameter(command, "DivName", System.Data.DbType.AnsiString, seg.KeShiMc.Value);              //科别名称
+            //ctx.AddInParameter(command, "keshibm", System.Data.DbType.AnsiString, seg.KeShiBm.Value);
+            //ctx.AddInParameter(command, "weizhism", System.Data.DbType.AnsiString, seg.WeiZhiSm.Value);
+            //wuchengwu 0904 不再更新renshiks数据
+            ctx.AddInParameter(command, "DivEngName", System.Data.DbType.AnsiString, seg.YingWenMing.Value);    //英文名
+            ctx.AddInParameter(command, "IsVirtual", System.Data.DbType.Int16, 0);                             //是否为虚拟科别
+            ctx.AddInParameter(command, "IsConsultation", System.Data.DbType.Int16, 1);                          //是否可会诊
+            ctx.AddInParameter(command, "DivType", System.Data.DbType.Int16, seg.KeShiLB.Value);                 //科别类型
+            //ctx.AddInParameter(command, "lianxidh", System.Data.DbType.AnsiString, seg.LianXiDh.PhoneNumber.Value);
+            //ctx.AddInParameter(command, "hesuanks", System.Data.DbType.AnsiString, seg.HeSuanKs.Identifier.Value);
+            //ctx.AddInParameter(command, "chengbenks", System.Data.DbType.AnsiString, seg.ChengBenKs.Identifier.Value);
+            //wuchengwu 0904 不再更新renshiks数据
+            //ctx.AddInParameter(command, "renshiks", System.Data.DbType.AnsiString, seg.RenShiKs.Identifier.Value);
+            ctx.AddInParameter(command, "EmgUseType", System.Data.DbType.Int16, seg.JiZhenSyBz.Value == "1" ? (short)1 : (short)0); //11.04
+
+            //根据Division表的急诊标志,修改HealthCare.dbo.OpdRoomSet表的LocArea标志
+
+            int _EmgUseType = seg.JiZhenSyBz.Value == "1" ? (short)1 : (short)0;
+            string _SQL = "select LocArea from HealthCare.dbo.OpdRoomSet where DivNo = @_DivNo";
+            DbCommand comd = ctx.GetSqlStringCommand(_SQL.ToString());
+            ctx.AddInParameter(comd, "_DivNo", System.Data.DbType.AnsiString, seg.KeShiId.Value);
+            DataTable dt2 = ctx.ExecuteDataSet(comd).Tables[0];
+            string _LocArea = "";
+            if (dt2.Rows.Count > 0)
+            {
+                _LocArea = dt2.Rows[0]["LocArea"].ToString();
+
+                if (1 == _EmgUseType)
+                {
+                    string _LocArea2 = "E00";
+                    if (_LocArea != "E00")
+                    { AlertLocArea(_LocArea2, seg.KeShiId.Value); }
+                }
+                else if (0 == _EmgUseType)
+                {
+                    string _LocArea2 = "O00";
+                    if (_LocArea != "O00")
+                    { AlertLocArea(_LocArea2, seg.KeShiId.Value); }
+                }
+            }
+
+            ctx.AddInParameter(command, "OpdUseType", System.Data.DbType.Int16, seg.MenZhenSyBz.Value == "1" ? (short)1 : (short)0);
+            ctx.AddInParameter(command, "InpUseType", System.Data.DbType.Int16, seg.ZhuYuanSyBz.Value == "1" ? (short)1 : (short)0);
+            //wuchengwu 0904 不再更新jizhenbz数据
+            //ctx.AddInParameter(command, "jizhenbz", System.Data.DbType.Int16, seg.JiZhenSyBz.Value == "1" ? (short)1 : (short)0);
+
+            ctx.AddInParameter(command, "IsIss", System.Data.DbType.Int16, 0);//seg.ZuoFeiBZ.Value == "1" ? (short)1 : (short)0);  //是否IIS分数(病人注记中)
+            //ctx.AddInParameter(command, "shangjiywks", System.Data.DbType.AnsiString, seg.ShangJiKs.Identifier.Value);
+
+            string SHURUMA1 = string.Empty;
+            string SHURUMA2 = string.Empty;
+            string SHURUMA3 = string.Empty;
+            for (int i = 0; i < seg.ShuRuMaRepetitionsUsed; i++)
+            {
+                NHapi.Model.V24.Datatype.CE shuRuMa = seg.GetShuRuMa(i);
+                if (SHURUMA1 == string.Empty)
+                {
+                    SHURUMA1 = string.IsNullOrEmpty(shuRuMa.Text.Value) ? MFNBase.GetInputCode(0, seg.KeShiMc.Value) : shuRuMa.Text.Value;
+                    continue;
+                }
+                if (SHURUMA2 == string.Empty)
+                {
+                    SHURUMA2 = string.IsNullOrEmpty(shuRuMa.Text.Value) ? MFNBase.GetInputCode(1, seg.KeShiMc.Value) : shuRuMa.Text.Value;
+                    continue;
+                }
+                if (SHURUMA3 == string.Empty)
+                {
+                    SHURUMA3 = shuRuMa.Text.Value;
+                    continue;
+                }
+            }
+            ctx.AddInParameter(command, "Keyword1", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA1) ? MFNBase.GetInputCode(0, seg.KeShiMc.Value) : SHURUMA1.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "Keyword2", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA2) ? MFNBase.GetInputCode(1, seg.KeShiMc.Value) : SHURUMA2.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "Keyword3", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA3) ? "" : SHURUMA3.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "UpdateUser", System.Data.DbType.AnsiString, seg.XiuGaiRen.IDNumber.Value);
+            ctx.AddInParameter(command, "UpdateTime", System.Data.DbType.DateTime, seg.XiuGaiSJ.TimeOfAnEvent.GetAsDate());
+        }
+
+
+
+        /// <summary>
+        /// 部门新增
+        /// </summary>
+        /// <param name="seg"></param>
+        /// <param name="HealthCareContainer"></param>
+        /// <param name="scope"></param>
+
+       
+
+
+        /// <summary>
+        /// 科室删除
+        /// </summary>
+        /// <param name="seg">传入资料</param>
+        /// <param name="HealthCareContainer">连线</param>
+        /// <param name="scope">交易</param>
+        public void Division_SyncDel(string pkid)
+        {
+            //string sql4 = "update HealthCare.dbo.Division set IsIss=1 where DivNo=@DivNo";
+            string sql4 = "delete from HealthCare.dbo.Division where DivNo=@DivNo";
+            DbCommand command4 = ctx.GetSqlStringCommand(sql4.ToString());
+            ctx.AddInParameter(command4, "DivNo", System.Data.DbType.AnsiString, pkid);
+            ctx.ExecuteNonQuery(command4);
+        }
+
+
+      
+        public void AlertLocArea(string LocArea, string KeShiID)
+        {
+            if (!string.IsNullOrEmpty(LocArea) && !string.IsNullOrEmpty(KeShiID))
+            {
+                string sql = "update HealthCare.dbo.OpdRoomSet set LocArea = @LocArea where DivNo=@Loc_DivNo";
+                DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
+                ctx.AddInParameter(command, "LocArea", System.Data.DbType.AnsiString, LocArea);
+                ctx.AddInParameter(command, "Loc_DivNo", System.Data.DbType.AnsiString, KeShiID);
+                ctx.ExecuteNonQuery(command);
+            }
+        }
+
+
+        private string GetZone(string value)
+        {
+            string sql = @"SELECT Zone FROM HealthCare.dbo.HisInfo WHERE HisZone = @HisZone";
+            DbCommand command1 = ctx.GetSqlStringCommand(sql.ToString());
+            ctx.AddInParameter(command1, "HisZone", System.Data.DbType.AnsiString, value);
+            DataTable dt = ctx.ExecuteDataSet(command1).Tables[0];
+            string ZONE = "";
+            if (dt.Rows.Count > 0)
+            {
+                ZONE = dt.Rows[0]["Zone"].ToString();
+            }
+            return ZONE;
+        }
+
+    }
+}

+ 285 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/MFN_Z3H_GY_YAOPINFL.cs

@@ -0,0 +1,285 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using NHapi.Model.V24.Segment;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data.Common;
+using System.Transactions;
+using NHapi.Model.V24.Message;
+using NHapi.Model.V24.Group;
+
+namespace MediII.Adapter.BizComponent.MFN
+{
+    /// <summary>
+    /// Z3H(药品分类)
+    /// wuchengwu 2014-05-23
+    /// </summary>
+    public class MFN_Z3H_GY_YAOPINFL : MFNBase
+    {
+        //数据库连接
+        private Database ctx = null;
+        public MFN_Z3H_GY_YAOPINFL(Database dbCtx)
+        {
+            ctx = dbCtx;
+        }
+
+        #region 消息处理
+        /// <summary>
+        /// 消息处理
+        /// </summary>
+        /// <param name="message"></param>
+        /// <returns></returns>
+        public override int Process(NHapi.Base.Model.IMessage message)
+        {
+            //取得消息类型 MAD新增 MUP更新 MDL删除 "MDC"作废 "MAC"恢复
+            string strMsgType;
+
+            MFN_Z3H msg = message as MFN_Z3H;
+
+           
+                for (int i = 0; i < msg.MFRepetitionsUsed; i++)
+                {
+                    MFN_Z3H_Nofification group = msg.GetMF(i);
+                    strMsgType = group.MFE.RecordLevelEventCode.Value;
+
+                    string pkid = group.Z3H.YaoPinFlId.Value;
+                     string qurysql = "select count(*) from HealthCare.dbo.MedWaySet where WayNo=@WayNo";
+                    DbCommand command = ctx.GetSqlStringCommand(qurysql.ToString());
+                    ctx.AddInParameter(command, "WayNo", System.Data.DbType.String, pkid);
+                    int counts = Convert.ToInt32(ctx.ExecuteScalar(command));
+
+ using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                    if (counts == 0)
+                    {
+                    //switch (strMsgType)
+                    //{
+                        //case MAD:
+                            #region 新增
+                            AddData(group, pkid);
+                            #endregion
+                            //break;
+                    }
+                    else
+                    { 
+                        //case MUP:
+                        if ("MUP" == strMsgType || "MAD" == strMsgType)
+                        {
+                            #region 修改
+                            StringBuilder sql1 = new StringBuilder();
+
+                            #region wuchengwu 20140911 modi 去掉顺序号(shunxuhao)的更新
+                            /*MediIIB-242(205628):Modified By ZhangM.Y.@2014-09-03:发送过来的修改消息不要去同步MoJiBZ,因为这个字段是在Z3A_YAOPINXX里面处理。去掉(mojibz=:mojibz,)*/
+                            //                            sql1.AppendFormat(@" UPDATE gy_yaopinfl 
+                            //                                                 SET shangjifl=:shangjifl,
+                            //                                                     fenleimc =:fenleimc,
+                            //                                                     biaozhunbm =:biaozhunbm,
+                            //                                                     yaopinlx=:yaopinlx,
+                            //                                                     shunxuhao=:shunxuhao,
+                            //                                                     xiugairen=:xiugairen,
+                            //                                                     xiugaisj=:xiugaisj,
+                            //                                                     fenleilb=:fenleilb,
+                            //                                                     zuofeibz=:zuofeibz,
+                            //                                                     shuruma1=:shuruma1,
+                            //                                                     shuruma2=:shuruma2,
+                            //                                                     shuruma3=:shuruma3
+                            //                                                 WHERE yaopinflid=:yaopinflid ");
+                            sql1.AppendFormat(@" UPDATE gy_yaopinfl 
+                                                 SET shangjifl=:shangjifl,
+                                                     fenleimc =:fenleimc,
+                                                     biaozhunbm =:biaozhunbm,
+                                                     yaopinlx=:yaopinlx,
+                                                     xiugairen=:xiugairen,
+                                                     xiugaisj=:xiugaisj,
+                                                     fenleilb=:fenleilb,
+                                                     zuofeibz=:zuofeibz,
+                                                     shuruma1=:shuruma1,
+                                                     shuruma2=:shuruma2,
+                                                     shuruma3=:shuruma3
+                                                 WHERE yaopinflid=:yaopinflid ");
+                            #endregion
+                            DbCommand command1 = ctx.GetSqlStringCommand(sql1.ToString());
+                            SetEntityForUpdating(group.Z3H, ctx, command1);
+                            ctx.AddInParameter(command1, "yaopinflid", System.Data.DbType.AnsiString, pkid);
+                            int affectedRecords = ctx.ExecuteNonQuery(command1);
+                            if (affectedRecords == 0)
+                            {
+                                //更新数据时,当返回受影响行数为0时,则跳转到新增数据操作
+                                AddData(group, pkid);
+                            }
+                            #endregion
+                            //break;
+                        }
+                        if ("MDL" == strMsgType)
+                        {
+                            //case MDL:
+                            #region 删除/作废
+                            StringBuilder sql2 = new StringBuilder();
+                            sql2.Append(" UPDATE GY_YAOPINFL SET ZUOFEIBZ = 1 WHERE YAOPINFLID = :YAOPINFLID ");
+                            DbCommand command2 = ctx.GetSqlStringCommand(sql2.ToString());
+                            ctx.AddInParameter(command2, "yaopinflid", System.Data.DbType.AnsiString, pkid);
+                            ctx.ExecuteNonQuery(command2);
+                            #endregion
+                            //break;
+                        }
+                    //}
+                    }
+scope.Complete();
+                }
+                
+            }
+            return 1;
+        } 
+        #endregion
+
+        #region 新增数据
+        /// <summary>
+        /// 新增数据
+        /// </summary>
+        /// <param name="group"></param>
+        /// <param name="pkid">主键</param>
+        private void AddData(MFN_Z3H_Nofification group, string pkid)
+        {
+            StringBuilder sql = new StringBuilder();
+            sql.AppendFormat(@"insert into gy_yaopinfl(
+                                                      yaopinflid,
+                                                      shangjifl,
+                                                      fenleimc,
+                                                      biaozhunbm,
+                                                      yaopinlx,
+                                                      shunxuhao,
+                                                      xiugairen,
+                                                      xiugaisj,
+                                                      fenleilb,
+                                                      zuofeibz,
+                                                      shuruma1,
+                                                      shuruma2,
+                                                      shuruma3,
+                                                      mojibz)
+                                               values(
+                                                      :yaopinflid,
+                                                      :shangjifl,
+                                                      :fenleimc,
+                                                      :biaozhunbm,
+                                                      :yaopinlx,
+                                                      :shunxuhao,
+                                                      :xiugairen,
+                                                      :xiugaisj,
+                                                      :fenleilb,
+                                                      :zuofeibz,
+                                                      :shuruma1,
+                                                      :shuruma2,
+                                                      :shuruma3,
+                                                      :mojibz )");
+            DbCommand command0 = ctx.GetSqlStringCommand(sql.ToString());
+            ctx.AddInParameter(command0, "yaopinflid", System.Data.DbType.AnsiString, pkid);
+            SetEntity(group.Z3H, ctx, command0);
+            ctx.AddInParameter(command0, "mojibz", System.Data.DbType.Int16, group.Z3H.MoJiBz.Value == "1" ? (short)1 : (short)0);
+            ctx.ExecuteNonQuery(command0);
+        } 
+        #endregion
+
+        #region 实体参数(新增数据)
+        /// <summary>
+        /// 对Entity进行赋值
+        /// wuchengwu 2014-05-23
+        /// </summary>
+        /// <param name="entity">The entity.</param>
+        /// <param name="zaa">The zaa.</param>
+        /// <param name="daiMaLb">The dai ma lb.</param>
+        /// <remarks></remarks>
+        public void SetEntity(Z3H seg, Database ctx, DbCommand command)
+        {
+            ctx.AddInParameter(command, "shangjifl", System.Data.DbType.AnsiString, seg.FuLeiId.Value);
+            ctx.AddInParameter(command, "fenleimc", System.Data.DbType.AnsiString, seg.YaoPinFlMc.Value);
+            ctx.AddInParameter(command, "biaozhunbm", System.Data.DbType.AnsiString, seg.BiaoZhunBm.Value);
+            ctx.AddInParameter(command, "yaopinlx", System.Data.DbType.Int16, seg.YaoPinLx.Value);
+            ctx.AddInParameter(command, "shunxuhao", System.Data.DbType.Int32, MFNBase.GetSortNum(ctx, "gy_yaopinfl"));
+            ctx.AddInParameter(command, "xiugairen", System.Data.DbType.AnsiString, seg.XiuGaiRen.IDNumber.Value);
+            ctx.AddInParameter(command, "xiugaisj", System.Data.DbType.DateTime, seg.XiuGaiSJ.TimeOfAnEvent.GetAsDate());
+            ctx.AddInParameter(command, "fenleilb", System.Data.DbType.Int16, 1);//分类类别待定
+            ctx.AddInParameter(command, "zuofeibz", System.Data.DbType.Int16, seg.ZuoFeiBz.Value == "1" ? (short)1 : (short)0);
+            #region 获取输入码
+            string SHURUMA1 = string.Empty;
+            string SHURUMA2 = string.Empty;
+            string SHURUMA3 = string.Empty;
+            for (int i = 0; i < seg.ShuRuMaRepetitionsUsed; i++)
+            {
+                NHapi.Model.V24.Datatype.CE shuRuMa = seg.GetShuRuMa(i);
+                if (SHURUMA1 == string.Empty)
+                {
+                    SHURUMA1 = string.IsNullOrEmpty(shuRuMa.Text.Value) ? MFNBase.GetInputCode(0, seg.YaoPinFlMc.Value) : shuRuMa.Text.Value;
+                    continue;
+                }
+                if (SHURUMA2 == string.Empty)
+                {
+                    SHURUMA2 = string.IsNullOrEmpty(shuRuMa.Text.Value) ? MFNBase.GetInputCode(1, seg.YaoPinFlMc.Value) : shuRuMa.Text.Value;
+                    continue;
+                }
+                if (SHURUMA3 == string.Empty)
+                {
+                    SHURUMA3 = shuRuMa.Text.Value;
+                    continue;
+                }
+            }
+            ctx.AddInParameter(command, "shuruma1", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA1) ? "" : SHURUMA1.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "shuruma2", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA2) ? "" : SHURUMA2.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "shuruma3", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA3) ? "" : SHURUMA3.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            #endregion
+        } 
+        #endregion
+
+        #region 实体参数(更新数据)
+        /// <summary>
+        /// 对Entity进行赋值
+        /// wuchengwu 2014-05-23
+        /// </summary>
+        /// <param name="entity">The entity.</param>
+        /// <param name="zaa">The zaa.</param>
+        /// <param name="daiMaLb">The dai ma lb.</param>
+        /// <remarks></remarks>
+        public void SetEntityForUpdating(Z3H seg, Database ctx, DbCommand command)
+        {
+            ctx.AddInParameter(command, "shangjifl", System.Data.DbType.AnsiString, seg.FuLeiId.Value);
+            ctx.AddInParameter(command, "fenleimc", System.Data.DbType.AnsiString, seg.YaoPinFlMc.Value);
+            ctx.AddInParameter(command, "biaozhunbm", System.Data.DbType.AnsiString, seg.BiaoZhunBm.Value);
+            ctx.AddInParameter(command, "yaopinlx", System.Data.DbType.Int16, seg.YaoPinLx.Value);
+            //wuchengwu 20140911 modi 去掉顺序号的更新
+            //ctx.AddInParameter(command, "shunxuhao", System.Data.DbType.Int32, MFNBase.GetSortNum(ctx, "gy_yaopinfl"));
+            ctx.AddInParameter(command, "xiugairen", System.Data.DbType.AnsiString, seg.XiuGaiRen.IDNumber.Value);
+            ctx.AddInParameter(command, "xiugaisj", System.Data.DbType.DateTime, seg.XiuGaiSJ.TimeOfAnEvent.GetAsDate());
+            ctx.AddInParameter(command, "fenleilb", System.Data.DbType.Int16, 1);//分类类别待定
+            ctx.AddInParameter(command, "zuofeibz", System.Data.DbType.Int16, seg.ZuoFeiBz.Value == "1" ? (short)1 : (short)0);
+            #region 获取输入码
+            string SHURUMA1 = string.Empty;
+            string SHURUMA2 = string.Empty;
+            string SHURUMA3 = string.Empty;
+            for (int i = 0; i < seg.ShuRuMaRepetitionsUsed; i++)
+            {
+                NHapi.Model.V24.Datatype.CE shuRuMa = seg.GetShuRuMa(i);
+                if (SHURUMA1 == string.Empty)
+                {
+                    SHURUMA1 = string.IsNullOrEmpty(shuRuMa.Text.Value) ? MFNBase.GetInputCode(0, seg.YaoPinFlMc.Value) : shuRuMa.Text.Value;
+                    continue;
+                }
+                if (SHURUMA2 == string.Empty)
+                {
+                    SHURUMA2 = string.IsNullOrEmpty(shuRuMa.Text.Value) ? MFNBase.GetInputCode(1, seg.YaoPinFlMc.Value) : shuRuMa.Text.Value;
+                    continue;
+                }
+                if (SHURUMA3 == string.Empty)
+                {
+                    SHURUMA3 = shuRuMa.Text.Value;
+                    continue;
+                }
+            }
+            ctx.AddInParameter(command, "shuruma1", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA1) ? "" : SHURUMA1.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "shuruma2", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA2) ? "" : SHURUMA2.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            ctx.AddInParameter(command, "shuruma3", System.Data.DbType.AnsiString, string.IsNullOrEmpty(SHURUMA3) ? "" : SHURUMA3.Replace(" ", "").Replace("\r", "").Replace("\t", "").Replace("\n", ""));
+            #endregion
+        }
+        #endregion
+    }
+}

+ 113 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/MediII.Adapter.BizComponent.MFN.csproj

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{70F1BFF2-22D0-4B1D-BD85-4279FAC616C1}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.BizComponent.MFN</RootNamespace>
+    <AssemblyName>MediII.Adapter.BizComponent.MFN</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <DocumentationFile>
+    </DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.ServiceLocation.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Transactions" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BizComponent_MFN.cs" />
+    <Compile Include="MFNBase.cs" />
+    <Compile Include="MFN_Z2B_GY_KESHI.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj">
+      <Project>{4e8c6d0e-e696-4f02-812f-cedd6fe3f6dc}</Project>
+      <Name>MediII.Adapter.Scan.Interface</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.BizComponent.Base\MediII.Adapter.BizComponent.Base.csproj">
+      <Project>{619b1dbf-55b7-446b-af40-852a6ab689a0}</Project>
+      <Name>MediII.Adapter.BizComponent.Base</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScan\UE\
+Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScanServer\UE\</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
IL.BizComponent/MediII.Adapter.BizComponent.MFN/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.BizComponent.MFN")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MediII.Adapter.BizComponent.MFN")]
+[assembly: AssemblyCopyright("Copyright ©  2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("115a6a94-1cf1-4141-8b5c-740ce3ae0cef")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 668 - 0
IL.BizComponent/MediII.Adapter.BizComponent.PMU/BizComponent_PMU.cs

@@ -0,0 +1,668 @@
+using System;
+using System.Data;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+//using MediII.Adapter.BaseBiz;
+using System.Data.Common;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+//using MediII.Adapter.Model.UE;
+using System.Globalization;
+using MediII.Adapter.BizComponent.Base;
+using IL.Common;
+using System.Xml;
+
+namespace MediII.Adapter.BizComponent.PMU
+{
+    public class BizComponent_PMU : BaseBizComponent, IBizComponent
+    {
+        const string Insert = "B01"; //增加个人纪录
+        //const string Update = "B02"; //更新个人记录
+        //const string Delete = "B03"; //删除个人记录
+        //数据库连接
+        protected Database ctx
+        {
+            get { return base.HealthCarectx; }
+        }
+        public BizComponent_PMU()
+        {
+
+        }
+        ////HealthCareContainer HealthCareContainer = new HealthCareContainer();
+        //private Database ctx = null;
+        //public BizComponent_PMU(Database dbCtx)
+        //{
+        //    ctx = dbCtx;
+        //}
+        public override string DoProcess(string m, string msgType)
+        {
+            string strMsgType = null;
+            //try
+            //{
+            //try
+            // {
+            //取得消息类型 MAD新增 MUP更新 MDL删除 "MDC"作废 "MAC"恢复
+            OperateXmlUtil helper = new OperateXmlUtil();
+            string qurysql = "select count(*) from dbo.his_doct where DOCT_CODE=@DOCT_CODE";
+            DbCommand command = ctx.GetSqlStringCommand(qurysql.ToString());
+            string pkid = helper.XpathRead(m, "//*[@root='2.16.156.10011.1.4']", "extension");
+            ctx.AddInParameter(command, "DOCT_CODE", System.Data.DbType.String, pkid);
+            int counts = Convert.ToInt32(ctx.ExecuteScalar(command));
+
+
+            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+            {
+                //for (int i = 0; i < pmuB01.EDURepetitionsUsed; i++)
+                //{ 
+                if (counts == 0)
+                {
+                    //没有查询到记录则新增,否则修改
+                    AddData(m, pkid);
+                }
+                else
+                {
+                    UpDateData(m, pkid);
+                }
+
+
+
+                scope.Complete();
+            }
+            return string.Empty;
+        }
+        public void AddData(string message, string id)
+        {
+            #region 新增
+            string sql = @"INSERT INTO dbo.his_doct
+                                    ( DOCT_CODE ,
+                                    DOCT_NAME ,
+                                    HIS_DEPT_CODE ,
+                                    HIS_DEPT_NAME ,
+                                    status
+                                    )
+                            VALUES  ( @DOCT_CODE,
+                                    @DOCT_NAME ,
+                                    @HIS_DEPT_CODE ,
+                                    @HIS_DEPT_NAME ,
+                                    @status)";
+            DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
+
+            SetEntity(message, command, id);
+            SqlDataAccess.ExecuteNonQuery(ctx, command);
+            #endregion
+        }
+        public void UpDateData(string message, string id)
+        {
+            #region 修改
+            string sql1 = @"update dbo.his_doct set 
+                                    DOCT_NAME =@DOCT_NAME,
+                                    HIS_DEPT_CODE =@HIS_DEPT_CODE,
+                                    HIS_DEPT_NAME =@HIS_DEPT_NAME,
+                                    status=@status
+                                where DOCT_CODE=@DOCT_CODE";
+            DbCommand command1 = ctx.GetSqlStringCommand(sql1.ToString());
+
+            SetEntity(message, command1, id);
+            SqlDataAccess.ExecuteNonQuery(ctx, command1);
+            #endregion
+        }
+
+        public void SetEntity(string message, DbCommand command, string id)
+        {
+            string value = string.Empty;
+            OperateXmlUtil xmlHelper = new OperateXmlUtil();
+
+            ctx.AddInParameter(command, "DOCT_CODE", System.Data.DbType.String, id);
+            var valueNode = xmlHelper.XpathRead(message, "//*[name()='healthCarePrincipalPerson']").Item(0);
+
+            foreach (XmlNode xe in valueNode.ChildNodes)
+            {
+                if (xe.Name == "name")
+                {
+                    value = xe.LastChild.LastChild.Attributes["value"].Value;
+                    ctx.AddInParameter(command, "DOCT_NAME", System.Data.DbType.String, value);
+
+                    break;
+                }
+            }
+
+            value = xmlHelper.XpathRead(message, "//*[@root='2.16.156.10011.1.26']", "extension");
+            ctx.AddInParameter(command, "HIS_DEPT_CODE", System.Data.DbType.AnsiString, value);
+
+            valueNode = xmlHelper.XpathRead(message, "//*[name()='affiliatedPrincipalOrganization']").Item(0);
+            foreach (XmlNode xe in valueNode.ChildNodes)
+            {
+                if (xe.Name == "name")
+                {
+                    value = xe.LastChild.LastChild.Attributes["value"].Value;
+                    ctx.AddInParameter(command, "HIS_DEPT_NAME", System.Data.DbType.String, value);
+
+                    break;
+                }
+            }
+            ctx.AddInParameter(command, "status", System.Data.DbType.String, "在用");
+            //ctx.ExecuteNonQuery(command);
+        }
+        public void AddEmpLicense(string type, string pkid, string bm, string updateuser)
+        {
+            #region 新增资格编码
+            var sql = @"INSERT INTO HealthCare.dbo.EmpLicense
+                                ( EmpLicenseID ,
+                                  EmpNo ,
+                                  LicenseType ,
+                                  LicenseClass ,
+                                  LicenseNo ,
+                                  IsMajor ,
+                                  IssueDate ,
+                                  StartDate ,
+                                  EndDate ,
+                                  UpdateUser ,
+                                  UpdateTime ,
+                                  IsDel
+                                )
+                        VALUES  ( NEXT VALUE FOR HealthCare.dbo.Seq_EmpLicense_EmpLicenseID ,
+                                  @EmpNo , 
+                                  @LicenseType , 
+                                  1 ,
+                                  @LicenseNo , 
+                                  0 , 
+                                  GETDATE() , 
+                                  GETDATE() , 
+                                  '2999-12-31 00:00:00.000',
+                                  @UpdateUser , 
+                                  GETDATE() , 
+                                  0
+                                )";
+            #endregion
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "EmpNo", DbType.AnsiString, pkid);
+            SqlDataAccess.AddInParameter(ctx, cmd, "LicenseType", DbType.AnsiString, type);
+            SqlDataAccess.AddInParameter(ctx, cmd, "LicenseNo", DbType.AnsiString, bm);
+            SqlDataAccess.AddInParameter(ctx, cmd, "UpdateUser", DbType.AnsiString, updateuser);
+            SqlDataAccess.DBExecuteNonQuery(ctx, cmd);
+
+
+        }
+        public void UpdateEmpLicense(string type, string pkid, string bm)
+        {
+            var sql = @"UPDATE HealthCare.dbo.EmpLicense SET LicenseNo=@LicenseNo WHERE EmpNo=@EmpNo AND LicenseType=@LicenseType ";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "EmpNo", DbType.AnsiString, pkid);
+            SqlDataAccess.AddInParameter(ctx, cmd, "LicenseType", DbType.AnsiString, type);
+            SqlDataAccess.AddInParameter(ctx, cmd, "LicenseNo", DbType.AnsiString, bm);
+            SqlDataAccess.DBExecuteNonQuery(ctx, cmd);
+        }
+        public void DeleteEmpLicense(string type, string pkid)
+        {
+            var sql = "DELETE FROM HealthCare.dbo.EmpLicense WHERE EmpNo=@EmpNo AND LicenseType=@LicenseType";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "EmpNo", DbType.AnsiString, pkid);
+            SqlDataAccess.AddInParameter(ctx, cmd, "LicenseType", DbType.AnsiString, type);
+            SqlDataAccess.DBExecuteNonQuery(ctx, cmd);
+        }
+
+
+
+
+
+        ///// <summary>
+        ///// 获取当前时间
+        ///// </summary> 
+        //internal DateTime GetNow(Database ctx)
+        //{ 
+        //    object obj = (DateTime)SqlDataAccess.ExecuteScalar(ctx, CommandType.Text, "select GETDATE()");
+        //    if (obj != null)
+        //        return Convert.ToDateTime(obj.ToString());
+        //    else
+        //        return DateTime.Now;
+        //}
+
+        //获取性别,转化
+        public string GetSex(string value)
+        {
+            string sex = "0";
+            switch (value)
+            {
+                case "F":
+                    sex = "1";//男
+                    break;
+                case "男":
+                    sex = "1";//男
+                    break;
+                case "M":
+                    sex = "2";//女
+                    break;
+                case "女":
+                    sex = "2";//女
+                    break;
+                default:
+                    sex = "9";//不定
+                    break;
+            }
+            return sex;
+        }
+        public string GetYsdj(string hiscodeid)
+        {
+            var sql = "SELECT CodeID FROM HealthCare.dbo.V_UserLevel WHERE HisCodeID=@HisCodeID";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "HisCodeID", DbType.AnsiString, hiscodeid);
+            string codeid = StrHelepr.Obj2StrTrim(SqlDataAccess.DBExecuteScalar(ctx, cmd));
+            if (codeid != null)
+            {
+                return codeid;
+            }
+            else
+            {
+                throw new Exception("V_UserLevel没有找到对应的医生等级");
+            }
+
+        }
+        public string GetEmpType(string value)
+        {
+            string emptype = "";
+            switch (value) // 员工分类
+            {
+                case "1"://1	医生
+                    emptype = "1";
+                    break;
+                case "2"://2	护士
+                    emptype = "2";
+                    break;
+                case "3"://3	财务人员
+                    emptype = "3";
+                    break;
+                case "4"://4	药剂人员
+                    emptype = "4";
+                    break;
+                case "5"://5	技师(检验)
+                    emptype = "5";
+                    break;
+                case "6"://6	技师(影像)
+                    emptype = "6";
+                    break;
+                case "7"://7	管理人员
+                    emptype = "7";
+                    break;
+                case "8"://8	其他卫生技术人员
+                    emptype = "8";
+                    break;
+                case "9"://9	其他人员
+                    emptype = "9";
+                    break;
+            }
+            return emptype;
+        }
+
+    }
+
+}
+#region 此为老版本代码
+/*
+Employee Module_Employee = new Employee();
+
+strMsgType = pmuB01.EVN.EventTypeCode.Value;
+
+#region STG
+STF stf = pmuB01.STF;
+
+Module_Employee.EmpNo = Convert.ToInt16(stf.PrimaryKeyValueSTF.Identifier.Value);// 员工代号
+Module_Employee.EmpCode = stf.GetStaffIDCode(0).ID.Value;// 员工代码
+Module_Employee.EmpName = stf.GetStaffName(0).GivenName.Value;// 姓名
+Module_Employee.EngName = stf.GetStaffName(0).GivenName.Value;// 英文姓名
+Module_Employee.IdNo = stf.DriverSLicenseNumberStaff.DriverSLicenseNumber.Value.Trim() ;// 身份证号 <<<<<<<<<<<<<<<<<<<<<< 目前ISNULL
+
+#region 性别转换
+// 1:男 2:女
+Module_Employee.Sex = His.MediIITransfer.MediII2Ue.GetSex(stf.AdministrativeSex.Value);
+#endregion
+
+Module_Employee.Birthday = His.Time.TryParseExact(stf.DateTimeOfBirth.TimeOfAnEvent.Value, "yyyyMMddhhmmss");
+
+#region 婚姻状况
+// 婚姻状况 (0:未婚,1:已婚,2:离婚)
+switch (stf.MaritalStatus.Text.Value)
+{
+    case "S"://S	独身
+    case "P"://P	同性恋
+    case "G"://G	同居
+    case "B"://B	未婚
+    case "U"://U	未知
+    case "O"://O	其他
+    case "T"://T	未报告
+        Module_Employee.MaritalStatus = "0";
+        break;
+    case "M"://M	结婚
+    case "A":  //A	分居
+    case "W"://W	丧偶
+    case "R"://R	已登记同性恋
+    case "E"://E	合法分居
+    // case "C"://C	普通法律
+    case "I"://I	诉讼中
+        Module_Employee.MaritalStatus = "1";
+        break;
+
+    case "D"://D	离婚
+        Module_Employee.MaritalStatus = "2";
+        break;
+    default:
+        Module_Employee.MaritalStatus = "0";
+        break;
+}
+#endregion
+
+Module_Employee.HomeAdrArea = 0;// 住处区域代码 <<<<<<<<<<<<<<<<<<<<<<<<<<<
+Module_Employee.HomeAdrDesc = stf.GetOfficeHomeAddress(0).StreetAddress.StreetOrMailingAddress.Value;// 住处地址
+Module_Employee.HomeTel1 = stf.GetPhone(0).PhoneNumber.Value;// 住处电话1
+Module_Employee.HomeTel2 = "0"; // 住处电话2(不同步)
+
+Module_Employee.MobilePhone = stf.GetPhone(0).PhoneNumber.Value; // 移动电话
+
+Module_Employee.NativeAdrArea = 0;// 户籍区域代码(不同步)
+Module_Employee.NativeAdrDesc = "";// 户籍地址(不同步)
+Module_Employee.NativeTel = "";// 户籍电话(不同步)
+
+Module_Employee.ConName = "";// 联系人姓名(不同步)
+Module_Employee.ConTel1 = "";// 络人电话(不同步)
+Module_Employee.ConTel2 = "";// 络人电话(不同步)
+
+Module_Employee.ConAdrArea = 0;// 联系人区域代码(不同步)
+Module_Employee.ConAdrDesc = "";// 联系人地址(不同步)
+
+Module_Employee.Affiliation = "";// 与联系人关系(不同步)
+
+try
+{
+     string sHireDate =stf.GetInstitutionActivationDate(0).Date.TimeOfAnEvent.Value;
+    DateTime dtHireDate = His.Time.TryParseExact(sHireDate, "yyyyMMddhhmmss");
+
+    Module_Employee.HireDate = dtHireDate == His.Time.MaxDateTime ? Convert.ToDateTime("1911-01-01 00:00:00") : dtHireDate; // 到职日期
+
+}
+catch
+{
+    Module_Employee.HireDate = Convert.ToDateTime("1911-01-01 00:00:00");
+}
+               
+Module_Employee.Zone = "A";// 归属院区(联众会开栏位**********)<<<<<<<<<<<<<<<<<<<<<<
+
+string tmp = stf.GetDepartment(0).Identifier.Value;
+
+try
+{
+    string sDepartNo = His.MediIITransfer.MediII2Ue.GetDepartNo(stf.GetDepartment(0).Identifier.Value);
+    Module_Employee.DepartNo = Convert.ToInt16(sDepartNo);// 部门代码
+}
+catch (Exception ex)
+{
+    Module_Employee.DepartNo = -1;
+}
+
+Module_Employee.EmpType = stf.GetStaffType(0).Value;
+
+#region 员工分类
+
+switch (stf.GetStaffType(0).Value) // 员工分类
+{
+    case "1"://1	医生
+        Module_Employee.EmpType = "1";
+        break;
+    case "2"://2	护士
+        Module_Employee.EmpType = "2";
+        break;
+    case "3"://3	财务人员
+        Module_Employee.EmpType = "3";
+        break;
+    case "4"://4	药剂人员
+        Module_Employee.EmpType = "4";
+        break;
+    case "5"://5	技师(检验)
+    case "6"://6	技师(影像)
+    case "7"://7	管理人员
+    case "8"://8	其他卫生技术人员
+    case "9"://9	其他人员
+        Module_Employee.EmpType = "0";
+        break;
+}
+#endregion
+string tmp2 = stf.JobCodeClass.JobCode.Value;
+
+try
+{
+    Module_Employee.Title = Convert.ToInt16(stf.JobCodeClass.JobCode.Value);// 职称
+}
+catch (Exception ex)
+{
+    Module_Employee.Title = -1;
+}
+
+
+Module_Employee.ChiefNo = Convert.ToInt16(stf.GetHospitalService(0).Identifier.Value);// 职位
+string tmp3 = stf.GetDepartment(0).Identifier.Value;
+
+try
+{
+    string sWorkDepartNo = His.MediIITransfer.MediII2Ue.GetDepartNo(stf.GetDepartment(0).Identifier.Value);
+    Module_Employee.WorkDepartNo = Convert.ToInt16(sWorkDepartNo);// 工作单位代号  <<<<<<<<<<<<<
+
+}
+catch
+{
+    Module_Employee.WorkDepartNo = -1;
+}
+
+Module_Employee.SimpleTel = stf.GetPhone(0).PhoneNumber.Value;// 速拨码
+Module_Employee.SubTel = stf.GetPhone(0).PhoneNumber.Value;// 分机
+
+string sPassword = stf.GetBackupPersonID(0).Identifier.Value;
+
+Module_Employee.Password = sPassword == null ? "" : sPassword;
+Module_Employee.PasswordTime = DateTime.Now; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+Module_Employee.PressCard = 0;// 工作卡号(暫時不填)
+
+
+string  sActiveInactiveFlag = stf.ActiveInactiveFlag.Value; // A,在职;I,离职
+Module_Employee.ResignDate = sActiveInactiveFlag == "A" ? His.Time.MaxDateTime : His.Time.MaxDateTime; 
+
+int iIntParse;
+int.TryParse(stf.PreferredMethodOfContact.Identifier.Value, out iIntParse);
+if (iIntParse != 0)
+{
+    Module_Employee.UpdateUser = Convert.ToInt16(iIntParse);// 最后修改人
+}
+
+Module_Employee.UpdateTime = DateTime.Now;
+
+Module_Employee.EMail = "";// 电子信箱(不同步)
+
+Module_Employee.Remark = "";// 备注说明(不同步)
+
+Module_Employee.Team = 0;// 组别
+
+#endregion
+
+#region 測試
+
+string sErrMsg;
+if (string.IsNullOrEmpty(Module_Employee.IdNo))
+{
+    sErrMsg = "【身份证】无法为空";
+    SetACK(m, "ACK", strMsgType, "ACK", sErrMsg);
+}
+
+if (string.IsNullOrEmpty(Module_Employee.HomeAdrDesc))
+{
+    Module_Employee.HomeAdrDesc = "";
+}
+
+if (string.IsNullOrEmpty(Module_Employee.HomeTel1))
+{
+    Module_Employee.HomeTel1 = "";
+}
+
+if (string.IsNullOrEmpty(Module_Employee.HomeTel1))
+{
+    Module_Employee.HomeTel1 = ""; // 住处电话1
+}
+
+if (string.IsNullOrEmpty(Module_Employee.MobilePhone))
+{
+    Module_Employee.MobilePhone = ""; // 移动电话1
+}
+
+if (string.IsNullOrEmpty(Module_Employee.MobilePhone))
+{
+    Module_Employee.MobilePhone = ""; // 移动电话1
+}
+
+
+//Module_Employee.HireDate = His.Time.TryParseExact(sHireDate, "yyyyMMdd"); // 到职日期
+//Module_Employee.Title = Convert.ToInt16(stf.JobCodeClass.JobCode.Value);// 职称
+
+//Module_Employee.ChiefNo = Convert.ToInt16(stf.GetHospitalService(0).Identifier.Value);// 职位
+
+if (string.IsNullOrEmpty(Module_Employee.MobilePhone))
+{
+    Module_Employee.SimpleTel = "";// 速拨码
+}
+
+if (string.IsNullOrEmpty(Module_Employee.MobilePhone))
+{
+    Module_Employee.SubTel = "";// 分机
+}
+
+if (string.IsNullOrEmpty(Module_Employee.Password))
+{
+    sErrMsg = "【密碼】无法为空";
+    SetACK(m, "ACK", strMsgType, "ACK", sErrMsg);
+}
+
+//if (Module_Employee.HireDate == DateTime.MinValue)
+//{
+//    Module_Employee.HireDate = His.Time.MaxDateTime;
+//}
+if (Module_Employee.PasswordTime == DateTime.MinValue)
+{
+    Module_Employee.PasswordTime = His.Time.MaxDateTime;
+}
+if (Module_Employee.UpdateTime == DateTime.MinValue)
+{
+    Module_Employee.UpdateTime = His.Time.MaxDateTime;
+}
+
+if (Module_Employee.ResignDate == DateTime.MinValue)
+{
+    Module_Employee.ResignDate = His.Time.MaxDateTime;
+}
+
+
+//Module_Employee.ResignDate = His.Time.TryParseExact(sResignDate, "yyyyMMdd"); // 离职日期
+#endregion
+
+
+// 開始存入資料庫
+int iEmpNo = Convert.ToInt16(stf.PrimaryKeyValueSTF.Identifier.Value);// 员工代号
+using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
+{
+    switch (strMsgType)
+    {
+        case Insert:
+        case Update:
+            EmployeeDelete(iEmpNo, ref HealthCareContainer, scope, ref Module_Employee);
+            EmployeeInsert(iEmpNo, ref HealthCareContainer, scope, ref Module_Employee);
+            break;
+        case Delete:
+            EmployeeDelete(iEmpNo, ref HealthCareContainer, scope, ref Module_Employee);
+            break;
+    }
+
+    #region 存入資料庫
+
+    try
+    {
+        HealthCareContainer.SaveChanges();
+    }
+    catch (System.Data.Entity.Validation.DbEntityValidationException ex)
+    {
+        scope.Dispose();
+        throw ex;
+    }
+    #endregion
+
+    scope.Complete();
+
+
+}
+*/
+//        return string.Empty;
+
+//    }
+//    catch (Exception ex)
+//    {
+//        string errMsg = string.Empty;
+//        if (ex.InnerException == null)
+//        {
+//            errMsg = ex.Message + "\r\n" + ex.StackTrace;
+//        }
+//        else
+//        {
+//            errMsg = ex.Message + "\r\n" + ex.InnerException.Message + "\r\n" + ex.InnerException.StackTrace;
+//        }
+//        return errMsg;
+//    }
+//}
+// catch (System.Data.Entity.Validation.DbEntityValidationException ex)
+//{
+//var tmp = ex.EntityValidationErrors.FirstOrDefault().ValidationErrors;
+//string errString = "";
+//foreach (var item in tmp)
+//{
+//    errString += item.ErrorMessage;
+//}
+//string ack = SetACK(m, "ACK", mType, "ACK", ex.EntityValidationErrors.ToString());
+//throw new Exception(string.Format("{0}\r\n{1}", ex.EntityValidationErrors.ToString()));
+
+//return ex.Message;
+//}
+//}
+
+
+/*
+
+public void EmployeeInsert(int iEmpNo, ref HealthCareContainer HealthCareContainer, TransactionScope scope, ref Employee Module_Employee)
+{
+    try
+    {
+        HealthCareContainer.Employee.Add(Module_Employee);
+
+    }
+    catch (Exception ex)
+    {
+        scope.Dispose();
+        throw ex;
+    }
+}
+
+public void EmployeeDelete(int iEmpNo, ref HealthCareContainer HealthCareContainer, TransactionScope scope, ref Employee Module_Employee)
+{
+    try
+    {
+        IEnumerable<Employee> EmployeeList = HealthCareContainer.Employee.Where(x => x.EmpNo == iEmpNo);
+        if (EmployeeList.Count() != 0)
+        {
+            Employee Module_Employee_Del = EmployeeList.FirstOrDefault();
+            HealthCareContainer.Employee.Remove(Module_Employee_Del);
+            HealthCareContainer.SaveChanges();
+        }
+
+    }
+    catch (Exception ex)
+    {
+        scope.Dispose();
+        throw ex;
+    }
+}
+*/
+// }
+//}
+#endregion

+ 102 - 0
IL.BizComponent/MediII.Adapter.BizComponent.PMU/MediII.Adapter.BizComponent.PMU.csproj

@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{B937B9E7-11DE-47BF-9D62-FEAD3DE51D0D}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.BizComponent.PMU</RootNamespace>
+    <AssemblyName>MediII.Adapter.BizComponent.PMU</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <DocumentationFile>
+    </DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Transactions" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BizComponent_PMU.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj">
+      <Project>{4e8c6d0e-e696-4f02-812f-cedd6fe3f6dc}</Project>
+      <Name>MediII.Adapter.Scan.Interface</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.BizComponent.Base\MediII.Adapter.BizComponent.Base.csproj">
+      <Project>{619b1dbf-55b7-446b-af40-852a6ab689a0}</Project>
+      <Name>MediII.Adapter.BizComponent.Base</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScan\UE\
+Copy $(TargetDir)   $(ProjectDir)..\..\MessageToScanServer\UE\</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
IL.BizComponent/MediII.Adapter.BizComponent.PMU/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.BizComponent.PMU")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MediII.Adapter.BizComponent.PMU")]
+[assembly: AssemblyCopyright("Copyright ©  2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("ff47b8b9-7d92-43ac-93a8-dcd10d1ff028")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 20 - 0
MediII.Adapter.MsgToScanServer/ApplictStatic.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace MediII.Adapter.MsgToScanServer
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class ApplictStatic
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public const string ServerName = "KC.HL7.MsgToScanServer";
+    }
+}

+ 100 - 0
MediII.Adapter.MsgToScanServer/MediII.Adapter.MsgToScanServer.csproj

@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{76458091-5802-4284-8861-5F96360119FF}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.MsgToScanServer</RootNamespace>
+    <AssemblyName>MediII.Adapter.MsgToScanServer</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <DocumentationFile>
+    </DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Configuration.Install" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Management" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.ServiceProcess" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ApplictStatic.cs" />
+    <Compile Include="MsgToScanServer.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="MsgToScanServer.Designer.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="ProjectInstaller.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="ProjectInstaller.Designer.cs">
+      <DependentUpon>ProjectInstaller.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ServiceStatusPublishManager.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="app.config">
+      <SubType>Designer</SubType>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj">
+      <Project>{4e8c6d0e-e696-4f02-812f-cedd6fe3f6dc}</Project>
+      <Name>MediII.Adapter.Scan.Interface</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.Scanner\MediII.Adapter.Scanner.csproj">
+      <Project>{0adddb14-b0f6-4d12-8025-5ec8124a511b}</Project>
+      <Name>MediII.Adapter.Scanner</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="ProjectInstaller.resx">
+      <DependentUpon>ProjectInstaller.cs</DependentUpon>
+    </EmbeddedResource>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>Copy $(TargetDir)   $(ProjectDir)..\MessageToScanServer\</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 37 - 0
MediII.Adapter.MsgToScanServer/MsgToScanServer.Designer.cs

@@ -0,0 +1,37 @@
+namespace MediII.Adapter.MsgToScanServer
+{
+    partial class MsgToScanServer
+    {
+        /// <summary> 
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region 组件设计器生成的代码
+
+        /// <summary> 
+        /// 设计器支持所需的方法 - 不要
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            components = new System.ComponentModel.Container();
+            this.ServiceName = "Service1";
+        }
+
+        #endregion
+    }
+}

+ 105 - 0
MediII.Adapter.MsgToScanServer/MsgToScanServer.cs

@@ -0,0 +1,105 @@
+using IL.Common;
+using MediII.Adapter.Scan.Interface;
+using MediII.Adapter.Scanner;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.IO.Pipes;
+using System.Linq;
+using System.ServiceProcess;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+
+namespace MediII.Adapter.MsgToScanServer
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public partial class MsgToScanServer : ServiceBase
+    {
+
+        private bool _addPool = false;//是否启动  
+        private Scaner scanner = new Scaner();
+        /// <summary>
+        /// 
+        /// </summary>
+        public MsgToScanServer()
+        {
+            InitializeComponent();
+
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="args"></param>
+        protected override void OnStart(string[] args)
+        {
+            sp_MessageLog(null,
+                new LogEventArgs()
+                {
+                    LogTime = DateTime.Now,
+                    LogModel = new LogModel() { Message = "服务启动" }
+                });
+
+            LogHelper.LogDebug("服务启动", LogCatagories.General);
+            LogHelper.LogInfo("服务启动", LogCatagories.General);
+            LogHelper.LogError("服务启动", LogCatagories.General);
+
+
+            LogHelper.LogDebug("服务启动", LogCatagories.Sock);
+            LogHelper.LogInfo("服务启动", LogCatagories.Sock);
+            LogHelper.LogError("服务启动", LogCatagories.Sock);
+
+            LogHelper.LogDebug("服务启动", LogCatagories.AdapterScan);
+            LogHelper.LogInfo("服务启动", LogCatagories.AdapterScan);
+            LogHelper.LogError("服务启动", LogCatagories.AdapterScan);
+
+            LogHelper.LogDebug("服务启动", LogCatagories.SQL);
+            LogHelper.LogInfo("服务启动", LogCatagories.SQL);
+            LogHelper.LogError("服务启动", LogCatagories.SQL);
+
+
+            System.Diagnostics.Debug.WriteLine("OnStart", ApplictStatic.ServerName);
+            //_running = true;
+            if (!_addPool)
+            {
+                ThreadPool.QueueUserWorkItem(DoTask);
+                _addPool = true;
+            }
+        }
+
+        private void DoTask(object state)
+        {
+            var args = new string[] { "UE" };
+            if (args.Length > 0)
+            {
+
+                string dllPath = System.IO.Path.Combine(Application.StartupPath, args[0]);
+                string path = Environment.GetEnvironmentVariable("path") + ";" + dllPath;
+                Environment.SetEnvironmentVariable("path", path);
+                scanner.Start(new string[] { dllPath }, sp_MessageLog);
+            }
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        protected override void OnStop()
+        {
+            sp_MessageLog(null, new LogEventArgs() { LogTime = DateTime.Now, LogModel = new LogModel() { Message = "服务停止" } });
+
+            scanner.Stop();
+            System.Threading.Thread.Sleep(10 * 1000);//暂时10秒再退出
+        }
+
+
+        void sp_MessageLog(object sender, LogEventArgs e)
+        {
+            ServiceStatusPublishManager.Instance.AppendMessage(e);
+        }
+    }
+
+
+}

+ 24 - 0
MediII.Adapter.MsgToScanServer/Program.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.ServiceProcess;
+using System.Text;
+
+namespace MediII.Adapter.MsgToScanServer
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        static void Main()
+        {
+            ServiceBase[] ServicesToRun;
+            ServicesToRun = new ServiceBase[] 
+            { 
+                new MsgToScanServer() 
+            };
+            ServiceBase.Run(ServicesToRun);
+        }
+    }
+}

+ 59 - 0
MediII.Adapter.MsgToScanServer/ProjectInstaller.Designer.cs

@@ -0,0 +1,59 @@
+namespace MediII.Adapter.MsgToScanServer
+{
+    partial class ProjectInstaller
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region 组件设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
+            this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
+            // 
+            // serviceProcessInstaller1
+            // 
+            this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
+            this.serviceProcessInstaller1.Password = null;
+            this.serviceProcessInstaller1.Username = null;
+            // 
+            // serviceInstaller1
+            // 
+            this.serviceInstaller1.Description = "康程HL7消息解析服务";
+            this.serviceInstaller1.DisplayName = "KC.HL7.MsgToScanServer";
+            this.serviceInstaller1.ServiceName = "KC.HL7.MsgToScanServer";
+            // 
+            // ProjectInstaller
+            // 
+            this.Installers.AddRange(new System.Configuration.Install.Installer[] {
+            this.serviceProcessInstaller1,
+            this.serviceInstaller1});
+
+        }
+
+        #endregion
+
+        private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
+        private System.ServiceProcess.ServiceInstaller serviceInstaller1;
+    }
+}

+ 24 - 0
MediII.Adapter.MsgToScanServer/ProjectInstaller.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Configuration.Install;
+using System.Linq;
+
+namespace MediII.Adapter.MsgToScanServer
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    [RunInstaller(true)]
+    public partial class ProjectInstaller : System.Configuration.Install.Installer
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public ProjectInstaller()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 129 - 0
MediII.Adapter.MsgToScanServer/ProjectInstaller.resx

@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>208, 17</value>
+  </metadata>
+  <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>False</value>
+  </metadata>
+</root>

+ 36 - 0
MediII.Adapter.MsgToScanServer/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.MsgToSIServer")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("MediII.Adapter.MsgToSIServer")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("8b78e209-53d5-48ff-add9-af57b4a0013c")]
+
+// 程序集的版本信息由下面四个值组成: 
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: 
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 149 - 0
MediII.Adapter.MsgToScanServer/ServiceStatusPublishManager.cs

@@ -0,0 +1,149 @@
+using IL.Common;
+using System;
+using System.Collections.Generic;
+using System.IO.Pipes;
+using System.Linq;
+using System.Text;
+using System.Threading;
+
+namespace MediII.Adapter.MsgToScanServer
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class ServiceStatusPublishManager
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        static public readonly ServiceStatusPublishManager Instance = new ServiceStatusPublishManager();
+
+        private const int MAX_LENGTH = 1000;
+        private const string PIPENAME = ApplictStatic.ServerName;
+        private List<LogEventArgs> _msgs;
+
+        private ManagerImple _managerImp;
+        /// <summary>
+        /// 
+        /// </summary>
+        protected ServiceStatusPublishManager()
+        {
+            _managerImp = new ManagerImple(this);
+            _msgs = new List<LogEventArgs>();
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="msg"></param>
+        public void AppendMessage(LogEventArgs msg)
+        {
+            lock (this) _msgs.Add(msg);
+
+            if (_msgs.Count > MAX_LENGTH)
+            {
+                lock (this)
+                {
+                    _msgs.RemoveAt(0);
+                    //if (_managerImp._msgIndex == _msgs.Count) _managerImp._msgIndex -= 2;
+                }
+            }
+        }
+
+
+
+        public LogEventArgs GetMessage()
+        {
+            lock (this)
+            {
+                if (_msgs.Count <= 0)
+                    return null;
+                var data = _msgs[_msgs.Count - 1];
+                _msgs.Remove(data);
+                return data;
+            }
+        }
+
+        class ManagerImple
+        {
+            private ServiceStatusPublishManager _trace;
+
+            private Thread _thread;
+
+            public ManagerImple(ServiceStatusPublishManager trace)
+            {
+                _trace = trace;
+                _thread = new Thread(WriteServiceStatus);
+                _thread.Start();
+            }
+
+            //public int _msgIndex = 0;
+
+            private void WriteServiceStatus(object stats)
+            {
+                while (true)
+                {
+                    try
+                    {
+                        using (var serverStream = new NamedPipeServerStream(PIPENAME, PipeDirection.InOut, 10, PipeTransmissionMode.Message))
+                        {
+                            serverStream.WaitForConnection();
+
+                            while (serverStream.IsConnected)
+                            {
+                                System.Diagnostics.Debug.WriteLine("serverStream.IsConnected", ApplictStatic.ServerName);
+
+                                bool writeSomeMessage = false;
+                                LogEventArgs logData = null;
+                                while ((logData = _trace.GetMessage()) != null)
+                                {
+                                    var msg = string.Format("时间:{0}  是否成功:{1} 消息ID:{2} 消息内容:{3}  ", logData.LogTime, string.IsNullOrEmpty(logData.LogModel.ErrorMsg),  logData.LogModel.MessageID,
+                                     logData.LogModel.Message);
+                                    if (!string.IsNullOrEmpty(logData.LogModel.ErrorMsg))
+                                    {
+                                        msg += " 错误消息:"+logData.LogModel.ErrorMsg;
+                                    }
+                                    byte[] bytes = Encoding.UTF8.GetBytes(msg);
+                                    serverStream.Write(bytes, 0, bytes.Length);
+                                    serverStream.Flush(); 
+                                    writeSomeMessage = true;
+                                    Thread.Sleep(100);
+                                }
+
+
+
+                                //while (_msgIndex < _trace._msgs.Count)
+                                //{
+                                //    var logData = _trace._msgs[_msgIndex];
+                                //    var msg = string.Format("时间:{0}  是否成功:{1} 消息ID:{2} 消息内容:{3} 错误信息:{4} ", logData.LogTime, string.IsNullOrEmpty(logData.LogModel.ErrorMsg), logData.LogModel.MessageID,
+                                //        logData.LogModel.Message, logData.LogModel.ErrorMsg);
+                                //    byte[] bytes = Encoding.UTF8.GetBytes(msg);
+                                //    serverStream.Write(bytes, 0, bytes.Length);
+                                //    serverStream.Flush();
+                                //    _msgIndex++;
+                                //    writeSomeMessage = true;
+                                //}
+
+                                if (!writeSomeMessage)
+                                {
+                                    byte[] bytes = Encoding.UTF8.GetBytes("无消息输出");
+                                    serverStream.Write(bytes, 0, bytes.Length);
+                                    serverStream.Flush();
+                                    Thread.Sleep(1000 * 10);
+                                }
+                                Thread.Sleep(1000);
+                            }
+
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        System.Diagnostics.Debug.WriteLine(ex.ToString(), ApplictStatic.ServerName);
+                    }
+                }
+
+            }
+        }
+    }
+}

+ 97 - 0
MediII.Adapter.MsgToScanServer/app.config

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <configSections>
+    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
+    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
+  </configSections>
+  <!--日志配置-->
+  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
+    <listeners>
+      <add name="GeneralListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        fileName="General\rolling.log" formatter="Text Formatter" rollFileExistsBehavior="Increment"
+        rollInterval="Day" maxArchivedFiles="0" traceOutputOptions="None" />
+      <add name="SockListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        fileName="Sock\rolling.log" formatter="Text Formatter" rollInterval="Day" />
+      <add name="ScanListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        fileName="Scan\rolling.log" formatter="Text Formatter" rollInterval="Day" />
+      <add name="SqlListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        fileName="SQL\logSql.log" formatter="Text Formatter" rollInterval="Day" />
+    </listeners>
+    <formatters>
+      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
+        template="Timestamp: {timestamp}{newline}&#xA;Message: {message}"
+        name="Text Formatter" />
+    </formatters>
+    <categorySources>
+      <add switchValue="All" name="General">
+        <listeners>
+          <add name="GeneralListener" />
+        </listeners>
+      </add>
+      <add switchValue="All" name="Sock">
+        <listeners>
+          <add name="SockListener" />
+        </listeners>
+      </add>
+      <add switchValue="All" name="AdapterScan">
+        <listeners>
+          <add name="ScanListener" />
+        </listeners>
+      </add>
+      <add switchValue="All" name="SQL">
+        <listeners>
+          <add name="SqlListener" />
+        </listeners>
+      </add>
+    </categorySources>
+    <specialSources>
+      <allEvents switchValue="All" name="All Events" />
+      <notProcessed switchValue="All" name="Unprocessed Category" />
+      <errors switchValue="All" name="Logging Errors &amp; Warnings" />
+    </specialSources>
+  </loggingConfiguration>
+  <dataConfiguration defaultDatabase="DefaultDB" />
+  <connectionStrings>
+    <add name="DefaultDB" connectionString="Data Source=192.168.1.26;
+                       Initial Catalog=HL7_Platform;
+                       Persist Security Info=True;
+                       Integrated Security=False;
+                       User ID=sa;Password=sa26" providerName="System.Data.SqlClient"/>
+
+    <add name="HealthCare" connectionString="Data Source=192.168.1.26;
+                       Initial Catalog=HealthCare;
+                       Persist Security Info=True;
+                       Integrated Security=False;
+                       User ID=sa;Password=sa26" providerName="System.Data.SqlClient"/>
+
+
+  </connectionStrings>
+  <appSettings>
+    <!--测试-->
+    <!--正式-->
+    <add key="MediIIAddress" value="192.9.216.206" />
+    <add key="MediIIPort" value="31001" />
+    <add key="BufferSize" value="4048" />
+    <add key="ReviceTimeOut" value="30000" />
+    <add key="ErrorRepeatCount" value="1" />
+    <add key="ErrorSleepMSecodes" value="3000" />
+    <!--<add key="SedingApplication" value="UEHIS" />-->
+    <add key="HosiptalName" value=""/>
+
+    <add key="AddMinues" value="30"/>
+    <add key="BranchID" value=""/>
+    <!--查询数量-->
+    <add key="SearchNum" value="50"/>
+
+    <!--任务解锁时间  单位分钟-->
+    <add key="TaskRunTime" value="5"/>
+
+
+    <!--启动SQL日志-->
+    <add key="LogSql" value="1"/>
+  </appSettings>
+</configuration>

+ 13 - 0
MediII.Adapter.ReceiveToScanModel/BaseEntity.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MediII.Adapter.ReceiveToScanModel
+{
+    [Serializable]
+    public abstract class BaseEntity
+    {
+    }
+}

+ 46 - 0
MediII.Adapter.ReceiveToScanModel/HL7_MessageSetEntity.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+
+
+namespace MediII.Adapter.ReceiveToScanModel
+{ 
+
+
+	[Serializable]
+	public partial class HL7_MessageSetEntity:BaseEntity
+	{
+
+			/// <summary> 
+			///  消息ID
+			/// </summary>
+			public string  MessageId { get; set; } 
+
+			/// <summary> 
+			///  消息类型 1扫描 2接收
+			/// </summary>
+			public int  MessageType { get; set; } 
+
+			/// <summary> 
+			///  执行时间
+			/// </summary>
+			public DateTime?  ExecuteTime { get; set; } 
+
+			/// <summary> 
+			///  间隔时间
+			/// </summary>
+			public int?  IntervalTime { get; set; } 
+
+			/// <summary> 
+			///  
+			/// </summary>
+			public int?  IsDel { get; set; } 
+
+			/// <summary> 
+			///  备注
+			/// </summary>
+			public string  Remark { get; set; } 
+	}
+}
+//MessageId,MessageType,ExecuteTime,IntervalTime,IsDel,Remark,

+ 107 - 0
MediII.Adapter.ReceiveToScanModel/HL7_ReceiveEntity.cs

@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+
+
+namespace MediII.Adapter.ReceiveToScanModel
+{
+
+
+    [Serializable]
+    public partial class HL7_ReceiveEntity : BaseEntity
+    {
+
+        /// <summary> 
+        ///  主键Guid
+        /// </summary>
+        public string ID { get; set; }
+
+        /// <summary> 
+        ///  顺序 自增长
+        /// </summary>
+        public int SeqNo { get; set; }
+
+        /// <summary> 
+        ///  发送系统ID
+        /// </summary>
+        public string SourceID { get; set; }
+
+        /// <summary> 
+        ///  消息唯一主键
+        /// </summary>
+        public string MsgConID { get; set; }
+
+        /// <summary> 
+        ///  消息内容
+        /// </summary>
+        public string MsgContent { get; set; }
+
+        /// <summary> 
+        ///  回复消息
+        /// </summary>
+        public string ReplyMsg { get; set; }
+
+        /// <summary> 
+        ///  接收时间
+        /// </summary>
+        public DateTime ReceivingTime { get; set; }
+
+        /// <summary> 
+        ///  发送IP
+        /// </summary>
+        public string IP { get; set; }
+
+        /// <summary> 
+        ///  任务处理状态 1未处理 2 处理中 
+        /// </summary>
+        public int? TaskStatus { get; set; }
+
+        /// <summary> 
+        ///  处理开始时间
+        /// </summary>
+        public DateTime? StartTime { get; set; }
+
+        /// <summary> 
+        ///  处理结束时间
+        /// </summary>
+        public DateTime? EndTime { get; set; }
+
+        /// <summary> 
+        ///  处理任务机器IP
+        /// </summary>
+        public string TaskIP { get; set; }
+
+        /// <summary> 
+        ///  处理任务机器MAC
+        /// </summary>
+        public string TaskMac { get; set; }
+
+        /// <summary> 
+        ///  处理错误信息
+        /// </summary>
+        public string TaskMsg { get; set; }
+
+        /// <summary> 
+        ///  
+        /// </summary>
+        public string MessageID { get; set; }
+
+        /// <summary> 
+        ///  
+        /// </summary>
+        public string MessageType { get; set; }
+
+        /// <summary> 
+        ///  备注
+        /// </summary>
+        public string Remark { get; set; }
+
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        public int Sequeue { get; set; }
+    }
+}
+//ID,SeqNo,SourceID,MsgConID,MsgContent,ReplyMsg,ReceivingTime,IP,TaskStatus,StartTime,EndTime,TaskIP,TaskMac,TaskMsg,MessageID,MessageType,Remark,

+ 126 - 0
MediII.Adapter.ReceiveToScanModel/HL7_ScanEntity.cs

@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+
+
+namespace MediII.Adapter.ReceiveToScanModel
+{ 
+
+
+	[Serializable]
+	public partial class HL7_ScanEntity:BaseEntity
+	{
+
+			/// <summary> 
+			///  主键Guid
+			/// </summary>
+			public string  ID { get; set; } 
+
+			/// <summary> 
+			///  流水号 自增长
+			/// </summary>
+			public int  SeqNo { get; set; } 
+
+			/// <summary> 
+			///  病历号
+			/// </summary>
+			public string  ChartNo { get; set; } 
+
+			/// <summary> 
+			///  就诊ID
+			/// </summary>
+			public string  VisitNo { get; set; } 
+
+			/// <summary> 
+			///  业务表主键1
+			/// </summary>
+			public string  OtherNo1 { get; set; } 
+
+			/// <summary> 
+			///  业务表主键2
+			/// </summary>
+			public string  OtherNo2 { get; set; } 
+
+			/// <summary> 
+			///  业务表主键3
+			/// </summary>
+			public string  OtherNo3 { get; set; } 
+
+			/// <summary> 
+			///  业务表名称
+			/// </summary>
+			public string  OtherName { get; set; } 
+
+			/// <summary> 
+			///  任务类型,由HL7定义
+			/// </summary>
+			public string  TaskType { get; set; } 
+
+			/// <summary> 
+			///  任务状态 1未处理 2 处理中 3失
+			/// </summary>
+			public int?  TaskStatus { get; set; } 
+
+			/// <summary> 
+			///  更新人
+			/// </summary>
+			public string  UpdateUser { get; set; } 
+
+			/// <summary> 
+			///  更新时间
+			/// </summary>
+			public DateTime?  UpdateTime { get; set; } 
+
+			/// <summary> 
+			///  保留字段1
+			/// </summary>
+			public string  Reserve1 { get; set; } 
+
+			/// <summary> 
+			///  保留字段2
+			/// </summary>
+			public string  Reserve2 { get; set; } 
+
+			/// <summary> 
+			///  保留字段3
+			/// </summary>
+			public string  Reserve3 { get; set; } 
+
+			/// <summary> 
+			///  操作任务机器IP      操作任
+			/// </summary>
+			public string  IP { get; set; } 
+
+			/// <summary> 
+			///  操作任务机器MAC   
+			/// </summary>
+			public string  MAC { get; set; } 
+
+			/// <summary> 
+			///  任务开始时间
+			/// </summary>
+			public DateTime?  BeginTime { get; set; } 
+
+			/// <summary> 
+			///  任务结束时间
+			/// </summary>
+			public DateTime?  EndTime { get; set; } 
+
+			/// <summary> 
+			///  任务结果
+			/// </summary>
+			public int?  Result { get; set; } 
+
+			/// <summary> 
+			///  任务失败原因
+			/// </summary>
+			public string  TaskMsg { get; set; } 
+
+			/// <summary> 
+			///  结果返回时间
+			/// </summary>
+			public DateTime?  ResultTime { get; set; } 
+	}
+}
+//ID,SeqNo,ChartNo,VisitNo,OtherNo1,OtherNo2,OtherNo3,OtherName,TaskType,TaskStatus,UpdateUser,UpdateTime,Reserve1,Reserve2,Reserve3,IP,MAC,BeginTime,EndTime,Result,TaskMsg,ResultTime,

+ 66 - 0
MediII.Adapter.ReceiveToScanModel/HL7_SendMessageEntity.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+
+
+namespace MediII.Adapter.ReceiveToScanModel
+{ 
+
+
+	[Serializable]
+	public partial class HL7_SendMessageEntity:BaseEntity
+	{
+
+			/// <summary> 
+			///  主键
+			/// </summary>
+			public string  ID { get; set; } 
+
+			/// <summary> 
+			///  HL7_Scan主键
+			/// </summary>
+			public string  ScanID { get; set; } 
+
+			/// <summary> 
+			///  顺序 自增长
+			/// </summary>
+			public int  SeqNo { get; set; } 
+
+			/// <summary> 
+			///  消息类型
+			/// </summary>
+			public string  MessageType { get; set; } 
+
+			/// <summary> 
+			///  消息内容
+			/// </summary>
+			public string  MsgContent { get; set; } 
+
+			/// <summary> 
+			///  发送时间
+			/// </summary>
+			public DateTime?  SendTime { get; set; } 
+
+			/// <summary> 
+			///  重复次数
+			/// </summary>
+			public int?  RepeatTimes { get; set; } 
+
+			/// <summary> 
+			///  回复内容
+			/// </summary>
+			public string  ReplyContent { get; set; } 
+
+			/// <summary> 
+			///  回复时间
+			/// </summary>
+			public DateTime?  ReplyTime { get; set; } 
+
+			/// <summary> 
+			///  处理标志 
+			/// </summary>
+			public int?  TaskStatus { get; set; } 
+	}
+}
+//ID,ScanID,SeqNo,MessageType,MsgContent,SendTime,RepeatTimes,ReplyContent,ReplyTime,TaskStatus,

+ 58 - 0
MediII.Adapter.ReceiveToScanModel/MediII.Adapter.ReceiveToScanModel.csproj

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{F182AC2B-A0D5-40D2-89AF-8D547606B6AC}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.ReceiveToScanModel</RootNamespace>
+    <AssemblyName>MediII.Adapter.ReceiveToScanModel</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="BaseEntity.cs" />
+    <Compile Include="HL7_MessageSetEntity.cs" />
+    <Compile Include="HL7_ReceiveEntity.cs" />
+    <Compile Include="HL7_ScanEntity.cs" />
+    <Compile Include="HL7_SendMessageEntity.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
MediII.Adapter.ReceiveToScanModel/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.ReceiveToScanModel")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("MediII.Adapter.ReceiveToSIModel")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。  如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("6ff93c25-5666-4619-a817-7bb0ecc44d98")]
+
+// 程序集的版本信息由下面四个值组成: 
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: 
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 23 - 0
MediII.Adapter.Scan.UE/DebugScanner.cs

@@ -0,0 +1,23 @@
+using System.Collections.Generic;
+using MediII.Adapter.ReceiveToScanModel;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    public class DebugScanner : DefaultDBScanner
+    {
+        protected override string GetMessageType()
+        {
+            return string.Empty;
+        }
+
+        /// <summary>
+        /// 调试消息并更新表"HL7_Receive"
+        /// </summary>
+        /// <param name="entity"></param>
+        public void DebugMsg(HL7_ReceiveEntity entity)
+        {
+            var list = new List<HL7_ReceiveEntity> { entity };
+            base.DebugMsg(list);
+        }
+    }
+}

+ 207 - 0
MediII.Adapter.Scan.UE/DefaultDBScanner.cs

@@ -0,0 +1,207 @@
+using MediII.Adapter.ReceiveToScanModel;
+using MediII.Adapter.Scanner;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using MediII.Adapter.BizComponent.Base;
+using System.Data;
+using System.Diagnostics;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    public abstract class DefaultDBScanner : DBScaner
+    {
+        private int SearchNum
+        {
+            get
+            {
+                var searchNum = System.Configuration.ConfigurationManager.AppSettings["SearchNum"];
+                int num = 0;
+                if (!int.TryParse(searchNum, out num))
+                {
+                    num = 10;
+                }
+                return num;
+            }
+        }
+
+
+
+        protected override long OnDo(DateTime dtEventTime, Action<LogModel> setLog)
+        {
+
+            Stopwatch stopwatch = new Stopwatch();
+
+
+            var type = GetMessageType();
+            stopwatch.Start();
+            try
+            {
+
+                if (setLog != null)
+                    setLog(new LogModel { Message = "开始一次消息处理扫描 消息类型:" + type });
+                 
+                if (type == "MFN") //字典消息大于20个.一直解析
+                {
+                    RunExec(type, setLog); //执行一次
+
+                    int num = 20;
+                    while (true)
+                    { 
+                        var sql = @"SELECT top {0} ID FROM dbo.HL7_Receive WITH(NOLOCK)  WHERE TaskStatus='1' and MessageID='MFN'";
+                        sql = string.Format(sql, num);
+                        var cmd = ctx.DBGetSqlStringCommand(sql);
+                        var dt = new DataTable();
+                        var dr = ctx.DBExecuteReader(cmd);
+                        dt.Load(dr);
+                        if (dt.Rows.Count >= num)
+                        {
+                            RunExec(type, setLog);
+                        }
+                        else
+                        {
+                            break;
+                        }  
+                    } 
+                }
+                else
+                {
+                    RunExec(type, setLog);
+                } 
+            }
+            finally
+            {
+                stopwatch.Stop();
+
+                //LogHelper.LogError(string.Format("{0}耗时{1}-->{2}", type, stopwatch.Elapsed, stopwatch.ElapsedTicks), LogCatagories.AdapterScan);
+            }
+
+            return 1;
+        }
+
+        private void RunExec(string type, Action<LogModel> setLog)
+        {
+            var num = SearchNum;
+            var orderSeq = string.Empty;
+            if (type == "MFN")
+            {
+                orderSeq = " Sequeue ASC,";
+            }
+
+            var sql = @"SELECT top {0} ID , SeqNo , SourceID ,MsgConID ,  MsgContent ,ReplyMsg ,   ReceivingTime ,       IP ,TaskStatus ,StartTime ,EndTime ,TaskIP , TaskMac ,TaskMsg ,MessageID ,MessageType ,Remark ,Sequeue  FROM dbo.HL7_Receive WITH(NOLOCK)  WHERE TaskStatus='1' and MessageID='{1}' ORDER BY {2} SeqNo ASC ";
+            sql = string.Format(sql, num, type, orderSeq);
+            try
+            {
+                var listRow = SqlDataAccess.ExecuteSqlStringAccessor<HL7_ReceiveEntity>(ctx, sql).Take(num).ToList();
+                if (listRow.Count() > 0)
+                {
+                    Process(listRow, setLog);
+                }
+            }
+            catch (Exception ex)
+            {
+                LogHelper.LogError(ex, LogCatagories.AdapterScan);
+                throw ex;
+            }
+        }
+
+        private void Process(IEnumerable<HL7_ReceiveEntity> listRow, Action<LogModel> setLog)
+        {
+            listRow.ToList().ForEach(o =>
+            {
+
+                //验证
+                var model = GetListRow(o.ID);
+                if (null != model)
+                {
+                    try
+                    {
+                        if (setLog != null)
+                            setLog(new LogModel { Message = o.MsgContent, MessageID = o.MessageID });
+
+
+                        SetStartBiz(o.ID);
+                        string mesStruct = o.MessageID;
+
+                        var behavior = BizComponentFactory.GetBizComponent(mesStruct);
+                        var errMsg = behavior.Process(o.MsgContent,o.MessageType);
+                        SetEndBiz(o.ID, errMsg);
+
+                    }
+                    catch (Exception ex)
+                    {
+                        if (setLog != null)
+                            setLog(new LogModel { Message = o.MsgContent, MessageID = o.MessageID, ErrorMsg = "消息处理错误 :" + ex.Message });
+                        SetEndBiz(o.ID, ex.Message);
+                    }
+
+                }
+            });
+        }
+
+
+        /// <summary>
+        /// 获取消息类型
+        /// </summary>
+        /// <returns></returns>
+        protected abstract string GetMessageType();
+
+
+
+        /// <summary>
+        /// 获取当前记录
+        /// </summary>
+        /// <param name="id">id</param>
+        /// <returns></returns>
+        protected HL7_ReceiveEntity GetListRow(string id)
+        {
+            var sql = "SELECT *  FROM dbo.HL7_Receive  WHERE TaskStatus='1' and   StartTime is null and ID='" + id + "'";
+            var model = SqlDataAccess.ExecuteSqlStringAccessor<HL7_ReceiveEntity>(ctx, sql).Take(1).FirstOrDefault();
+            return model;
+
+        }
+
+
+        //开始时间
+        protected int SetStartBiz(string id)
+        {
+            var sql = "UPDATE dbo.HL7_Receive SET StartTime=GETDATE() , TaskStatus='2',TaskIP=@TaskIP,TaskMac=@TaskMac WHERE  ID=@ID";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ID", DbType.String, id);
+            SqlDataAccess.AddInParameter(ctx, cmd, "TaskIP", DbType.String, NetHelper.GetIP());
+            SqlDataAccess.AddInParameter(ctx, cmd, "TaskMac", DbType.String, NetHelper.GetMacAddress());
+            return SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+        }
+
+
+        //结束时间
+        protected int SetEndBiz(string id, string errMsg)
+        {
+            var sql = "UPDATE dbo.HL7_Receive SET EndTime=GETDATE(),TaskStatus=@TaskStatus,TaskMsg=@TaskMsg WHERE  ID=@ID";
+            var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+            SqlDataAccess.AddInParameter(ctx, cmd, "ID", DbType.String, id);
+            if (!string.IsNullOrEmpty(errMsg))
+            {
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskMsg", DbType.String, errMsg);
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskStatus", DbType.Int32, 3);
+            }
+            else
+            {
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskMsg", DbType.String, DBNull.Value);
+                SqlDataAccess.AddInParameter(ctx, cmd, "TaskStatus", DbType.Int32, 4);
+            }
+
+            return SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+        }
+
+        public void DebugMsg(IEnumerable<HL7_ReceiveEntity> list)
+        {
+            Process(list, null);
+        }
+
+    }
+}

+ 23 - 0
MediII.Adapter.Scan.UE/HL7_ADT_Scanner.cs

@@ -0,0 +1,23 @@
+
+using MediII.Adapter.Scanner;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using MediII.Adapter.BizComponent.Base;
+using IL.Common;
+using MediII.Adapter.ReceiveToScanModel;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    public class HL7_ADT_Scanner : DefaultDBScanner
+    {
+        protected override string GetMessageType()
+        {
+            return "ADT";
+        }
+    }
+}

+ 84 - 0
MediII.Adapter.Scan.UE/HL7_Lock_Scanner.cs

@@ -0,0 +1,84 @@
+using MediII.Adapter.ReceiveToScanModel;
+using MediII.Adapter.Scanner;
+using System;
+using System.Configuration;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Data;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    public class HL7_Lock_Scanner : DBScaner
+    {
+
+        private int TaskRunTime = 5;
+
+        public HL7_Lock_Scanner()
+        {
+
+            var tm = ConfigurationManager.AppSettings["TaskRunTime"];
+            if (!int.TryParse(tm, out TaskRunTime))
+            {
+                TaskRunTime = 5;
+            }
+
+        }
+
+
+        protected override long OnDo(DateTime dtEventTime, Action<LogModel> setLog)
+        {
+            if (setLog != null)
+                setLog(new LogModel { Message = "开始一次解锁消息处理扫描 " });
+            var sql = string.Format(" SELECT * FROM dbo.HL7_Receive WHERE TaskStatus=2 AND StartTime<DATEADD(mi,-{0},getdate())   ", TaskRunTime);//操作中数据
+            try
+            {
+                var listRow = SqlDataAccess.ExecuteSqlStringAccessor<HL7_ReceiveEntity>(ctx, sql).Take(100).ToList();
+                if (listRow.Count() > 0)
+                {
+                    process(listRow, setLog);
+
+                }
+            }
+            catch (Exception ex)
+            {
+                if (setLog != null)
+                    setLog(new LogModel { Message = "解锁消息发生错误", ErrorMsg = ex.Message + "\r\n" + ex.StackTrace });
+            }
+            return 1;
+        }
+
+
+        private void process(IEnumerable<HL7_ReceiveEntity> listRow, Action<LogModel> setLog)
+        {
+            listRow.ToList().ForEach(o =>
+            {
+                try
+                {
+                    if (setLog != null)
+                        setLog(new LogModel { Message = "解锁消息:"+o.MsgContent, MessageID = o.MessageID });
+
+                    var sql = "UPDATE dbo.HL7_Receive SET TaskStatus=1,StartTime=NULL,TaskIP=NULL,TaskMsg = null, TaskMac=NULL WHERE ID=@ID";
+                    var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+                    SqlDataAccess.AddInParameter(ctx, cmd, "ID", DbType.String, o.ID);
+                    SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+                }
+                catch (Exception ex)
+                {
+                    if (setLog != null)
+                        setLog(new LogModel
+                        {
+                            Message = string.Format("解锁消息发生错误:HL7ReceiveID:{0}", o.ID),
+                            ErrorMsg = ex.Message + "\r\n" + ex.StackTrace
+                        });
+                }
+
+            });
+        }
+
+
+
+    }
+}

+ 23 - 0
MediII.Adapter.Scan.UE/HL7_MFN_Scanner.cs

@@ -0,0 +1,23 @@
+
+using MediII.Adapter.Scanner;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using MediII.Adapter.BizComponent.Base;
+using IL.Common;
+using MediII.Adapter.ReceiveToScanModel;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    class HL7_MFN_Scanner : DefaultDBScanner
+    { 
+        protected override string GetMessageType()
+        {
+            return "MFN";
+        } 
+    }
+}

+ 24 - 0
MediII.Adapter.Scan.UE/HL7_PMU_Scanner.cs

@@ -0,0 +1,24 @@
+
+using MediII.Adapter.Scanner;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Transactions;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using MediII.Adapter.BizComponent.Base;
+using IL.Common;
+using MediII.Adapter.ReceiveToScanModel;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    class HL7_PMU_Scanner : DefaultDBScanner
+    {
+        protected override string GetMessageType()
+        {
+            return "PMU";
+        } 
+         
+    }
+}

+ 85 - 0
MediII.Adapter.Scan.UE/HL7_ReceiveEntity.cs

@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+
+
+namespace MediII.Adapter.BizComponent.UE
+{
+
+
+    [Serializable]
+    public partial class HL7_ReceiveEntity
+    {
+
+        /// <summary> 
+        ///  主键Guid
+        /// </summary>
+        public string ID { get; set; }
+
+        /// <summary> 
+        ///  顺序 自增长
+        /// </summary>
+        public int SeqNo { get; set; }
+
+        /// <summary> 
+        ///  发送系统ID
+        /// </summary>
+        public string SourceID { get; set; }
+
+        /// <summary> 
+        ///  消息唯一主键
+        /// </summary>
+        public string MsgConID { get; set; }
+
+        /// <summary> 
+        ///  消息内容
+        /// </summary>
+        public string MsgContent { get; set; }
+
+        /// <summary> 
+        ///  回复消息
+        /// </summary>
+        public string ReplyMsg { get; set; }
+
+        /// <summary> 
+        ///  接收时间
+        /// </summary>
+        public DateTime ReceivingTime { get; set; }
+
+        /// <summary> 
+        ///  发送IP
+        /// </summary>
+        public string IP { get; set; }
+
+        /// <summary> 
+        ///  任务处理状态 1未处理 2 处理中 
+        /// </summary>
+        public int? TaskStatus { get; set; }
+
+        /// <summary> 
+        ///  处理开始时间
+        /// </summary>
+        public DateTime? StartTime { get; set; }
+
+        /// <summary> 
+        ///  处理结束时间
+        /// </summary>
+        public DateTime? EndTime { get; set; }
+
+        /// <summary> 
+        ///  处理任务机器IP
+        /// </summary>
+        public string TaskIP { get; set; }
+
+        /// <summary> 
+        ///  处理任务机器MAC
+        /// </summary>
+        public string TaskMac { get; set; }
+
+        /// <summary> 
+        ///  处理错误信息
+        /// </summary>
+        public string TaskMsg { get; set; }
+    }
+}

+ 94 - 0
MediII.Adapter.Scan.UE/HL7_TimeOut_Scanner.cs

@@ -0,0 +1,94 @@
+using MediII.Adapter.ReceiveToScanModel;
+using MediII.Adapter.Scanner;
+using System;
+using System.Configuration;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Data;
+using IL.Common;
+
+namespace MediII.Adapter.BizComponent.UE
+{
+    public class HL7_TimeOut_Scanner : DBScaner
+    {
+
+        private int TaskRunTime = 5;
+
+        public HL7_TimeOut_Scanner()
+        {
+
+            var tm = ConfigurationManager.AppSettings["TaskRunTime"];
+            if (!int.TryParse(tm, out TaskRunTime))
+            {
+                TaskRunTime = 5;
+            }
+
+        }
+
+
+        protected override long OnDo(DateTime dtEventTime, Action<LogModel> setLog)
+        {
+            if (setLog != null)
+                setLog(new LogModel { Message = "开始一次数据库错误消息处理扫描 " });
+            var sql = @" 
+                        SELECT *   
+                        FROM    HL7_Platform.dbo.HL7_Receive with(nolock)
+                        WHERE   1 = 1 
+                                AND ( TaskMsg LIKE '%Timeout 时间已到。%'
+                                        OR TaskMsg LIKE '%此操作对该事务的状态无效%'
+                                        OR TaskMsg LIKE '%请重新运行该事务。%' )
+                                AND (ErrNum<4 or ErrNum is null) 
+                                AND TaskStatus = 3
+                                AND ReceivingTime > DATEADD(dy,-{0},getdate()) 
+                        ORDER BY SeqNo DESC  ";
+            sql = string.Format(sql, TaskRunTime);//操作中数据
+            try
+            {
+                var listRow = SqlDataAccess.ExecuteSqlStringAccessor<HL7_ReceiveEntity>(ctx, sql).Take(100).ToList();
+                if (listRow.Any())
+                {
+                    process(listRow, setLog); 
+                }
+            }
+            catch (Exception ex)
+            {
+                if (setLog != null)
+                    setLog(new LogModel { Message = "重置数据库错误消息发生错误", ErrorMsg ="sql:"+ sql+"\r\n"+ ex.Message + "\r\n" + ex.StackTrace });
+            }
+            return 1;
+        }
+
+
+        private void process(IEnumerable<HL7_ReceiveEntity> listRow, Action<LogModel> setLog)
+        {
+            listRow.ToList().ForEach(o =>
+            {
+                try
+                {
+                    if (setLog != null)
+                        setLog(new LogModel { Message = "重置数据库错误消息:" + o.MsgContent, MessageID = o.MessageID });
+
+                    var sql = "UPDATE dbo.HL7_Receive SET TaskStatus=1,StartTime=NULL,TaskIP=NULL,TaskMsg = null, TaskMac=NULL,ErrNum=ISNULL(ErrNum,0)+1 WHERE ID=@ID";
+                    var cmd = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+                    SqlDataAccess.AddInParameter(ctx, cmd, "ID", DbType.String, o.ID);
+                    SqlDataAccess.ExecuteNonQuery(ctx, cmd);
+                }
+                catch (Exception ex)
+                {
+                    if (setLog != null)
+                        setLog(new LogModel
+                        {
+                            Message = string.Format("重置数据库错误消息发生错误:HL7ReceiveID:{0}", o.ID),
+                            ErrorMsg = ex.Message + "\r\n" + ex.StackTrace
+                        });
+                }
+
+            });
+        }
+
+
+
+    }
+}

+ 114 - 0
MediII.Adapter.Scan.UE/MediII.Adapter.BizComponent.UE.csproj

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{0786BB9F-0092-44A2-9CA0-263F5A0AA86E}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.BizComponent.UE</RootNamespace>
+    <AssemblyName>MediII.Adapter.BizComponent.UE</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DocumentationFile>
+    </DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Transactions" />
+    <Reference Include="System.XML" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="DebugScanner.cs" />
+    <Compile Include="DefaultDBScanner.cs" />
+    <Compile Include="HL7_MFN_Scanner.cs" />
+    <Compile Include="HL7_PMU_Scanner.cs" />
+    <Compile Include="HL7_ADT_Scanner.cs" />
+    <Compile Include="HL7_Lock_Scanner.cs" />
+    <Compile Include="HL7_TimeOut_Scanner.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj">
+      <Project>{4e8c6d0e-e696-4f02-812f-cedd6fe3f6dc}</Project>
+      <Name>MediII.Adapter.Scan.Interface</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\IL.BizComponent\MediII.Adapter.BizComponent.Base\MediII.Adapter.BizComponent.Base.csproj">
+      <Project>{619b1dbf-55b7-446b-af40-852a6ab689a0}</Project>
+      <Name>MediII.Adapter.BizComponent.Base</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.ReceiveToScanModel\MediII.Adapter.ReceiveToScanModel.csproj">
+      <Project>{f182ac2b-a0d5-40d2-89af-8d547606b6ac}</Project>
+      <Name>MediII.Adapter.ReceiveToSIModel</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.Scanner\MediII.Adapter.Scanner.csproj">
+      <Project>{0adddb14-b0f6-4d12-8025-5ec8124a511b}</Project>
+      <Name>MediII.Adapter.Scanner</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>Copy $(TargetDir)   $(ProjectDir)..\MessageToScan\UE\
+Copy $(TargetDir)   $(ProjectDir)..\MessageToScanServer\UE\</PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 36 - 0
MediII.Adapter.Scan.UE/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.Scan.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("MediII.Adapter.Scan.Test")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("cf431a49-66d7-41d5-b0bc-26a22bb02d24")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 11 - 0
MediII.Adapter.Scan.UE/app.config

@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<configuration>
+	<runtime>
+		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+			<dependentAssembly>
+				<assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
+				<bindingRedirect oldVersion="0.0.0.0-5.0.505.0" newVersion="5.0.505.0"/>
+			</dependentAssembly>
+		</assemblyBinding>
+	</runtime>
+</configuration>

+ 17 - 0
MediII.Adapter.Scanner/App.Config

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
+  <connectionStrings>
+    <add name="HIS3Context" connectionString="metadata=res://*/HISContext.csdl|res://*/HISContext.ssdl|res://*/HISContext.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=MediIIPlat;PASSWORD=his3;USER ID=HIS3&quot;" providerName="System.Data.EntityClient" />
+  </connectionStrings>
+  <entityFramework>
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+      <parameters>
+        <parameter value="v11.0" />
+      </parameters>
+    </defaultConnectionFactory>
+  </entityFramework>
+</configuration>

+ 124 - 0
MediII.Adapter.Scanner/DBScaner.cs

@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MediII.Adapter.Scan.Interface;
+using System.Collections.Concurrent;
+using Microsoft.Practices.EnterpriseLibrary.Common;
+using Microsoft.Practices.EnterpriseLibrary.Data;
+using System.Data.Common;
+using System.Threading.Tasks;
+using System.Data;
+using MediII.Adapter.ReceiveToScanModel;
+using IL.Common;
+
+namespace MediII.Adapter.Scanner
+{
+    public abstract class DBScaner : BaseScan
+    {
+
+        DatabaseProviderFactory factory = new DatabaseProviderFactory();
+        //数据库连接
+        protected Database ctx;
+
+        public DBScaner()
+        {
+            ctx = factory.CreateDefault();
+        }
+
+        protected override void OnStart()
+        {
+            string typeName = this.GetType().Name.Trim();
+            MediII.Common.LogHelper.LogInfo(string.Format("Scaner:{0} Started...", typeName), Common.LogCatagories.MQAccess);
+
+            var entity = GetSaoMiao(typeName);
+            if (entity == null)
+            {
+                LastTime = GetNow().AddDays(-1);
+            }
+            else
+            {
+                if (entity.IsDel == 1)
+                {
+                    this.Stop();
+                    return;
+                }
+
+                MediII.Common.LogHelper.LogInfo(string.Format("Scaner:{0} Started...", typeName), Common.LogCatagories.MQAccess);
+                int minus = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["AddMinues"]);
+                if (AddMinusDay)
+                    LastTime = entity.ExecuteTime.AddDays(-1);
+                else
+                    LastTime = entity.ExecuteTime;
+
+                //设置扫描间隔
+                var jianGe = entity.IntervalTime;
+                if (jianGe != null)
+                {
+                    this.Interval = (int)jianGe;
+                    MediII.Common.LogHelper.LogInfo(string.Format("Scaner:{0} jianGe:{1}", typeName, this.Interval), Common.LogCatagories.MQAccess);
+                }
+            }
+        }
+
+        private HL7_MessageSetEntity GetSaoMiao(string typeName)
+        {
+            var sql = string.Format("select * from HL7_MessageSet where MessageType=2 and  MessageId = '{0}'", typeName);
+            var entity = SqlDataAccess.ExecuteSqlStringAccessor<HL7_MessageSetEntity>(ctx, sql).FirstOrDefault();
+            return entity;
+        }
+
+        protected override void OnStop()
+        {
+            SetNewExecTime(LastTime);
+        }
+
+        protected override void OnElapsed(DateTime elapsedTime)
+        {
+            SetNewExecTime(elapsedTime);
+        }
+
+        /// <summary>
+        /// 最后执行时间
+        /// </summary>
+        /// <param name="elapsedTime"></param>
+        private void SetNewExecTime(DateTime elapsedTime)
+        {
+            try
+            {
+                var typeName = this.GetType().Name.Trim();
+                var sql = "update HL7_MessageSet set ExecuteTime = @ExecuteTime where MessageId=@MessageId";
+                var dbCommand = SqlDataAccess.GetSqlStringCommand(ctx, sql);
+                SqlDataAccess.AddInParameter(ctx, dbCommand, "ExecuteTime", System.Data.DbType.DateTime, elapsedTime);
+                SqlDataAccess.AddInParameter(ctx, dbCommand, "MessageId", System.Data.DbType.AnsiString, typeName);
+                SqlDataAccess.ExecuteNonQuery(ctx, dbCommand);
+            }
+            catch (Exception ex)
+            {
+                MediII.Common.LogHelper.LogError(ex, Common.LogCatagories.MQAccess);
+            }
+        }
+
+         
+        public override long GetMaxSCN()
+        {
+            return 0;
+        }
+
+        protected override DateTime GetNow()
+        {
+            try
+            {
+                return (DateTime)SqlDataAccess.ExecuteScalar(ctx, CommandType.Text, "select GETDATE()");
+            }
+            catch (Exception ex)
+            {
+                MediII.Common.LogHelper.LogError(ex, Common.LogCatagories.MQAccess);
+                return DateTime.Now;
+            }
+        }
+         
+
+       
+    }
+}

+ 12 - 0
MediII.Adapter.Scanner/Entity/BaseEntity.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MediII.Adapter.Scanner
+{
+    [Serializable]
+    public class BaseEntity
+    {
+    }
+}

+ 45 - 0
MediII.Adapter.Scanner/Entity/HL7_MessageSetEntity.cs

@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+
+
+namespace MediII.Adapter.Scanner
+{
+
+
+    [Serializable]
+    public partial class HL7_MessageSetEntity : BaseEntity
+    {
+
+        /// <summary> 
+        ///  消息ID
+        /// </summary>
+        public string MessageId { get; set; }
+
+        /// <summary> 
+        ///  消息类型 1扫描 2接收
+        /// </summary>
+        public int MessageType { get; set; }
+
+        /// <summary> 
+        ///  执行时间
+        /// </summary>
+        public DateTime ExecuteTime { get; set; }
+
+        /// <summary> 
+        ///  间隔时间
+        /// </summary>
+        public int? IntervalTime { get; set; }
+
+        /// <summary> 
+        ///  
+        /// </summary>
+        public int? IsDel { get; set; }
+
+        /// <summary> 
+        ///  备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+}

+ 106 - 0
MediII.Adapter.Scanner/MediII.Adapter.Scanner.csproj

@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{0ADDDB14-B0F6-4D12-8025-5EC8124A511B}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.Scanner</RootNamespace>
+    <AssemblyName>MediII.Adapter.Scanner</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.Composition" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Entity\BaseEntity.cs" />
+    <Compile Include="DBScaner.cs" />
+    <Compile Include="Entity\HL7_MessageSetEntity.cs" />
+    <Compile Include="MessageItem.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Scaner.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.Config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="ScanNormalTemplate.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Public\IL.Common\IL.Common.csproj">
+      <Project>{f320951f-886b-4f99-a3fd-5686c0a97868}</Project>
+      <Name>IL.Common</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj">
+      <Project>{4e8c6d0e-e696-4f02-812f-cedd6fe3f6dc}</Project>
+      <Name>MediII.Adapter.Scan.Interface</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.ReceiveToScanModel\MediII.Adapter.ReceiveToScanModel.csproj">
+      <Project>{f182ac2b-a0d5-40d2-89af-8d547606b6ac}</Project>
+      <Name>MediII.Adapter.ReceiveToScanModel</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 14 - 0
MediII.Adapter.Scanner/MessageItem.cs

@@ -0,0 +1,14 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MediII.Adapter.Scanner
+{
+    public class MessageItem
+    {
+        //public AbstractMessage MessageStruct { get; set; }
+        public object Item { get; set; }
+    }
+}

+ 36 - 0
MediII.Adapter.Scanner/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.Scan.HIS")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MediII.Adapter.Scan.HIS")]
+[assembly: AssemblyCopyright("Copyright ©  2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("0cb95154-1314-4aa1-929d-1f31002ae570")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 44 - 0
MediII.Adapter.Scanner/ScanNormalTemplate.txt

@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Data;
+using MediII.Adapter.Scan.Interface;
+using MediII.Adapter.Builder.Interface;
+
+namespace MediII.Adapter.Scanner.@@SYSNAME
+{
+    public class @@SCANNAME_Scanner : DBScaner, IScan
+    {
+        public override long Do(DateTime dtEventTime)
+        {
+            IEnumerable<DataRow> listRow;
+            string sql = "@@SQL";
+            listRow = ctx.ExecuteDataSet(CommandType.Text, sql).Tables[0].AsEnumerable();
+
+            if (listRow.Count() > 0)
+            {
+                List<MessageItem> listMessage = BuildMSG<DataRow>(listRow, entity =>
+                {
+                    //OML_O21_Builder builder = HIS_MessageBuilder.GetBuilder<OML_O21_Builder>();
+                    //builder.BuildCheXiao(entity);
+                    //return builder.MessageHolder;
+					var o = new NHapi.Model.V24.Message.OML_O21();
+                    o.MSH.MessageControlID.Value = Guid.NewGuid().ToString("N");
+                    return o;
+					//return null;
+                });
+
+                BeforeSend(listMessage.Select(s => s.MessageStruct).ToList());
+                SendMessages<DataRow>(listMessage, list =>
+                {
+                    string[] idList = list.Select(s => s["XUHAO"].ToString()).ToArray();
+                    string sqlUpdate = string.Format("update hl7_l_laborder set zhuangtai = 1 where xuhao in ('{0}')", string.Join(",", idList));
+                    SqlDataAccess.ExecuteNonQuery(ctx,System.Data.CommandType.Text, sqlUpdate);
+                    return 1;
+                });
+            }
+            return 0;
+        }
+    }
+}

+ 58 - 0
MediII.Adapter.Scanner/Scaner.cs

@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MediII.Adapter.Scan.Interface;
+using IL.Common;
+
+namespace MediII.Adapter.Scanner
+{
+    public class Scaner
+    {
+        IEnumerable<IScan> listScaner = new List<IScan>();
+
+
+        public int Start(string[] importsPaths)
+        {
+            return Start(importsPaths, null);
+        }
+        public int Start(string[] importsPaths, MessageLogDelegate msgLog)
+        {
+            ServicesContainer container = new ServicesContainer();
+            foreach (string path in importsPaths)
+            {
+                HostingMEF.SatisfyImports(container, path);
+            }
+            listScaner = container.Scanners;
+
+            foreach (var scanner in container.Scanners)
+            {
+                //间隔可以分别设置
+                //scanner.Interval = XX
+                //启动扫描     
+                //if (!scanner.ToString().Contains("HL7_Treatment_Create_Scanner"))
+                //{
+                //    continue;
+                //}
+                LogHelper.LogInfo("服务启动 " + scanner.GetType().FullName, LogCatagories.AdapterScan);
+                scanner.MessageLog += msgLog;
+                scanner.Start();
+            }
+            return 1;
+        }
+
+        public int Stop()
+        {
+            foreach (var scaner in listScaner)
+            {
+                if (scaner.IsRuning)
+                {
+                    LogHelper.LogInfo("服务停止 " + scaner.GetType().FullName, LogCatagories.AdapterScan);
+                    scaner.Stop();
+                }
+                   
+            }
+            return 1;
+        }
+    }
+}

+ 169 - 0
MediII.Adapter.WinForm.Scan/MediII.Adapter.WinForm.Scanner.csproj

@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{5E125823-EC26-4F15-B178-48E8387C5F1A}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MediII.Adapter.WinForm.Scanner</RootNamespace>
+    <AssemblyName>MediII.Adapter.WinForm.Scanner</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+    <FileAlignment>512</FileAlignment>
+    <SccProjectName>
+    </SccProjectName>
+    <SccLocalPath>
+    </SccLocalPath>
+    <SccAuxPath>
+    </SccAuxPath>
+    <SccProvider>
+    </SccProvider>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <PublishUrl>发布\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup />
+  <PropertyGroup>
+    <ApplicationIcon>
+    </ApplicationIcon>
+  </PropertyGroup>
+  <PropertyGroup />
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+    <DebugSymbols>true</DebugSymbols>
+    <OutputPath>bin\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DebugType>full</DebugType>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+    <DocumentationFile>
+    </DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <Optimize>true</Optimize>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <ErrorReport>prompt</ErrorReport>
+    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MediII.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\MediII.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Common.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Data">
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Data.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=e44a2bc38ed2c13c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\dll\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.Composition" />
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Web.Extensions" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <None Include="app.config">
+      <SubType>Designer</SubType>
+    </None>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include=".NETFramework,Version=v4.0">
+      <Visible>False</Visible>
+      <ProductName>Microsoft .NET Framework 4 %28x86 和 x64%29</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 4.5</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Public\MediII.Adapter.Scan.Interface\MediII.Adapter.Scan.Interface.csproj">
+      <Project>{4e8c6d0e-e696-4f02-812f-cedd6fe3f6dc}</Project>
+      <Name>MediII.Adapter.Scan.Interface</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\MediII.Adapter.Scanner\MediII.Adapter.Scanner.csproj">
+      <Project>{0adddb14-b0f6-4d12-8025-5ec8124a511b}</Project>
+      <Name>MediII.Adapter.Scanner</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <PropertyGroup>
+    <PostBuildEvent>
+    </PostBuildEvent>
+  </PropertyGroup>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 38 - 0
MediII.Adapter.WinForm.Scan/Program.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MediII.Adapter.Scanner;
+using MediII.Adapter.Scan.Interface; 
+
+namespace MediII.Adapter.WinForm.Scanner
+{
+    class Program
+    {
+        static Scaner scanner = new Scaner();
+
+        static void Main(string[] args)
+        {
+
+            //try
+            //{
+
+            //    var sca = new BizComponent_MFN();
+            //}
+            //catch (Exception ex)
+            //{
+            //    Console.WriteLine(ex.Message);
+            //}
+
+            args = new string[] { "UE" };
+            if (args.Length > 0)
+            {
+                string dllPath = System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath, args[0]);
+                string path = Environment.GetEnvironmentVariable("path") + ";" + dllPath;
+                Environment.SetEnvironmentVariable("path", path);
+                scanner.Start(new string[] { dllPath });
+            }
+            Console.Read();
+        }
+    }
+}

+ 36 - 0
MediII.Adapter.WinForm.Scan/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("MediII.Adapter.WinForm.Scan")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MediII.Adapter.WinForm.Scan")]
+[assembly: AssemblyCopyright("Copyright ©  2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("9b49a670-5a28-42ed-a4ff-2b252c3f1454")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      内部版本号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 63 - 0
MediII.Adapter.WinForm.Scan/Properties/Resources.Designer.cs

@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.18063
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MediII.Adapter.WinForm.Scanner.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   一个强类型的资源类,用于查找本地化的字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources() {
+        }
+        
+        /// <summary>
+        ///   返回此类使用的缓存的 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MediII.Adapter.WinForm.Scanner.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   使用此强类型资源类,为所有资源查找
+        ///   重写当前线程的 CurrentUICulture 属性。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
MediII.Adapter.WinForm.Scan/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 26 - 0
MediII.Adapter.WinForm.Scan/Properties/Settings.Designer.cs

@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.18063
+//
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace MediII.Adapter.WinForm.Scanner.Properties {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+        
+        public static Settings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
MediII.Adapter.WinForm.Scan/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 93 - 0
MediII.Adapter.WinForm.Scan/app.config

@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
+    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
+  </configSections>
+  <!--日志配置-->
+  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
+    <listeners>
+      <add name="GeneralListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="General\rolling.log" formatter="Text Formatter" rollFileExistsBehavior="Increment" rollInterval="Day" maxArchivedFiles="0" traceOutputOptions="None" />
+      <add name="SockListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Sock\rolling.log" formatter="Text Formatter" rollInterval="Day" />
+      <add name="ScanListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="Scan\rolling.log" formatter="Text Formatter" rollInterval="Day" />
+      <add name="SqlListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="SQL\logSql.log" formatter="Text Formatter" rollInterval="Day" />
+    </listeners>
+    <formatters>
+      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp}{newline}&#xA;Message: {message}" name="Text Formatter" />
+    </formatters>
+    <categorySources>
+      <add switchValue="All" name="General">
+        <listeners>
+          <add name="GeneralListener" />
+        </listeners>
+      </add>
+      <add switchValue="All" name="Sock">
+        <listeners>
+          <add name="SockListener" />
+        </listeners>
+      </add>
+      <add switchValue="All" name="AdapterScan">
+        <listeners>
+          <add name="ScanListener" />
+        </listeners>
+      </add>
+      <add switchValue="All" name="SQL">
+        <listeners>
+          <add name="SqlListener" />
+        </listeners>
+      </add>
+    </categorySources>
+    <specialSources>
+      <allEvents switchValue="All" name="All Events" />
+      <notProcessed switchValue="All" name="Unprocessed Category" />
+      <errors switchValue="All" name="Logging Errors &amp; Warnings" />
+    </specialSources>
+  </loggingConfiguration>
+  <dataConfiguration defaultDatabase="DefaultDB" />
+  <connectionStrings>
+    <add name="DefaultDB" connectionString="Data Source=.;
+                       Initial Catalog=HL7_Platform;
+                       Persist Security Info=True;
+                       Integrated Security=False;
+                       User ID=sa;Password=123" providerName="System.Data.SqlClient"/>
+
+    <add name="HealthCare" connectionString="Data Source=.;
+                       Initial Catalog=HL7_Platform;
+                       Persist Security Info=True;
+                       Integrated Security=False;
+                       User ID=sa;Password=123" providerName="System.Data.SqlClient"/>
+  </connectionStrings>
+  <appSettings>
+    <!--测试-->
+    <!--正式-->
+    <add key="MediIIAddress" value="192.9.216.206" />
+    <add key="MediIIPort" value="31001" />
+    <add key="BufferSize" value="4048" />
+    <add key="ReviceTimeOut" value="30000" />
+    <add key="ErrorRepeatCount" value="1" />
+    <add key="ErrorSleepMSecodes" value="3000" />
+    <!--<add key="SedingApplication" value="UEHIS" />-->
+    <add key="HosiptalName" value="" />
+    <add key="AddMinues" value="30" />
+    <add key="BranchID" value="" />
+    <!--查询数量-->
+    <add key="SearchNum" value="50" />
+    <!--任务解锁时间  单位分钟-->
+    <add key="TaskRunTime" value="5" />
+    <!--启动SQL日志-->
+    <add key="LogSql" value="1" />
+    <add key="ClientSettingsProvider.ServiceUri" value="" />
+  </appSettings>
+  <system.web>
+    <membership defaultProvider="ClientAuthenticationMembershipProvider">
+      <providers>
+        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
+      </providers>
+    </membership>
+    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
+      <providers>
+        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
+      </providers>
+    </roleManager>
+  </system.web>
+</configuration>

BIN
MessageToScan/UE/Dapper.dll


BIN
MessageToScan/UE/IL.Common.dll


BIN
MessageToScan/UE/KC_HN_Tools.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.ADT.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.Base.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.MFN.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.OML.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.OMP.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.ORU.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.PMU.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.RAS.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.RDS.dll


BIN
MessageToScan/UE/MediII.Adapter.BizComponent.UE.dll


BIN
MessageToScan/UE/MediII.Adapter.ReceiveToSIModel.dll


BIN
MessageToScan/UE/MediII.Adapter.ReceiveToScanModel.dll


BIN
MessageToScan/UE/MediII.Adapter.Scan.Interface.dll


BIN
MessageToScan/UE/MediII.Adapter.Scanner.dll


BIN
MessageToScan/UE/MediII.Common.dll


BIN
MessageToScan/UE/Microsoft.Practices.EnterpriseLibrary.Common.dll


BIN
MessageToScan/UE/Microsoft.Practices.EnterpriseLibrary.Data.dll


BIN
MessageToScan/UE/Microsoft.Practices.EnterpriseLibrary.Logging.dll


BIN
MessageToScan/UE/Microsoft.Practices.ServiceLocation.dll


BIN
MessageToScan/UE/Microsoft.Practices.Unity.Interception.dll


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio