Пример #1
0
        public void Login(string username, string pwd)
        {
            ServiceLogin.ServiceLoginClient client = new ServiceLogin.ServiceLoginClient();
            client.LoginCompleted += (sender, e) =>
            {
                ServicesEventArgs <bool> arg = new ServicesEventArgs <bool>();

                if (e.Error == null)
                {
                    arg.Result   = e.Result;
                    arg.Succesed = true;
                }
                else
                {
                    arg.Succesed = false;
                    arg.Error    = e.Error;
#if DEBUG
                    arg.Succesed = true;
                    arg.Result   = true;
#endif
                    //写错误日志
                    //.....
                }
                if (LoginCompleted != null)
                {
                    LoginCompleted.Invoke(this, arg);
                }
            };
            client.LoginAsync(username, pwd);
        }
Пример #2
0
        public void GetUserInfo(string userid)
        {
            ServiceLogin.ServiceLoginClient client = new ServiceLogin.ServiceLoginClient();
            client.GetUserInfoCompleted += (sender, e) =>
            {
                ServicesEventArgs <PW.Common.UserInfo> arg = new ServicesEventArgs <PW.Common.UserInfo>();

                if (e.Error == null)
                {
                    if (e.Result != null)
                    {
                        arg.Result = new PW.Common.UserInfo()
                        {
                            fullname = e.Result.fullname, role = e.Result.role, userid = e.Result.userid, username = e.Result.username
                        };
                    }
                    else
                    {
                        arg.Result = null;
                    }

                    arg.Succesed = true;
                }
                else
                {
                    arg.Succesed = false;
                    arg.Error    = e.Error;
                    //写错误日志
                    //.....
                }
                if (GetUserInfoCompleted != null)
                {
                    GetUserInfoCompleted.Invoke(this, arg);
                }
            };
            client.GetUserInfoAsync(userid);
        }