Exemplo n.º 1
0
        private void frmCfg_Load(object sender, EventArgs e)
        {
            try
            {
                foreach (string snme in GetDatabases())
                {
                    cbxServerName.Items.Add(snme);
                }


                int i;

                string strCfgFile = ConfigHelper.CreateConfig(ConfigHelper.GetCfgName());


                _ca = ConfigurationManager.OpenExeConfiguration(strCfgFile);
                bool hasKey = _ca.AppSettings.Settings.AllKeys.Contains("HIS认证服务名称");

                if (cbxServerName.Items.Count <= 0)
                {
                    return;
                }

                if (hasKey)
                {
                    string loginServer = _ca.AppSettings.Settings["HIS认证服务名称"].Value;
                    i = cbxServerName.Items.IndexOf(loginServer);

                    if (i >= 0)
                    {
                        cbxServerName.SelectedIndex = i;
                    }
                }
                else
                {
                    cbxServerName.SelectedIndex = 0;
                    _ca.AppSettings.Settings.Add("HIS认证服务名称", cbxServerName.Text);
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 开始认证
        /// </summary>
        /// <param name="user"></param>
        /// <param name="pwd"></param>
        /// <param name="attachInfo"></param>
        /// <param name="strErr"></param>
        /// <returns></returns>
        public ILoginUser StartVerify(string userAccount, string pwd, out string attachInfo, out string strErr)
        {
            attachInfo = "";
            strErr     = "";

            string verifyHint = "(" + _name + ")";

            string        strCfgFile = ConfigHelper.CreateConfig(ConfigHelper.GetCfgName());
            Configuration ca         = ConfigurationManager.OpenExeConfiguration(strCfgFile);

            bool hasKey = ca.AppSettings.Settings.AllKeys.Contains("HIS认证服务名称");


            if (hasKey == false)
            {
                MessageBox.Show(verifyHint + "未找到HIS认证的服务名称。", "提示");
                return(null);
            }

            //开始进行认证
            string serverName = ca.AppSettings.Settings["HIS认证服务名称"].Value;

            object dbCon = null;

            try
            {
                dbCon = Helper.GetConnection(serverName, pwd, userAccount);
            }
            catch (Exception ex)
            {
                if (ex.Message.ToUpper().IndexOf("ORA-01017") >= 0)
                {
                    MessageBox.Show(verifyHint + "无效的用户或密码,拒绝登录。", "提示");
                    return(null);
                }
                else
                {
                    throw new Exception(verifyHint + "用户认证异常", ex);
                }
            }

            if (dbCon == null)
            {
                MessageBox.Show(verifyHint + "用户认证失败,请联系管理员。", "提示");
                return(null);
            }

            //判断是否绑定本地系统账号
            UserModel    um       = new UserModel(_dbLocal);
            UserInfoData userData = um.GetUserInfoByAccountName(userAccount);

            if (userData == null)
            {
                MessageBox.Show(verifyHint + "当前系统未绑定此用户账号,请联系管理员。", "提示");
                return(null);
            }

            if (userData.用户ID.Equals(UserModel.ADMIN_ID))
            {
                MessageBox.Show(verifyHint + "不能使用管理员账号登录此系统。", "提示");
                return(null);
            }

            UserInfoData userInfo = um.GetUserInfoByAccountName(userAccount);

            if (userInfo == null)
            {
                MessageBox.Show("未获取到对应的用户信息。", "提示");
                return(null);
            }

            UserData loginUser = new UserData();

            loginUser.UserId  = userInfo.用户ID;
            loginUser.Account = userInfo.系统账号;
            loginUser.Name    = userInfo.用户名称;
            loginUser.Level   = userInfo.职称级别;
            loginUser.SignImg = userInfo.签名图片;
            loginUser.Pwd     = pwd;

            loginUser.AssistUserInfo1.Account = userInfo.系统账号;
            loginUser.AssistUserInfo1.Name    = userInfo.用户名称;
            loginUser.AssistUserInfo1.UserId  = userInfo.用户ID;
            loginUser.AssistUserInfo1.SignImg = userInfo.签名图片;

            loginUser.AssistUserInfo2.Account = userInfo.系统账号;
            loginUser.AssistUserInfo2.Name    = userInfo.用户名称;
            loginUser.AssistUserInfo2.UserId  = userInfo.用户ID;
            loginUser.AssistUserInfo2.SignImg = userInfo.签名图片;

            loginUser.AssistUserInfo3.Account = userInfo.系统账号;
            loginUser.AssistUserInfo3.Name    = userInfo.用户名称;
            loginUser.AssistUserInfo3.UserId  = userInfo.用户ID;
            loginUser.AssistUserInfo3.SignImg = userInfo.签名图片;

            //同步认证密码
            userData.账号信息.密码 = UserModel.EncryPwd(pwd);
            um.UpdateUserInfo(userData, null);

            return(loginUser);
        }