Пример #1
0
 //---------------------------------------------------------------------
 public void SetValeur(object objet, object valeur)
 {
     if (objet != null && objet is IObjetDonneeAChamps)
     {
         if (valeur is int)
         {
             if ((int)valeur >= 0)
             {
                 CContexteDonnee contexte = ((IObjetDonneeAChamps)objet).ContexteDonnee;
                 CChampCustom    champ    = new CChampCustom(contexte);
                 if (champ.ReadIfExists(IdChampCustom))
                 {
                     CObjetDonneeAIdNumerique objetDonne = (CObjetDonneeAIdNumerique)Activator.CreateInstance(champ.TypeObjetDonnee, new object[] { contexte });
                     if (objetDonne.ReadIfExists((int)valeur))
                     {
                         CUtilElementAChamps.SetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom, objetDonne);
                     }
                     else
                     {
                         throw new Exception(I.T("Object @1 @2 doesn't exist|515",
                                                 DynamicClassAttribute.GetNomConvivial(champ.TypeObjetDonnee),
                                                 valeur.ToString()));
                     }
                 }
             }
         }
         else
         {
             CUtilElementAChamps.SetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom, null);
         }
     }
 }
Пример #2
0
        //-------------------------------------------------------------------------------
        //Optimisation : l'entité pour sup n'est créée qu'une seul fois lors d'appels multiples
        public CResultAErreur ReadChampSnmp(int nIdChampCustom, CInterrogateurSnmp dynamicAgent, ref CEntiteSnmpPourSupervision ettPourSup)
        {
            CResultAErreur result = CResultAErreur.True;

            CResultAErreurType <string> resOID = GetFieldOIDWithEntitePourSupervision(nIdChampCustom, ettPourSup);

            if (!resOID)
            {
                result.EmpileErreur(resOID.Erreur);
                return(result);
            }

            string    strOID = resOID.DataType;
            ISnmpData valeur = dynamicAgent.Get(strOID) as ISnmpData;
            CRelationEntiteSnmp_ChampCustom relChamp = CUtilElementAChamps.GetRelationToChamp(this, nIdChampCustom) as CRelationEntiteSnmp_ChampCustom;

            if (relChamp != null)
            {
                if (valeur == null)
                {
                    relChamp.LastSnmpValue = null;
                }
                else
                {
                    relChamp.LastSnmpValue = valeur.ConvertToTypeDotNet();
                }
            }
            result.Data = valeur != null?valeur.ConvertToTypeDotNet() : null;

            return(result);
        }
Пример #3
0
 //---------------------------------------------------------------------
 public void SetValeur(object objet, object valeur)
 {
     if (objet != null && objet is IObjetDonneeAChamps)
     {
         CUtilElementAChamps.SetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom, valeur);
     }
 }
Пример #4
0
        //-----------------------------------------------
        void WriteValue(object sender, EventArgs e)
        {
            CEntiteSnmp entiteSnmp = EditedElement as CEntiteSnmp;

            if (entiteSnmp != null)
            {
                CResultAErreur result = MajChamps(true);
                if (!result)
                {
                    CFormAlerte.Afficher(result.Erreur);
                    return;
                }
                CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(entiteSnmp, ((CChampCustom)WndSnmp.FieldZone.Variable).Id) as CRelationEntiteSnmp_ChampCustom;
                if (rel != null)
                {
                    result = rel.WriteSnmpValue();
                    if (!result)
                    {
                        CFormAlerte.Afficher(result.Erreur);
                    }
                    else
                    {
                        ReadSnmpValue(this, null);
                        MyUpdateValeursCalculees();
                    }
                }
            }
        }
Пример #5
0
 //---------------------------------------------------------------------
 public object GetValeur(object objet)
 {
     if (objet != null && objet is IObjetDonneeAChamps)
     {
         return(CUtilElementAChamps.GetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom));
     }
     return(null);
 }
Пример #6
0
        //-----------------------------------------------------------------------
        public void CopieValeurSnmpDansValeurChamp(int nIdChampCustom)
        {
            CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(this, nIdChampCustom) as CRelationEntiteSnmp_ChampCustom;

            if (rel != null)
            {
                SetValeurFromSnmp(nIdChampCustom, rel.LastSnmpValue);
            }
        }
Пример #7
0
 //---------------------------------------------------------------------
 public object GetValeur(object objet)
 {
     if (objet != null && objet is IObjetDonneeAChamps)
     {
         CObjetDonneeAIdNumerique retour = (CObjetDonneeAIdNumerique)CUtilElementAChamps.GetValeurChamp((IObjetDonneeAChamps)objet, m_nIdChampCustom);
         if (retour == null)
         {
             return(DBNull.Value);
         }
         return(retour.Id);
     }
     return(null);
 }
