public void PruebaConsultaFicherosBinarios() { var f = new Ficheros() { Datos = "", DatosB = new byte[] {}, Nombre = "Borrar", TipoFichero = 1, Tipo = "azure" }; int n = 0; db.Ficheros.Add(f); try { n = db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } Assert.IsFalse(n == 0); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Project.Dispose(); tasker.Dispose(); relations.Dispose(); computers.Dispose(); computerIPs.Dispose(); files.Dispose(); Ips.Dispose(); computerDomains.Dispose(); lstLimits.Dispose(); domains.Dispose(); plugins.Dispose(); } Project = null; tasker = null; computerDomains = null; lstLimits = null; domains = null; relations = null; computers = null; files = null; Ips = null; plugins = null; disposedValue = true; } }
public Data() { Project = new Project(); files = new Ficheros(); Ips = new IPs(); domains = new Domains(); relations = new Relations(); computers = new Computers(); computerIPs = new ComputerIPs(); computerDomains = new ComputerDomains(); resolver = new Resolver(); #if PLUGINS plugins = new PluginList(); #endif lstLimits = new ThreadSafeList <Limits>(); }
public static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Sintaxis: Ejercicio3 " + "<fichero1>" + "<fichero2>"); } else { Ficheros ficheros = new Ficheros(); try { ficheros.abrir(args[0], args[1]); ficheros.fusionar(); } catch (IOException e) { Console.WriteLine("Error: " + e.Message); } } }
public void SetArchivo(Ficheros Archivo) { this.Archivo = Archivo; }
public ActionResult Subida(Ficheros model, HttpPostedFileBase fichero) // Cada control File del html envía un objeto de tipo HttpPostedFileBase. // HttpPostedFileBase es un string con t0do el flujo de datos del fichero. { if (model.Tipo == "interno") { var n = GestionarFicheros.GuardarFicheroDisco(fichero, Server); if (n != null) { model.Datos = n; model.DatosB = new byte[] { 1 }; db.Ficheros.Add(model); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else if (model.Tipo == "base64") { var data = GestionarFicheros.ToBinario(fichero); if (data != null) { model.Datos = Convert.ToBase64String(data); model.DatosB = new byte[] { 1 }; model.Nombre = fichero.FileName; db.Ficheros.Add(model); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else if (model.Tipo == "binario") { var datab = GestionarFicheros.ToBinario(fichero); if (datab != null) { model.Datos = ""; model.DatosB = datab; model.Nombre = fichero.FileName; db.Ficheros.Add(model); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else if (model.Tipo == "azure") { var cuenta = ConfigurationManager.AppSettings["CuentaAS"]; var clave = ConfigurationManager.AppSettings["ClaveAS"]; var contenedor = ConfigurationManager.AppSettings["ContenedorAS"]; var az = new AzureStorageUtils(cuenta, clave, contenedor); var n = Guid.NewGuid(); var ext = fichero.FileName.Substring(fichero.FileName.LastIndexOf(".")); az.SubirFichero(fichero.InputStream, n + ext); model.Datos = n + ext; model.Nombre = fichero.FileName; db.Ficheros.Add(model); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Subida(Ficheros model, HttpPostedFileBase fichero) { if (model.tipo == "interno") { var n = GestionarFicheros.GuardarFicheroDisco(fichero, Server); if (n != null) { model.datos = n; model.datosb = new byte[] { 1 }; db.Ficheros.Add(model); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else if (model.tipo == "base64") { var data = GestionarFicheros.ToBinario(fichero); if (data != null) { model.datos = Convert.ToBase64String(data); model.datosb = new byte[] { 1 }; model.nombre = fichero.FileName; db.Ficheros.Add(model); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else if (model.tipo == "binario") { var datab = GestionarFicheros.ToBinario(fichero); if (datab != null) { model.datos = ""; model.datosb = datab; model.nombre = fichero.FileName; db.Ficheros.Add(model); try { db.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); } } } else if (model.tipo == "azure") { var cu = ConfigurationManager.AppSettings["cuentaAzureStorage"]; var cl = ConfigurationManager.AppSettings["claveAzureStorage"]; var co = ConfigurationManager.AppSettings["contenedorAzureStorage"]; var az = new AzureStorageUtils(cu, cl, co); var n = Guid.NewGuid(); var ext = fichero.FileName.Substring(fichero.FileName.LastIndexOf(".")); az.SubirFichero(fichero.InputStream, n + ext); model.datos = n + ext; model.nombre = fichero.FileName; db.Ficheros.Add(model); db.SaveChanges(); } return(RedirectToAction("Index")); }
static void Main(string[] args) { Ficheros[] fichas = new Ficheros[700]; int n = 0; int i; int opcion; string Buscar; do { Console.WriteLine(); Console.WriteLine("Escoja una opción:"); Console.WriteLine("1.- Añadir una ficha nueva"); Console.WriteLine("2.- Ver todas las fichas"); Console.WriteLine("3.- Buscar el nombre de la ficha"); Console.WriteLine("4.- Salir"); opcion = Convert.ToInt32(Console.ReadLine()); switch (opcion) { case 1: if (n < fichas.Length) { Console.WriteLine("Introduce el nombre de la imagen: "); fichas[n].Fichero = Console.ReadLine(); Console.WriteLine("Introduce el ancho de píxeles: "); fichas[n].anpix = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Introduce el alto de píxeles: "); fichas[n].alpix = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Introduce el tamaño en KiloByte: "); fichas[n].tm = float.Parse(Console.ReadLine()); n++; Console.Clear(); } else { Console.WriteLine("\nEl programa ha alcanzado su capacidad máxima (700)"); } break; case 2: for (i = 0; i < n; i++) { Console.WriteLine("\nNombre: {0} | Tamaño: {1} Kb | Ancho: {2} x Alto: {3}", fichas[i].Fichero, fichas[i].tm, fichas[i].anpix, fichas[i].alpix); } break; case 3: Console.WriteLine("Introduzca el nombre de la imagen"); Buscar = Console.ReadLine(); for (i = 0; i < n; i++) { if (fichas[i].Fichero == Buscar) { Console.WriteLine("\nNombre: {0} | Tamaño: {1} Kb | Ancho: {2} x Alto: {3}", fichas[i].Fichero, fichas[i].tm, fichas[i].anpix, fichas[i].alpix); } } break; case 4: Environment.Exit(0); break; default: break; } } while (opcion != 4); }