private void Button_Click(object sender, RoutedEventArgs e) { cancelar = false; if (txNombre.Text == "" || txProfesion.Text == "") { MessageBox.Show("Le faltan datos"); return; } string nombre = txNombre.Text; string profesion = txProfesion.Text; if (nombre.Count() > 75 || profesion.Count() > 75) { MessageBox.Show("Exceso de Caracteres"); return; } Certificacion certificacion = new Certificacion(); id = certificacion.crear(new TC_Certificacion { solicitante = nombre, profesion = profesion, idSolicitud = idSolicitud, fecha = DateTime.Today }); this.Close(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CertificacionDescripcion,Duracion,Anio,UnidadTiempo")] Certificacion certificacion) { if (id != certificacion.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(certificacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CertificacionExists(certificacion.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(certificacion)); }
private void especial_click(object sebder, RoutedEventArgs e) { scrollBackground.Visibility = Visibility.Collapsed; if (this.contenido.Children.Count > 0) { var a = MessageBox.Show("Esta cambiando de formulario", "Alerta", MessageBoxButton.OKCancel); if (a == MessageBoxResult.OK) { if (reporteAdministrador) { this.menu.Items.Clear(); menuAdministrador(); } this.contenido.Children.Clear(); var reportes = new Certificacion() { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch }; this.contenido.Children.Add(reportes); } } else { this.contenido.Children.Clear(); var reportes = new Certificacion() { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch }; this.contenido.Children.Add(reportes); } }
public IHttpActionResult UpdateCertificacion(Certificacion certificacion) { _context.Entry(certificacion).State = EntityState.Modified; _context.SaveChanges(); return(Ok(certificacion)); }
public IHttpActionResult AddCertificacion(Certificacion certificacion) { certificacion.Id = Guid.NewGuid(); _context.Certificaciones.Add(certificacion); _context.SaveChanges(); return(Ok(certificacion)); }
public async Task <IActionResult> Create([Bind("Id,CertificacionDescripcion,Duracion,Anio,UnidadTiempo")] Certificacion certificacion) { if (ModelState.IsValid) { _context.Add(certificacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(certificacion)); }
/// <summary> /// Crea un nuevo registro de Certificacion /// </summary> /// <param name="Certificacion">objeto tipo Certificacion</param> /// <returns></returns> public async Task Create(Certificacion Certificacion) { try { _ctx.Certificacion.Add(Certificacion); await _ctx.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public int UpdateCertificacion(Certificacion item, String ip) { try { _context.Certificacions.Update(item); procLog.AddLog(ip, procLog.GetPropertyValues(item, System.Reflection.MethodBase.GetCurrentMethod().Name), "OK", 200); return(_context.SaveChanges()); } catch (Exception ex) { procLog.AddLog(ip, procLog.GetPropertyValues(item, System.Reflection.MethodBase.GetCurrentMethod().Name), ex.InnerException.Message, 400); return(0); } }
public long AddCertificacion(Certificacion newItem, String ip) { try { var CertificacionRes = _context.Certificacions.Add(newItem); procLog.AddLog(ip, procLog.GetPropertyValues(newItem, System.Reflection.MethodBase.GetCurrentMethod().Name), "OK", 200); _context.SaveChanges(); return(Int32.Parse(CertificacionRes.Entity.IdCertificacion.ToString())); } catch (Exception ex) { procLog.AddLog(ip, procLog.GetPropertyValues(newItem, System.Reflection.MethodBase.GetCurrentMethod().Name), ex.InnerException.Message, 400); var r = ex.Message; return(0); } }
public async Task <IEnumerable <Certificacion> > GetAllCertificacion(int id) { try { List <Certificacion> Cert = new List <Certificacion>(); Cert = await _ctx.Certificacion.Where(e => e.Estado == 1 && e.IdiomaId == id).AsNoTracking().ToListAsync(); Certificacion AuxiliarDatosTecnicas = await _ctx.Certificacion.Where(e => e.Estado == 1 && e.IdiomaId == 13).AsNoTracking().FirstOrDefaultAsync(); Cert.Add(AuxiliarDatosTecnicas); return(Cert); } catch (Exception e) { throw new Exception(e.Message, e); } }
/// <summary> /// Actualiza un registro de la tabla de Certificacion /// </summary> /// <param name="Certificacion">objeto de tipo Certificacion con los nuevos datos</param> /// <returns></returns> public async Task Update(Certificacion Certificacion) { try { var _Certificacion = await _ctx.Certificacion .FirstOrDefaultAsync(e => e.CertificacionId == Certificacion.CertificacionId); if (_Certificacion != null) { _ctx.Entry(_Certificacion).CurrentValues.SetValues(Certificacion); await _ctx.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public Proveedor consultarPadronRest(string cuit) { log.Info("Cuit Ingresado " + cuit); cuit = Funciones.ConvertToCUIT(cuit); Certificacion[] certificaciones = new Certificacion[0]; Proveedor proveedor = new Proveedor(); IT_Mensaje mensaje = new IT_Mensaje(); string usuarioProxy = ConfigurationManager.AppSettings["CPA_Proxy_Usuario"]; string passwdProxy = ConfigurationManager.AppSettings["CPA_Proxy_Passwd"]; string domainProxy = ConfigurationManager.AppSettings["CPA_Proxy_Dominio"]; string WSApiEndpoint = ConfigurationManager.AppSettings["WS_ApiEndpoint"]; string WSApiParameter = ConfigurationManager.AppSettings["WS_ApiParameter"]; Uri WSUriApi = new Uri(WSApiEndpoint + "?" + WSApiParameter + "=" + cuit); var client = new RestClient(WSApiEndpoint); client.Proxy = Funciones.CrearProxy(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11; ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationCallback; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); }); mensaje.Consulta = cuit; mensaje.Mensaje = string.Empty; var request = new RestRequest("?" + WSApiParameter + "=" + cuit, Method.GET); System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); string content = string.Empty; log.Info("Invocacion al Endpoint de Renappo " + WSApiEndpoint + " con el siguiente parametro y valor " + WSApiParameter + "=" + cuit); timer.Start(); var response = client.Execute(request); timer.Stop(); long tiempo = timer.ElapsedMilliseconds / 1000; log.Info("Tiempo Renappo - invocacion: " + tiempo + "segundos"); timer.Restart(); if (response != null && !string.IsNullOrEmpty(response.Content) && response.StatusCode == HttpStatusCode.OK) { log.Info("Respuesta Renappo - Servicio : " + Environment.NewLine + JValue.Parse(response.Content)?.ToString(Newtonsoft.Json.Formatting.Indented)); log.Info("Parseando el la respuesta previamente obtenida"); certificaciones = JsonConvert.DeserializeObject <Certificacion[]>(response.Content); } else { mensaje.Tipo = "E"; log.Info( "Respuesta Renappo - Servicio : " + Environment.NewLine + "Estado - " + response?.StatusCode + Environment.NewLine + "Descripcion" + response?.StatusDescription); } if (certificaciones != null && certificaciones.Any()) { if (certificaciones.Any(x => x.Fallo)) { mensaje.Mensaje = certificaciones.FirstOrDefault(x => x.Fallo)?.Mensaje; mensaje.Tipo = "E"; proveedor.Detalle = null; proveedor.Actividades = null; } else { string mensajeVacio = "No se pudo obtener información"; mensaje.Tipo = "S"; IT_Detalle detalle = new IT_Detalle(); List <IT_Actividad> actividades = new List <IT_Actividad>(); foreach (var certificacion in certificaciones) { detalle.RazonSocial = !string.IsNullOrEmpty(certificacion.RazonSocial) ? certificacion.RazonSocial : mensajeVacio; detalle.Intermediario = !string.IsNullOrEmpty(certificacion.Medio) ? certificacion.Medio : mensajeVacio; detalle.Habilitado = !string.IsNullOrEmpty(certificacion.Habilitado) ? certificacion.Habilitado : mensajeVacio; detalle.FechaVigenciaDesde = Funciones.ConvertToFechaFormato(Funciones.ConvertToFechaVigencia(certificacion.FechaVigencia, Parametros.FechaVigencia.Desde), null); detalle.FechaVigenciaHasta = Funciones.ConvertToFechaFormato(Funciones.ConvertToFechaVigencia(certificacion.FechaVigencia, Parametros.FechaVigencia.Hasta), null); #region Tarifario if (!string.IsNullOrEmpty(certificacion.Tarifario)) { var tarifario = SubirArchivoRest(certificacion.Tarifario); if (tarifario != null && !tarifario.Error && !string.IsNullOrEmpty(tarifario.Id)) { detalle.Tarifario = tarifario.Id; } else { mensaje.Tipo = "W"; mensaje.Mensaje = mensaje.Mensaje + tarifario.Detalle + "; "; detalle.Tarifario = null; } } else { detalle.Tarifario = mensajeVacio; } #endregion #region Cobertura Geografica if (!string.IsNullOrEmpty(certificacion.CoberturaGeografica)) { var cobertura = SubirArchivoRest(certificacion.CoberturaGeografica); if (cobertura != null && !cobertura.Error && !string.IsNullOrEmpty(cobertura.Id)) { detalle.CoberturaGeografica = cobertura.Id; } else { mensaje.Tipo = "W"; mensaje.Mensaje = mensaje.Mensaje + cobertura.Detalle + "; "; detalle.CoberturaGeografica = null; } } else { detalle.CoberturaGeografica = mensajeVacio; } #endregion if (!string.IsNullOrEmpty(certificacion.Certificado)) { log.Info("Parseando el campo certificado para obtener la/s actividad/es del Proveedor"); var elementos = XElement.Parse(certificacion.Certificado); if (elementos.HasElements) { foreach (var elemento in elementos.Elements()) { var elementosTexto = elemento.Descendants()?.Where(x => x.FirstNode != null && x.FirstNode.NodeType == XmlNodeType.Text); if (elementosTexto != null && elementosTexto.Any()) { var actividad = new IT_Actividad(); actividad.Actividad = elementosTexto?.FirstOrDefault(x => x.Parent.Value.Contains("CERTIFICADO HABILITANTE") && x.Name == "strong").Value; actividad.Fecha = Funciones.ConvertToFechaFormato(elementosTexto?.FirstOrDefault(x => x.Value.Contains("Fecha:"))?.Value, "Fecha:"); actividad.Vencimiento = Funciones.ConvertToFechaFormato(elementosTexto?.FirstOrDefault(x => x.Value.Contains("Vencimiento:"))?.Value, "Vencimiento:"); actividad.Certificado = elementosTexto?.FirstOrDefault(x => x.Value.Contains("RENAPPO")).Value.Trim() ?? mensajeVacio; actividades.Add(actividad); } } } proveedor.Actividades = actividades.ToArray(); } else { log.Info("No se pudo obtener la/s actividad/es del Proveedor"); } } proveedor.Detalle = detalle; } } proveedor.Mensaje = mensaje; timer.Stop(); tiempo = timer.ElapsedMilliseconds / 1000; log.Info("Tiempo Servicio - procesamiento: " + tiempo + "segundos"); return(proveedor); }
public Proveedor consultarPadron(string cuit) { log.Info("Cuit Ingresado " + cuit); cuit = Funciones.ConvertToCUIT(cuit); Certificacion[] certificaciones = new Certificacion[0]; Proveedor proveedor = new Proveedor(); string usuarioProxy = ConfigurationManager.AppSettings["CPA_Proxy_Usuario"]; string passwdProxy = ConfigurationManager.AppSettings["CPA_Proxy_Passwd"]; string domainProxy = ConfigurationManager.AppSettings["CPA_Proxy_Dominio"]; string WSApiEndpoint = ConfigurationManager.AppSettings["WS_ApiEndpoint"]; string WSApiParameter = ConfigurationManager.AppSettings["WS_ApiParameter"]; Uri WSUriApi = new Uri(WSApiEndpoint + "?" + WSApiParameter + "=" + cuit); log.Debug("Seteando PROXY."); string urlProxy = ConfigurationManager.AppSettings["CPA_Proxy_URL"]; WebProxy Proxy = new WebProxy(new Uri(urlProxy)); Proxy.BypassProxyOnLocal = false; Proxy.UseDefaultCredentials = false; Proxy.Credentials = new NetworkCredential(usuarioProxy, passwdProxy, domainProxy); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11; ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationCallback; ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return(true); }); log.Info("Invocacion al Endpoint de Renappo " + WSApiEndpoint + " con el siguiente parametro y valor " + WSApiParameter + "=" + cuit); //HttpWebRequest request = Funciones.GenerarRequest(WSApiEndpoint + "?" + WSApiParameter + "=" + cuit); HttpWebRequest request = WebRequest.Create(WSUriApi) as HttpWebRequest; request.ContentType = "text/html; charset=utf-8"; //request.ContentType = "application/x-www-form-urlencoded"; //request.Accept = "application/json"; request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"; request.Method = WebRequestMethods.Http.Get; //request.KeepAlive = true; request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"; request.PreAuthenticate = true; //request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested; request.Proxy = Proxy; //request.Credentials = CredentialCache.DefaultCredentials; string content = string.Empty; WebResponse response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { content = reader.ReadToEnd(); } if (!string.IsNullOrEmpty(content) && content.Length > 0 && !content.StartsWith("[{")) { throw new Exception(content); } log.Info("Respuesta del Endpoint " + WSApiEndpoint + ": " + Environment.NewLine + content); log.Info("Parseando el la respuesta previamente obtenida"); certificaciones = JsonConvert.DeserializeObject <Certificacion[]>(content); if (certificaciones != null && certificaciones.Any()) { if (certificaciones.Any(x => x.Fallo)) { throw new Exception(certificaciones.FirstOrDefault(x => x.Fallo)?.Mensaje); } IT_Detalle detalle = new IT_Detalle(); List <IT_Actividad> actividades = new List <IT_Actividad>(); foreach (var certificacion in certificaciones) { detalle.RazonSocial = certificacion.RazonSocial; detalle.Intermediario = certificacion.Medio; detalle.Habilitado = certificacion.Habilitado; detalle.FechaVigenciaDesde = Funciones.ConvertToFechaFormato(Funciones.ConvertToFechaVigencia(certificacion.FechaVigencia, Parametros.FechaVigencia.Desde), null); detalle.FechaVigenciaHasta = Funciones.ConvertToFechaFormato(Funciones.ConvertToFechaVigencia(certificacion.FechaVigencia, Parametros.FechaVigencia.Hasta), null); detalle.Tarifario = SubirArchivo(certificacion.Tarifario); detalle.CoberturaGeografica = SubirArchivo(certificacion.CoberturaGeografica); if (!string.IsNullOrEmpty(certificacion.Certificado)) { log.Info("Parseando el campo certificado para obtener la/s actividad/es del Proveedor"); var elementos = XElement.Parse(certificacion.Certificado); if (elementos.HasElements) { foreach (var elemento in elementos.Elements()) { var elementosTexto = elemento.Descendants()?.Where(x => x.FirstNode != null && x.FirstNode.NodeType == XmlNodeType.Text); var actividad = new IT_Actividad(); actividad.Actividad = elementosTexto?.FirstOrDefault(x => x.Parent.Value.Contains("CERTIFICADO HABILITANTE") && x.Name == "strong").Value; actividad.Fecha = Funciones.ConvertToFechaFormato(elementosTexto?.FirstOrDefault(x => x.Value.Contains("Fecha:"))?.Value, "Fecha:"); actividad.Vencimiento = Funciones.ConvertToFechaFormato(elementosTexto?.FirstOrDefault(x => x.Value.Contains("Vencimiento:"))?.Value, "Vencimiento:"); actividad.Certificado = elementosTexto?.FirstOrDefault(x => x.Value.Contains("RENAPPO")).Value.Trim(); actividades.Add(actividad); } } } } proveedor.Detalle = detalle; proveedor.Actividades = actividades.ToArray(); } return(proveedor); }
public async Task <IHttpActionResult> UpdateEstado(Certificacion Certificacion) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _CertificacionRepo.UpdateEstado(Certificacion); return(Ok("Registro actualizado correctamente")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
[Authorize] public async Task <IHttpActionResult> Create(Certificacion Certificacion) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _CertificacionRepo.Create(Certificacion); return(Ok("Registro creado correctamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
public async Task UpdateEstado(Certificacion Certificacion) { try { var _Certificacion = await _ctx.Certificacion .FirstOrDefaultAsync(e => e.CertificacionId == Certificacion.CertificacionId); if (_Certificacion != null) { _Certificacion.Estado = Certificacion.Estado; await _ctx.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
private static DataSet certificacion(String xml, String xmlGenerado) { Certificacion certificacion = new Certificacion(); certificacion.nit_emisor = Constants.NIT_EMISOR; certificacion.correo_copia = Constants.CORREO_COPIA; certificacion.xml_dte = xml; DataSet dataSet = new DataSet(); DataSet dsError = new DataSet(); //pasar a json el objeto string json = JsonConvert.SerializeObject(certificacion); RespuestaCertificacion respuesta = new RespuestaCertificacion(); String d = ""; using (var client = new HttpClient()) { client.BaseAddress = new Uri(Constants.URL_CERTIFICACION_DTE); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Constants.METODO_CERTIFICACION_DTE); request.Headers.Add(Constants.HEADER_USUARIO, Constants.HEADER_USUARIO_TOKEN); request.Headers.Add(Constants.HEADER_LLAVE, Constants.HEADER_LLAVE_EMISOR); request.Headers.Add(Constants.HEADER_IDENTIFICADOR, Constants.IDENTIFICADOR_DTE); request.Content = new StringContent(json, Encoding.UTF8, "application/json"); using (HttpResponseMessage response = client.SendAsync(request).Result) { using (HttpContent content = response.Content) { respuesta = JsonConvert.DeserializeObject <RespuestaCertificacion>(content.ReadAsStringAsync().Result); try { DataTable dt = new DataTable("respuesta"); dt.Columns.Add(new DataColumn("resultado", typeof(string))); dt.Columns.Add(new DataColumn("fecha", typeof(string))); dt.Columns.Add(new DataColumn("origen", typeof(string))); //dt.Columns.Add(new DataColumn("control_emision", typeof(ControlEmision))); dt.Columns.Add(new DataColumn("alertas_infile", typeof(bool))); //dt.Columns.Add(new DataColumn("descripcion_alertas_infile", typeof(List<string>))); //dt.Columns.Add(new DataColumn("alertas_sat", typeof(bool))); //dt.Columns.Add(new DataColumn("descripcion_alertas_sat", typeof(List<object>))); dt.Columns.Add(new DataColumn("cantidad_errores", typeof(int))); //// dt.Columns.Add(new DataColumn("descripcion_errores", typeof(List<DescripcionErrores>))); dt.Columns.Add(new DataColumn("descripcion", typeof(string))); //dt.Columns.Add(new DataColumn("informacion_adicional", typeof(string))); dt.Columns.Add(new DataColumn("uuid", typeof(string))); dt.Columns.Add(new DataColumn("serie", typeof(string))); dt.Columns.Add(new DataColumn("numero", typeof(long))); dt.Columns.Add(new DataColumn("xml_certificado", typeof(string))); dt.Columns.Add(new DataColumn("xmlGenerado", typeof(string))); DataRow dr = dt.NewRow(); String fechaEmision = respuesta.fecha; DateTime oDate = Convert.ToDateTime(fechaEmision); LlenarEstructuras.formatDate(oDate); dr["resultado"] = respuesta.resultado.ToString(); dr["fecha"] = respuesta.fecha; dr["origen"] = respuesta.origen; //dr["control_emision"] = respuesta.control_emision; dr["alertas_infile"] = respuesta.alertas_infile; //dr["descripcion_alertas_infile"] = respuesta.descripcion_alertas_infile; //dr["alertas_sat"] = respuesta.alertas_sat; //dr["descripcion_alertas_sat"] = respuesta.descripcion_alertas_sat; dr["cantidad_errores"] = respuesta.cantidad_errores; //dr["resultado"] = respuesta.resultado; string text = string.Join(",", respuesta.descripcion_errores); dr["descripcion"] = text; //dr["informacion_adicional"] = respuesta.informacion_adicional; dr["uuid"] = respuesta.uuid; dr["serie"] = respuesta.serie; // dr["numero"] = respuesta.serie; dr["xml_certificado"] = respuesta.xml_certificado; dr["xmlGenerado"] = xmlGenerado; dt.Rows.Add(dr); dataSet.Tables.Add(dt); //dataSet = dsError; } catch (Exception ex) { DataTable dt = new DataTable("resultado"); dt.Columns.Add(new DataColumn("xmlGenerado", typeof(string))); DataRow dr = dt.NewRow(); dr["resultado"] = ex.ToString(); dr["xmlGenerado"] = xmlGenerado; dt.Rows.Add(dr); dsError.Tables.Add(dt); dataSet = dsError; } } } } return(dataSet); }