Пример #8
0
        //-------------------------------------------------------------------------------------
        public CFormulaire[] GetFormulaires()
        {
            return(CUtilElementAChamps.GetFormulaires(this));

            /*ArrayList lst = new ArrayList();
             * if (TypeTicket != null)
             * {
             *      foreach (CRelationTypeTicket_Formulaire rel in TypeTicket.RelationsFormulaires)
             *              lst.Add(rel.Formulaire);
             * }
             * //if (OrigineTicket != null)
             * //{
             * //    lst.Add(OrigineTicket.Formulaire);
             * //}
             * return (CFormulaire[])lst.ToArray(typeof(CFormulaire));*/
        }
Пример #9
0
        //----------------------------------------------------
        public CResultAErreur SetValeurFromSnmp(int nIdChampCustom, object valeur)
        {
            CResultAErreur result = SetValeurChamp(nIdChampCustom, valeur);

            if (!result)
            {
                return(result);
            }
            CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(this, nIdChampCustom) as CRelationEntiteSnmp_ChampCustom;

            if (rel != null)
            {
                rel.LastSnmpValue = valeur;
            }

            return(result);
        }
Пример #10
0
        public CFormMain()
        {
            InitializeComponent();

            if (CImportMyanmarConst.SessionClient != null)
            {
                CListeObjetDonneeGenerique <CProjet> lst = new CListeObjetDonneeGenerique <CProjet>(CImportMyanmarConst.ContexteDonnee);
                lst.Filtre = new CFiltreData(
                    CTypeProjet.c_champId + "=@1", 4);
                CUtilElementAChamps.ReadChampsCustom(lst, 2567);
                foreach (CProjet projet in lst)
                {
                    string strVal = projet.GetValeurChamp(2567) as string;
                    if (strVal != null && strVal.Length > 0)
                    {
                        m_dicNominalCodeToProjet[strVal] = projet;
                    }
                }
            }
        }
Пример #11
0
        //------------------------------------------------------------------------
        public object GetObjectValueForGrid(object element)
        {
            CEntiteSnmp entite = element as CEntiteSnmp;

            if (entite != null)
            {
                CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(entite, m_wndChampCustom.ChampCustom.Id) as CRelationEntiteSnmp_ChampCustom;
                if (rel != null)
                {
                    string strRetour = rel.Valeur == null ? "" : rel.Valeur.ToString();
                    strRetour += "  (";
                    object val = rel.LastSnmpValue;
                    return(val);
                }
            }
            if (m_wndChampCustom != null)
            {
                return(m_wndChampCustom.GetObjectValueForGrid(element));
            }
            return("");
        }
Пример #12
0
        //--------------------------------------------------------------------
        private void UpdateDateSNMP()
        {
            DateTime?                dtOld   = null;
            CSchemaReseau            schema  = m_stackCheminsReseau.Peek();
            CListeCouplesEntiteChamp couples = schema.GetListeValeursSnmpAffichees();

            foreach (CCoupleEntiteSnmp_Champ couple in couples)
            {
                CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(couple.Entite, couple.ChampCustom.Id) as CRelationEntiteSnmp_ChampCustom;
                if (rel != null && rel.DateSynchroSnmp != null)
                {
                    if (dtOld == null || rel.DateSynchroSnmp.DateTimeValue < dtOld.Value)
                    {
                        dtOld = rel.DateSynchroSnmp.DateTimeValue;
                    }
                }
            }
            m_bHasSnmpEntities  = couples.Count > 0;
            m_panelSNMP.Visible = m_bHasSnmpEntities;
            m_lastSnmpUpdate    = dtOld;
            UpdateLabelSnmpUpdate();
        }
Пример #13
0
 public object GetValeurChamp(string strIdVariable)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, strIdVariable));
 }
Пример #14
0
 //----------------------------------------------------------------------------
 public object GetValeurChamp(int nIdChamp)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, nIdChamp));
 }
Пример #15
0
 //-----------------------------------------------------------------------------
 public object GetValeurChamp(int nIdChamp, DataRowVersion version)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, nIdChamp, version));
 }
