protected override async Task <ResponseAppMessanger> GetSender(AccountSend accountSend) { ResponseAppMessanger response = new ResponseAppMessanger { IsAutorize = true }; try { var config = await this.Context.GetConfiguration <ConfigWhatsApp>(ServiceName, accountSend.UserName); SenderWhatsAppMessagesFactory messagesFactory = new SenderWhatsAppMessagesFactory(this.Context); var resConnect = await messagesFactory.ConnectAndLogin(config.Phone, config.Token, accountSend.Name); if (resConnect.IsError) { response.IsError = true; response.Message = resConnect.Message; return(response); } var WhatsAppMessanger = new WhatsAppMessanger(Context, this, resConnect.Result); return(await Task.FromResult(new ResponseAppMessanger { IsAutorize = true, IsError = false, Result = WhatsAppMessanger })); } catch (Exception e) { response.IsError = true; response.Message = e.Message; } return(response); }
protected async override Task <ResponseAppMessanger> GetSender(RegisterSender register) { ResponseAppMessanger response = new ResponseAppMessanger(); try { var mckHttpSend = new MockHttpSend(this.Context, this); response.Result = mckHttpSend; } catch (Exception e) { response.IsError = true; response.Message = e.Message; } return(await Task.FromResult <ResponseAppMessanger>(response)); }
//protected async override Task<ResponseAppMessanger> GetSender(RegisterSender register) //{ // ResponseAppMessanger response = new ResponseAppMessanger(); // try // { // var mckHttpSend = new MockHttpSend(this.Context,this); // response.Result = mckHttpSend; // } // catch (Exception e) // { // response.IsError = true; // response.Message = e.Message; // } // return await Task.FromResult<ResponseAppMessanger>( response); //} protected override async Task <ResponseAppMessanger> GetSender(AccountSend accountSend) { ResponseAppMessanger response = new ResponseAppMessanger { IsAutorize = true }; try { var mckHttpSend = new MockHttpSend(this.Context, this); response.Result = mckHttpSend; } catch (Exception e) { response.IsError = true; response.Message = e.Message; } return(await Task.FromResult <ResponseAppMessanger>(response)); }
//protected override async Task<ResponseAppMessanger> GetSender(RegisterSender register) //{ // ResponseAppMessanger response = new ResponseAppMessanger(); // try // { // var mockSend = new MockTcpSend(Context,this); // response =await mockSend.SetSocketClient(new SignUpSender { UserName= register.Id},register.CanExcute); // return response; // } // catch (Exception e) // { // response.IsError = true; // response.Message = e.Message; // } // return response; //} protected override async Task <ResponseAppMessanger> GetSender(AccountSend accountSend) { ResponseAppMessanger response = new ResponseAppMessanger { IsAutorize = true }; try { var mockSend = new MockTcpSend(Context, this); response = await mockSend.SetSocketClient(new SignUpSender { UserId = accountSend.AccountId }, true); return(response); } catch (Exception e) { response.IsError = true; response.Message = e.Message; } return(response); }
public async Task <ResponseAppMessanger> SetSocketClient(SignUpSender sender, bool canExcute = true) { ResponseAppMessanger response = new ResponseAppMessanger(); response.Result = this; if (_test != null) { return(response); } var authenticationManager = GetAuthenticationManager(); var token = await authenticationManager.GetToken(sender); if (token == null) { response.IsAutorize = false; response.IsError = false; } else { response.IsAutorize = true; SenderMessagesFactory sendFactory = new SenderMessagesFactory(this.Context); var respndFactory = await sendFactory.ConnectAndLogin(sender.UserId, token.Token); if (respndFactory.IsError) { response.IsAutorize = true; response.IsError = true; response.Message = respndFactory.Message; } else { _test = respndFactory.Result; } } return(response); }