コード例 #1
0
    void CreateAccountResponseDo(CreateAccountResponse createAccountResponse)

    {
        switch (createAccountResponse.Reason)
        {
        case CreateAccountResponse.Types.Reason.Ok:
            Debug.Log("创建成功,使用此账号登陆");
            SendLogin();
            break;

        case CreateAccountResponse.Types.Reason.AlreadyExist:
            Debug.Log("此账号已存在,使用账号密码登陆");
            SendLogin();
            break;

        case CreateAccountResponse.Types.Reason.NoGoodPassword:
            Debug.Log("密码不符合格式");
            break;

        case CreateAccountResponse.Types.Reason.Other:
            Debug.Log("未知错误");
            break;

        default:
            Debug.Log("未知错误");
            break;
        }
    }
コード例 #2
0
        public async Task <ActionResult <CreateAccountResponse> > CreateVoucher([FromHeader] string client, [FromRoute] string cpf, [FromBody] CreateAccountRequest request)
        {
            CreateAccountResponse response = new CreateAccountResponse();
            string responseCode            = $"CREATE_VOUCHER_{client}_{cpf}";

            try
            {
                var factory = WalletFactory.Instance.GetCreateAccount(_configuration);
                var account = await factory.Create(client, cpf,
                                                   request.AccountID, request.LocationID,
                                                   request.InitialValue, request.ExpiresOn,
                                                   1, request.ExtensionAttributes);

                var dto = new NewAccountDTO
                {
                    AccountID     = account.Item1,
                    TransactionID = account.Item2
                };
                response.StatusCode = "200";
                response.Data       = dto;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                response.StatusCode = "500";
                response.Messages.Add(ResponseMessage.Create(ex, responseCode));
                return(StatusCode(500, response));
            }
        }
コード例 #3
0
        /**
         * Coutries Supported:
         *     AU - Australia
         *     CA - Canada
         *     CY - Cyprus
         *     CZ - Czech Republic
         *     DK - Denmark
         *     EE - Estonia
         *     FI - Finland
         *     FR - France
         *     DE - Germany
         *     GR - Greece
         *     HU - Hungary
         *     IT - Italy
         *     LV - Latvia
         *     LT - Lithuania
         *     LU - Luxembourg
         *     MT - Malta
         *     NL - Netherlands
         *     PL - Poland
         *     PT - Portugal
         *     SK - Slovak Republic
         *     SI - Slovenia
         *     ES - Spain
         *     SE - Sweden
         *     UK - United Kingdom
         *     US - United States
         *
         *
         *
         *
         *
         */
        public CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest, string apiUserName)
        {
            string  response = Call("CreateAccount", createAccountRequest.ToNVPString(""), apiUserName);
            NVPUtil util     = new NVPUtil();

            return(CreateAccountResponse.CreateInstance(util.ParseNVPString(response), "", -1));
        }
コード例 #4
0
        public async ValueTask <CreateAccountResponse> CadastrarNovaContaAsync(CreateAccountRequest request, Guid correlationId, CancellationToken ct)
        {
            CreateAccountResponse response;

            string requestUri  = $"{_urlBaseBolao}/account/signup";
            string requestJson = JsonConvert.SerializeObject(request);
            var    content     = new StringContent(requestJson, Encoding.UTF8, "application/json");

            var httpResponse = await _bolaoHttpClient.PostAsync
                               (
                requestUri,
                content,
                correlationId,
                ct
                               );

            var jsonResponse = await httpResponse.Content.ReadAsStringAsync();

            if (httpResponse.StatusCode != HttpStatusCode.OK)
            {
                var errorsResponse = JsonConvert.DeserializeObject <IList <ErrorResponse> >(jsonResponse);
                response = new CreateAccountResponse();
                response.SetErrors(errorsResponse);
            }
            else
            {
                response = JsonConvert.DeserializeObject <CreateAccountResponse>(jsonResponse);
            }

            return(response);
        }