Пример #16
0
        //-------------------------------------
        protected override void  MyUpdateValeursCalculees()
        {
            if (m_controleSnmp == null)
            {
                return;
            }
            CEntiteSnmp entiteSnmp = EditedElement as CEntiteSnmp;

            if (entiteSnmp == null)
            {
                return;
            }

            CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(entiteSnmp, ((CChampCustom)WndSnmp.FieldZone.Variable).Id) as CRelationEntiteSnmp_ChampCustom;

            if (m_createur != null && m_controleSnmp != null)
            {
                m_createur.SetTooltip(m_controleSnmp, "");
            }
            if (rel == null)
            {
                m_controleSnmp.Visible = false;
                m_imageWarning.Visible = false;
            }
            else
            {
                CDateTimeEx dt = rel.DateSynchroSnmp;
                if (dt != null)
                {
                    if (m_createur != null && m_controleSnmp != null)
                    {
                        m_createur.SetTooltip(m_controleSnmp, I.T("Last updated : @1 @2|20317",
                                                                  dt.DateTimeValue.ToShortDateString(),
                                                                  dt.DateTimeValue.ToLongTimeString()));
                    }
                }
                m_controleSnmp.Visible = true;
                object val = rel.LastSnmpValue;
                if (val == null)
                {
                    m_controleSnmp.Text = "";
                }
                else
                {
                    if (WndSnmp.ChampCustom.IsChoixParmis())
                    {
                        m_controleSnmp.Text = WndSnmp.ChampCustom.DisplayFromValue(val);
                    }
                    else if (m_controleSnmp is CheckBox)
                    {
                        ((CheckBox)m_controleSnmp).Checked = (val is bool) ? (bool)val : false;
                    }
                    else
                    {
                        m_controleSnmp.Text = val.ToString();
                    }
                }
                string strVal1 = m_wndChamp.Value != null?m_wndChamp.Value.ToString() : "";

                string strVal2 = val != null?val.ToString() : "";

                if (strVal1 != strVal2 && rel.DateSynchroSnmp != null)
                {
                    m_imageWarning.Visible = true;
                    m_controleSnmp.Width   = m_wndChamp.Control.Width - 16;
                }
                else
                {
                    m_imageWarning.Visible = false;
                    m_controleSnmp.Width   = m_wndChamp.Control.Width;
                }
            }
        }
Пример #17
0
 public CFormulaire[] GetFormulaires()
 {
     return(CUtilElementAChamps.GetFormulaires(this));
 }
Пример #18
0
        // /////////////////////////////////////////////////////////
        /// <summary>
        /// Le data du result contient un IBaseGantt
        /// </summary>
        /// <returns></returns>
        public static CResultAErreur CreateGantt(
            CMetaProjet metaProjet,
            CParametreNiveauArbreGanttGroupe groupeRacine,
            CFiltreData filtreElements)
        {
            CResultAErreur result = CResultAErreur.True;
            if (metaProjet == null)
                return result;
            CElementDeGanttMetaProjet elementRacine = new CElementDeGanttMetaProjet(null, metaProjet);
            if (!result)
                return result;
            List<CProjet> lstProjets = new List<CProjet>();

            bool bLectureDansContexteCourant = false;
            //S'il y a des éléments modifiés, ajoutés ou supprimés dans
            //les relations, charge manuellement
            DataTable table = metaProjet.ContexteDonnee.GetTableSafe(CRelationMetaProjet_Projet.c_nomTable);
            if ( table != null )
            {
                if ( table.Select ( "", "", DataViewRowState.Added | DataViewRowState.Deleted | DataViewRowState.ModifiedCurrent ).Length > 0 )
                {
                    bLectureDansContexteCourant = true;
                    //Il y a des modifs, on ne peut donc pas appliquer le filtre,
                    //et on doit aller chercher les projets manuellement
                    foreach ( CRelationMetaProjet_Projet rel in metaProjet.RelationsProjets )
                    {
                        List<CProjet> lstTmp = new List<CProjet>();
                        lstTmp.Add ( rel.Projet );
                        while ( lstTmp.Count > 0 )
                        {
                            List<CProjet> lstSuivante = new List<CProjet>();
                            foreach ( CProjet prj in lstTmp )
                            {
                                lstProjets.Add ( prj );
                                lstSuivante.AddRange ( prj.ProjetsFils.ToList<CProjet>());
                            }
                            lstTmp = lstSuivante;
                        }
                    }
                }
            }
            if (!bLectureDansContexteCourant)
            {
                CFiltreData filtre = result.Data as CFiltreData;
                filtre = CFiltreData.GetAndFiltre(filtreElements,
                    new CFiltreDataAvance(
                        CProjet.c_nomTable,
                        CRelationMetaProjet_Projet.c_nomTable + "." +
                        CMetaProjet.c_champId + "=@1",
                        metaProjet.Id));

                filtre.IntegrerFilsHierarchiques = !metaProjet.HideChildProjects;
                CListeObjetsDonnees lstObjetProjets = new CListeObjetsDonnees(metaProjet.ContexteDonnee, typeof(CProjet), filtre);
                lstObjetProjets.PreserveChanges = true;
                lstObjetProjets.ModeSansTri = true;
                lstProjets.AddRange(lstObjetProjets.ToList<CProjet>());
                if ( metaProjet.HideChildProjects )
                    lstObjetProjets.ReadDependances("LiensEnTantQueProjetA.ProjetB", "LiensEnTantQueProjetB.ProjetA", "ContraintesPropres", "AnomaliesDuProjet");
                else
                    lstObjetProjets.ReadDependances("ProjetsFils", "LiensEnTantQueProjetA.ProjetB", "LiensEnTantQueProjetB.ProjetA", "ContraintesPropres", "AnomaliesDuProjet");
                CUtilElementAChamps.ReadChampsCustom(lstObjetProjets);
            }

            CContexteDonnee contexteDeTravail = metaProjet.ContexteDonnee;

            return PrepareGantt(groupeRacine, result, elementRacine, lstProjets, contexteDeTravail);
        }
