//private static Common.Contracts.Account convert(Inovix.Service.ConsoleHost.KgbService.Account account) //{ // if (account != null) // { // return new AptService.Account() // { // AccountNumber = account.AccountNumber, // Agency = account.Agency, // Id = account.Id // }; // } // return null; //} //private static Common.Contracts.Customer convert(Inovix.Service.ConsoleHost.KgbService.Customer customer) //{ // if (customer == null) // { // return new AptService.Customer() // { // Cpf = customer.Cpf, // FinanceStatus = customer.FinanceStatus, // Id = customer.Id, // Name = customer.Name, // Phone = customer.Phone // }; // } // return null; //} public static Common.Contracts.Portability SolicitarBilhetePortabilidade(Common.Contracts.Customer customer, Common.Contracts.Account account) { Common.Contracts.Portability p = null; AptService.AptServiceClient service = null; try { service = new AptService.AptServiceClient(); p = service.SolicitarBilhetePortabilidade(customer, account); } catch (Exception) { if (service != null) { service.Abort(); } throw; } finally { if (service != null) { service.Close(); } } return(p); }
static void Main(string[] args) { Console.WriteLine("Digite o cpf para migrar o telefone:"); var cpf = Console.ReadLine(); customer = getCustumer(cpf); Console.WriteLine("Customer name: {0} and telefone {1}", customer.Name, customer.Phone); Console.WriteLine("Validando financeiro"); customer = ObterStatusFinanceiroCliente(cpf); if (customer.FinanceStatus) { Common.Contracts.Account account = ObterDadosConta(customer); Console.WriteLine("Account: {0} , solicitando portabilidade", account.Agency); abrirHost(); bilhete = SolicitarBilhetePortabilidade(customer, account); Console.WriteLine("Recebido Ticket {0}. aguardando resposta anatel", bilhete.Ticket); } else { Console.WriteLine("É necessário atualizar o financeiro."); } Console.ReadKey(); if (host != null) { if (host.State == CommunicationState.Faulted) { host.Abort(); } host.Close(); ((IDisposable)host).Dispose(); } }
public void UpdateCustomer(Customer customer) { var client = new CrmDataServiceChannel(); try { client.UpdateCustomer(customer); client.Close(); } catch (CommunicationException) { client.Abort(); throw; } catch (TimeoutException) { client.Abort(); throw; } catch (Exception) { client.Abort(); throw; } }
public Customer[] GetCustomers() { var client = new CrmDataServiceChannel(); var customers = new Customer[] { }; try { customers = client.GetCustomers(); client.Close(); } catch (CommunicationException) { client.Abort(); throw; } catch (TimeoutException) { client.Abort(); throw; } catch (Exception) { client.Abort(); throw; } return customers; }
public static bool UpdateCustomer(Customer customer) { Customer result = Repository.GetCustomers().FirstOrDefault(c => customer.Cpf == c.Cpf); if (result == null) { return false; } result.PortabilityDate = customer.PortabilityDate; return true; }
public Account ObterDadosConta(Customer customer) { if (customer != null) { var result = Repository.GetCustomers().Where(c => c.Cpf == customer.Cpf); if (result == null || result.Count() == 0) { throw new FaultException<ClientNotFoundException>(new ClientNotFoundException()); } return result.FirstOrDefault().Account; } return null; }
public Issue GetTicketPortabilidade(Customer customer, Account account) { if (customer == null || account == null) { throw new Exception("Customer e Account obrigatórios"); } DateTime portability = DateTime.Now.AddDays(4); Issue issue = new Issue() { Detail = String.Format("Ticket Confirmado para o telefone: {0} , data: {1}", customer.Phone, portability.ToString("dd/MM/yyyy hh:mm")), PortabilityDate = portability, Status = TicketStatus.OK }; return issue; }
private static Common.Contracts.Account ObterDadosConta(Common.Contracts.Customer customer) { Common.Contracts.Account custumer = null; ServiceKGB((service) => { try { custumer = service.ObterDadosConta(customer); } catch (Exception) { Console.WriteLine("Custumer not found"); } }); return(custumer); }
private static Common.Contracts.Customer ObterStatusFinanceiroCliente(string cpf) { Common.Contracts.Customer custumer = null; ServiceKGB((service) => { try { custumer = service.ObterStatusFinanceiroCliente(cpf); } catch (Exception) { Console.WriteLine("Custumer not found"); } }); return(custumer); }
private static Common.Contracts.Customer getCustumer(string cpf) { Common.Contracts.Customer custumer = null; ServiceKGB((service) => { try { custumer = service.GetCustomerByCPF(cpf); } catch (Exception) { Console.WriteLine("Custumer not found"); } }); return(custumer); }
public Portability SolicitarBilhetePortabilidade(Customer customer, Account account) { if (customer != null && account != null) { var result = Repository.GetCustomers().Where(c => c.Cpf == customer.Cpf); if (result == null || result.Count() == 0) { throw new FaultException<ClientNotFoundException>(new ClientNotFoundException()); } string ticket = Guid.NewGuid().ToString(); //wait for anatel response Task.Factory.StartNew(() => { TcpChannel tcpChannel = new TcpChannel(); ChannelServices.RegisterChannel(tcpChannel,false); Type requiredType = typeof(AnatelObject); AnatelObject remoteObject = (AnatelObject)Activator.GetObject(requiredType, "tcp://localhost:9998/AnatelService"); var issue = remoteObject.GetTicketPortabilidade(customer,account); ChannelServices.UnregisterChannel(tcpChannel); //send to Inovix issue.Ticket = new Portability() { Ticket = ticket }; //envio o isso para inovix }); //send wait ticket to Inovix return new Portability { Ticket = ticket }; } return null; }
public void UpdateCustomer(Customer customer) { var originalCustomer = this.customers.Where(c => c.Id.Equals(customer.Id)).SingleOrDefault(); originalCustomer.Name = customer.Name; originalCustomer.Address = customer.Address; originalCustomer.City = customer.City; originalCustomer.Zip = customer.Zip; originalCustomer.State = customer.State; originalCustomer.Country = customer.Country; originalCustomer.Email = customer.Email; originalCustomer.Phone = customer.Phone; originalCustomer.BankingEntity = customer.BankingEntity; this.Persist(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("[{0}] Updated info for customer: {1}", DateTime.Now, customer.Name); Console.ResetColor(); }
public bool UpdateCustomer(Customer customer) { return Repository.UpdateCustomer(customer); }