예제 #1
0
        /// <summary>
        /// key盘验证签名者
        /// 适用于选择签名的时候使用
        /// </summary>
        /// <param name="p_strEmployeeID"></param>
        /// <param name="p_strEmployeeName"></param>
        /// <returns></returns>
        private bool m_blnCheckEmployeeSignByKey(string p_strEmployeeID, string p_strEmployeeName)
        {
            try
            {
                //key操作类
                clsDigitalSign objsign = new clsDigitalSign();
                //获取证书
                clsSignCert_VO objCert = new clsSignCert_VO();
                long           lngR    = objsign.GetSpecifyCert(out objCert);
                if (objCert == null)
                {
                    MessageBox.Show("检测不到Key盘。不能继续进行操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                //先验证是否签名者的Key
                if (m_objViewer.m_lsvItemList.SelectedItems[0].SubItems[4].Text.Trim() != objCert.m_strSerialNumber.Trim())
                {
                    MessageBox.Show("检测到key盘证书和指定的签名者不一致,不能通过验证", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                //虚拟签名使弹出密码窗口
                string strContentTemp = null;
                strContentTemp = objsign.sign("1", 0);
                if (strContentTemp == null)
                {
                    MessageBox.Show("key盘校验失败,请确认已插入key盘!", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                //返回
                return(true);
            }
            catch (Exception exp)
            {
                com.digitalwave.Utility.clsLogText objLogger = new com.digitalwave.Utility.clsLogText();
                bool blnRes = objLogger.LogError(exp);
                MessageBox.Show("未能检测到key盘,确认是否插入key盘", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 保存信息
        /// 包括保存前验证,此调用适用还有多签名的表单
        /// </summary>
        /// <param name="p_byeContent">对象字节</param>
        /// <param name="p_strForm">窗体ID</param>
        /// <param name="p_strRecordID">记录ID,通常为住院号+住院时间 || 住院号+记录时间</param>
        /// <returns>返回9不需要电子签名,返回1为成功电子签名,其他均视为失败 返回-1为中止</returns>
        public long CheckSigner(Object p_objContent, clsEmrDigitalSign_VO p_objSign_VO)
        {
            long lngRes = 0;

            #region 验证方式
            if (strReturnSetting != null)
            {
                switch (strReturnSetting)
                {
                case "0":                        //无需验证
                    break;

                case "1":                        //密码验证
//						if(!m_blnCheckEmployeeSignByPwd(m_objViewer.m_lsvItemList.SelectedItems[0].SubItems[0].Text,m_objViewer.m_lsvItemList.SelectedItems[0].SubItems[1].Text))
//							return;
                    break;

                case "2":                        //key盘验证

                    #region 是否检测到key盘
                    clsSignCert_VO objCert = new clsSignCert_VO();
                    clsDigitalSign obj     = new clsDigitalSign();
                    long           lngR    = obj.GetSpecifyCert(out objCert);
                    if (objCert == null)
                    {
                        MessageBox.Show("检测不到Key盘。不能继续进行操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(-1);
                    }
                    #endregion

                    #region 根据配置检查是否要与当前登录用户一致
                    clsSignature_srv objServ =
                        (clsSignature_srv)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsSignature_srv));

                    string strCheckLogin = string.Empty;
                    lngRes = objServ.m_lngGetConfigBySettingID("3007", out strCheckLogin);

                    if (strCheckLogin == "1")
                    {
                        if (com.digitalwave.emr.BEDExplorer.frmHRPExplorer.objpCurrentEmployee.m_strEMPKEY_VCHR != objCert.m_strSerialNumber.Trim())
                        {
                            MessageBox.Show("Key持有人" + objCert.m_strCersName.Trim() + "不是当前登录用户,不能继续操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(-1);
                        }
                    }


                    #endregion

                    #region 检测Key持有者是否在签名集合中
                    //前提一定有签名存在,取值是已做判断
                    bool blnConfirmSign = false;
                    for (int i = 0; i < objSignerArr.Count; i++)
                    {
                        if (((clsEmrEmployeeBase_VO)objSignerArr[i]).m_strEMPKEY_VCHR.Trim() == objCert.m_strSerialNumber.Trim())
                        {
                            blnConfirmSign = true;
                            break;
                        }
                    }
                    if (blnConfirmSign != true)
                    {
                        MessageBox.Show("Key持有人" + objCert.m_strCersName.Trim() + "未在签名集合中,不能继续操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(-1);
                    }
                    #endregion

                    #region 多签名时若要无痕迹修改需要验证所有签名者
                    if (blnMark)
                    {
                        if (objSignerArr.Count > 1)
                        {
                            frmVerifySigners frm = new frmVerifySigners(objSignerArr);
                            if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                            {
                                MessageBox.Show("未能验证所有签名者,不能继续无痕迹修改操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return(-1);
                            }
                        }
                    }
                    #endregion

                    #region 保存签名信息
                    try
                    {
                        if (p_objContent == null)
                        {
                            return(-1);
                        }
                        bool blncheck = false;
                        clsDigitalSign_domain objSvc = new clsDigitalSign_domain();
                        objSvc.m_lngCheckNeedToSign(p_objSign_VO.m_strFORMID_VCHR, out blncheck);
                        if (blncheck)
                        {
                            MemoryStream    ms        = new MemoryStream();
                            BinaryFormatter formatter = new BinaryFormatter();
                            formatter.Serialize(ms, p_objContent);
                            byte[] bys = ms.ToArray();
                            //哈希
                            HashAlgorithm MD5      = HashAlgorithm.Create("MD5");
                            byte[]        Hashbyte = MD5.ComputeHash(bys);

                            //数字签名
                            string strContent = System.Text.Encoding.UTF8.GetString(Hashbyte);
                            string strCode    = obj.sign(strContent, 0);
                            if (strCode == null)
                            {
                                return(-1);
                            }
                            clsEmrDigitalSign_VO objSign = new clsEmrDigitalSign_VO();
                            objSign.m_datSIGNDATE_DAT      = DateTime.Now;
                            objSign.m_bteCONTENT_TXT       = Hashbyte;
                            objSign.m_strDSCONTENT_TXT     = strCode;
                            objSign.m_strSIGNNAME_VCHR     = objCert.m_strCersName;                              //clsEMRLogin.LoginInfo.m_strEmpName;
                            objSign.m_strSIGNIDID_VCHR     = p_objSign_VO.m_strSIGNIDID_VCHR;
                            objSign.m_strFORMID_VCHR       = p_objSign_VO.m_strFORMID_VCHR;
                            objSign.m_strFORMRECORDID_VCHR = p_objSign_VO.m_strFORMRECORDID_VCHR;
                            objSign.m_strRegisterId        = p_objSign_VO.m_strRegisterId;
                            lngRes = objSvc.m_lngAddDigitalSign(objSign);
                        }
                        else
                        {
                            lngRes = 9;
                        }
                    }
                    catch (Exception exp)
                    {
                        //异常
                        com.digitalwave.Utility.clsLogText objLogger = new com.digitalwave.Utility.clsLogText();
                        bool blnRes = objLogger.LogError(exp);
                        lngRes = -1;
                    }
                    #endregion

                    break;

                case "3":                        //指纹验证
//						if (!m_blnCheckEmployeeSignByFinger(m_objViewer.m_lsvItemList.SelectedItems[0].SubItems[0].Text,m_objViewer.m_lsvItemList.SelectedItems[0].SubItems[1].Text))
//							return;
                    break;

                default:
                    break;
                }
            }
            #endregion

            return(lngRes);
        }
예제 #3
0
        /// <summary>
        /// 删除表单验证
        /// </summary>
        /// <param name="p_objSignArr">签名者集合</param>
        /// <param name="p_objOperator">操作者集合</param>
        /// <returns>返回 false=不可以删除 true=可以删除</returns>
        public bool m_mthIsDelete(clsEmrEmployeeBase_VO[] p_objSignArr, clsEmrEmployeeBase_VO p_objOperator)
        {
            bool blnReturn = false;

            if (p_objOperator == null || p_objOperator == null)
            {
                MessageBox.Show("没有获取足够的验证信息,不能继续进行操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(blnReturn);
            }
            try
            {
                //确认方式
                #region 验证方式
                string           strReturnSetting = string.Empty;
                clsSignature_srv objServ          =
                    (clsSignature_srv)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(clsSignature_srv));

                long lngRes = objServ.m_lngGetConfigBySettingID("3003", out strReturnSetting);
                //objServ.Dispose();
                if (strReturnSetting != null)
                {
                    switch (strReturnSetting)
                    {
                    case "0":    //无需验证
                        blnReturn = true;
                        break;

                    case "1":    //密码验证
                        blnReturn = true;
                        break;

                    case "2":    //key盘验证
                        //key操作类
                        clsDigitalSign objsign = new clsDigitalSign();
                        //获取证书
                        clsSignCert_VO objCert = new clsSignCert_VO();
                        long           lngR    = objsign.GetSpecifyCert(out objCert);
                        if (objCert == null)
                        {
                            MessageBox.Show("检测不到Key盘。不能继续进行操作", "iCare Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(false);
                        }
                        //检查当前操作者与key是否一致
                        if (objsign.currentCerts.m_strSerialNumber.Trim() != p_objOperator.m_strEMPKEY_VCHR.Trim())
                        {
                            blnReturn = false;
                            break;
                        }
                        //虚拟签名使弹出密码窗口
                        string strContentTemp = null;
                        strContentTemp = objsign.sign("1", 0);
                        if (strContentTemp == null)
                        {
                            blnReturn = false;
                        }
                        else
                        {
                            blnReturn = true;
                        }
                        break;

                    case "3":    //指纹验证
                        blnReturn = true;
                        break;

                    default:
                        blnReturn = true;
                        break;
                    }
                }
                #endregion
                //验证方式
            }
            catch (Exception exp)
            {
                blnReturn = false;
                com.digitalwave.Utility.clsLogText objLogger = new com.digitalwave.Utility.clsLogText();
                bool blnRes = objLogger.LogError(exp);
            }
            return(blnReturn);
        }