Ejemplo n.º 1
0
 //---------------------------------------
 public void AddFieldFromTrap(CTrapField field)
 {
     if (field == null)
     {
         return;
     }
     if (FieldsFromTrapList.FirstOrDefault(f => f.Name == field.Name) == null)
     {
         FieldsFromTrapList.Add(field);
     }
 }
Ejemplo n.º 2
0
        //---------------------------------------
        public static CTrapHandler CreateFromMib(
            IObjectTree tree,
            IDefinition defNotification,
            CMemoryDb db)
        {
            NotificationType notification = defNotification.Entity as NotificationType;

            if (notification != null)
            {
                CTrapHandler handler = new CTrapHandler(db);
                handler.CreateNew();
                handler.Libelle     = defNotification.Name;
                handler.Description = defNotification.Description;
                foreach (string strObjet in notification.Objects)
                {
                    CTrapField field = new CTrapField();
                    field.Name = strObjet;
                    IDefinition def = tree.Find(strObjet);
                    if (def != null)
                    {
                        field.OID = ObjectIdentifier.Convert(def.GetNumericalForm());
                        handler.AddFieldFromTrap(field);
                    }
                }
                handler.GenericRequestedValue    = GenericCode.EnterpriseSpecific;
                handler.EntrepriseRequestedValue = ObjectIdentifier.Convert(defNotification.GetNumericalForm());
                if (handler.EntrepriseRequestedValue.EndsWith("." + notification.Value.ToString()))
                {
                    handler.EntrepriseRequestedValue = handler.EntrepriseRequestedValue.Remove(handler.EntrepriseRequestedValue.Length - notification.Value.ToString().Length - 1);
                }
                handler.SpecificRequestedValue = notification.Value.ToString();
                return(handler);
            }
            TrapType trap = defNotification.Entity as TrapType;

            if (trap != null)
            {
                CTrapHandler handler = new CTrapHandler(db);
                handler.CreateNew();
                handler.Libelle     = trap.Name;
                handler.Description = trap.Description;
                foreach (string strObjet in trap.Variables)
                {
                    CTrapField field = new CTrapField();
                    field.Name = strObjet;
                    IDefinition def = tree.Find(strObjet);
                    if (def != null)
                    {
                        field.OID = ObjectIdentifier.Convert(def.GetNumericalForm());
                        handler.AddFieldFromTrap(field);
                    }
                }
                handler.GenericRequestedValue    = GenericCode.EnterpriseSpecific;
                handler.EntrepriseRequestedValue = ObjectIdentifier.Convert(defNotification.GetNumericalForm());
                if (handler.EntrepriseRequestedValue.EndsWith("." + trap.Value.ToString()))
                {
                    handler.EntrepriseRequestedValue = handler.EntrepriseRequestedValue.Remove(handler.EntrepriseRequestedValue.Length - trap.Value.ToString().Length - 1);
                }
                handler.SpecificRequestedValue = trap.Value.ToString();
                return(handler);
            }
            return(null);
        }
Ejemplo n.º 3
0
 //---------------------------------------
 public void RemoveFieldFromTrap(CTrapField field)
 {
     FieldsFromTrapList.Remove(field);
 }
Ejemplo n.º 4
0
 public CDefinitionProprieteDynamiqueTrapField(CTrapField field)
     : base(field.Name, field.OID.Replace('.', '_'), new CTypeResultatExpression(typeof(CTrapFieldValueAvecIndex), false), true, true)
 {
 }