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 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); }
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; }
//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); }