public ResponseBusinessPartnerRegister RegistrarCliente(RequestBusinessPartnerRegister request) { var responseToken = GenerarToken(); var url = ConfigurationManager.AppSettings["UrlRegistrarCliente"]; var response = Helper.InvocarServicio <ResponseBusinessPartnerRegister>(request, "POST", url, responseToken.access_token); if (response == null) { throw new Exception(string.Format("Problemas con el servicio: {0}", url)); } return(response); }
public string RegistrarClienteTRD(string Ruc, string Cliente) { string Rpta = ""; string RptaValClie = ""; ResponseBusinessPartnerRegister response; RequestBusinessPartnerRegister requestBP; Roles Rol; List <Roles> lstRol; Documents Doc; List <Documents> lstDoc; List <Certificates> lstCerti; try { RptaValClie = da.ValidarCliente(Ruc); if (RptaValClie == "N") { requestBP = new RequestBusinessPartnerRegister(); requestBP.Code = null; requestBP.ParentBusinessPartner = null; requestBP.OrganizationCode = "TRA"; requestBP.ERPCode = Ruc; if (Cliente is null || Cliente.Equals("")) { string rz = da.ObtenerRazonSocialAS400(Ruc); if (rz.Length > 50) { requestBP.Name = rz.Substring(0, 50); } else { requestBP.Name = rz.Trim(); } } else { requestBP.Name = Cliente; } requestBP.RowStatus = true; requestBP.ShortName = null; requestBP.EmailAddress = null; requestBP.TelephoneNumber = null; requestBP.IsCustomer = true; requestBP.IsVendor = false; lstRol = new List <Roles>(); Rol = new Roles(); Rol.Code = "CUS"; Rol.Name = "CLIENTE"; lstRol.Add(Rol); Rol = new Roles(); Rol.Code = "SHI"; Rol.Name = "EXPORTADOR"; lstRol.Add(Rol); Rol = new Roles(); Rol.Code = "CON"; Rol.Name = "CONSIGNATARIO"; lstRol.Add(Rol); Rol = new Roles(); Rol.Code = "NOT"; Rol.Name = "NOTIFICADO"; lstRol.Add(Rol); Rol = new Roles(); Rol.Code = "3PL"; Rol.Name = "OPERADOR LOGÍSTICO"; lstRol.Add(Rol); requestBP.Roles = lstRol; lstDoc = new List <Documents>(); Doc = new Documents(); Doc.DocumentType = "DCI"; Doc.DocumentNumber = Ruc; Doc.StartDate = null; Doc.EndDate = null; lstDoc.Add(Doc); requestBP.Documents = lstDoc; lstCerti = new List <Certificates>(); requestBP.Certificates = lstCerti; response = proxy.RegistrarCliente(requestBP); if (response.isValid == true) { Rpta = "OK"; } else { Rpta = "NO"; } } else { Rpta = "OK"; } }
void invocarServicio() { TransDepotProxy proxy = new TransDepotProxy(); RequestBusinessPartnerRegister request = new RequestBusinessPartnerRegister(); request.OrganizationCode = "TRA"; if (ParentBusinessPartner != null && ParentBusinessPartner.Trim() != "") { request.ParentBusinessPartner = ParentBusinessPartner; } request.ERPCode = ERPCode; request.Name = NameBusinessPartner; if (RowStatus != null && RowStatus.Equals("S")) { request.RowStatus = true; } else { request.RowStatus = false; } if (ShortName != null && ShortName.Trim() != "") { request.ShortName = ShortName; } if (EmailAddress != null && EmailAddress.Trim() != "") { request.EmailAddress = EmailAddress; } request.IsCustomer = true; request.IsVendor = false; if (IsCustomer != null && IsCustomer.Equals("S")) { request.Roles.Add(new Roles() { Code = "CUS", Name = "CLIENTE" }); request.Roles.Add(new Roles() { Code = "SHI", Name = "EXPORTADOR" }); request.Roles.Add(new Roles() { Code = "CON", Name = "CONSIGNATARIO" }); request.Roles.Add(new Roles() { Code = "NOT", Name = "NOTIFICADO" }); request.Roles.Add(new Roles() { Code = "3PL", Name = "OPERADOR LOGÍSTICO" }); } request.Documents.Add(new Documents() { DocumentType = DocumentType, DocumentNumber = DocumentNumber }); ResponseBusinessPartnerRegister resp = new ResponseBusinessPartnerRegister(); resp = proxy.RegistrarCliente(request); if (!resp.isValid) { List <string> listaDestinatarios = new List <string>(); List <string> listaCopia = new List <string>(); List <string> listaCopiaOculta = new List <string>(); string destinatarios = ConfigurationManager.AppSettings["Destinatarios"].ToString(); if (destinatarios != "" && destinatarios.Contains(";")) { var correosDestino = destinatarios.Split(';'); foreach (string item in correosDestino) { listaDestinatarios.Add(item); } } else { listaDestinatarios.Add(destinatarios); } string copia = ConfigurationManager.AppSettings["ConCopia"].ToString(); if (copia != "" && copia.Contains(";")) { var correosCopia = copia.Split(';'); foreach (string item in correosCopia) { listaCopia.Add(item); } } else { listaCopia.Add(copia); } string copiaOculta = ConfigurationManager.AppSettings["CopiaOculta"].ToString(); if (copiaOculta != "" && copiaOculta.Contains(";")) { var correosCopiaOculta = copiaOculta.Split(';'); foreach (string item in correosCopiaOculta) { listaCopiaOculta.Add(item); } } else { listaCopiaOculta.Add(copiaOculta); } new ManejadorCorreos().EnviarCorreo(ConfigurationManager.AppSettings["AsuntoCorreoError"].ToString(), resp.messages[0].message, listaDestinatarios, listaCopia, listaCopiaOculta); MessageBox.Show("Error al registrar cliente", "Mensaje"); } //else //{ // MessageBox.Show("Cliente registrado con éxito", "Mensaje"); //} }