MFN_Z2B_GY_KESHI.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.Common;
  6. using System.Transactions;
  7. using Microsoft.Practices.EnterpriseLibrary.Data;
  8. using System.Data;
  9. using IL.Common;
  10. using System.Xml;
  11. //using MediII.Adapter.Model.UE;
  12. namespace MediII.Adapter.BizComponent.MFN
  13. {
  14. /// <summary>
  15. /// 公用科室
  16. /// zengfan 2012-09-04
  17. /// </summary>
  18. /// <remarks></remarks>
  19. public class MFN_Z2B_GY_KESHI : MFNBase
  20. {
  21. //数据库连接
  22. //HealthCareContainer HealthCareContainer = new HealthCareContainer();
  23. private Database ctx = null;
  24. public MFN_Z2B_GY_KESHI(Database dbCtx)
  25. {
  26. ctx = dbCtx;
  27. }
  28. /// <summary>
  29. /// 消息处理,入库
  30. /// </summary>
  31. /// <param name="message">转化过的强类型消息</param>
  32. /// <returns></returns>
  33. /// <remarks></remarks>
  34. public override int Process(string message,string msgType)
  35. {
  36. string strMsgType;
  37. using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
  38. {
  39. string sqlSel = "select count(*) from dbo.his_unit where id=@id";
  40. OperateXmlUtil helper = new OperateXmlUtil();
  41. string pkid = helper.XpathRead(message, "//*[@root='2.16.156.10011.1.26']", "extension");
  42. DbCommand cmd = ctx.DBGetSqlStringCommand(sqlSel);
  43. ctx.AddInParameter(cmd, "id", System.Data.DbType.String, pkid);
  44. int counts = Convert.ToInt32(ctx.ExecuteScalar(cmd));
  45. if (counts == 0)
  46. {
  47. string sql = @"insert into dbo.his_unit(id,
  48. name,
  49. pym)
  50. VALUES(@id,
  51. @name,
  52. @pym)";
  53. OperateXmlUtil xmlHelper = new OperateXmlUtil();
  54. DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
  55. Resolving(message, ctx, command);
  56. ctx.ExecuteNonQuery(command);
  57. }
  58. else
  59. {
  60. string sql = "update dbo.his_unit set name=@name,pym=@pym where id=@id";
  61. OperateXmlUtil xmlHelper = new OperateXmlUtil();
  62. DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
  63. Resolving(message, ctx, command);
  64. ctx.ExecuteNonQuery(command);
  65. }
  66. scope.Complete();
  67. }
  68. return 1;
  69. }
  70. /// <summary>
  71. /// 科室删除
  72. /// </summary>
  73. /// <param name="seg">传入资料</param>
  74. /// <param name="HealthCareContainer">连线</param>
  75. /// <param name="scope">交易</param>
  76. public void Division_SyncDel(string pkid)
  77. {
  78. //string sql4 = "update HealthCare.dbo.Division set IsIss=1 where DivNo=@DivNo";
  79. string sql4 = "delete from HealthCare.dbo.Division where DivNo=@DivNo";
  80. DbCommand command4 = ctx.GetSqlStringCommand(sql4.ToString());
  81. ctx.AddInParameter(command4, "DivNo", System.Data.DbType.AnsiString, pkid);
  82. ctx.ExecuteNonQuery(command4);
  83. }
  84. public void Resolving(string Content, Database ctx, DbCommand command)
  85. {
  86. string value = string.Empty;
  87. OperateXmlUtil xmlHelper = new OperateXmlUtil();
  88. value = xmlHelper.XpathRead(Content, "//*[@root='2.16.156.10011.1.26']", "extension");
  89. ctx.AddInParameter(command, "id", System.Data.DbType.String, value);
  90. var valueNode = xmlHelper.XpathRead(Content, "//*[name()='assignedPrincipalOrganization']").Item(0);
  91. foreach (XmlNode xe in valueNode.ChildNodes)
  92. {
  93. if (xe.Name == "name")
  94. {
  95. value = xe.LastChild.LastChild.Attributes["value"].Value;
  96. ctx.AddInParameter(command, "name", System.Data.DbType.String, value);
  97. value = xe.LastChild.LastChild.Attributes["code"].Value;
  98. ctx.AddInParameter(command, "pym", System.Data.DbType.String, value);
  99. break;
  100. }
  101. }
  102. }
  103. }
  104. }