Пример #19
0
        //-----------------------------------------------------------------------
        //Si idsChampsAMettreAJour est vide, il faut tout mettre à jour
        public CResultAErreur SendToSnmp(bool bOnlyModifiés, params int[] idsChampsAMettreAJour)
        {
            CResultAErreur result = CResultAErreur.True;

            if (TypeEntiteSnmp == null)
            {
                return(result);
            }
            if (TypeEntiteSnmp.ReadOnly)
            {
                result.EmpileErreur(I.T("This is a readonly entity|20127"));
                return(result);
            }
            IEnumerable <CChampEntiteFromQueryToChampCustom> lstChamps = TypeEntiteSnmp.ChampsFromQuery;
            Dictionary <string, object>            lstValeurs          = new Dictionary <string, object>();
            CResultAErreurType <IObjetDeEasyQuery> resObj = TypeEntiteSnmp.FindSourceObjetInQuery( );

            if (!resObj || resObj.DataType == null)
            {
                result.EmpileErreur(resObj.Erreur);
                return(result);
            }

            IObjetDeEasyQuery objetSource = resObj.DataType;
            CEasyQuery        query       = objetSource.Query;

            Dictionary <string, string> dicOIDStringToChamp = new Dictionary <string, string>();
            CEntiteSnmpPourSupervision  ettPourSup          = null;

            foreach (CChampEntiteFromQueryToChampCustom champ in lstChamps)
            {
                if (champ.IdChampCustom != null && (idsChampsAMettreAJour.Length == 0 ||
                                                    idsChampsAMettreAJour.Contains(champ.IdChampCustom.Value)))
                {
                    CRelationElementAChamp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(this, champ.IdChampCustom.Value);
                    if (rel != null && (bOnlyModifiés && (rel.Row.RowState == DataRowState.Added || rel.Row.RowState == DataRowState.Modified) ||
                                        !bOnlyModifiés))
                    {
                        object valeur = rel.Valeur;

                        ITableDefinition  table = null;
                        IColumnDefinition col   = null;
                        if (query.FindSource(champ.Champ.ColonneSource, objetSource,
                                             out table,
                                             out col))
                        {
                            CColumnDefinitionSNMP colSnmp = col as CColumnDefinitionSNMP;

                            if (colSnmp != null && !champ.Champ.IsReadOnly)
                            {
                                ISnmpData snmpVal = AbstractTypeAssignment.GetSnmpFromDotNet(colSnmp.SnmpType, valeur);
                                if (snmpVal == null && valeur != null)
                                {
                                    snmpVal = new OctetString(valeur.ToString());
                                }
                                if (snmpVal != null)
                                {
                                    string strIndex = Index;
                                    if (champ.Champ.FormuleIndex != null)
                                    {
                                        if (ettPourSup == null)
                                        {
                                            ettPourSup = GetEntitePourSupervision(TypeEntiteSnmp.GetTypeEntitePourSupervision(null, false));
                                        }
                                        CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(ettPourSup);
                                        CResultAErreur restTmp            = champ.Champ.FormuleIndex.Eval(ctx);
                                        if (restTmp && restTmp.Data != null)
                                        {
                                            strIndex = restTmp.Data.ToString();
                                        }
                                    }
                                    if (!strIndex.StartsWith("."))
                                    {
                                        strIndex = "." + strIndex;
                                    }
                                    lstValeurs[colSnmp.OIDString + strIndex]          = snmpVal;
                                    dicOIDStringToChamp[colSnmp.OIDString + strIndex] = champ.ChampCustom.Nom;
                                }
                            }
                        }
                    }
                }
            }
            if (lstValeurs.Count > 0)
            {
                CInterrogateurSnmp agent = new CInterrogateurSnmp();
                agent.Connexion.Version  = AgentSnmp.SnmpVersion;
                agent.ConnexionIp        = AgentSnmp.SnmpIp;
                agent.ConnexionPort      = AgentSnmp.SnmpPort;
                agent.ConnexionCommunity = AgentSnmp.SnmpCommunaute;
                foreach (KeyValuePair <string, object> kv in lstValeurs)
                {
                    try
                    {
                        CResultAErreur resTmp = agent.Set(kv.Key, kv.Value);

                        if (!resTmp)
                        {
                            string strChamp = null;
                            if (dicOIDStringToChamp.TryGetValue(kv.Key, out strChamp))
                            {
                                result.EmpileErreur(new CErreurValidation(I.T("Entity @1 (@2), Field @3 : |20105", Libelle, Index, strChamp) + resTmp.Erreur.ToString(), resTmp.IsAvertissement));
                            }
                            else
                            {
                                result.EmpileErreur(resTmp.Erreur);
                            }
                            if (!result.IsAvertissement)
                            {
                                return(result);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        result.EmpileErreur(new CErreurException(e));
                    }
                }
            }
            return(result);
        }
Пример #20
0
        //-------------------------------------------------------------
        public CResultAErreur GenereItems(CMapDatabase database, CContexteDonnee ctxDonnee)
        {
            CResultAErreur result = CResultAErreur.True;

            //Calcule les éléments à générer
            if (Filtre == null || Filtre.TypeElements == null)
            {
                return(result);
            }
            if (FormuleLatitude == null || FormuleLongitude == null)
            {
                return(result);
            }
            result = Filtre.GetFiltreData();
            if (!result)
            {
                return(result);
            }
            CFiltreData         filtre    = result.Data as CFiltreData;
            CListeObjetsDonnees lstObjets = new CListeObjetsDonnees(ctxDonnee, Filtre.TypeElements);

            lstObjets.Filtre      = filtre;
            lstObjets.ModeSansTri = true;

            CMapLayer layer = null;

            if (lstObjets.Count > 0)
            {
                layer = database.GetLayer(Generator.LayerId, true);
            }
            else
            {
                return(result);
            }

            int?nIdChampLatitude  = null;
            int?nIdChampLongitude = null;
            Dictionary <int, double> dicValeursLatitude  = new Dictionary <int, double>();
            Dictionary <int, double> dicValeursLongitude = new Dictionary <int, double>();

            if (typeof(IObjetDonneeAChamps).IsAssignableFrom(lstObjets.TypeObjets))
            {
                nIdChampLatitude  = GetIdChampOptimFromFormule(FormuleLatitude);
                nIdChampLongitude = GetIdChampOptimFromFormule(FormuleLongitude);
                List <int> lst = new List <int>();
                if (nIdChampLatitude != null)
                {
                    lst.Add(nIdChampLatitude.Value);
                }
                if (nIdChampLongitude != null)
                {
                    lst.Add(nIdChampLongitude.Value);
                }
                if (lst.Count > 0)
                {
                    CUtilElementAChamps.ReadChampsCustom(lstObjets, lst.ToArray());
                }
                DataTable table = ctxDonnee.Tables[((IObjetDonneeAChamps)lstObjets[0]).GetNomTableRelationToChamps()];
                if (table != null && (nIdChampLatitude != null || nIdChampLatitude != null))
                {
                    string strCle    = ((CObjetDonneeAIdNumerique)lstObjets[0]).GetChampId();
                    string strFiltre = "";
                    if (nIdChampLatitude != null)
                    {
                        strFiltre = CChampCustom.c_champId + "=" + nIdChampLatitude.Value;
                    }
                    if (nIdChampLongitude != null)
                    {
                        if (strFiltre.Length > 0)
                        {
                            strFiltre += " or ";
                        }
                        strFiltre += CChampCustom.c_champId + "=" + nIdChampLongitude.Value;
                    }
                    DataRow[] rows = table.Select(strFiltre);
                    foreach (DataRow row in table.Rows)
                    {
                        if ((int)row[CChampCustom.c_champId] == nIdChampLatitude)
                        {
                            dicValeursLatitude[(int)row[strCle]] = (double)row[CRelationElementAChamp_ChampCustom.c_champValeurDouble];
                        }
                        else if ((int)row[CChampCustom.c_champId] == nIdChampLongitude)
                        {
                            dicValeursLongitude[(int)row[strCle]] = (double)row[CRelationElementAChamp_ChampCustom.c_champValeurDouble];
                        }
                    }
                }
            }
            else
            {
                nIdChampLatitude  = null;
                nIdChampLongitude = null;
            }


            foreach (object obj in lstObjets)
            {
                DateTime dt = DateTime.Now;
                m_currentGeneratedItem = obj;
                CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(obj);
                double?fLat  = null;
                double?fLong = null;
                if (nIdChampLatitude != null)
                {
                    double fTmp = 0;
                    if (dicValeursLatitude.TryGetValue(((CObjetDonneeAIdNumerique)obj).Id, out fTmp))
                    {
                        fLat = fTmp;
                    }
                }
                else
                {
                    result = FormuleLatitude.Eval(ctxEval);
                    if (result)
                    {
                        try
                        {
                            fLat = Convert.ToDouble(result.Data);
                        }
                        catch { }
                    }
                }
                if (fLat != null)
                {
                    if (nIdChampLongitude != null)
                    {
                        double fTmp = 0;
                        if (dicValeursLongitude.TryGetValue(((CObjetDonneeAIdNumerique)obj).Id, out fTmp))
                        {
                            fLong = fTmp;
                        }
                    }
                    else
                    {
                        result = FormuleLongitude.Eval(ctxEval);
                        if (result)
                        {
                            try
                            {
                                fLong = Convert.ToDouble(result.Data);
                            }
                            catch { }
                        }
                    }
                }
                TimeSpan sp = DateTime.Now - dt;
                if (obj is CObjetDonnee)
                {
                    //Console.WriteLine("Coord "+((CObjetDonnee)obj).DescriptionElement + " : " + sp.TotalMilliseconds);
                }
                if (fLong != null && fLat != null)
                {
                    foreach (CMapItemDessin mapItemDessin in ItemsDessin)
                    {
                        if (mapItemDessin.GenereItem(
                                obj,
                                fLat.Value,
                                fLong.Value,
                                layer))
                        {
                            break;
                        }
                    }
                }
                sp = DateTime.Now - dt;
                if (obj is CObjetDonnee)
                {
                    //Console.WriteLine(((CObjetDonnee)obj).DescriptionElement + " : " + sp.TotalMilliseconds);
                }
            }

            return(result);
        }
Пример #21
0
        // /////////////////////////////////////////////////////////
        /// <summary>
        /// Le data du result contient un IBaseGantt
        /// </summary>
        /// <returns></returns>
        public static CResultAErreur CreateGantt ( 
            CProjet projet, 
            CParametreNiveauArbreGanttGroupe groupeRacine,
            CFiltreData filtreElements )
        {
            CResultAErreur result = CResultAErreur.True;
            if (projet == null)
                return result;
            CElementDeGanttProjet elementRacine = new CElementDeGanttProjet(null, projet);
            if (!result)
                return result;
            List<CProjet> lstProjets = new List<CProjet>();
            if (!projet.IsNew())//Si le projet est nouveau, on ne peut pas filtrer
                //car les éléments ne sont pas encore en base
            {
                CFiltreData filtre = result.Data as CFiltreData;
                filtre = CFiltreData.GetAndFiltre(filtreElements,
                    new CFiltreData(CProjet.c_champCodeSystemeComplet + " like @1 and " +
                        CProjet.c_champId + "<>@2",
                        projet.CodeSystemeComplet + "%",
                        projet.Id));
                CListeObjetsDonnees lstObjetProjets = new CListeObjetsDonnees(projet.ContexteDonnee, typeof(CProjet), filtre);

                lstObjetProjets.PreserveChanges = true;
                lstObjetProjets.ModeSansTri = true;
                lstProjets.AddRange(lstObjetProjets.ToList<CProjet>());


                lstObjetProjets.ReadDependances("ProjetsFils","LiensEnTantQueProjetA", "LiensEnTantQueProjetB", "ContraintesPropres", "AnomaliesDuProjet");
                CUtilElementAChamps.ReadChampsCustom(lstObjetProjets);
            }
            //Il faut ajouter les projets qui ne sont pas encore en base et qui n'ont donc pas de code system
            List<CProjet> lstALire = new List<CProjet>();
            lstALire.Add(projet);
            DataRelation relation = null;
            foreach ( DataRelation rel in projet.ContexteDonnee.Tables[CProjet.c_nomTable].ChildRelations )
            {
                if ( rel.ChildTable.TableName == CProjet.c_nomTable )
                {
                    relation = rel;
                    break;
                }
            }
            while (lstALire.Count > 0 && relation != null)
            {
                List<CProjet> prochaineGeneration = new List<CProjet>();
                foreach (CProjet test in lstALire)
                {
                    DataRow[] rowsDeps = test.Row.Row.GetChildRows(relation);
                    foreach (DataRow row in rowsDeps)
                    {
                        if (row.RowState != DataRowState.Deleted)
                        {
                            CProjet prj = new CProjet(row);
                            if (prj.IsNew() && !lstProjets.Contains(prj) )
                            {
                                lstProjets.Add(prj);
                                
                            }
                            prochaineGeneration.Add(prj);
                        }
                    }
                }
                lstALire = prochaineGeneration;
            }
           
            

            
            //Comme on est passé par un filtre Avancé, les nouveaux éléments ne sont
            //pas dans la liste. On les ajoute donc !
            //Vérifie qu'il y a des éléments dont l'id est négatif
            CListeObjetsDonnees lstTmp = new CListeObjetsDonnees(projet.ContexteDonnee,
                typeof(CProjet));
            lstTmp.Filtre = new CFiltreData(CProjet.c_champId + "<@1", 0);
            lstTmp.InterditLectureInDB = true;
            if (lstTmp.Count > 0)//Il y a des projets tous neufs dans le contexte
            {
                foreach (CProjet projetTmp in new ArrayList(lstProjets))
                {
                    //N'utilise pas ProjetsFils pour ne pas lire dans la base
                    CListeObjetsDonnees lstFils = new CListeObjetsDonnees(projet.ContexteDonnee,
                        typeof(CProjet),
                        new CFiltreData(CProjet.c_champIdParent + "=@1", projetTmp.Id));
                    lstFils.InterditLectureInDB = true;
                    lstFils.Filtre = new CFiltreData(CProjet.c_champId + "<0");
                    foreach (CProjet projetFils in lstFils)
                        if (!lstProjets.Contains(projetFils))
                            lstProjets.Add(projetFils);
                }
                //Les nouveaux sous projet du projet principal doivent également être ajoutés
                CListeObjetsDonnees lstFilsPrincipal = projet.ProjetsFils;
                lstFilsPrincipal.Filtre = new CFiltreData(CProjet.c_champId + "<0");
                foreach (CProjet projetFils in lstFilsPrincipal)
                    if (!lstProjets.Contains(projetFils))
                        lstProjets.Add(projetFils);
            }
            CContexteDonnee contexteDeTravail = projet.ContexteDonnee;

            return PrepareGantt(groupeRacine,result, elementRacine, lstProjets, contexteDeTravail);
        }
Пример #22
0
 //----------------------------------------------------------------
 public void SetValeurChamp(string strIdChamp, object valeur)
 {
     CUtilElementAChamps.SetValeurChamp(this, strIdChamp, valeur);
 }
Пример #23
0
 //------------------------------------------------------------------
 public object GetValeurChamp(int idVariable, DataRowVersion version)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, idVariable, version));
 }
