示例#1
0
        void ExecLogin()
        {
            BPMSServiceRef.Binding = EBinding.WsHttpBinding;
            BPMSServiceRef.IP      = "localhost";
            BPMSServiceRef.Port    = 8081;
            RefProvider.Init();
            int             systemId = 0;
            int             userId   = 0;
            string          userName = "";
            List <RoleInfo> roleList = null;

            /// 0登录失败
            /// 1登录成功
            /// 2账号不存在
            /// 3用户已禁用
            /// 4密码不正确
            /// 5当前IP不许登录
            /// 6当前用户没有任何权限
            try
            {
                int rlt = RefProvider.BPMSServiceRefInstance.Login(Consts.ConstValue.SystemCode, Account, Password, out systemId, out userId, out userName, out roleList);
                if (rlt == 0)
                {
                }
            }
            catch (Exception)
            {
                throw;
            }


            this.RaiseClosed();
        }
示例#2
0
        void ExecLogin()
        {
            if (_selectRoleCanLogin)
            {
                RoleInfo role = User.Current.RoleList.First(t => t.ID == _selectedRole.ID);
                User.Current.RoleId   = role.ID;
                User.Current.RoleCode = role.Code;
                User.Current.RoleName = role.Name;
                //选择角色后登录
                User.Current.PurviewDt = RefProvider.BPMSServiceRefInstance.PubGetUserPurviewList(User.Current.SystemId, User.Current.ID, User.Current.ID);
            }
            else
            {
                //直接登录
                #region
                BPMSServiceRef.Binding = EBinding.WsHttpBinding;
                BPMSServiceRef.IP      = IP;
                BPMSServiceRef.Port    = ServicePort;

                RefProvider.Init();
                int             systemId = 0;
                int             userId   = 0;
                string          userName = "";
                List <RoleInfo> roleList = null;
                /// 0登录失败
                /// 1登录成功
                /// 2账号不存在
                /// 3用户已禁用
                /// 4密码不正确
                /// 5当前IP不许登录
                /// 6当前用户没有任何权限
                Result rltModel = new Result();
                int    result   = 0;
                CanLogin = false;
                Action action = new Action(() =>
                {
                    try
                    {
                        result = RefProvider.BPMSServiceRefInstance.Login(Consts.ConstValue.SystemCode, Account, Password, out systemId, out userId, out userName, out roleList);
                        if (result == 1)
                        {
                            User.Current.Credentials = new ClientCredentials()
                            {
                                Account = this.Account, Password = this.Password
                            };
                            User.Current.ID       = userId;
                            User.Current.Name     = userName;
                            User.Current.SystemId = systemId;
                            User.Current.RoleList = roleList;
                        }
                    }
                    catch (Exception ex)
                    {
                        rltModel.Message = ex.Message;
                    }
                });
                action.BeginInvoke(new AsyncCallback((rlt) =>
                {
                    if (rlt.IsCompleted)
                    {
                        CanLogin = true;
                        if (string.IsNullOrEmpty(rltModel.Message))
                        {
                            rltModel.Message = Consts.ReturnCodeMessage.GetMessage(result);
                        }
                        if (result == 1)
                        {
                            rltModel.IsSuccess = true;
                        }
                        else
                        {
                            rltModel.IsSuccess = false;
                        }
                        if (GetResult != null)
                        {
                            GetResult(rltModel);
                        }
                    }
                }), null);
                #endregion
            }
        }