Пример #1
0
        private void btnSelectImg_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "图片文件(*.PNG)|*.png";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Bitmap       image        = Bitmap.FromFile(dialog.FileName) as Bitmap;
                QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();
                qcMsgChatLog.ChatID          = qcMsgChatLog.MakeChatID();
                qcMsgChatLog.ChatContent     = this.txtMessage.Text.Trim();
                qcMsgChatLog.ChatSendDate    = DateTime.Now;
                qcMsgChatLog.Sender          = this.m_szListener;
                qcMsgChatLog.PatientID       = this.m_szPatientID;
                qcMsgChatLog.VisitID         = this.m_szVisitID;
                qcMsgChatLog.Listener        = this.m_szSender;
                qcMsgChatLog.MsgChatDataType = SystemData.MsgChatDataType.Image;

                byte[] byteChatImage = ImageAccess.Instance.ImageToBuffer(image, ImageFormat.Bmp);
                short  shRet         = QcMsgChatAccess.Instance.SaveQCMsgChatLog(qcMsgChatLog, byteChatImage);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    MessageBoxEx.ShowError("截图发送失败");
                    return;
                }
                SetChatContentToForm(qcMsgChatLog);
                this.richTextBox1.Focus();
                richTextBox1.SelectionStart = richTextBox1.Text.Length;
                richTextBox1.ScrollToCaret();
            }
        }
Пример #2
0
        private void btnSendMsg_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtMessage.Text.Trim()))
            {
                return;
            }
            QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();

            qcMsgChatLog.ChatID       = qcMsgChatLog.MakeChatID();
            qcMsgChatLog.ChatContent  = this.txtMessage.Text.Trim();
            qcMsgChatLog.ChatSendDate = DateTime.Now;
            qcMsgChatLog.Sender       = this.m_szSender;
            qcMsgChatLog.PatientID    = this.m_szPatientID;
            qcMsgChatLog.VisitID      = this.m_szVisitID;
            qcMsgChatLog.Listener     = this.m_szListener;
            qcMsgChatLog.MsgID        = this.MsgID;
            byte[] byteChatImage = null;
            short  shRet         = QcMsgChatAccess.Instance.SaveQCMsgChatLog(qcMsgChatLog, byteChatImage);

            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.ShowError("消息发送失败");
                return;
            }

            SetChatContentToForm(qcMsgChatLog);

            richTextBox1.SelectionStart = richTextBox1.Text.Length;
            richTextBox1.ScrollToCaret();
            this.txtMessage.Focus();
            this.txtMessage.Clear();
        }
Пример #3
0
        private void Screenshot()
        {
            ScreenSnapForm form = new ScreenSnapForm(this);

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.image == null)
                {
                    return;
                }
                QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();
                qcMsgChatLog.ChatID          = qcMsgChatLog.MakeChatID();
                qcMsgChatLog.ChatContent     = this.txtMessage.Text.Trim();
                qcMsgChatLog.ChatSendDate    = DateTime.Now;
                qcMsgChatLog.Sender          = this.m_szSender;
                qcMsgChatLog.PatientID       = this.m_szPatientID;
                qcMsgChatLog.VisitID         = this.m_szVisitID;
                qcMsgChatLog.Listener        = this.m_szListener;
                qcMsgChatLog.MsgID           = this.MsgID;
                qcMsgChatLog.MsgChatDataType = SystemData.MsgChatDataType.Image;

                byte[] byteChatImage = ImageAccess.Instance.ImageToBuffer(form.image, ImageFormat.Bmp);
                short  shRet         = QcMsgChatAccess.Instance.SaveQCMsgChatLog(qcMsgChatLog, byteChatImage);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    MessageBoxEx.ShowError("截图发送失败");
                    return;
                }
                SetChatContentToForm(qcMsgChatLog);
                this.richTextBox1.Focus();
                richTextBox1.SelectionStart = richTextBox1.Text.Length;
                richTextBox1.ScrollToCaret();
            }
        }
