public static List<DataGridViewRow> ToDataGridViewRow(CimPropertyList properties, CimPropertyList keyProperties, bool canEditKeyProperties) { int keyPropertyPos = 0; List<DataGridViewRow> newList = new List<DataGridViewRow>(); foreach (CimProperty prop in properties) { DataGridViewRow row = new DataGridViewRow(); row.ReadOnly = true; row.Height = 17; row.Cells.Add(new DataGridViewImageCell()); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells.Add(new DataGridViewTextBoxCell()); row.Cells[1].Value = prop.Name.ToString(); row.Cells[2].Value = prop.Type.ToString(); row.Cells[3].Value = prop.Value; if (keyProperties.Contains(prop.Name)) { row.Cells[0].Value = ImageUtils.ImageList.Images[(int)ImageUtils.ImageIndex.KeyProperty]; //row.Cells[2].Value = "Key Property"; // Set whether key properties can be edited row.Cells[3].ReadOnly = !canEditKeyProperties; newList.Insert(keyPropertyPos, row); keyPropertyPos++; } else { row.Cells[0].Value = ImageUtils.ImageList.Images[(int)ImageUtils.ImageIndex.Property]; //row.Cells[2].Value = "Property"; row.Cells[3].ReadOnly = false; newList.Add(row); } } return newList; }
public static TreeNode CimToNode(CimPropertyList list) { TreeNode root = new TreeNode("Properties"); foreach (CimProperty prop in list) { if (prop != null) root.Nodes.Add(CimToNode(prop)); } return root; }
public static List<ListViewItem> ToList(CimPropertyList list, CimName className, bool AllowEditProperties, bool AllowEditKeyProperties) { System.Drawing.Color localColor = System.Drawing.Color.MediumSlateBlue; List<ListViewItem> newList = new List<ListViewItem>(); foreach (CimProperty property in list) { ListViewItem item; string classOrigin = property.ClassOrigin.ToString(); if (property.IsKeyProperty) item = new ListViewItem(new string[] { property.Name.ToString(), "Key Property", property.Value, classOrigin }, (int)ImageUtils.ImageIndex.KeyProperty); else item = new ListViewItem(new string[] { property.Name.ToString(), "Property", property.Value, classOrigin }, (int)ImageUtils.ImageIndex.Property); if ((className != null) && (className == property.ClassOrigin)) { // It's a local property item.SubItems[3].Text = "( Local )"; item.ForeColor = localColor; } newList.Add(item); } return newList; }
public static List<ListViewItem> ToList(CimPropertyList list, CimName className) { return ToList(list, className, false, false); }
public void WriteCimPropertyList(CimPropertyList propertyList) { #region Actual XML Request /* [...] <PROPERTY NAME="CSCreationClassName" TYPE="string" CLASSORIGIN="CIM_FileSystem" PROPAGATED="true" > <QUALIFIER NAME="Key" TYPE="boolean" OVERRIDABLE="false" > <VALUE>true</VALUE> </QUALIFIER> [...] <VALUE>tCSCreationClassName</VALUE> </PROPERTY> [...] <PROPERTY NAME="Root" TYPE="string" CLASSORIGIN="CIM_FileSystem" PROPAGATED="true" > <QUALIFIER NAME="Description" TYPE="string" TRANSLATABLE="true" > <VALUE>Path name or other information defining the root of the FileSystem.</VALUE> </QUALIFIER> [...] </PROPERTY> [...] <PROPERTY.ARRAY NAME="OperationalStatus" TYPE="uint16" CLASSORIGIN="CIM_ManagedSystemElement" PROPAGATED="true" > <QUALIFIER NAME="Description" TYPE="string" TRANSLATABLE="true" > <VALUE>Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail. "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on. "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future. "In Service" describes an element being configured, maintained, cleaned, or otherwise administered. "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it. "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable. "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated. "Dormant" indicates that the element is inactive or quiesced. "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems. "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error). "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association. OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.</VALUE> </QUALIFIER> [...] <VALUE.ARRAY> <VALUE></VALUE> </VALUE.ARRAY> </PROPERTY.ARRAY> [...] */ #endregion if (propertyList == null) return; //Changing to for loop for MONO for(int i = 0; i < propertyList.Count; ++i) { WriteCimProperty(propertyList[i]); } }
/// <summary> /// Checks the properties of a CimInstance object against the keyProperties list /// </summary> /// <param name="keyProperties">list of key properties to check</param> /// <returns>Returns true if all the key properties are set</returns> public bool AreKeyPropertiesSet(CimPropertyList keyProperties) { //This method is only called in one place, in CimInstanceForm. Should this be in GUI library somewhere //Changed for MONO for (int i = 0; i < keyProperties.Count; ++i) { CimProperty curKeyProp = keyProperties[i]; if (! this.Properties.Contains(curKeyProp.Name)) return false; // This instance is missing a key property if (this.Properties[curKeyProp.Name].Value == string.Empty) return false; // The key property isn't set } // if it makes it to here then all key properties are set. return true; }