MFN_Z2B_GY_KESHI.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.dic_department 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.dic_department(id,
  48. name,
  49. status,
  50. search_code)
  51. VALUES(@id,
  52. @name,
  53. @status,
  54. @search_code)";
  55. OperateXmlUtil xmlHelper = new OperateXmlUtil();
  56. DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
  57. Resolving(message, ctx, command);
  58. ctx.ExecuteNonQuery(command);
  59. }
  60. else
  61. {
  62. string sql = "update dbo.dic_department set name=@name,search_code=@search_code where id=@id";
  63. OperateXmlUtil xmlHelper = new OperateXmlUtil();
  64. DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
  65. Resolving(message, ctx, command);
  66. ctx.ExecuteNonQuery(command);
  67. }
  68. scope.Complete();
  69. }
  70. return 1;
  71. }
  72. /// <summary>
  73. /// 科室删除
  74. /// </summary>
  75. /// <param name="seg">传入资料</param>
  76. /// <param name="HealthCareContainer">连线</param>
  77. /// <param name="scope">交易</param>
  78. public void Division_SyncDel(string pkid)
  79. {
  80. //string sql4 = "update HealthCare.dbo.Division set IsIss=1 where DivNo=@DivNo";
  81. string sql4 = "delete from HealthCare.dbo.Division where DivNo=@DivNo";
  82. DbCommand command4 = ctx.GetSqlStringCommand(sql4.ToString());
  83. ctx.AddInParameter(command4, "DivNo", System.Data.DbType.AnsiString, pkid);
  84. ctx.ExecuteNonQuery(command4);
  85. }
  86. public void Resolving(string Content, Database ctx, DbCommand command)
  87. {
  88. string value = string.Empty;
  89. OperateXmlUtil xmlHelper = new OperateXmlUtil();
  90. value = xmlHelper.XpathRead(Content, "//*[@root='2.16.156.10011.1.26']", "extension");
  91. ctx.AddInParameter(command, "id", System.Data.DbType.String, value);
  92. var valueNode = xmlHelper.XpathRead(Content, "//*[name()='assignedPrincipalOrganization']").Item(0);
  93. foreach (XmlNode xe in valueNode.ChildNodes)
  94. {
  95. if (xe.Name == "name")
  96. {
  97. value = xe.LastChild.LastChild.Attributes["value"].Value;
  98. ctx.AddInParameter(command, "name", System.Data.DbType.String, value);
  99. value = xe.LastChild.LastChild.Attributes["code"].Value;
  100. ctx.AddInParameter(command, "search_code", System.Data.DbType.String, value);
  101. ctx.AddInParameter(command, "status", System.Data.DbType.String, "1");
  102. break;
  103. }
  104. }
  105. }
  106. }
  107. }