public App() { InitializeComponent(); Conversando = false; Argumentos = new Argumentos(); MainPage = new MainPage(); }
private static void disclaimer(string[] args) { if (args.Length == 0) { logger.EscribirLog("Por favor indique los parametros a utilizar", Logger.Tipo.Error, false); logger.EscribirLog("", Logger.Tipo.Nada, false); logger.EscribirLog("-vf\t(Requerido)\tparametro que indica el archivo que necesitamos usar", Logger.Tipo.Error, false); logger.EscribirLog("-v\t(Opcional)\tparametro que indica si se desean mas datos", Logger.Tipo.Error, false); System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_BAD_FORMAT); } if (Argumentos.chequeoArgunto("-log", false, args)) { logger.NombreLog = Argumentos.traerArgumento("-log", args); } logger.EscribirLog("Vamos a utilizrar el archivo " + logger.NombreLog + " como log.", Logger.Tipo.Informativo, false); if (!PharmaHansen.Util.Files.Exists(args, "vcf", out vcfFile)) { if (vcfFile == String.Empty) { System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_INVALID_COMMAND_LINE); } else { System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_FILE_NOT_FOUND); } } if (!PharmaHansen.Util.Files.Exists(args, "dbSNP", out dbSNP)) { if (dbSNP == String.Empty) { System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_INVALID_COMMAND_LINE); } else { System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_FILE_NOT_FOUND); } } logger.EscribirLog("Chequeamos los indices de " + dbSNP, Logger.Tipo.Informativo, false); if (!File.Exists(dbSNP + ".bin")) { logger.EscribirLog("No se encontro el indice para el archivo" + dbSNP + " por favor ejecutar el comando vcfindex.exe -vcf " + dbSNP, Logger.Tipo.Error, false); System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_FILE_NOT_FOUND); } logger.Verbose = Argumentos.chequeoArgunto("-v", true, args); if (logger.Verbose) { logger.EscribirLog("Verbose activado se escribira mas detalle", Logger.Tipo.Informativo, false); } }
public static void Main(string[] args) { try { Console.WriteLine("Atividade 5"); Console.WriteLine("Alunos: Guilherme Henrique de Aguiar Diniz, Luiz Henrique Gomes Guimarães, Yuske Eduardo Velit Arruda."); Console.WriteLine("CALCULADORA"); Console.WriteLine(); var argumentos = new Argumentos(args); decimal resultado; switch (argumentos.Operacao) { case Operacao.Soma: resultado = Calculadora.Soma(argumentos.X, argumentos.Y); break; case Operacao.Subtracao: resultado = Calculadora.Subtrai(argumentos.X, argumentos.Y); break; case Operacao.Multiplicacao: resultado = Calculadora.Multiplica(argumentos.X, argumentos.Y); break; case Operacao.Divisao: resultado = Calculadora.Divide(argumentos.X, argumentos.Y); break; default: resultado = 0; break; } Console.WriteLine("Resultado: " + args[0] + " " + args[1] + " " + args[2] + " = " + resultado); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine(); Console.WriteLine("Pressione qualquer tecla para fechar a calculadora"); Console.ReadKey(); } }
private static void BusquedaExactaInexacta(List<char> copiaCadena, List<char> copiaClave, Argumentos arg) { for (int i = 0; i < Clases.ClaveMaligno.LONGITUD_CODIGO; i++) { switch (arg) { case Argumentos.EXACTA: if (copiaClave[i].Equals(copiaCadena[i])) copiaClave[i] = POSICION_EXACTA; break; case Argumentos.INEXACTA: if (copiaCadena.Contains(copiaClave[i])) copiaClave[i] = POSICION_INEXACTA; break; } } }
static void Main(string[] args) { stopWatch.Start(); if (args.Length == 0) { logger.EscribirLog("Por favor indique los parametros a utilizar", Logger.Tipo.Error, false); logger.EscribirLog("", Logger.Tipo.Nada, false); logger.EscribirLog("-vf\t(Requerido)\tparametro que indica el archivo que necesitamos usar", Logger.Tipo.Error, false); logger.EscribirLog("-v\t(Opcional)\tparametro que indica si se desean mas datos", Logger.Tipo.Error, false); System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_INVALID_COMMAND_LINE); } if (Argumentos.chequeoArgunto("-log", false, args)) { logger.NombreLog = Argumentos.traerArgumento("-log", args); } logger.EscribirLog("Vamos a utilizrar el archivo " + logger.NombreLog + " como log.", Logger.Tipo.Informativo, false); if (!PharmaHansen.Util.Files.Exists(args, "vcf", out vcfFile)) { if (vcfFile == String.Empty) { System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_INVALID_COMMAND_LINE); } else { System.Environment.Exit(PharmaHansen.Util.CodigoSalida.ERROR_FILE_NOT_FOUND); } } logger.Verbose = Argumentos.chequeoArgunto("-v", true, args); if (logger.Verbose) { logger.EscribirLog("Verbose activado se escribira mas detalle", Logger.Tipo.Informativo, false); } aTimer = new System.Timers.Timer(6000); aTimer.Elapsed += OnTimedEvent; aTimer.AutoReset = true; aTimer.Enabled = true; int contador = 0; string auxs = string.Empty; int cantB = 0; int paginador = 0; byte flag = 10; String chrAnterior = string.Empty; logger.EscribirLog("Comenzamos a leer el archivo " + vcfFile, Logger.Tipo.Informativo, false); using (FileStream fsb = new FileStream(vcfFile, FileMode.Open, FileAccess.Read)) { long length = 0; int bufint = 1073741824; long tama = fsb.Length; Boolean ultino = false; long dif = 0; while (length < fsb.Length) { byte[] buffer = new byte[bufint]; int b = fsb.Read(buffer, paginador * bufint, bufint); length += buffer.Length; if (tama - length < bufint) { dif = tama - length; Console.WriteLine(tama - length); ultino = true; } if (buffer.Contains(flag)) { for (int x = 0; x < bufint; x++) { if (buffer[x] == flag) { contador++; cantB++; if (contador == 1000) { string[] aux = auxs.Split('\t'); if (chrAnterior == string.Empty) { chrAnterior = aux[0]; } Indice ind = new Indice(); ind.chrStart = chrAnterior; ind.chrEnd = aux[0]; ind.PosicionStart = PosicionS; Int64 Pose = 0; Boolean PoseB = Int64.TryParse(aux[1], out Pose); if (PoseB) { ind.PosicionEnd = Pose; } ind.ByteStart = anterior; ind.ByteEnd = anterior + cantB; anterior += cantB; indices.Add(ind); PosicionS = Pose; contador = 0; cantB = 0; auxs = string.Empty; chrAnterior = aux[0]; } } else { if (contador == 999) { if (buffer[x] == flag) { auxs = String.Empty; } else { auxs += Convert.ToChar(buffer[x]); } } if (contador == 998 && (bufint - 1000) < x) { Boolean pasol = true; for (int x1 = x; x1 < bufint; x1++) { if (buffer[x1] == flag) { pasol = false; } } if (pasol) { auxs += Convert.ToChar(buffer[x]); } } if (ultino && dif + x < 200) { for (int x1 = 0; x1 < 200; x1++) { if (buffer[x1] == flag) { auxs = string.Empty; } else { auxs += Convert.ToChar(buffer[x1]); } } string[] aux = auxs.Split('\t'); Indice ind = new Indice(); if (chrAnterior == String.Empty) { chrAnterior = aux[0]; } ind.chrStart = chrAnterior; ind.chrEnd = aux[0]; ind.PosicionStart = PosicionS; Int64 Pose = 0; Boolean PoseB = Int64.TryParse(aux[1], out Pose); if (PoseB) { ind.PosicionEnd = Pose; } ind.ByteStart = anterior; ind.ByteEnd = anterior + cantB; anterior += cantB; indices.Add(ind); PosicionS = Pose; contador = 0; cantB = 0; auxs = string.Empty; chrAnterior = aux[0]; break; } cantB++; } } } } } aTimer.Enabled = false; logger.EscribirLog("Terminamos la lectura del Archivo " + vcfFile + " en " + stopWatch.Elapsed, Logger.Tipo.Informativo, false); logger.EscribirLog("Comenzamos a grabar el archivo " + vcfFile + ".bin", Logger.Tipo.Informativo, false); //File.WriteAllText(vcfFile + ".json", JsonConvert.SerializeObject(indices, Formatting.Indented)); //using (var file = File.Create(vcfFile + ".bin")) { Serializer.Serialize(file, indices); } using (Stream stream = File.Open(vcfFile + ".bin", FileMode.Create)) { BinaryFormatter bin = new BinaryFormatter(); bin.Serialize(stream, indices); } logger.EscribirLog("Terminamos de grabar el archivo " + vcfFile + ".bin", Logger.Tipo.Informativo, false); logger.EscribirLog("Finalizamos el proceso", Logger.Tipo.Informativo, false); logger.EscribirLog("Demoramos " + stopWatch.Elapsed, Logger.Tipo.Informativo, true); stopWatch.Stop(); }
static void Main(string[] losArgumentos) { // Procesa los argumentos. Argumentos argumentos = new Argumentos(); if (!argumentos.ParseAndContinue(losArgumentos)) { return; } if (argumentos.DirectorioDeEntrada == null) { Console.WriteLine( argumentos.GetUsage("ERROR: Falta directorio de entrada.")); Environment.Exit(1); } if (argumentos.DirectorioDeSalida == null) { Console.WriteLine( argumentos.GetUsage("ERROR: Falta directorio de salida.")); Environment.Exit(1); } // Chequea que los directorios no sean los mismos. if (argumentos.DirectorioDeEntrada == argumentos.DirectorioDeSalida) { Console.WriteLine( argumentos.GetUsage("ERROR: El directorio de entrada y salida deben ser diferentes.")); Environment.Exit(1); } // Procesa cada archivo en el directorio fuente. IEscuchadorDeEstatus escuchadorDeEstatus = new EscuchadorDeEstatusPorOmisión(); ManejadorDeMapa manejadorDeMapa = new ManejadorDeMapa(escuchadorDeEstatus); DirectoryInfo informaciónDelDirectorio = new DirectoryInfo(argumentos.DirectorioDeEntrada); FileInfo[] archivosFuente = informaciónDelDirectorio.GetFiles("*.mp"); foreach (FileInfo archivo in archivosFuente) { // Verifica que el archivo de salida no existe. string archivoDeSalida = Path.Combine(argumentos.DirectorioDeSalida, archivo.Name); if (File.Exists(archivoDeSalida)) { Console.WriteLine(string.Format("ERROR: Archivo de salida '{0}' ya existe.", archivoDeSalida)); Environment.Exit(1); break; } // Lee mapa. Console.Write(string.Format("Leyendo '{0}' ... ", archivo.FullName)); manejadorDeMapa.Abrir(archivo.FullName); Console.WriteLine("listo."); // Procesa cada uno de los 'procesamientos'. Console.WriteLine("Procesando ... "); foreach (string procesamiento in argumentos.Procesamientos) { Console.Write(string.Format(" -> {0} ...", procesamiento)); int númeroDeProblemas = 0; switch (procesamiento) { case "ProcesarTodo": { númeroDeProblemas += manejadorDeMapa.ProcesarTodo(); } break; case "ArreglaIndices": { númeroDeProblemas += manejadorDeMapa.ManejadorDePdis.ArregladorDeIndicesDeCiudad.Procesa(); númeroDeProblemas += manejadorDeMapa.ManejadorDeVías.ArregladorDeIndicesDeCiudad.Procesa(); } break; default: Console.WriteLine( argumentos.GetUsage(string.Format("ERROR: Procesamiento '{0}' es desconocido.", procesamiento))); Environment.Exit(1); break; } // Imprime el número de problemas encontrados. Console.WriteLine(string.Format(" {0} problemas.", númeroDeProblemas)); // Imprime cambios. ImprimeCambios(manejadorDeMapa.ManejadorDePdis.Elementos, "PDI"); ImprimeCambios(manejadorDeMapa.ManejadorDeVías.Elementos, "Via"); } // Escribe el archivo de salida. Console.Write(string.Format("Guardando mapa '{0}' ... ", archivoDeSalida)); manejadorDeMapa.GuardaEnFormatoPolish( archivoDeSalida, string.Format("Generado por {0} @ {1}", Assembly.GetExecutingAssembly().GetName().Name, DateTime.Now)); Console.WriteLine("listo."); Console.WriteLine(); } }