/// <summary> /// Shows the supplementary information of the instance. /// </summary> /// <param name="oids">List of Oids.</param> private void ShowSupplementaryInfo(List <Oid> oids) { if (mSupplementaryInfo == null) { return; } // Clear supplementary information. if ((oids == null) || (oids.Count == 0)) { mSupplementaryInfo.SetPopulation(null, true, null); return; } // If there is only one instance. if (oids.Count == 1) { try { DataTable dataTable = null; string attributes = mSupplementaryInfo.DisplaySetAttributes; attributes = UtilFunctions.ReturnMissingAttributes(oids[0].ExtraInfo, attributes); if (attributes != "") { try { // Logic API call. dataTable = Logic.ExecuteQueryInstance(Logic.Agent, Domain, oids[0], attributes); } catch (Exception logicException) { ScenarioManager.LaunchErrorScenario(logicException); } oids[0].ExtraInfo.Merge(dataTable); } // Set the supplementary information. mSupplementaryInfo.SetPopulation(oids[0].ExtraInfo, true, null); } catch { // If there is something wrong, clear the supplementary information. mSupplementaryInfo.SetPopulation(null, true, null); } } else { // If there is more than one instance, show warning message. object[] lArgs = new object[1]; lArgs[0] = oids.Count.ToString(); string lMessage = CultureManager.TranslateStringWithParams(LanguageConstantKeys.L_ELEMENTSELECTED, LanguageConstantValues.L_ELEMENTSELECTED, lArgs); mSupplementaryInfo.SetMessage(lMessage); } }
/// <summary> /// Query the attribute values used in the State Change Detection. /// </summary> /// <param name="oids">Oid list.</param> protected void GetValuesForSCD(List <Oid> oids) { // No Oids, do nothing. if (oids == null || (oids != null && oids.Count == 0)) { return; } // Check that all the elements of the list are valid Oids. foreach (Oid lOid in oids) { if (!Oid.IsNotNullAndValid(lOid)) { return; } } // More than one object select means no SCD. if (oids.Count > 1) { foreach (Oid oid in oids) { // Empty the lists. oid.SCDAttributesValues.Clear(); oid.SCDAttributesTypes.Clear(); oid.SCDAttributesDomains.Clear(); } return; } // No SCD declared for this argument. if (SCDAttributes == null || SCDAttributes.DisplaySetItems == null || SCDAttributes.DisplaySetItems.Count == 0) { return; } // Empty the list. oids[0].SCDAttributesValues.Clear(); oids[0].SCDAttributesTypes.Clear(); oids[0].SCDAttributesDomains.Clear(); // Query for all Data Valued attributes. string lAttributes = ""; foreach (DisplaySetItem lItem in SCDAttributes.DisplaySetItems) { if (lItem.ModelType != ModelType.Oid) { if (!lAttributes.Equals(string.Empty)) { lAttributes += ","; } lAttributes += lItem.Name; } else { // Add the OID fields foreach (string oidField in lItem.OIDFields) { if (!lAttributes.Equals(string.Empty)) { lAttributes += ","; } lAttributes += lItem.Name + "." + oidField; } } } lAttributes = UtilFunctions.ReturnMissingAttributes(oids[0].ExtraInfo, lAttributes); if (lAttributes != "") { DataTable dataTable = null; try { dataTable = Logic.ExecuteQueryInstance(Logic.Agent, Domain, oids[0], lAttributes); } catch { return; } if (dataTable == null || dataTable.Rows.Count == 0) { return; } oids[0].ExtraInfo.Merge(dataTable); } // Pass the values to the Oid list. foreach (DisplaySetItem lItem in SCDAttributes.DisplaySetItems) { string lName = Name + "." + lItem.Name; if (lItem.ModelType != ModelType.Oid) { object attValue = oids[0].ExtraInfo.Rows[0][lItem.Name]; attValue = (attValue == DBNull.Value) ? null : attValue; oids[0].SCDAttributesValues.Add(lName, attValue); oids[0].SCDAttributesTypes.Add(lName, lItem.ModelType); oids[0].SCDAttributesDomains.Add(lName, lItem.ClassName); } else { // Create a new Oid using the field values. Oid lOid = null; List <Object> lOIDFieldValues = new List <object>(); bool lNUllValue = false; foreach (string oidField in lItem.OIDFields) { object lValue = oids[0].ExtraInfo.Rows[0][lItem.Name + "." + oidField]; lValue = (lValue == DBNull.Value) ? null : lValue; if (lValue == null) { lNUllValue = true; } lOIDFieldValues.Add(lValue); } if (!lNUllValue) { lOid = Oid.Create(lItem.ClassName, lOIDFieldValues); } oids[0].SCDAttributesValues.Add(lName, lOid); oids[0].SCDAttributesTypes.Add(lName, lItem.ModelType); oids[0].SCDAttributesDomains.Add(lName, lItem.ClassName); } } }