Esempio n. 1
0
    //------------------------------------------------------------------------
    private static void AddSystemesCoordonnees(CContexteDonnee ctx, CMemoryDb db)
    {
        CListeObjetDonneeGenerique <CSystemeCoordonnees> lst = new CListeObjetDonneeGenerique <CSystemeCoordonnees>(ctx);

        lst.ReadDependances("RelationFormatsNumerotation");
        foreach (CSystemeCoordonnees systemeTimos in lst)
        {
            TID.CSystemeCoordonnees systeme = new TID.CSystemeCoordonnees(db);
            systeme.CreateNew(systemeTimos.Id);
            systeme.Libelle = systemeTimos.Libelle;
            foreach (CRelationSystemeCoordonnees_FormatNumerotation relTimos in systemeTimos.RelationFormatsNumerotation)
            {
                TID.CRelationSystemeCoordonnees_FormatNumerotation rel = new TID.CRelationSystemeCoordonnees_FormatNumerotation(db);
                TID.CFormatNumerotation format = new TID.CFormatNumerotation(db);
                int?nId = (int?)relTimos.Row[CFormatNumerotation.c_champId, true];
                if (nId == null || format.ReadIfExistsIdTimos(nId.Value))
                {
                    TID.CUniteCoordonnee unite = new TID.CUniteCoordonnee(db);
                    nId = (int?)relTimos.Row[CUniteCoordonnee.c_champId, true];
                    if (nId == null || unite.ReadIfExistsIdTimos(nId.Value))
                    {
                        rel.CreateNew(relTimos.Id);
                        rel.FormatNumerotation   = format;
                        rel.Libelle              = relTimos.Libelle;
                        rel.Position             = relTimos.Position;
                        rel.Prefixes             = relTimos.Prefixes;
                        rel.SystemeDeCoordonnees = systeme;
                        rel.Unite = unite;
                    }
                }
            }
        }
    }
Esempio n. 2
0
    //------------------------------------------------------------------------
    public static DataSet GetListeSitesPourReferences(C2iSessionWeb session)
    {
        using (CContexteDonnee ctx = new CContexteDonnee(session.Session.IdSession, true, false))
        {
            CMemoryDb db = new CMemoryDb();
            AddTypesSitesToDb(ctx, db);
            TID.CIndexIdTimos <TID.CTypeSite> dicTypesSites = TID.CIndexIdTimos <TID.CTypeSite> .GetIdTimosIndex(db);

            CListeObjetDonneeGenerique <CSite> lstSites = new CListeObjetDonneeGenerique <CSite>(ctx);
            lstSites.AssureLectureFaite();
            lstSites.ReadDependances("SitesFils");
            lstSites.ReadDependances("TypeSite");
            lstSites.Filtre = new CFiltreData(CSite.c_champIdParent + " is null");
            foreach (CSite site in lstSites)
            {
                AddSitePourReference(site, null, db, dicTypesSites);
            }
            return(db);
        }
    }
Esempio n. 3
0
    //------------------------------------------------------------------------
    private static void AddConstructeursToDb(CContexteDonnee ctx, CMemoryDb db)
    {
        CListeObjetDonneeGenerique <CDonneesActeurConstructeur> lst = new CListeObjetDonneeGenerique <CDonneesActeurConstructeur>(ctx);

        lst.ReadDependances("Acteur");
        foreach (CDonneesActeurConstructeur timosConst in lst)
        {
            TID.CConstructeur constructeur = new TID.CConstructeur(db);
            constructeur.CreateNew(timosConst.Id);
            constructeur.Libelle = timosConst.Acteur.Nom;
        }
    }