Пример #4
0
        private void SetChatContentToForm(QcMsgChatLog qcMsgChatLog)
        {
            short shRet = SystemData.ReturnValue.OK;

            richTextBox1.SelectionFont = new Font(Font, FontStyle.Bold);
            bool bIsSend = false;

            if (SystemParam.Instance.QChatArgs == null)
            {
                SystemParam.Instance.QChatArgs = new QChatArgs();
            }
            if (qcMsgChatLog.Sender == this.m_szListener)
            {
                //隐藏质控科人员名字
                if (SystemParam.Instance.QChatArgs.UserType == "0")
                {
                    bIsSend = true;
                }
            }
            else
            {
                richTextBox1.SelectionColor = Color.Blue;
            }
            this.richTextBox1.AppendText(string.Format("  {0}|{1} {2}    "
                                                       , bIsSend ? "质控科" : qcMsgChatLog.Sender
                                                       , qcMsgChatLog.ChatSendDate
                                                       , System.Environment.NewLine));
            richTextBox1.SelectionFont  = new Font(Font, FontStyle.Regular);
            richTextBox1.SelectionColor = Color.Black;
            if (qcMsgChatLog.MsgChatDataType == SystemData.MsgChatDataType.Image)
            {
                byte[] byteImage = null;
                //插入图片
                shRet = QcMsgChatAccess.Instance.GetQCMsgChatInfoImage(qcMsgChatLog.ChatID, ref byteImage);
                if (byteImage != null && byteImage.Length > 0)
                {
                    Clipboard.Clear();
                    Bitmap image = ImageAccess.Instance.BufferToImage(byteImage);
                    if (image != null)
                    {
                        this.richTextBox1.ReadOnly = false;
                        Clipboard.SetImage(image);//将图片添加到剪贴板
                        this.richTextBox1.Paste();
                        Clipboard.Clear();
                        this.richTextBox1.ReadOnly = true;
                    }
                }
            }
            else
            {
                this.richTextBox1.AppendText(string.Format("{0}"
                                                           , qcMsgChatLog.ChatContent));
            }
            this.richTextBox1.AppendText(string.Format("{0}{1}"
                                                       , System.Environment.NewLine
                                                       , System.Environment.NewLine));
        }
Пример #5
0
        private void UpdateChatLog(MessageInfo item)
        {
            QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();

            qcMsgChatLog.ChatID = item.MessageID;
            qcMsgChatLog.IsRead = true;
            short shRet = QcMsgChatAccess.Instance.UpdateQCMsgChatLog(qcMsgChatLog);

            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.ShowError("消息更新失败");
                return;
            }
        }
Пример #6
0
        /// <summary>
        /// 保存一条质控问题沟通消息
        /// </summary>
        /// <param name="HdpUIConfig">界面配置信息</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short SaveQCMsgChatLog(QcMsgChatLog qcMsgChatLog, byte[] byteImage)
        {
            string szField = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}"
                                           , SystemData.QCMsgChatTable.CHAT_CONTENT
                                           , SystemData.QCMsgChatTable.CHAT_ID
                                           , SystemData.QCMsgChatTable.CHAT_SEND_DATE
                                           , SystemData.QCMsgChatTable.IS_READ
                                           , SystemData.QCMsgChatTable.LISTENER
                                           , SystemData.QCMsgChatTable.PATIENT_ID
                                           , SystemData.QCMsgChatTable.SENDER
                                           , SystemData.QCMsgChatTable.VISIT_ID
                                           , SystemData.QCMsgChatTable.MSG_CHAT_DATA_TYPE
                                           , "MSG_ID");
            string szValue = string.Format("'{0}','{1}',{2},{3},'{4}','{5}','{6}','{7}',{8},'{9}'"
                                           , qcMsgChatLog.ChatContent
                                           , qcMsgChatLog.ChatID
                                           , base.MedQCAccess.GetSqlTimeFormat(qcMsgChatLog.ChatSendDate)
                                           , qcMsgChatLog.IsRead ? "1" : "0"
                                           , qcMsgChatLog.Listener
                                           , qcMsgChatLog.PatientID
                                           , qcMsgChatLog.Sender
                                           , qcMsgChatLog.VisitID
                                           , qcMsgChatLog.MsgChatDataType
                                           , qcMsgChatLog.MsgID
                                           );

            int nCount = 0;

            DbParameter[] pmi = null;
            if (byteImage != null)
            {
                szField = string.Format("{0},{1}", szField, SystemData.QCMsgChatTable.CHAT_IMAGE);
                szValue = string.Format("{0},{1}", szValue, base.MedQCAccess.GetSqlParamName("CHAT_IMAGE"));

                pmi    = new DbParameter[1];
                pmi[0] = new DbParameter("CHAT_IMAGE", byteImage);
            }
            string szSQL = string.Format(SystemData.SQL.INSERT, SystemData.DataTable.QC_MSG_CHAT_LOG, szField, szValue);

            try
            {
                nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text, ref pmi);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("DBAccess.SaveQCMsgChatLog", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(nCount > 0 ? SystemData.ReturnValue.OK : SystemData.ReturnValue.EXCEPTION);
        }
