private void button1_Click(object sender, EventArgs e) { DBConn dbcon = new DBConn(); String myHL7string = txtOutput.Text; string[] list = myHL7string.Split('\n'); if (myHL7string.Contains(ConfigurationManager.AppSettings["AcceptTitleConfig"])) { paibanModel paiban = HL7ToXmlConverter.toDataBae(myHL7string); string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"]; if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 1) { int i = dbcon.UpdatePaibanAll(paiban, tableName); if (i > 0) { MessageBox.Show("修改手术成功"); } } } if (myHL7string.Contains(ConfigurationManager.AppSettings["AcceptTitle"])) { paibanModel paiban = HL7ToXmlConverter.toDataBae(myHL7string); string tableName = ConfigurationManager.AppSettings["PaibanTableName"]; if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 0) { int i = dbcon.InsertPaiban(paiban, tableName); if (i > 0) { MessageBox.Show("新加手术成功"); } } else { MessageBox.Show("病人已经存在!"); } } if (myHL7string.Contains(ConfigurationManager.AppSettings["AcceptTitleCancel"])) { string PatID = ""; myHL7string = myHL7string.Replace("ARQ", "\nARQ"); string[] sList = myHL7string.Split('\n'); foreach (string str in sList) { if (str.Contains("ARQ|")) { PatID = str.Split('|')[1].Replace("^", ""); } } string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"]; int i = dbcon.UpdatePaiban(tableName, PatID); if (i > 0) { MessageBox.Show("取消手术成功"); } } }
/// <summary> /// 消息达到后交个Biz处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void SocketHelper_MessageReviced(object sender, MessageRevicedEventArgs e) { string sendingApp = AppSettingString.SendingApp; string recvApp = AppSettingString.RecvApp; //System.Configuration.ConfigurationManager.AppSettings["recvApp"]; try { DBConn dbcon = new DBConn(); PipeParser parser = new PipeParser(); //解析出消息类型,创建对应的Biz进行处理 string message = System.Text.Encoding.UTF8.GetString(e.Contents); message = MediII.Common.MLLPHelper.TrimMLLP(message, true, false); LogHelp.WriteLog(message); ////手术字典 //if (message.Contains(_AcceptTitleOperDic)) //{ // OperDicModel dic = HL7ToXmlConverter.ToOperDic(message); // dbcon.InsertOperDic(dic); //} if (message.Contains(_NewOperApply)) { OTypesetting paiban = null; paiban = HL7ToXmlConverter.toDataBae(message, paiban); if (dbcon.GetPaiban(paiban.PatZhuYuanID) == null) { dbcon.InsertPaiban(paiban); } } //修改 else if (message.Contains(_UpdateOperApply)) { string zhuyuanid = HL7ToXmlConverter.GetZhuyuanId(message); OTypesetting paiban = dbcon.GetPaiban(zhuyuanid); paiban = HL7ToXmlConverter.toDataBae(message, paiban); if (paiban != null) { if (paiban.Ostate == 0) { dbcon.UpdatePaiban(paiban); } } } else if (message.Contains(_CancelOperApply)) { string zhuyuanid = ""; message = message.Replace("ARQ", "\nARQ"); string[] sList = message.Split('\n'); foreach (string str in sList) { if (str.Contains("ARQ|")) { zhuyuanid = str.Split('|')[1].Replace("^", ""); } } dbcon.UpdatePaibanOstate(zhuyuanid, -1); } //string mesStruct = parser.GetMessageStructure(message).Substring(0, 3); string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", recvApp, recvApp, sendingApp, sendingApp, Guid.NewGuid().ToString("N")); LogHelp.WriteLog(ackMsg); SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler); } catch (Exception ex) { //出现异常需要返回,避免队列堵塞 string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", recvApp, recvApp, sendingApp, sendingApp, Guid.NewGuid().ToString("N"), ex.Message); LogHelp.WriteErrorLog(ackMsg); SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler); MediII.Common.LogHelper.LogError(ex, Common.LogCatagories.AdapterBiz); } }
/// <summary> /// 消息达到后交个Biz处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void SocketHelper_MessageReviced(object sender, MessageRevicedEventArgs e) { try { DBConn dbcon = new DBConn(); PipeParser parser = new PipeParser(); //解析出消息类型,创建对应的Biz进行处理 string message = System.Text.Encoding.UTF8.GetString(e.Contents); message = MediII.Common.MLLPHelper.TrimMLLP(message, true, false); LogTxt.WriteError("接收到信息:", message, EventLogEntryType.Information); if (message.Contains(ConfigurationManager.AppSettings["AcceptTitle"])) { paibanModel paiban = HL7ToXmlConverter.toDataBae(message); string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"]; if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 0) { dbcon.InsertPaiban(paiban, tableName); } } if (message.Contains(ConfigurationManager.AppSettings["AcceptTitleConfig"])) { paibanModel paiban = HL7ToXmlConverter.toDataBae(message); string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"]; if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 1) { dbcon.UpdatePaibanAll(paiban, tableName); } } if (message.Contains(ConfigurationManager.AppSettings["AcceptTitleCancel"])) { string PatID = ""; message = message.Replace("ARQ", "\nARQ"); string[] sList = message.Split('\n'); foreach (string str in sList) { if (str.Contains("ARQ|")) { PatID = str.Split('|')[1].Replace("^", ""); } } string tableName = System.Configuration.ConfigurationManager.AppSettings["PaibanTableName"]; dbcon.UpdatePaiban(tableName, PatID); } string mesStruct = parser.GetMessageStructure(message).Substring(0, 3); string sendingApp = System.Configuration.ConfigurationManager.AppSettings["sendingApp"]; string recvApp = System.Configuration.ConfigurationManager.AppSettings["recvApp"]; string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", sendingApp, sendingApp, recvApp, recvApp, "123456789"); DBConn.SaveLog(ackMsg); SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler); } catch (Exception ex) { //出现异常需要返回,避免队列堵塞 string sendingApp = System.Configuration.ConfigurationManager.AppSettings["SedingApplication"]; string recvApp = "SSMZ"; string ackMsg = MediII.Common.MessageHelper.SetACK("ACK", "", "", sendingApp, sendingApp, recvApp, recvApp, "123456789", ex.Message); SocketHelper.SendAck(MediII.Common.MLLPHelper.AddMLLP(ackMsg), e.SocketHandler); MediII.Common.LogHelper.LogError(ex, Common.LogCatagories.AdapterBiz); } }
private void button1_Click(object sender, EventArgs e) { string sendingApp = AppSettingString.SendingApp; string recvApp = AppSettingString.RecvApp; //System.Configuration.ConfigurationManager.AppSettings["recvApp"]; String message = txtOutput.Text; ////手术字典 //if (message.Contains(Program._AcceptTitleOperDic)) //{ // OperDicModel dic = HL7ToXmlConverter.ToOperDic(message); // int res = dbcon.InsertOperDic(dic); // if (res > 0) // { // MessageBox.Show("插入字典成功"); // } //} if (message.Contains(Program._NewOperApply)) { OTypesetting paiban = null; paiban = HL7ToXmlConverter.toDataBae(message, paiban); if (dbcon.GetPaiban(paiban.PatZhuYuanID) == null) { int i = dbcon.InsertPaiban(paiban); if (i > 0) { MessageBox.Show("新加手术成功"); } } else { MessageBox.Show("病人已经存在!"); } } else if (message.Contains(Program._UpdateOperApply)) { string zhuyuanid = HL7ToXmlConverter.GetZhuyuanId(message); OTypesetting paiban = dbcon.GetPaiban(zhuyuanid); paiban = HL7ToXmlConverter.toDataBae(message, paiban); if (paiban != null) { if (paiban.Ostate == 0) { dbcon.UpdatePaiban(paiban); } } } else if (message.Contains(Program._CancelOperApply)) { string zhuyuanid = ""; message = message.Replace("ARQ", "\nARQ"); string[] sList = message.Split('\n'); foreach (string str in sList) { if (str.Contains("ARQ|")) { zhuyuanid = str.Split('|')[1].Replace("^", ""); } } int i = dbcon.UpdatePaibanOstate(zhuyuanid, -1); if (i > 0) { MessageBox.Show("取消手术成功"); } } }
private void button1_Click(object sender, EventArgs e) { string sendingApp = AppSettingString.SendingApp; string recvApp = AppSettingString.RecvApp; //System.Configuration.ConfigurationManager.AppSettings["recvApp"]; DBConn dbcon = new DBConn(); String message = txtOutput.Text; //手术字典 if (message.Contains(Program._AcceptTitleOperDic)) { OperDicModel dic = HL7ToXmlConverter.ToOperDic(message); int res = dbcon.InsertOperDic(dic); if (res > 0) { MessageBox.Show("插入字典成功"); } } if (message.Contains(Program._UpdateOperApply)) { paibanModel paiban = HL7ToXmlConverter.toDataBae(message); if (dbcon.GetPaiban(paiban, Program._PaibanTable).Rows.Count == 1) { int i = dbcon.UpdatePaibanAll(paiban, Program._PaibanTable); if (i > 0) { MessageBox.Show("修改手术成功"); } } } if (message.Contains(Program._NewOperApply)) { paibanModel paiban = HL7ToXmlConverter.toDataBae(message); if (dbcon.GetPaiban(paiban, Program._PaibanTable).Rows.Count == 0) { int i = dbcon.InsertPaiban(paiban, Program._PaibanTable); if (i > 0) { MessageBox.Show("新加手术成功"); } } else { MessageBox.Show("病人已经存在!"); } } if (message.Contains(Program._CancelOperApply)) { string PatID = ""; message = message.Replace("ARQ", "\nARQ"); string[] sList = message.Split('\n'); foreach (string str in sList) { if (str.Contains("ARQ|")) { PatID = str.Split('|')[1].Replace("^", ""); } } int i = dbcon.UpdatePaibanOstate(Program._PaibanTable, PatID); if (i > 0) { MessageBox.Show("取消手术成功"); } } }