Esempio n. 4
0
    //------------------------------------------------------------------------
    private static void AddChampsCustom(CContexteDonnee ctx, CMemoryDb db)
    {
        CListeObjetDonneeGenerique <CChampCustom> lst = new CListeObjetDonneeGenerique <CChampCustom>(ctx);

        lst.Filtre = CChampCustom.GetFiltreChampsForRole(CReleveEquipement.c_roleChampCustom);
        lst.ReadDependances("ListeValeurs");
        foreach (CChampCustom champTimos in lst)
        {
            if (champTimos.TypeDonneeChamp.TypeDonnee != TypeDonnee.tObjetDonneeAIdNumeriqueAuto)
            {
                AssureChampInMemoryDb(champTimos, db);
            }
        }
    }
        public static CMemoryDb GetAlarmesAAfficher(int nIdSession)
        {
            using (CContexteDonnee ctx = new CContexteDonnee(nIdSession, true, false))
            {
                CMemoryDb db = CMemoryDbPourSupervision.GetMemoryDb(ctx);
                //Catégories de masquage
                CListeObjetDonneeGenerique <CCategorieMasquageAlarme> lstCat = new CListeObjetDonneeGenerique <CCategorieMasquageAlarme>(ctx);
                foreach (CCategorieMasquageAlarme cat in lstCat)
                {
                    CLocalCategorieMasquageAlarme local = cat.GetLocalCategorieForSupervision(db);
                }

                CListeObjetDonneeGenerique <CAlarme> lst = new CListeObjetDonneeGenerique <CAlarme>(ctx);
                lst.Filtre = new CFiltreData(CAlarme.c_champDateFin + " is null and " +
                                             CAlarme.c_champIdParent + " is null");
                int nCount = 0;
                if (lst.Count == 0)
                {
                    return(db);
                }
                CListeObjetsDonnees lstFilles = lst;
                while (ctx.Tables[CAlarme.c_nomTable].Rows.Count != nCount)
                {
                    nCount    = ctx.Tables[CAlarme.c_nomTable].Rows.Count;
                    lstFilles = lstFilles.GetDependances("AlarmesFilles");
                }
                lst = new CListeObjetDonneeGenerique <CAlarme>(ctx);
                lst.InterditLectureInDB = true;
                lst.ReadDependances("RelationsChampsCustom");
                lst.Filtre = new CFiltreData(CAlarme.c_champIdParent + " is null");
                CListeObjetDonneeGenerique <CTypeAlarme> lstTypes = new CListeObjetDonneeGenerique <CTypeAlarme>(ctx);
                lstTypes.AssureLectureFaite();

                foreach (CAlarme alrm in lst)
                {
                    CLocalAlarme newAlrm = alrm.GetLocalAlarme(db, true);
                }
                return(db);
            }
        }
Esempio n. 6
0
    public static DataSet GetEquipments(C2iSessionWeb sessionWeb,
                                        int nIdSiteContenant)
    {
        using (CContexteDonnee ctx = new CContexteDonnee(sessionWeb.Session.IdSession, true, false))
        {
            CMemoryDb db = new CMemoryDb();
            db.EnforceConstraints = false;

            //Identifie les champs custom interessants
            CListeObjetDonneeGenerique <CChampCustom> lstChamps = new CListeObjetDonneeGenerique <CChampCustom>(ctx);
            lstChamps.Filtre = CChampCustom.GetFiltreChampsForRole(CReleveEquipement.c_roleChampCustom);
            StringBuilder blChampsCustom = new StringBuilder();
            foreach (CChampCustom champ in lstChamps)
            {
                blChampsCustom.Append(champ.Id);
                blChampsCustom.Append(",");
                AssureChampInMemoryDb(champ, db);
            }
            if (blChampsCustom.Length > 0)
            {
                blChampsCustom.Remove(blChampsCustom.Length - 1, 1);
            }



            //Ajout des équipements
            CListeObjetDonneeGenerique <CEquipement> equipements = new CListeObjetDonneeGenerique <CEquipement>(ctx);
            equipements.Filtre = new CFiltreData(CSite.c_champId + "=@1", nIdSiteContenant);
            equipements.AssureLectureFaite();
            equipements.ReadDependances("EquipementsContenus.ParametragesSystemesCoordonnees", "RelationsChampsCustom");
            equipements.Filtre = new CFiltreData(CEquipement.c_champIdEquipementContenant + " is null");
            equipements.InterditLectureInDB = true;
            foreach (CEquipement eqt in equipements)
            {
                AddDetailEquipementToDb(eqt, null, blChampsCustom.ToString(), db);
            }
            return(db);
        }
    }