コード例 #5
0
ファイル: UnitTests.cs プロジェクト: atulsc2010/user-api
        public async Task CreateAccountCommand_DoesNot_create_account_when_Income_threshold_is_not_met()
        {
            //Arrange
            var userId  = Guid.NewGuid();
            var request = new CreateAccountRequest {
                UserId = userId
            };
            var response = new CreateAccountResponse();

            using (var db = MockDbContext())
            {
                db.Users.RemoveRange(db.Users);
                db.SaveChanges();

                db.Users.Add(new User {
                    Id = userId, Name = "Tester1", Email = "*****@*****.**", Salary = 2000, Expenses = 1500
                });
                db.SaveChanges();

                var command = new CreateAccountCommand(request);
                var handler = new CreateAccountCommandHandler(db);

                //Act
                response = await handler.Handle(command, CancellationToken.None);
            }

            //Assert
            response.Status.Should().Contain("Income");
            response.Id.Should().BeEmpty();
        }
コード例 #6
0
ファイル: UnitTests.cs プロジェクト: atulsc2010/user-api
        public async Task CreateAccountCommand_DoesNot_create_account_when_User_notfound()
        {
            //Arrange
            var userId  = Guid.NewGuid();
            var request = new CreateAccountRequest {
                UserId = userId
            };
            var response = new CreateAccountResponse();

            using (var db = MockDbContext())
            {
                db.Users.RemoveRange(db.Users);
                db.SaveChanges();

                var command = new CreateAccountCommand(request);
                var handler = new CreateAccountCommandHandler(db);

                //Act
                response = await handler.Handle(command, CancellationToken.None);
            }

            //Assert
            response.Status.Should().Contain("not be created");
            response.Id.Should().BeEmpty();
        }
コード例 #7
0
        public void AccountCreateAccountResponseFromJson()
        {
            CreateAccountResponse response = CreateAccountResponse.FromJson(@"{""api_key"":""a123afdaf23fa231245fadcbbb"",""password"":""1234""}");

            Assert.AreEqual("a123afdaf23fa231245fadcbbb", response.ApiKey);
            Assert.AreEqual("1234", response.Password);
        }
コード例 #8
0
        public void MarketPayAccountCreatedNotificationTest()
        {
            string json = GetFileContents("Mocks/marketpay/notification/account-created-success.json");
            NotificationHandler       notificationHandler = new NotificationHandler();
            IGenericNotification      notificationMessage = notificationHandler.HandleMarketpayNotificationJson(json);
            AccountCreateNotification accountCreateNotificationMessage = (AccountCreateNotification)notificationMessage;

            Assert.AreEqual("ACCOUNT_CREATED", accountCreateNotificationMessage.EventType);
            Assert.AreEqual("000", accountCreateNotificationMessage.Error.ErrorCode);
            Assert.AreEqual("test error message", accountCreateNotificationMessage.Error.Message);
            Assert.IsNotNull(accountCreateNotificationMessage.Content);

            CreateAccountResponse content = accountCreateNotificationMessage.Content;

            Assert.AreEqual("TestAccountHolder", content.AccountHolderCode);
            Assert.AreEqual("AC0000000001", content.AccountCode);
            Assert.AreEqual("account description", content.Description);
            Assert.AreEqual("MetaValue", content.Metadata["MetaKey"]);
            Assert.AreEqual(CreateAccountResponse.StatusEnum.Active, content.Status);

            PayoutScheduleResponse payoutSchedule = content.PayoutSchedule;

            Assert.AreEqual(PayoutScheduleResponse.ScheduleEnum.DAILY, payoutSchedule.Schedule);
            Assert.AreEqual(1, content.InvalidFields.Count);

            ErrorFieldType errorFieldType = content.InvalidFields[0];

            Assert.AreEqual(1, (long)errorFieldType.ErrorCode);
            Assert.AreEqual("Field is missing", errorFieldType.ErrorDescription);
            Assert.AreEqual("AccountHolderDetails.BusinessDetails.Shareholders.unknown", errorFieldType.FieldType.Field);
            Assert.AreEqual(FieldType.FieldNameEnum.Unknown, errorFieldType.FieldType.FieldName);
            Assert.AreEqual("SH00001", errorFieldType.FieldType.ShareholderCode);
        }