Пример #24
0
        public CTodoValeurChamp(DataSet ds, IObjetDonneeAChamps obj, CChampTimosWebApp champWeb, int nIdGroupeAssocie, bool bIsEditable)
        {
            DataTable dt = ds.Tables[c_nomTable];

            if (dt == null)
            {
                return;
            }

            DataRow row = dt.NewRow();

            int    nIdChampWeb    = champWeb.Id;
            int    nIdChampTimos  = champWeb.IdTimos;
            string strLibelleWeb  = champWeb.WebLabel;
            int    nOrdreWeb      = champWeb.WebNumOrder;
            string strValeur      = "";
            string strElementType = "";
            int    nElementId     = -1;

            CChampCustom champ         = champWeb.Champ;
            bool         bAutoComplete = champWeb.UseAutoComplete;

            if (champ != null)
            {
                if (obj != null)
                {
                    strElementType = obj.GetType().ToString();
                    nElementId     = ((IObjetDonneeAIdNumerique)obj).Id;

                    m_valeur = CUtilElementAChamps.GetValeurChamp(obj, nIdChampTimos);
                    if (m_valeur != null)
                    {
                        if (champ.TypeDonneeChamp.TypeDonnee == TypeDonnee.tObjetDonneeAIdNumeriqueAuto)
                        {
                            IObjetDonneeAIdNumerique objetValeur = m_valeur as IObjetDonneeAIdNumerique;
                            if (objetValeur != null)
                            {
                                try
                                {
                                    if (bIsEditable && !bAutoComplete)
                                    {
                                        strValeur = objetValeur.Id.ToString();
                                    }
                                    else
                                    {
                                        strValeur = objetValeur.DescriptionElement;
                                    }
                                }
                                catch
                                {
                                    strValeur = "";
                                }
                            }
                        }
                        else if (champ.IsChoixParmis())
                        {
                            try
                            {
                                if (bIsEditable)
                                {
                                    strValeur = m_valeur.ToString();
                                }
                                else
                                {
                                    strValeur = champ.DisplayFromValue(m_valeur);
                                }
                            }
                            catch
                            {
                                strValeur = "";
                            }
                        }
                        else
                        {
                            try
                            {
                                strValeur = m_valeur.ToString();
                            }
                            catch
                            {
                                strValeur = "";
                            }
                        }
                    }
                }
            }
            else
            {
                C2iExpression formule = champWeb.Formule;
                if (formule != null)
                {
                    CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(obj);
                    CResultAErreur resFormule         = formule.Eval(ctx);
                    if (resFormule && resFormule.Data != null)
                    {
                        strValeur = resFormule.Data.ToString();
                    }
                }
            }


            row[c_champId]              = nIdChampWeb;
            row[c_champLibelle]         = strLibelleWeb;
            row[c_champOrdreAffichage]  = nOrdreWeb;
            row[c_champValeur]          = strValeur;
            row[c_champElementType]     = strElementType;
            row[c_champElementId]       = nElementId;
            row[c_champIdGroupeChamps]  = nIdGroupeAssocie;
            row[c_champUseAutoComplete] = champWeb.UseAutoComplete;

            m_row = row;
            dt.Rows.Add(row);
        }
