示例#1
0
 /// <summary>
 /// Values the tuple.
 /// </summary>
 /// <param name="conn">La conexión a SQLite.</param>
 public void LoadComponentesAndCircuits(SQLite_Connector conn, Tablero tab = null)
 {
     var ctos = conn.Select<Circuito>(TABLE_CIRCUIT.SelectAll(this.CreatePrimaryKeyCondition()), Circuito.CircuitoParser);
     //Guarda los circuitos existentes
     string compQ;
     foreach (Circuito c in ctos)
     {
         if (tab != null)
             c.Tension = tab.Sistema.Tension;
         compQ = TABLE_COMPONENT.SelectAll(String.Format("\"cir_id\" = {0}", c.Id));
         if (!this.Circuitos.ContainsKey(c.ToString()))
             this.Circuitos.Add(c.ToString(), c);
         var cmps = conn.Select<Componente>(compQ, Componente.ComponentParser);
         cmps.ForEach(x =>
         {
             x.Circuito = c;
             x.CircuitoName = c.ToString();
             if (!this.Componentes.ContainsKey(x.Id))
             {
                 this.Componentes.Add(x.Id, x);
                 c.Componentes.Add(x.Id, x);
             }
         });
     }
 }
示例#2
0
 /// <summary>
 /// Inicializa la información de la aplicación
 /// </summary>
 /// <returns>La información de la base de datos</returns>
 public Object InitApplication(SQLite_Connector conn, Object input)
 {
     try
     {
         var prjs = conn.Select <Project>(TABLE_PROYECTOS.SelectAll("\"prj_name\" = 'Sin Proyecto'"));
         CurrentProject = prjs[0];
         string        query = TABLE_HP_WATTS.SelectAll();
         List <HPItem> items = conn.Select <HPItem>(query);
         //Se carga las referencias de los tableros
         //sin cargar circuitos ni componentes
         var tabs = conn.Select <Tablero>(TABLE_TABLERO.SelectAll(CurrentProject.CreatePrimaryKeyCondition()));
         foreach (Tablero tab in tabs)
         {
             CurrentProject.Tableros.Add(tab.Id, tab);
         }
         var   alims   = conn.Select <AlimInput>("alimentador".SelectAll(CurrentProject.CreatePrimaryKeyCondition()));
         var   motores = conn.Select <BigMotor>("motores".SelectAll());
         var   extras  = conn.Select <ExtraData>("extras".SelectAll());
         Linea line;
         foreach (var alimInput in alims)
         {
             var destinations = conn.Select <DestinationRow>("destination".SelectAll(alimInput.CreatePrimaryKeyCondition()));
             line = alimInput.CreateLinea(tabs, motores, extras, destinations, conn);
             CurrentProject.Lineas.Add(line.Id, line);
         }
         //Se cargan las referencias del tablero actual que es el último creado
         CurrentTablero = tabs.LastOrDefault();
         if (CurrentTablero != null)
         {
             CurrentTablero.LoadComponentesAndCircuits(conn);
         }
         return(new Object[] { prjs, tabs, items });
     }
     catch (Exception exc)
     {
         return(new Object[] { exc });
     }
 }