コード例 #9
0
        public CreateAccountResponse CreateAccount(CreateAccountRequest request)
        {
            var response = new CreateAccountResponse();

            try
            {
                var propertyValues = new
                {
                    Email = request.Email
                };

                response.ActivateAccountToken = WebSecurity.CreateUserAndAccount(request.UserName, request.Password, propertyValues, requireConfirmationToken: request.RequireActivation);
                response.Success = true;
            }
            // https://msdn.microsoft.com/en-us/library/system.web.security.membershipcreateuserexception.statuscode(v=vs.110).aspx
            catch (MembershipCreateUserException ex)
            {
                response.Message = this.GetErrorMessage(ex.StatusCode);
            }
            catch (Exception ex)
            {
                this.exceptionHandler.HandleException(ex);
                response.Message = Resources.Common.InternalServerError;
            }

            return(response);
        }
コード例 #10
0
    public void CreatePremierAccount()
    {
        CreateAccountSample   sample = new CreateAccountSample();
        CreateAccountRequest  requestCreateAccount  = sample.CreatePremierAccount();
        CreateAccountResponse responseCreateAccount = sample.CreateAccountAPIOperations(requestCreateAccount);

        Assert.AreEqual(responseCreateAccount.responseEnvelope.ack.ToString().Trim().ToUpper(), "SUCCESS");
    }
コード例 #11
0
        public static CreateAccountResponse Unmarshall(UnmarshallerContext context)
        {
            CreateAccountResponse createAccountResponse = new CreateAccountResponse();

            createAccountResponse.HttpResponse = context.HttpResponse;
            createAccountResponse.RequestId    = context.StringValue("CreateAccount.RequestId");

            return(createAccountResponse);
        }
        public static CreateAccountResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateAccountResponse createAccountResponse = new CreateAccountResponse();

            createAccountResponse.HttpResponse = _ctx.HttpResponse;
            createAccountResponse.RequestId    = _ctx.StringValue("CreateAccount.RequestId");
            createAccountResponse.Code         = _ctx.IntegerValue("CreateAccount.Code");
            createAccountResponse.ErrMsg       = _ctx.StringValue("CreateAccount.ErrMsg");

            return(createAccountResponse);
        }
        public static CreateAccountResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateAccountResponse createAccountResponse = new CreateAccountResponse();

            createAccountResponse.HttpResponse = _ctx.HttpResponse;
            createAccountResponse.RequestId    = _ctx.StringValue("CreateAccount.RequestId");
            createAccountResponse.Success      = _ctx.BooleanValue("CreateAccount.Success");
            createAccountResponse.Message      = _ctx.StringValue("CreateAccount.Message");

            return(createAccountResponse);
        }
        public static CreateAccountResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateAccountResponse createAccountResponse = new CreateAccountResponse();

            createAccountResponse.HttpResponse = _ctx.HttpResponse;
            createAccountResponse.RequestId    = _ctx.StringValue("CreateAccount.RequestId");
            createAccountResponse.DBClusterId  = _ctx.StringValue("CreateAccount.DBClusterId");
            createAccountResponse.TaskId       = _ctx.IntegerValue("CreateAccount.TaskId");

            return(createAccountResponse);
        }
コード例 #15
0
ファイル: AccountController.cs プロジェクト: lecogrunge/Bolao
        public async Task <IActionResult> Signup(CreateAccountRequest signup)
        {
            CreateAccountResponse response = await _accountService.CreateAccountAsync(signup);

            if (response.IsValid())
            {
                return(Ok(response));
            }

            return(BadRequest(response.GetErrors()));
        }