Пример #7
0
        public MessageInfo ConvterToMessage(QcMsgChatLog chatLog)
        {
            if (chatLog == null)
            {
                return(null);
            }
            MessageInfo info = new MessageInfo();

            info.MessageID      = chatLog.ChatID;
            info.MessageFrom    = SystemCache.LstUserInfo.Find(i => i.USER_ID == chatLog.Sender);
            info.MessageTo      = SystemCache.LstUserInfo.Find(i => i.USER_ID == chatLog.Listener);
            info.MessageContent = chatLog.ChatContent;
            info.SendTime       = chatLog.ChatSendDate;
            info.MessageAction  = chatLog.MsgChatDataType == "0" ? (int)ActionType.SendMessage : (int)ActionType.SendPIc;
            return(info);
        }
Пример #8
0
        private void SaveChatContentToDB(MessageInfo message)
        {
            QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();

            qcMsgChatLog.ChatID       = message.MessageID;
            qcMsgChatLog.ChatContent  = message.MessageContent;
            qcMsgChatLog.ChatSendDate = message.SendTime;
            qcMsgChatLog.Sender       = message.MessageFrom.USER_ID;
            qcMsgChatLog.Listener     = message.MessageTo.USER_ID;
            byte[] byteChatImage = null;
            short  shRet         = QcMsgChatAccess.Instance.SaveQCMsgChatLog(qcMsgChatLog, byteChatImage);

            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.ShowError("消息发送失败");
                return;
            }
        }
Пример #9
0
        private void SaveChatPicToDB(MessageInfo message, Bitmap image)
        {
            QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();

            qcMsgChatLog.ChatID          = message.MessageID;
            qcMsgChatLog.ChatContent     = message.MessageContent;
            qcMsgChatLog.ChatSendDate    = message.SendTime;
            qcMsgChatLog.Sender          = message.MessageFrom.USER_ID;
            qcMsgChatLog.Listener        = message.MessageTo.USER_ID;
            qcMsgChatLog.MsgChatDataType = "1";
            byte[] byteChatImage = ImageAccess.Instance.ImageToBuffer(image, ImageFormat.Png);
            short  shRet         = QcMsgChatAccess.Instance.SaveQCMsgChatLog(qcMsgChatLog, byteChatImage);

            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.ShowError("消息发送失败");
                return;
            }
        }