Esempio n. 7
0
    //------------------------------------------------------------------------
    public static DataSet GetSites(
        C2iSessionWeb sessionWeb,
        int[] nIdSites)
    {
        using (CContexteDonnee ctx = new CContexteDonnee(sessionWeb.Session.IdSession, true, false))
        {
            CMemoryDb db = new CMemoryDb();
            db.EnforceConstraints = false;
            if (nIdSites != null && nIdSites.Length > 0)
            {
                StringBuilder bl = new StringBuilder();
                foreach (int nIdSite in nIdSites)
                {
                    bl.Append(nIdSite);
                    bl.Append(';');
                }
                bl.Remove(bl.Length - 1, 1);
                CFiltreDataAvance filtre = new CFiltreDataAvance(CSite.c_nomTable,
                                                                 CSite.c_champId + " in {" + bl.ToString() + "}");
                filtre.IntegrerFilsHierarchiques = true;
                CListeObjetDonneeGenerique <CSite> lstSites = new CListeObjetDonneeGenerique <CSite>(ctx);
                lstSites.Filtre = filtre;
                lstSites.AssureLectureFaite();
                lstSites.ReadDependances("SitesFils");
                lstSites.Filtre = new CFiltreData(CSite.c_champIdParent + " is null");
                lstSites.InterditLectureInDB = true;


                foreach (CSite site in lstSites)
                {
                    AddDetailSiteToDb(site, null, db);
                }
            }
            return(db);
        }
    }
Esempio n. 8
0
    //------------------------------------------------------------------------
    private static void AddTypesEquipementsToDb(CContexteDonnee ctx, CMemoryDb db)
    {
        CListeObjetDonneeGenerique <CTypeEquipement> lst = new CListeObjetDonneeGenerique <CTypeEquipement>(ctx);

        lst.ReadDependances("RelationsConstructeurs");
        lst.ReadDependances("ParametragesSystemesCoordonnees");
        lst.ReadDependances("RelationsTypesParents");

        TID.CIndexIdTimos <TID.CConstructeur> dicConstructeurs = TID.CIndexIdTimos <TID.CConstructeur> .GetIdTimosIndex(db);

        TID.CIndexIdTimos <TID.CSystemeCoordonnees> dicSC = TID.CIndexIdTimos <TID.CSystemeCoordonnees> .GetIdTimosIndex(db);

        TID.CIndexIdTimos <TID.CRelationSystemeCoordonnees_FormatNumerotation> dicRFN = TID.CIndexIdTimos <TID.CRelationSystemeCoordonnees_FormatNumerotation> .GetIdTimosIndex(db);

        foreach (CTypeEquipement tpTimos in lst)
        {
            TID.CTypeEquipement tp = new TID.CTypeEquipement(db);
            tp.CreateNew(tpTimos.Id);
            tp.Libelle          = tpTimos.Libelle;
            tp.NbUnitesOccupees = tpTimos.NbUnitesOccupees;
            tp.Row[TID.CTypeEquipement.c_champUniteOccupation] = tpTimos.Row[CTypeEquipement.c_champUniteOccupation];
            tp.OptionsControleCoordonneesPropreInt             = tpTimos.OptionsControleCoordonneesPropreInt;
            foreach (CRelationTypeEquipement_Constructeurs relConsTimos in tpTimos.RelationsConstructeurs)
            {
                TID.CTypeEquipementConstructeur tpCons = new TID.CTypeEquipementConstructeur(db);

                int?nId = (int?)relConsTimos.Row[CDonneesActeurConstructeur.c_champId, true];
                TID.CConstructeur cons = dicConstructeurs.GetSafe(nId);

                if (cons != null)
                {
                    tpCons.CreateNew(relConsTimos.Id);
                    tpCons.IdTimos        = relConsTimos.Id;
                    tpCons.TypeEquipement = tp;
                    tpCons.Constructeur   = cons;
                    tpCons.Reference      = relConsTimos.Reference;
                }
            }


            //Coordonnées
            CParametrageSystemeCoordonnees     paramTimos  = tpTimos.ParametrageCoordonneesPropre;
            TID.CParametrageSystemeCoordonnees parametrage = ImporteParametrageSC(
                paramTimos,
                db,
                dicSC,
                dicRFN);
            if (parametrage != null)
            {
                parametrage.TypeEquipement = tp;
            }

            foreach (CRelationTypeEquipement_Heritage relTimos in tpTimos.RelationsTypesParents)
            {
                TID.CRelationTypeEquipement_Heritage rel = new TimosInventory.data.CRelationTypeEquipement_Heritage(db);
                rel.CreateNew(relTimos.Id);
                rel.Row[TID.CRelationTypeEquipement_Heritage.c_champIdTypeFils]   = relTimos.Row[CRelationTypeEquipement_Heritage.c_champIdTypeFils];
                rel.Row[TID.CRelationTypeEquipement_Heritage.c_champIdTypeParent] = relTimos.Row[CRelationTypeEquipement_Heritage.c_champIdTypeParent];
            }
        }
    }