Esempio n. 1
0
 protected IList<ValoresFuente> LlenarTabla(IWorksheet sheet, int row, FichaIndicadores ficha)
 {
     var lista = new List<ValoresFuente>();
     var total = sheet.NumRows;
     var listaVars = ficha.Variables.Select(x => x.Value).OrderBy(x => x.Orden);
     for (int i = row; i <= total; i++) {
         var codigo = sheet.GetString("B", i);
         if (string.IsNullOrEmpty(codigo))
             break;
         // IMPORTANTE
         var f = new ValoresFuente { Tipo = ficha.Nombre, IdItem = total++, Codigo1 = codigo };
         var nombre = sheet.GetString("C", i);
         f.Codigo2 = string.IsNullOrEmpty(nombre) ? codigo : nombre;
         var off = 3;
         foreach (var v in listaVars) {
             off++;
             f[v.Codigo] = sheet.GetString(off, i);
         }
         lista.Add(f);
     }
     return lista;
 }
Esempio n. 2
0
        public void GuardarRedes(IList<Resultado> lista, string archivo, IList<FichaIndicadores> fichas)
        {
            var map = fichas.ToDictionary(x => x.Nombre);
            var grupos = lista.ToLookup(x => x.Tipo_item);

            using (var pck = new ExcelPackage(new FileInfo(archivo))) {
                try {
                    foreach (var grupo in grupos) {
                        if (!map.ContainsKey(grupo.Key))
                            continue;
                        Ficha = map[grupo.Key];
                        CrearHoja(grupo.ToList(), Ficha.Nombre, pck);
                    }
                    pck.Save();
                } catch (Exception ex) {
                    AppNotifier.Print("Error " + ex.Message, ex);
                }
            }
        }
Esempio n. 3
0
        public static IList<FichaIndicadores> CargarFichas(string file)
        {
            var book = SpreadsheetFactory.GetWorkbook(file);
            var lista = new List<FichaIndicadores>();
            var valoresStart = CellUtils.LetterToColumnNumber("G");
            foreach (var sheet in book.Sheets) {
                var ficha = new FichaIndicadores {
                    Nombre = sheet.Name,
                    Descripcion = sheet.GetString("A3")
                };
                lista.Add(ficha);
                bool fin = false;
                var start = valoresStart;
                while (!fin) {
                    var valor = sheet.GetString(start, 2);
                    if (string.IsNullOrEmpty(valor) || valor == "valores" || ficha.Temas.Contains(valor))
                        fin = true;
                    else
                        ficha.Temas.Add(valor);
                    start++;
                }

                var last = "";
                var countAme = ficha.Temas.Count;
                var numFicha = 0;
                for (int i = 3; i <= sheet.NumRows; i++) {
                    var expresion = sheet.GetString("F", i) ?? "";
                    if (expresion == "")
                        break;
                    var codigo = sheet.GetString("B", i) ?? "";
                    if (codigo != "" && codigo != last) {
                        numFicha++;
                        var v = new Variable(countAme) { Codigo = codigo, Orden = numFicha };
                        v.Nombre = sheet.GetString("D", i);
                        start = valoresStart + countAme + 1;
                        for (int j = 0; j < countAme; j++) {
                            v.Ponderaciones[j] = sheet.GetFloat(start, i);
                            start += 2;
                        }
                        ficha.Variables[codigo] = v;
                        var extra = sheet.GetString("C", i) ?? "";
                        if (extra.Contains("int"))
                            v.Tipo = "int";
                        if (extra.Contains("script"))
                            v.EsScript = true;
                        last = codigo;
                    }
                    var valor = new ValorVariable(countAme);
                    valor.Descripcion = sheet.GetString("E", i);
                    valor.Expresion = expresion;
                    for (int j = 0; j < countAme; j++) {
                        valor.Puntajes[j] = sheet.GetFloat(j + valoresStart, i);
                    }
                    ficha.Variables[last].Valores.Add(valor);
                }

            }
            if (book is IDisposable)
                (book as IDisposable).Dispose();
            return lista;
        }
Esempio n. 4
0
 public static MapeosFuente CrearDeFicha(FichaIndicadores ficha)
 {
     var mapeos = new MapeosFuente();
     foreach (var v in ficha.Variables.Values) {
         var mapeo = new MapeoCampo { CodigoVariable = v.Codigo };
         mapeos.Campos[v.Codigo] = mapeo;
     }
     return mapeos;
 }