Exemplo n.º 1
0
        public void RegisterProcess(QHMessage msg)
        {
            Chat.RegisterErrorCode ErrorCode = (Chat.RegisterErrorCode)(msg.GetAt((byte)Chat.MsgRegisterAckArg.ErrorCode) as QHNumber).value;
            switch (ErrorCode)
            {
            case Chat.RegisterErrorCode.SUCCESS:
            {
                UserDialogs.Instance.Toast("Bạn đã đăng ký thành công tài khoản");
                // Nếu đăng ký thành công thì gửi bản tin Login lên Server luôn
                if (!PhoneNumber.Equals("") && !PassWord.Equals(""))
                {
                    QHMessage msgLogin = new QHMessage((ushort)Chat.ChatMessage.MSG_LOGIN_REQ);
                    msgLogin.SetAt((byte)Chat.MsgLoginReqArg.PhoneNumber, new QHString(PhoneNumber));
                    msgLogin.SetAt((byte)Chat.MsgLoginReqArg.MD5Password, new QHString(MD5.MD5.GetMd5String(PassWord)));
                    msgLogin.SetAt((byte)Chat.MsgLoginReqArg.DeviceID, CrossDeviceInfo.Current.Id);
                    if (!Services.Service.Instiance().SendMessage(msgLogin))
                    {
                        NotifiDialog.Initiance().DialogErrorInternter();
                    }
                }
                else
                {
                    NotifiDialog.Initiance().DialogErrorNumber();
                }
                break;
            }

            case Chat.RegisterErrorCode.ERR_PHONE_IN_USED:
            {
                Device.BeginInvokeOnMainThread(() =>
                    {
                        NotifiDialog.Initiance().DialogExistPhoneNumber();
                    });
                break;
            }
            }
        }
Exemplo n.º 2
0
        private async Task AddConfirmation()
        {
            ProgressBarActivity(true);
            if (!String.IsNullOrWhiteSpace(NewUser.ID))
            {
                await ExistingUserID(NewUser.ID);
            }

            try
            {
                int numPB = 0, numCP = 0;
                if (String.IsNullOrWhiteSpace(NewUser.ID))
                {
                    throw new AddUserException(1);
                }
                if (!IsValidEmail(NewUser.ID))
                {
                    throw new AddUserException(2);
                }
                if (UserIDExisting == true)
                {
                    throw new AddUserException(3);
                }
                if (String.IsNullOrWhiteSpace(PassWord))
                {
                    throw new AddUserException(4);
                }
                if (String.IsNullOrWhiteSpace(ConfirmPassWord))
                {
                    throw new AddUserException(5);
                }
                if (PassWord.Length < 8)
                {
                    throw new AddUserException(6);
                }
                if (!IsValidPassword(PassWord))
                {
                    throw new AddUserException(7);
                }
                if (!PassWord.Equals(ConfirmPassWord))
                {
                    throw new AddUserException(8);
                }
                if (String.IsNullOrWhiteSpace(NewUser.LastName))
                {
                    throw new AddUserException(9);
                }
                if (String.IsNullOrWhiteSpace(NewUser.FirstName))
                {
                    throw new AddUserException(10);
                }
                if (Birthdate > _today.AddYears(-15))
                {
                    throw new AddUserException(11);
                }
                NewUser.BirthDate = Birthdate.DateTime;
                if (String.IsNullOrWhiteSpace(NewUser.Number))
                {
                    throw new AddressException(1);
                }
                if (!String.IsNullOrWhiteSpace(strPostBox))
                {
                    bool parsed = Int32.TryParse(strPostBox, out numPB);
                    if (!parsed)
                    {
                        throw new AddressException(2);
                    }
                }
                if (String.IsNullOrWhiteSpace(strZipCode))
                {
                    throw new AddressException(3);
                }
                else
                {
                    bool parsed = Int32.TryParse(strZipCode, out numCP);
                    if (!parsed)
                    {
                        throw new AddressException(4);
                    }
                }
                if (String.IsNullOrWhiteSpace(NewUser.Street))
                {
                    throw new AddressException(5);
                }
                if (String.IsNullOrWhiteSpace(NewUser.City))
                {
                    throw new AddressException(6);
                }
                if (String.IsNullOrWhiteSpace(NewUser.Country))
                {
                    throw new AddressException(7);
                }
                if ((numCP < 1000 || numCP >= 10000) && NewUser.Country.Equals("Belgique"))
                {
                    throw new AddressException(8);
                }
                if (String.IsNullOrWhiteSpace(NewUser.Picture))
                {
                    NewUser.Picture = null;
                }
                /**/
                NewUser.PassWord = PassWord;
                /**/
                NewUser.EmailAddress = NewUser.ID;
                NewUser.PostBox      = numPB;
                NewUser.ZipCode      = numCP;

                MessageDialog msgDialog = new MessageDialog("Etes-vous sûr de vouloir poursuivre la création d'un compte utilisateur ?", "Confirmation");

                UICommand okBtn         = new UICommand("Oui");
                okBtn.Invoked = GoNext;
                msgDialog.Commands.Add(okBtn);

                UICommand cancelBtn = new UICommand("Non");
                msgDialog.Commands.Add(cancelBtn);

                await msgDialog.ShowAsync();
            }
            catch (AddUserException addUserEx)
            {
                await DisplayException(addUserEx.ErrorMessage);
            }
            catch (AddressException addressEx)
            {
                await DisplayException(addressEx.ErrorMessage);
            }
            ProgressBarActivity(false);
        }