Пример #10
0
        public short UpdateQCMsgChatLog(QcMsgChatLog item)
        {
            string szField = string.Format("{0}={1}"
                                           , SystemData.QCMsgChatTable.IS_READ, item.IsRead ? "1" : "0");
            string szCondition = string.Format("{0}='{1}'"
                                               , SystemData.QCMsgChatTable.CHAT_ID, item.ChatID);
            string szSQL = string.Format(SystemData.SQL.UPDATE, SystemData.DataTable.QC_MSG_CHAT_LOG, szField, szCondition);

            int nCount = 0;

            try
            {
                nCount = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("DBAccess.UpdateQCMsgChatLog", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            return(nCount > 0 ? SystemData.ReturnValue.OK : SystemData.ReturnValue.EXCEPTION);
        }
Пример #11
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            QcMsgChatLog msg = this.dataGridView1.Rows[e.RowIndex].Tag as QcMsgChatLog;

            if (msg == null)
            {
                return;
            }
            QCQuestionChatForm form = new QCQuestionChatForm();

            form.PatientID = msg.PatientID;
            form.VisitID   = msg.VisitID;
            form.Sender    = msg.Listener;//弹出对话框,此处接收者、发送者应互换
            form.Listener  = msg.Sender;
            form.MsgID     = msg.MsgID;
            if (form.ShowDialog() == DialogResult.OK)
            {
                if (this.chkSearch.Checked
                    )
                {
                    this.SearchHistoryMsg();
                }
                else
                {
                    if (MessageHandler.Instance.IsRunning)
                    {
                        MessageHandler.Instance.StopCheckTimer();
                    }
                    MessageHandler.Instance.StartCheckTimer(this);
                }
            }
        }
Пример #12
0
        /// <summary>
        /// 获取质控问题沟通消息列表
        /// </summary>
        /// <param name="szListenserID"></param>
        /// <param name="bIsRead"></param>
        /// <param name="lstQcMsgChatLog"></param>
        /// <returns></returns>
        public short GetQCMsgChatLogList(string szListenser, bool bIsRead, ref List <QcMsgChatLog> lstQcMsgChatLog)
        {
            if (base.MedQCAccess == null)
            {
                return(SystemData.ReturnValue.PARAM_ERROR);
            }

            string szField = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}"
                                           , SystemData.QCMsgChatTable.CHAT_CONTENT
                                           , SystemData.QCMsgChatTable.CHAT_ID
                                           , SystemData.QCMsgChatTable.CHAT_SEND_DATE
                                           , SystemData.QCMsgChatTable.IS_READ
                                           , SystemData.QCMsgChatTable.LISTENER
                                           , SystemData.QCMsgChatTable.PATIENT_ID
                                           , SystemData.QCMsgChatTable.SENDER
                                           , SystemData.QCMsgChatTable.VISIT_ID
                                           , SystemData.QCMsgChatTable.MSG_CHAT_DATA_TYPE
                                           , "MSG_ID"
                                           );
            string szCondition = string.Format(" 1=1  and {0}='{1}' and {2}={3} "
                                               , SystemData.QCMsgChatTable.LISTENER, szListenser
                                               , SystemData.QCMsgChatTable.IS_READ, bIsRead ? "1" : "0"
                                               );

            string szSQL = string.Format(SystemData.SQL.SELECT_DISTINCT_WHERE_ORDER_DESC, szField
                                         , SystemData.DataTable.QC_MSG_CHAT_LOG
                                         , szCondition
                                         , SystemData.QCMsgChatTable.CHAT_SEND_DATE);
            IDataReader dataReader = null;

            try
            {
                dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text);
                if (dataReader == null || dataReader.IsClosed || !dataReader.Read())
                {
                    return(SystemData.ReturnValue.RES_NO_FOUND);
                }
                if (lstQcMsgChatLog == null)
                {
                    lstQcMsgChatLog = new List <QcMsgChatLog>();
                }
                do
                {
                    QcMsgChatLog qcMsgChatLog = new QcMsgChatLog();
                    if (!dataReader.IsDBNull(0))
                    {
                        qcMsgChatLog.ChatContent = dataReader.GetValue(0).ToString();
                    }
                    if (!dataReader.IsDBNull(1))
                    {
                        qcMsgChatLog.ChatID = dataReader.GetString(1);
                    }
                    if (!dataReader.IsDBNull(2))
                    {
                        qcMsgChatLog.ChatSendDate = dataReader.GetDateTime(2);
                    }
                    if (!dataReader.IsDBNull(3))
                    {
                        qcMsgChatLog.IsRead = dataReader.GetValue(3).ToString() == "1" ? true : false;
                    }
                    if (!dataReader.IsDBNull(4))
                    {
                        qcMsgChatLog.Listener = dataReader.GetString(4);
                    }
                    if (!dataReader.IsDBNull(5))
                    {
                        qcMsgChatLog.PatientID = dataReader.GetString(5);
                    }
                    if (!dataReader.IsDBNull(6))
                    {
                        qcMsgChatLog.Sender = dataReader.GetString(6);
                    }
                    if (!dataReader.IsDBNull(7))
                    {
                        qcMsgChatLog.VisitID = dataReader.GetValue(7).ToString();
                    }
                    if (!dataReader.IsDBNull(8))
                    {
                        qcMsgChatLog.MsgChatDataType = dataReader.GetValue(8).ToString();
                    }
                    if (!dataReader.IsDBNull(9))
                    {
                        qcMsgChatLog.MsgID = dataReader.GetString(9);
                    }
                    lstQcMsgChatLog.Add(qcMsgChatLog);
                } while (dataReader.Read());
                return(SystemData.ReturnValue.OK);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("DBAccess.GetQCMsgChatLogList", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return(SystemData.ReturnValue.EXCEPTION);
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                    dataReader = null;
                }
                base.MedQCAccess.CloseConnnection(false);
            }
        }