コード例 #16
0
        public static CreateAccountResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateAccountResponse createAccountResponse = new CreateAccountResponse();

            createAccountResponse.HttpResponse = _ctx.HttpResponse;
            createAccountResponse.RequestId    = _ctx.StringValue("CreateAccount.RequestId");
            createAccountResponse.InstanceId   = _ctx.StringValue("CreateAccount.InstanceId");
            createAccountResponse.AcountName   = _ctx.StringValue("CreateAccount.AcountName");

            return(createAccountResponse);
        }
コード例 #17
0
        public CreateAccountResponse CreateAccount(CreateAccountRequest request)
        {
            var accountHolder = request.AccountHolder;
            var isCreated     = _accountUseCase.CreateAccount(accountHolder);
            var response      = new CreateAccountResponse()
            {
                IsCreated = isCreated
            };

            return(response);
        }
コード例 #18
0
    // # CreateAccount API operations
    // The CreateAccount API operations enable you to create a PayPal account on behalf of a third party and download the SDK [here](https://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index)
    public CreateAccountResponse CreateAccountAPIOperations(CreateAccountRequest createAccountRequest)
    {
        // Create the CreateAccountResponse object
        CreateAccountResponse responseCreateAccount = new CreateAccountResponse();

        try
        {
            // Create the AdaptiveAccounts service object to make the API call
            AdaptiveAccountsService service = new AdaptiveAccountsService();

            // # API call
            // Invoke the CreateAccount method in service wrapper object
            responseCreateAccount = service.CreateAccount(createAccountRequest);

            if (responseCreateAccount != null)
            {
                // Response envelope acknowledgement
                string acknowledgement = "CreateAccount API operation - " + createAccountRequest.accountType;
                acknowledgement += " - " + responseCreateAccount.responseEnvelope.ack.ToString();
                logger.Info(acknowledgement + "\n");
                Console.WriteLine(acknowledgement + "\n");

                // # Success values
                if (responseCreateAccount.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    logger.Info("Create Account Key : " + responseCreateAccount.createAccountKey + "\n");
                    Console.WriteLine("Create Account Key : " + responseCreateAccount.createAccountKey + "\n");
                    // Redirection to PayPal
                    // The user is redirected to PayPal to enter password for the created account
                    // Set the redirection URL in responseCreateAccount.redirectURL
                    // Using this URL the user is redirected to PayPal
                }
                // # Error Values
                else
                {
                    List <ErrorData> errorMessages = responseCreateAccount.error;
                    foreach (ErrorData error in errorMessages)
                    {
                        logger.Debug("API Error Message : " + error.message);
                        Console.WriteLine("API Error Message : " + error.message + "\n");
                    }
                }
            }
        }
        // # Exception log
        catch (System.Exception ex)
        {
            // Log the exception message
            logger.Debug("Error Message : " + ex.Message);
            Console.WriteLine("Error Message : " + ex.Message);
        }

        return(responseCreateAccount);
    }
コード例 #19
0
        /// <summary>
        /// Coutries Supported:
        /// AU - Australia
        /// CA - Canada
        /// CY -
        /// Cyprus
        /// CZ - Czech Republic
        /// DK - Denmark
        /// EE - Estonia
        /// FI - Finland
        /// FR -
        /// France
        /// DE - Germany
        /// GR - Greece
        /// HU - Hungary
        /// IT - Italy
        /// LV - Latvia
        /// LT -
        /// Lithuania
        /// LU - Luxembourg
        /// MT - Malta
        /// NL - Netherlands
        /// PL - Poland
        /// PT -
        /// Portugal
        /// SK - Slovak Republic
        /// SI - Slovenia
        /// ES - Spain
        /// SE - Sweden
        /// UK -
        /// United Kingdom
        /// US - United States
        ///
        ///
        ///
        ///
        ///
        /// </summary>
        ///<param name="createAccountRequest"></param>
        ///<param name="apiUserName">API Username that you want to authenticate this call against. This username and the corresponding 3-token/certificate credentials must be available in Web.Config/App.Config</param>
        public CreateAccountResponse CreateAccount(CreateAccountRequest createAccountRequest, string apiUserName)
        {
            IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, createAccountRequest.ToNVPString(string.Empty), ServiceName, "CreateAccount", apiUserName, getAccessToken(), getAccessTokenSecret());

            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName    = SDKName;
            ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion;
            ((PlatformAPICallPreHandler)apiCallPreHandler).PortName   = "AdaptiveAccounts";

            NVPUtil util = new NVPUtil();

            return(CreateAccountResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1));
        }