Пример #25
0
 //-------------------------------------------------------------------
 public virtual object GetValeurChamp(string strIdChamp)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, strIdChamp));
 }
Пример #26
0
 //---------------------------------------------
 public CResultAErreur SetValeurChamp(string strIdVariable, object valeur)
 {
     return(CUtilElementAChamps.SetValeurChamp(this, strIdVariable, valeur));
 }
Пример #27
0
 //-------------------------------------------------------------------
 public virtual CResultAErreur SetValeurChamp(string strIdChamp, object valeur)
 {
     return(CUtilElementAChamps.SetValeurChamp(this, strIdChamp, valeur));
 }
Пример #28
0
 //-------------------------------------------------------------------
 public virtual object GetValeurChamp(int idChamp, DataRowVersion version)
 {
     return(CUtilElementAChamps.GetValeurChamp(this, idChamp, version));
 }
Пример #29
0
 //-------------------------------------------------------------------
 public CResultAErreur SetValeurChamp(int nIdChamp, object valeur)
 {
     return(CUtilElementAChamps.SetValeurChamp(this, nIdChamp, valeur));
 }
Пример #30
0
        //------------------------------------------------------------------------
        public bool Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, object element)
        {
            CEntiteSnmp entite = element as CEntiteSnmp;

            if (entite != null)
            {
                CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(entite, m_wndChampCustom.ChampCustom.Id) as CRelationEntiteSnmp_ChampCustom;
                if (rel != null)
                {
                    int       nWidthChampCustom = Math.Max((cellBounds.Width * m_wndChampCustom.Size.Width) / Math.Max(Size.Width, 1), 10);
                    object    val     = rel.Valeur;
                    object    valSnmp = rel.LastSnmpValue;
                    Rectangle rct     = new Rectangle(new Point(0, 0), new Size(nWidthChampCustom, cellBounds.Height));
                    rct.Offset(cellBounds.Location);
                    Pen   pen = new Pen(Color.Black, 1);
                    Brush br  = new SolidBrush(m_wndChampCustom.BackColor);
                    graphics.FillRectangle(br, rct);
                    graphics.DrawRectangle(pen, rct);

                    br.Dispose();

                    StringFormat format = new StringFormat();
                    format.LineAlignment = StringAlignment.Center;
                    format.Alignment     = StringAlignment.Near;
                    br = new SolidBrush(m_wndChampCustom.ForeColor);
                    graphics.DrawString(val == null ? "" : val.ToString(), m_wndChampCustom.Font, br, rct, format);
                    br.Dispose();
                    string strVal1 = val != null?val.ToString() : "";

                    string strVal2 = valSnmp != null?valSnmp.ToString() : "";

                    bool bHasDif = strVal1 != strVal2 && rel.DateSynchroSnmp != null;
                    rct = cellBounds;
                    rct.Offset(nWidthChampCustom, 0);
                    rct.Size = new Size(rct.Size.Width - nWidthChampCustom, rct.Size.Height);
                    if (bHasDif)
                    {
                        rct.Size = new Size(rct.Size.Width - 16, rct.Size.Height);
                    }
                    br = new SolidBrush(m_wndValeurAutre.BackColor);
                    graphics.FillRectangle(br, rct);
                    graphics.DrawRectangle(pen, rct);
                    br.Dispose();
                    pen.Dispose();
                    br = new SolidBrush(m_wndValeurAutre.ForeColor);
                    graphics.DrawString(valSnmp == null ? "" : valSnmp.ToString(), m_wndValeurAutre.Font, br, rct, format);
                    format.Dispose();
                    br.Dispose();
                    if (bHasDif)
                    {
                        rct = new Rectangle(cellBounds.Right - 16, cellBounds.Top, 16, cellBounds.Height);
                        br  = new SolidBrush(BackColor);
                        graphics.FillRectangle(br, rct);
                        br.Dispose();
                        rct.Location = new Point(rct.Left, rct.Top + rct.Height / 2 - 8);
                        rct.Height   = 16;
                        graphics.DrawImage(Resource.alerte, rct);
                    }
                    return(false);
                }
            }
            return(true);
        }