123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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.his_unit 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.his_unit(id,
- name,
- pym)
- VALUES(@id,
- @name,
- @pym)";
- OperateXmlUtil xmlHelper = new OperateXmlUtil();
- DbCommand command = ctx.GetSqlStringCommand(sql.ToString());
- Resolving(message, ctx, command);
- ctx.ExecuteNonQuery(command);
- }
- else
- {
- string sql = "update dbo.his_unit set name=@name,pym=@pym 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, "pym", System.Data.DbType.String, value);
- break;
- }
- }
- }
- }
- }
|