コード例 #20
0
        public ResponseBase Any(CreateAccount request)
        {
            _logger.Log(EErrorType.Info, " ****** Call start: CreateAccount");
            CreateAccountResponse response = new CreateAccountResponse();

            try
            {
                GetUserAccountInfoParams accParams = new GetUserAccountInfoParams();
                accParams.Email = request.Email;

                GetUserAccountInfoResult accResult = _dal.GetUserAccountInfo(accParams);
                if (accResult == null)
                {
                    // creating account
                    CreateUpdateUserAccountParams createParams = new CreateUpdateUserAccountParams();
                    createParams.Name           = request.Name;
                    createParams.Email          = request.Email;
                    createParams.AccountKey     = EncodeUtils.CreateAccountKey();
                    createParams.PwdHash        = EncodeUtils.GetPasswordHash(request.Pwd);
                    createParams.ActivationCode = EncodeUtils.CreateActivationCode();
                    createParams.State          = "Pending"; // TODO; change to consts

                    _dal.CreateUserAccount(createParams);

                    SendMailResponse mailerResponse = SendAccountConfirmEmail(createParams.Email, createParams.AccountKey, createParams.Name);

                    response.Payload.AccountKey = createParams.AccountKey;
                    response.Success            = true;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add(new Error()
                    {
                        Code = EErrorCodes.UserAccountExists, Type = EErrorType.Error, Message = "User with specified data already exists"
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex);
                response.Success = false;
                response.Errors.Add(new Error()
                {
                    Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unexpected error: {0}", ex.Message)
                });
            }

            _logger.Log(EErrorType.Info, " ****** Call end: CreateAccount");

            return(response);
        }
コード例 #21
0
        public void CreateUserAccount_Success(string name)
        {
            RunInitSql(name, "ConnectionStringAccounts");

            CreateAccount request = PrepareRequest <CreateAccount>(name);

            CreateAccountResponse response = Post <CreateAccount, CreateAccountResponse>("CreateAccount", request);

            RunFinalizeSql(name, "ConnectionStringAccounts");

            Assert.AreEqual(response.Success, true, "CreateAccount call failed");
            Assert.IsNotEmpty(response.Payload.AccountKey, "AccountKey is empty");
        }
コード例 #22
0
        public override async Task <CreateAccountResponse> CreateAccount(CreateAccountRequest createAccountRequest, ServerCallContext context)
        {
            Log.Information("CreateAccount called via gRPC remote service {@createAccountRequest}", createAccountRequest);

            //Use AutoMapper instance to transform GrpcRequest into MediatR Request (Configured in Startup)
            var createAccountCommand = _mapper.Map <CreateAccountCommand>(createAccountRequest);

            var result = await _mediator.Send(createAccountCommand);

            //Use AutoMapper instance to transform CommandResponse into GrpcResponse (Configured in Startup)
            CreateAccountResponse createAccountResponse = _mapper.Map <CreateAccountResponse>(result);

            return(createAccountResponse);
        }
コード例 #23
0
        public async System.Threading.Tasks.Task CreateOnlineAccountAsync()
        {
            var currAccount = Account;

            string email = Email;

            try
            {
                _response = await WebHelper.Download <CreateAccountRequest, CreateAccountResponse>(
                    Website.URL + "createaccountmodern",
                    new CreateAccountRequest()
                {
                    Username  = currAccount.Username,
                    Password  = currAccount.LocalToken,
                    Email     = email,
                    AddDevice = true
                }, Website.ApiKey);

                if (_response.Error != null)
                {
                    TelemetryExtension.Current?.TrackEvent("Error_ConvertToOnline", new Dictionary <string, string>()
                    {
                        { "Error", _response.Error }
                    });

                    Error = _response.Error;
                }

                else
                {
                    if (_response.ExistsButCredentialsMatched)
                    {
                        ShowConfirmMergeExisting = true;
                        return;
                    }

                    await finishConvertingToOnline(currAccount);

                    RemoveViewModel();
                    return;
                }

                return;
            }

            catch { }

            Error = PowerPlannerResources.GetString("Settings_ConvertToOnline_Errors_FailedCreateOnline");
        }
コード例 #24
0
        public void CreateUserAccount_AlreadyExists(string name)
        {
            RunInitSql(name, "ConnectionStringAccounts");

            CreateAccount request = PrepareRequest <CreateAccount>(name);

            CreateAccountResponse response = Post <CreateAccount, CreateAccountResponse>("CreateAccount", request);

            RunFinalizeSql(name, "ConnectionStringAccounts");

            Assert.AreEqual(response.Success, false, "User with duplicate name was successfully created");
            Assert.IsNotEmpty(response.Errors, "Error was not returned");
            Assert.AreEqual(response.Errors[0].Code, Interfaces.EErrorCodes.UserAccountExists, "Incorrect error code returned");
            Assert.IsTrue(string.IsNullOrEmpty(response.Payload.AccountKey), "AccountKey is not empty");
        }
コード例 #25
0
        public async Task <CreateAccountResponse> CreateAccountAsync(CreateAccountRequest request)
        {
            CreateAccountResponse response = new CreateAccountResponse();

            // E-mail validation
            Email            email          = new Email(request.Email);
            EmailValidator   emailValidator = new EmailValidator();
            ValidationResult emailResult    = await emailValidator.ValidateAsync(email);

            if (!emailResult.IsValid)
            {
                response.AddErrorValidationResult(emailResult);
                return(response);
            }

            bool emailExiste = await _unitOfWork.UserRepository.IsEmailExistsAsync(request.Email);

            if (emailExiste)
            {
                response.SetError(new ErrorResponse("Email", Msg.EmailExists));
                return(response);
            }

            // User validation
            User             user          = new User(request.Name, email, request.Password);
            UserValidator    userValidator = new UserValidator();
            ValidationResult userResult    = await userValidator.ValidateAsync(user);

            if (!userResult.IsValid)
            {
                response.AddErrorValidationResult(userResult);
                return(response);
            }

            // Crypt
            user.CryptPassword(user.Password);

            // Persistence
            await _unitOfWork.UserRepository.CreateAsync(user);

            await _unitOfWork.SaveAsync();

            // Send mail
            //emailService.SendEmailNewUser(user.Email.EmailAddress, user.UserSecurity.TokenCreateConfirmed, user.FisrtName);

            response.IdUser = user.UserId;
            return(response);
        }
コード例 #26
0
ファイル: AccountService.cs プロジェクト: huyle0110/LeStore
        public CreateAccountResponse CreateAccount(CreateAccountRequest request)
        {
            CreateAccountResponse res = new CreateAccountResponse();

            res = dao.CreateAccount(new CreateAccountRequest()
            {
                AccountName = request.AccountName,
                Password    = Securities.SHA1(request.Password),
                AccountType = request.AccountType,
                Address     = request.Address,
                DOB         = request.DOB,
                IDNumber    = request.IDNumber,
                PhoneNumber = request.PhoneNumber,
                Status      = request.Status
            });
            return(res);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateAccountResponse response = new CreateAccountResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("CreateAccountStatus", targetDepth))
                {
                    var unmarshaller = CreateAccountStatusUnmarshaller.Instance;
                    response.CreateAccountStatus = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
コード例 #28
0
        private void OnCreateAccountResponse(CreateAccountResponse response, ErrorResponse error)
        {
            if (error == null)
            {
                // Success
                InfoDialog.Create("Check your email!",
                                  "Thanks for signing up!\n\nA confirmation email has been sent."
                                  + " Please click the link in the email to activate your account.", OnClick_Close);
            }
            else
            {
                // Error occurred
                m_txtError.text = error.errorMessage;

                m_CanvasGroup.interactable = true;

                Debug.Log(error.ToDeveloperMessage(true));
            }
        }
コード例 #29
0
        private void checkedAndCreateNBS()
        {
            if (this.accountService == null)
            {
                return;
            }

            try
            {
                string acid = accountService.GetAccountHID();
                if (String.IsNullOrEmpty(acid))
                {
                    //bool cr = this.accountService.CreateAccount("123456");
                    var accountTask = new AccountTask.AccountTaskClient(GrpcBase.Channel);

                    CreateAccountResponse res = accountTask.CreateAccount(new CreateAccountRequest {
                        Password = "******"
                    });

                    if (String.IsNullOrEmpty(res.Message))
                    {
                        AppState.Instance.CID         = this.accountService.GetAccountHID();
                        AppState.Instance.RPC_RUNNING = true;
                    }
                    else
                    {
                        //为创建成功
                        throw new Exception("Create Account Error.");
                    }
                }
                AppState.Instance.CID         = acid;
                AppState.Instance.RPC_RUNNING = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("====================>>>Grpc error:" + e.Message);
            }
            finally
            {
                //
            }
        }
コード例 #30
0
ファイル: UMController.cs プロジェクト: herokumx/wimsite
        public HttpResponseMessage CreateAccount([FromBody] LoginRequest pLoginRequest)
        {
            Logger.Debug("Inside UMController- Create Account");
            //Logger.Debug("Request: " + new JavaScriptSerializer().Serialize(pLoginRequest));
            CreateAccountResponse CreateAccountResponse = new CreateAccountResponse();
            ErrorResponse         error = new ErrorResponse();
            var response = new Dictionary <string, object>();

            try
            {
                string[] lCred = Encoding.UTF8.GetString(Convert.FromBase64String(pLoginRequest.Cred)).Split(':');
                if (lCred.Count() > 1)
                {
                    pLoginRequest.UserName = lCred[0];
                    pLoginRequest.Password = lCred[1];
                }
                CreateAccountResponse = _IUMServer.CreateAccount(pLoginRequest);
                if (CreateAccountResponse != null)
                {
                    //Logger.Debug("Response: " + new JavaScriptSerializer().Serialize(CreateAccountResponse));
                    response.Add("CreateAccountResponse", CreateAccountResponse);
                    return(Request.CreateResponse(HttpStatusCode.Created, response));
                }
                else
                {
                    error.ErrorCode    = HttpStatusCode.Conflict;
                    error.ErrorMessage = "Unable to create account or account already exists";
                    response.Add("ErrorResponse", error);
                    return(Request.CreateResponse(HttpStatusCode.Conflict, response));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                error.ErrorCode    = HttpStatusCode.InternalServerError;
                error.ErrorMessage = "Failure";
                response.Add("ErrorResponse", error);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }
コード例 #31
0
 /// <summary>
 /// Utility function to print response data to the console.
 /// </summary>
 /// <param name="response">
 /// The CreateAccountResponse to be printed.<see cref="CreateAccountResponse"/>
 /// </param>
 public void PrintResponse(CreateAccountResponse response)
 {
     PrintResponse(response.Result, response.RequestErrors);
     if(response.Result.Equals(Result.REQUEST_SUCCESSFUL)) {
         Console.WriteLine("Account Id: " + response.Account.Id);
         Console.WriteLine("Account API Key: " + response.Account.ApiKey);
     }
 }
コード例 #32
0
        private void CreateAccountResponseHandler(CreateAccountResponse response)
        {
            if (response.Result == false) return;

            // Open the requested account
            _tradingService.OpenNewAccountAsync(response.AccountName);
        }
コード例 #33
0
 public CreateAccountResponse CreateAccount(LoginRequest pLoginRequest)
 {
     CreateAccountResponse CreateAccountResponse = new CreateAccountResponse();
     IUserRepository _IUserRepository;
     _IUserRepository = new UserRepository(new WorkersInMotionDB());
     IGlobalUserRepository _IGlobalUserRepository;
     _IGlobalUserRepository = new GlobalUserRepository(new WorkersInMotionDB());
     IUserProfileRepository _IUserProfileRepository;
     _IUserProfileRepository = new UserProfileRepository(new WorkersInMotionDB());
     int lRetVal = _IUserRepository.CheckUserName(pLoginRequest.UserName);
     if (lRetVal == 0)
     {
         GlobalUser _globalUser = new GlobalUser();
         _globalUser.UserGUID = Guid.NewGuid();
         _globalUser.UserName = pLoginRequest.UserName;
         _globalUser.Password = pLoginRequest.Password;
         _globalUser.Role_Id = _IGlobalUserRepository.GetRoleID("IND_C");
         _globalUser.IsActive = true;
         _globalUser.IsDelete = false;
         _globalUser.CreateDate = DateTime.UtcNow;
         _globalUser.CreateBy = _globalUser.UserGUID;
         _globalUser.LastModifiedDate = DateTime.UtcNow;
         _globalUser.LastModifiedBy = _globalUser.UserGUID;
         int result = _IGlobalUserRepository.InsertGlobalUser(_globalUser);
         //int result = _IGlobalUserRepository.Save();
         if (result > 0)
         {
             UserProfile _userProfile = new UserProfile();
             _userProfile.ProfileGUID = Guid.NewGuid();
             _userProfile.UserGUID = _globalUser.UserGUID;
             _userProfile.FirstName = _globalUser.UserName;
             _userProfile.LastModifiedDate = DateTime.UtcNow;
             _userProfile.LastModifiedBy = _globalUser.UserGUID;
             int resprofileInsert = _IUserProfileRepository.InsertUserProfile(_userProfile);
             //int resprofileInsert = _IUserProfileRepository.Save();
             if (resprofileInsert > 0)
             {
                 CreateAccountResponse.Role = 2;
                 CreateAccountResponse.UserGUID = _userProfile.UserGUID.ToString();
             }
             else
             {
                 _IGlobalUserRepository.DeleteGlobalUser(_globalUser.UserGUID);
                 //_IGlobalUserRepository.Save();
                 CreateAccountResponse = null;
             }
         }
         else
         {
             CreateAccountResponse = null;
         }
         return CreateAccountResponse;
     }
     else
     {
         return null;
     }
 }
コード例 #34
0
        public CreateAccountResponse CreateAccount(CreateAccountRequest request)
        {
            var response = new CreateAccountResponse();

            try
            {
                var propertyValues = new
                {
                    Email = request.Email
                };

                response.ActivateAccountToken = WebSecurity.CreateUserAndAccount(request.UserName, request.Password, propertyValues, requireConfirmationToken: request.RequireActivation);
                response.Status = StatusCode.OK;
            }
            // https://msdn.microsoft.com/en-us/library/system.web.security.membershipcreateuserexception.statuscode(v=vs.110).aspx
            catch (MembershipCreateUserException ex)
            {
                response.Status = StatusCode.BadRequest;
                response.CreateAccountStatus = this.MapCreateAccountStatus(ex.StatusCode);
            }
            catch (Exception ex)
            {
                response.Status = StatusCode.InternalServerError;
                this.exceptionHandler.HandleException(ex);
            }

            return response;
        }