public async Task <Response> Editar(int id, [Bind("IdOpcion,Nombre,NombreAlias,Precio,IdTipoOpcion")] Opciones opciones) { if (id != opciones.IdOpcion) { return(new Response { IsSuccess = false, Message = "Debes enviar un id", Result = null }); } try { db.Update(opciones); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = "Opcion actualizada correctamente", Result = opciones }); } catch (DbUpdateConcurrencyException ex) { if (!OpcionesExists(opciones.IdOpcion)) { return(new Response { IsSuccess = false, Message = ex.Message, Result = null }); } else { throw; } } }
// GET: public ActionResult Permiso(int perfilId) { Opciones opciones = new Opciones(); opciones.PuestosAtencion = estaOpcion(perfilId, "PuestosAtencion"); opciones.Profesionales = estaOpcion(perfilId, "Profesionales"); opciones.Especialidades = estaOpcion(perfilId, "Especialidades"); opciones.Diagnosticos = estaOpcion(perfilId, "Diagnosticos"); opciones.Pacientes = estaOpcion(perfilId, "Pacientes"); opciones.PacientesActivos = estaOpcion(perfilId, "PacientesActivos"); opciones.HistoriasCreadas = estaOpcion(perfilId, "HistoriasCreadas"); opciones.HistoriaClinica = estaOpcion(perfilId, "HistoriaClinica"); opciones.Usuarios = estaOpcion(perfilId, "Usuarios"); opciones.Perfiles = estaOpcion(perfilId, "Perfiles"); opciones.MatrizSeguridad = estaOpcion(perfilId, "MatrizSeguridad"); opciones.Bitacora = estaOpcion(perfilId, "Bitacora"); opciones.CargarArchivoDigital = estaOpcion(perfilId, "CargarArchivoDigital"); opciones.TipoAnexo = estaOpcion(perfilId, "TipoAnexo"); opciones.VolumenAlmacenamiento = estaOpcion(perfilId, "VolumenAlmacenamiento"); //cargar permisos return(View(opciones)); }
//El invocador es el que fabrica el comando concreto public string EjecutarOpcion(Opciones opcion) { string resultado = string.Empty; Comando comando = null; switch (opcion) { case Opciones.Copiar: comando = new ComandoCopiar(_receptor); break; case Opciones.Cortar: comando = new ComandoCortar(_receptor); break; case Opciones.Pegar: comando = new ComandoPegar(_receptor); break; } //El comando es tratado indistintamente resultado = comando.Ejecutar(); //Se agrega al repositorio de comandos ejecutados para poder hacer Undo _listaComandos.Add(comando); return(resultado); }
// GET: Lotes/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lotes lotes = await db.Lotes.FindAsync(id); if (lotes == null) { return(HttpNotFound()); } List <Opciones> lstOpciones = new List <Opciones>(); Opciones objOpcion = new Opciones(); objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "TiposAnimales").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotes.OpcionId); List <Opciones> lstOpcionesCuido = new List <Opciones>(); Opciones objOpcionCuido = new Opciones(); objOpcionCuido.OpcionId = -1; objOpcionCuido.Codigopcion = "-- Seleccione --"; lstOpcionesCuido.Add(objOpcionCuido); lstOpcionesCuido.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.CuidoId = new SelectList(lstOpcionesCuido, "OpcionId", "Codigopcion", lotes.CuidoId); return(View(lotes)); }
public async Task <ActionResult <Opciones> > PostOpciones(Opciones opciones) { _context.Opciones.Add(opciones); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOpciones", new { id = opciones.Id }, opciones)); }
public async Task <IActionResult> PutOpciones(int id, Opciones opciones) { if (id != opciones.Id) { return(BadRequest()); } _context.Entry(opciones).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OpcionesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: LotesComidas/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LotesComida lotesComida = await db.LotesComidas.FindAsync(id); if (lotesComida == null) { return(HttpNotFound()); } List <Opciones> lstOpciones = new List <Opciones>(); Opciones objOpcion = new Opciones(); objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotesComida.OpcionId); List <Lotes> lstLotes = new List <Lotes>(); Lotes objLote = new Lotes(); objLote.LoteId = -1; objLote.NombreLote = "-- Seleccione --"; lstLotes.Add(objLote); lstLotes.AddRange(db.Lotes); ViewBag.LoteId = new SelectList(lstLotes, "LoteId", "NombreLote", lotesComida.LoteId); return(View(lotesComida)); }
/// <summary> /// Muestra el menu creado con un color de fondo y de letra determinado. /// </summary> /// <param name="posInicialArriba">posicion inicial superior</param> /// <param name="posInicialIzquierda">posicion inicial izquierda</param> /// <param name="colorFondo">El color que se va a pintar la consola</param> /// <param name="colorLetra">El color que se va a pintar las letras</param> public void MostrarMenu(int posInicialArriba, int posInicialIzquierda, ConsoleColor colorFondo, ConsoleColor colorLetra) { if (Titulo == null || Opciones == null || Mensaje == null) { throw new ValoresNulosException("Error: Porfavor asigna el titulo, el contenido y el mensaje."); } Console.ForegroundColor = colorLetra; int anchura = 10; int altura = Opciones.Length + 3; int longitudMaxOpciones = Opciones.Max(x => x.Length); if (longitudMaxOpciones > Titulo.Length && longitudMaxOpciones > Mensaje.Length) { anchura += longitudMaxOpciones; } else if (Mensaje.Length > Titulo.Length) { anchura += Mensaje.Length; } else { anchura += Titulo.Length; } marco = new Marco(posInicialArriba, posInicialIzquierda, altura, anchura); marco.DibujarConsola(colorFondo); if (_tipo == Tipo.Doble) { marco.DibujarMarcoDoble(); } else { marco.DibujarMarcoSimple(); } Console.SetCursorPosition(posInicialIzquierda + 1, posInicialArriba + 1); Console.WriteLine(Titulo.PadLeft(Titulo.Length + 5)); Console.CursorTop++; for (int i = 0; i < Opciones.Length - 1; i++) { Console.CursorLeft = posInicialIzquierda + 1; Console.WriteLine("".PadLeft(5) + Opciones[i]); } Console.CursorLeft = posInicialIzquierda + 1; Console.WriteLine("".PadLeft(8) + Opciones.Last()); Console.CursorTop++; Console.CursorLeft = posInicialIzquierda + 1; Console.Write(Mensaje); Console.ResetColor(); }
// GET: Animales/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Animales animales = await db.Animales.FindAsync(id); if (animales == null) { return(HttpNotFound()); } List <Opciones> lstOpciones = new List <Opciones>(); Opciones objOpcion = new Opciones(); objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "TiposAnimales").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", animales.OpcionId); List <Razas> lstRazas = new List <Razas>(); Razas objRaza = new Razas(); objRaza.RazaId = -1; objRaza.NombreRaza = "-- Seleccione --"; lstRazas.Add(objRaza); lstRazas.AddRange(db.Razas); ViewBag.RazaId = new SelectList(lstRazas, "RazaId", "NombreRaza", animales.RazaId); return(View(animales)); }
public static decimal ObtenerTotal(Opciones opcionSeleccionada, Calculos calculos) { while (true) { switch (opcionSeleccionada) { case Opciones.Sumar: return(calculos.Sumar()); case Opciones.Restar: return(calculos.Restar()); case Opciones.Multiplicar: return(calculos.Multiplicar()); case Opciones.Dividir: return(calculos.Dividir()); case Opciones.CambiarValores: ObtenerValores.ObtenerCalculos(out calculos, out opcionSeleccionada); break; case Opciones.Salir: Environment.Exit(0); break; default: Console.WriteLine("No existe la opción seleccionada, intente de nuevo"); opcionSeleccionada = ObtenerValores.OpcionSeleccionada(); break; } } }
private void tsm_CrearArbolTipificacion_Click(object sender, EventArgs e) { if (!pnl_Contenedor.Controls.Contains(_uc_CrearArbolTipificacion)) { _opcion = Opciones.CrearArbolTipificacion; bgw_Principal.RunWorkerAsync(); } }
public ActionResult DeleteConfirmed(int id) { Opciones opciones = db.Opciones.Find(id); db.Opciones.Remove(opciones); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(Lotes lotes) { List <Opciones> lstOpciones = new List <Opciones>(); Opciones objOpcion = new Opciones(); List <Opciones> lstOpcionesCuido = new List <Opciones>(); Opciones objOpcionCuido = new Opciones(); if (ModelState.IsValid) { if (lotes.OpcionId == -1 || lotes.CuidoId == -1) { objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "TiposAnimales").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotes.OpcionId); objOpcionCuido.OpcionId = -1; objOpcionCuido.Codigopcion = "-- Seleccione --"; lstOpcionesCuido.Add(objOpcionCuido); lstOpcionesCuido.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.CuidoId = new SelectList(lstOpcionesCuido, "OpcionId", "Codigopcion", lotes.CuidoId); return(View(lotes)); } lotes.CerradoLote = false; lotes.FechaFinalLote = Convert.ToDateTime("1900-01-01"); //lotes.FechaFinal = this.fechaString(lotes.FechaFinalLote); //lotes.FechaApertura = this.fechaString(lotes.FechaAperturaLote); //MemoryStream stream1 = new MemoryStream(); //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Lotes)); //ser.WriteObject(stream1, lotes); //stream1.Position = 0; //StreamReader sr = new StreamReader(stream1); //String Resultado = sr.ReadToEnd(); db.Lotes.Add(lotes); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "TiposAnimales").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", lotes.OpcionId); objOpcionCuido.OpcionId = -1; objOpcionCuido.Codigopcion = "-- Seleccione --"; lstOpcionesCuido.Add(objOpcionCuido); lstOpcionesCuido.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.CuidoId = new SelectList(lstOpcionesCuido, "OpcionId", "Codigopcion", lotes.CuidoId); return(View(lotes)); }
public async Task <ActionResult> Create(InventariosView view) { List <Opciones> lstOpciones = new List <Opciones>(); Opciones objOpcion = new Opciones(); if (ModelState.IsValid) { if (view.OpcionId == -1) { objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion"); return(View(view)); } var pic = string.Empty; var folder = "~/Images"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = string.Format("{0}/{1}", folder, pic); } var Inventario = this.ToInventario(view, pic); Inventario.ValorTotalInventario = Inventario.PrecioInventario + Inventario.FleteInventario; Inventario.ValorUnitarioInventario = Inventario.ValorTotalInventario / Inventario.CantidadInventario; MemoryStream stream1 = new MemoryStream(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Inventarios)); ser.WriteObject(stream1, Inventario); stream1.Position = 0; StreamReader sr = new StreamReader(stream1); String Resultado = sr.ReadToEnd(); using (LocalDataContext db = new LocalDataContext()) { var Respuesta = db.Database.SqlQuery <Respuesta>(Sp.uspInventarioInsertar + " @json", new SqlParameter("json", Resultado)).ToList(); } return(RedirectToAction("Index")); } objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion", view.OpcionId); return(View(view)); }
public async Task <ActionResult> Edit(Opciones opciones) { if (ModelState.IsValid) { db.Entry(opciones).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(opciones)); }
public ActionResult Edit([Bind(Include = "Opciones_Id,Nombre_Opciones,Modulos_Modulos_Id")] Opciones opciones) { if (ModelState.IsValid) { db.Entry(opciones).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Modulos_Modulos_Id = new SelectList(db.Modulos, "Modulos_Id", "Nombre_Modulos", opciones.Modulos_Modulos_Id); return(View(opciones)); }
public async Task <ActionResult> Create(Opciones opciones) { if (ModelState.IsValid) { db.Opciones.Add(opciones); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(opciones)); }
// Inicialización al comenzar la sesión de juego public Juego() { // Inicializo modo grafico 800x600 puntos, 24 bits de color bool pantallaCompleta = false; Hardware.Inicializar(800, 600, 24, pantallaCompleta); // Inicializo componentes del juego presentacion = new Presentacion(); partida = new Partida(); creditos = new Creditos(); opciones = new Opciones(); }
private VistaOpciones ToVistaOpcion(Opciones opcion) { return(new VistaOpciones { IdOpcion = opcion.IdOpcion, Nombre = opcion.Nombre, NombreAlias = opcion.NombreAlias, IdTipoOpcion = opcion.IdTipoOpcion, Precio = opcion.Precio, Activa = opcion.Activa }); }
public void Editar(object obj) { if (vista == null) { vista = obj as MainWindow; } opcion = Opciones.editar; if (!worker.IsBusy) { worker.RunWorkerAsync(); } }
public void Eliminar(object obj) { if (vista == null) { vista = obj as AlmacenWindow; } opcion = Opciones.eliminar; if (!worker.IsBusy) { worker.RunWorkerAsync(); } }
public void Nuevo(object obj) { if (vista == null) { vista = obj as AlmacenWindow; } opcion = Opciones.nuevo; if (!worker.IsBusy) { worker.RunWorkerAsync(); } }
private void bgwSorteo_DoWork(object sender, DoWorkEventArgs e) { object[] arg = e.Argument as object[]; Opciones opc = (Opciones)arg[0]; List <string> listaNombres = arg[1] as List <string>; if (opc == Opciones.Manual) { int conta = 0; bool continua = true; while (continua) { if (this.bgwSorteo.CancellationPending) { continua = false; } this.bgwSorteo.ReportProgress(0, listaNombres[conta]); Thread.Sleep(TimeSpan.FromMilliseconds(70)); conta++; if (conta == listaNombres.Count) { conta = 0; } } } else { Random ran = new Random(DateTime.Now.Millisecond); int milisegundos = ran.Next(1000, 8000); int conta = 0; int sumaMili = 0; while (milisegundos > sumaMili) { if (this.bgwSorteo.CancellationPending) { milisegundos = 0; } this.bgwSorteo.ReportProgress(0, listaNombres[conta]); Thread.Sleep(TimeSpan.FromMilliseconds(70)); sumaMili += 70; conta++; if (conta == listaNombres.Count) { conta = 0; } } } e.Result = opc; }
// GET: Inventarios/Create public ActionResult Create() { List <Opciones> lstOpciones = new List <Opciones>(); Opciones objOpcion = new Opciones(); objOpcion.OpcionId = -1; objOpcion.Codigopcion = "-- Seleccione --"; lstOpciones.Add(objOpcion); lstOpciones.AddRange(db.Opciones.Where(O => O.TipoOpcion == "CuidoCerdos").ToList()); ViewBag.OpcionId = new SelectList(lstOpciones, "OpcionId", "Codigopcion"); return(View()); }
private void btnIniciarSesion_Click(object sender, EventArgs e) { if (cmbUsuarioInicioSesion.SelectedItem.ToString() == "Administrador" && txtContrasenia.Text == "12345") { Opciones form2 = new Opciones(); form2.Show(); this.Hide(); } else { MessageBox.Show("Contraseña o usuario incorrectos"); } }
/// <summary> /// Muestra el menu creado con la posición de inicio por defecto. /// </summary> public void MostrarMenu() { if (Titulo == null || Opciones == null || Mensaje == null) { throw new ValoresNulosException("Error: Porfavor asigna el titulo, el contenido y el mensaje."); } int posDefecto = 10; int anchura = 10; int altura = Opciones.Length + 3; int longitudMaxOpciones = Opciones.Max(x => x.Length); if (longitudMaxOpciones > Titulo.Length && longitudMaxOpciones > Mensaje.Length) { anchura += longitudMaxOpciones; } else if (Mensaje.Length > Titulo.Length) { anchura += Mensaje.Length; } else { anchura += Titulo.Length; } marco = new Marco(posDefecto, posDefecto, altura, anchura); if (_tipo == Tipo.Doble) { marco.DibujarMarcoDoble(); } else { marco.DibujarMarcoSimple(); } Console.SetCursorPosition(posDefecto + 1, posDefecto + 1); Console.WriteLine(Titulo.PadLeft(Titulo.Length + 5)); Console.CursorTop++; for (int i = 0; i < Opciones.Length; i++) { Console.CursorLeft = posDefecto + 1; Console.WriteLine(Opciones[i].PadRight(longitudMaxOpciones)); } Console.CursorTop++; Console.CursorLeft = posDefecto + 1; Console.Write(Mensaje); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Opciones opciones = db.Opciones.Find(id); if (opciones == null) { return(HttpNotFound()); } return(View(opciones)); }
/// <summary> /// Maneja el evento "Load" del formulario "BIMainForm" /// </summary> /// <param name="sender">El formulario "BIMainForm"</param> /// <param name="e">Los argumentos del evento</param> private void BIMainForm_Load(object sender, EventArgs e) { try { // Establecemos la pantalla y la opción en blank this.DockForm(MyForms.blank); this.OpcionActual = Opciones.blank; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } // end BIMainForm_Load
// GET: Opciones/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Opciones opciones = await db.Opciones.FindAsync(id); if (opciones == null) { return(HttpNotFound()); } return(View(opciones)); }
public ActionResult Save(Opciones model) { var result = new ResultInfo(); if (model.Id == -1) { result = _opcionManager.Create(model); } else { result = _opcionManager.Update(model); } return(Json(result, JsonRequestBehavior.DenyGet)); }
private void ValidarOpcionesSeleccionadas(TreeNode nodo, List<Opciones> listaOpciones, List<AutorizacionesOpcion> listaAutorizaciones) { if (nodo.Checked && nodo.Value != "0") { if (nodo.Target != cadenaAutorizacion) { Opciones opcion = new Opciones(); opcion.Idopciones = int.Parse(nodo.Value); opcion.Titulo = ""; //opcion.Codigo = ""; listaOpciones.Add(opcion); UpdateNew.Update(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true); } else { AutorizacionesOpcion autorizacion = new AutorizacionesOpcion(); autorizacion.IdAutorizacion = int.Parse(nodo.Value); autorizacion.Titulo = ""; autorizacion.Codigo = ""; listaAutorizaciones.Add(autorizacion); UpdateNew.Update(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true); } } for (int i = 0; i < nodo.ChildNodes.Count; i++) { ValidarOpcionesSeleccionadas(nodo.ChildNodes[i], listaOpciones, listaAutorizaciones); UpdateNew.Update(); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "mostrarDatos();", true); } }
private static void Main(string[] args) { var options = new Opciones(); if (!Parser.Default.ParseArguments(args, options)) { var ht = HelpText.AutoBuild(options); ht.Copyright = new CopyrightInfo("Kevin López Brante", 2015); Console.WriteLine(ht); Environment.Exit(2); } else { var config = Config.LeerDesdeArchivo(options.ConfigurationFile); var spotifyRegex = new Regex(@"(?:https?:\/\/)?(?:open\.spotify\.com\/|spotify:)track(?:\/|:)(\w*)"); var ytRegex = new Regex(@"(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/(?:watch\?v=|embed\/)?(\w*)"); var client = new IrcClient($"{config.Hostname}:{config.Port}", new IrcUser(config.Nick, config.Ident, config.Password)); client.ConnectionComplete += (s, e) => { Console.WriteLine($"{DateTime.Now} ¡Conectado al servidor!"); foreach (var channel in config.Channels) { client.JoinChannel(channel); Console.WriteLine($"{DateTime.Now} Uniéndose al canal {channel}"); } }; client.RawMessageRecieved += (s, e) => { Console.WriteLine($"{DateTime.Now} <= {e.Message}"); }; client.RawMessageSent += (s, e) => { Console.WriteLine($"{DateTime.Now} => {e.Message}"); }; client.ChannelMessageRecieved += (s, e) => { var channel = client.Channels[e.PrivateMessage.Source]; Console.WriteLine($"{DateTime.Now} {channel.Name}/{e.PrivateMessage.User}: {e.PrivateMessage.Message}"); if (spotifyRegex.IsMatch(e.PrivateMessage.Message)) { Console.WriteLine($"{DateTime.Now} Capturado enlace de Spotify."); try { var mx = spotifyRegex.Match(e.PrivateMessage.Message); Console.WriteLine($"{DateTime.Now} Obteniendo info de pista..."); var spotify = SpotifyAPI.obtenerPista(mx.Groups[1].Value); Console.WriteLine($"{DateTime.Now} Info obtenida."); var ts = TimeSpan.FromMilliseconds(spotify.duration_ms); string artj = string.Join(", ", spotify.artists.Take(spotify.artists.Count - 1)) + (spotify.artists.Count <= 1 ? "" : " y ") + spotify.artists.LastOrDefault(); var ou = $"\x02{spotify.name}\x02 (\x1D{ts.ToString("hh':'mm':'ss")}\x1D) por \x02{artj}\x02 en \x02{spotify.album}\x02 (\x1D{"disco"} {spotify.disc_number}, pista {spotify.track_number}\x1D)"; channel.SendMessage(ou); Console.WriteLine($"{DateTime.Now} Mensaje enviado."); } catch (Exception exception) { Console.WriteLine(exception); channel.SendMessage(exception.Message); } } if (e.PrivateMessage.Message.StartsWith("!spotify")) { Console.WriteLine($"{DateTime.Now} Capturado comando Buscar en Spotify."); if (e.PrivateMessage.Message.StartsWith("!spotify ")) { var x = e.PrivateMessage.Message.Replace("!spotify ", ""); var sps = SpotifySearch.buscar(x); Console.WriteLine($"{DateTime.Now} Buscando \"{x}\" en Spotify..."); channel.SendMessage($"{e.PrivateMessage.User.Nick}, te mandé los resultados por privado."); for (int index = 0; index < sps.tracks.items.Count; index++) { var spotify = sps.tracks.items[index]; var ts = TimeSpan.FromMilliseconds(spotify.duration_ms); string artj = string.Join(", ", spotify.artists.Take(spotify.artists.Count - 1)) + (spotify.artists.Count <= 1 ? "" : " y ") + spotify.artists.LastOrDefault(); var ou = $"{index+1}: \x02{spotify.name}\x02 (\x1D{ts.ToString("hh':'mm':'ss")}\x1D) por \x02{artj}\x02 en \x02{spotify.album}\x02: spotify:track:{spotify.id}"; client.SendMessage(ou, e.PrivateMessage.User.Nick); } } else { channel.SendMessage("Debes poner algo después de !spotify."); } } if (ytRegex.IsMatch(e.PrivateMessage.Message)) { Console.WriteLine($"{DateTime.Now} Capturado enlace de YouTube."); try { var mx = ytRegex.Match(e.PrivateMessage.Message); Console.WriteLine($"{DateTime.Now} Obteniendo info de video..."); var youTube = YouTube.GetInfo(mx.Groups[1].Value); Console.WriteLine($"{DateTime.Now} Info obtenida."); _item = youTube.Items[0]; var ts = _item.ContentDetails.Duracion(); var ou = $"\x02{_item.Snippet.Title}\x02 (\x1D{ts.ToString("hh':'mm':'ss")}\x1D) por \x02{_item.Snippet.ChannelTitle}\x02 el \x02{_item.Snippet.PublishedAt.ToString(CultureInfo.GetCultureInfoByIetfLanguageTag("es"))}\x02"; channel.SendMessage(ou); Console.WriteLine($"{DateTime.Now} Mensaje enviado."); } catch (Exception exception) { Console.WriteLine(exception); channel.SendMessage(exception.Message); } } if (e.PrivateMessage.Message.StartsWith("!youtube")) { Console.WriteLine($"{DateTime.Now} Capturado comando Buscar en YouTube."); if (e.PrivateMessage.Message.StartsWith("!youtube ")) { var x = e.PrivateMessage.Message.Replace("!youtube ", ""); var sps = YouTubeSearch.buscar(x, config.ApiKeys.YtData); Console.WriteLine($"{DateTime.Now} Buscando \"{x}\" en YouTube..."); channel.SendMessage($"{e.PrivateMessage.User.Nick}, te mandé los resultados por privado."); for (int index = 0; index < sps.Items.Count; index++) { var yt = sps.Items[index]; var ou = $"{index + 1}: \x02{yt.Snippet.Title}\x02, publicado por \x02{yt.Snippet.ChannelTitle}\x02 el {yt.Snippet.PublishedAt.ToString(CultureInfo.GetCultureInfoByIetfLanguageTag("es"))}: https://www.youtube.com/watch?v={yt.Id.VideoId}"; client.SendMessage(ou, e.PrivateMessage.User.Nick); } } else { channel.SendMessage("Debes poner algo después de !spotify."); } } }; Console.WriteLine($"{DateTime.Now} Conectando al servidor {config.Hostname}:{config.Port} como {config.Nick}..."); client.ConnectAsync(); while (true) { Thread.Sleep(500); } } }
private void ValidarOpcionesSeleccionadas(TreeNode nodo, List<Opciones> listaOpciones, List<AutorizacionesOpcion> listaAutorizaciones) { if (nodo.Checked && nodo.Value != "0") { if (nodo.Target != cadenaAutorizacion) { Opciones opcion = new Opciones(); opcion.Idopciones = int.Parse(nodo.Value); opcion.Titulo = ""; //opcion.Codigo = ""; listaOpciones.Add(opcion); } else { AutorizacionesOpcion autorizacion = new AutorizacionesOpcion(); autorizacion.IdAutorizacion = int.Parse(nodo.Value); autorizacion.Titulo = ""; autorizacion.Codigo = ""; listaAutorizaciones.Add(autorizacion); } } for (int i = 0; i < nodo.ChildNodes.Count; i++) { ValidarOpcionesSeleccionadas(nodo.ChildNodes[i], listaOpciones, listaAutorizaciones); } }