Exemplo n.º 1
0
        /// <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))
                {
                    paibanModel paiban = HL7ToXmlConverter.toDataBae(message);
                    if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 0)
                    {
                        dbcon.InsertPaiban(paiban, tableName);
                    }
                }

                //修改
                if (message.Contains(_UpdateOperApply))
                {
                    paibanModel paiban = HL7ToXmlConverter.toDataBae(message);
                    if (dbcon.GetPaiban(paiban, tableName).Rows.Count == 1)
                    {
                        dbcon.UpdatePaibanAll(paiban, tableName);
                    }
                }

                if (message.Contains(_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("^", "");
                        }
                    }
                    dbcon.UpdatePaibanOstate(tableName, PatID);
                }

                //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);
            }
        }
Exemplo n.º 2
0
        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("取消手术成功");
                }
            }
        }