/// <summary> /// The the properties of an object /// </summary> /// <param name="ObjectName">The object to get the proeprties of</param> /// <returns>The properties associated to the object</returns> public static OSAEObjectPropertyCollection GetObjectProperties(string ObjectName) { OSAEObjectPropertyCollection props = new OSAEObjectPropertyCollection(); try { using (MySqlCommand command = new MySqlCommand()) { DataSet dataset = new DataSet(); command.CommandText = "SELECT object_property_id, property_name, property_value, property_datatype, last_updated FROM osae_v_object_property WHERE object_name=@ObjectName ORDER BY property_name"; command.Parameters.AddWithValue("@ObjectName", ObjectName); dataset = OSAESql.RunQuery(command); foreach (DataRow drp in dataset.Tables[0].Rows) { OSAEObjectProperty p = new OSAEObjectProperty(); p.Name = drp["property_name"].ToString(); p.Value = drp["property_value"].ToString(); p.DataType = drp["property_datatype"].ToString(); p.LastUpdated = drp["last_updated"].ToString(); p.Id = drp["object_property_id"].ToString(); props.Add(p); } } return props; } catch (Exception ex) { Logging.GetLogger().AddToLog("API - GetObjectProperty error: " + ex.Message, true); return props; } }
private void checkForExternal(string objName) { OSAEObjectPropertyCollection objProps = OSAEObjectPropertyManager.GetObjectProperties(objName); List <OSAEObjectProperty> oP = objProps.ToList <OSAEObjectProperty>(); int iCount = (oP.Count(r => r.DataType == "Image")); int fCount = (oP.Count(r => r.DataType == "File")); if (iCount > 0) { // Add Image files to zip List <OSAEObjectProperty> imgList = (oP.FindAll(r => r.DataType == "Image")); foreach (OSAEObjectProperty ip in imgList) { if (!string.IsNullOrEmpty(ip.Value)) { string fileLstName = @ip.Value + "::Image"; if (inFileList(fileLstName)) { // Do not add image to package. Already in list. } else { lstFileList.Items.Add(fileLstName); } } } } if (fCount > 0) { // Add External files to zip List <OSAEObjectProperty> fileList = (oP.FindAll(r => r.DataType == "File")); foreach (OSAEObjectProperty fp in fileList) { if (!string.IsNullOrEmpty(fp.Value)) { string fileLstName = @fp.Value + "::File"; if (inFileList(fileLstName)) { // Do not add image to package. Already in list. } else { lstFileList.Items.Add(fileLstName); //exportObjList.Add(exObj); } } } } }
/// <summary> /// Loads extra Parmeters in to edit screen /// </summary> private void getExtraParams(string controlName) { OSAEObjectPropertyCollection uc = OSAEObjectPropertyManager.GetObjectProperties(controlName); foreach (OSAEObjectProperty p in uc) { if (p.Name != "Control Type" & p.Name != "Object Name" & p.Name != "X" & p.Name != "Y" & p.Name != "ZOrder") { objParams oP = new objParams(); oP.Name = p.Name; oP.Value = p.Value; oParams.Add(oP); hasParams = true; paramList.Items.Add(oP.Name); } } }
private OSAEObjectPropertyCollection getProperties(string objName) { OSAEObject oObj = OSAEObjectManager.GetObjectByName(objName); OSAEObjectPropertyCollection props = oObj.Properties; OSAEObjectPropertyCollection properties = new OSAEObjectPropertyCollection(); foreach (OSAEObjectProperty prop in props) { OSAEObjectProperty p = new OSAEObjectProperty(); p.Name = prop.Name; p.Value = prop.Value; p.DataType = prop.DataType; p.LastUpdated = prop.LastUpdated; p.Id = prop.Id; properties.Add(p); } return(properties); }
private OSAEObjectPropertyCollection getProperties(string objName) { OSAEObject oObj = OSAEObjectManager.GetObjectByName(objName); OSAEObjectPropertyCollection props = oObj.Properties; OSAEObjectPropertyCollection properties = new OSAEObjectPropertyCollection(); foreach (OSAEObjectProperty prop in props) { OSAEObjectProperty p = new OSAEObjectProperty(); p.Name = prop.Name; p.Value = prop.Value; p.DataType = prop.DataType; p.LastUpdated = prop.LastUpdated; p.Id = prop.Id; properties.Add(p); } return properties; }
/// <summary> /// OSA Plugin Interface - Commands the be processed by the plugin /// </summary> /// <param name="method">Method containging the command to run</param> public override void ProcessCommand(OSAEMethod method) { string methodName = method.MethodName; string objectName = method.ObjectName; string combinedString = objectName + "_" + methodName; //get the called objects properties to see if there is a computer objet defined OSAEObject calledObject = OSAEObjectManager.GetObjectByName(method.ObjectName); OSAEObjectPropertyCollection ComputerProperty = calledObject.Properties; OSAEObjectCollection eventGhostObjects = OSAEObjectManager.GetObjectsByType("Computer"); OSAEObject computer = new OSAEObject(); //if there are no properties defined then grab the first available Computer object //logging.AddToLog("The Count of the Computer Properties is : " + ComputerProperty.Count, true); if (ComputerProperty.Count == 0) { //get the last object in the list foreach (OSAEObject test in eventGhostObjects) { computer = test; } //add log entry if mulptiple computer objects were dectected and no property was used to select which object if (eventGhostObjects.Count > 1) { Log.Info("There are multiple eventghost computer objects detected. " + computer.Name + " with an address of: " + OSAEObjectPropertyManager.GetObjectPropertyValue(computer.Name, "IPAddress") + ":" + OSAEObjectPropertyManager.GetObjectPropertyValue(computer.Name, "EventGhost Port") + " is being used to transmit the package. Please add a property called 'Computer' with a value of the object name of the computer you wish to transmit the UDP packet to."); } } // if the object type contains a property with ID "Computer" use that property to select the appropriate object else { OSAEObjectProperty whichComputer = OSAEObjectPropertyManager.GetObjectPropertyValue(calledObject.Name, "Computer"); computer = eventGhostObjects.Find(whichComputer.Value); //check to see if a computer object was found if none print the logged property value and select another object to use if (computer == null) { foreach (OSAEObject test in eventGhostObjects) { computer = test; } if (eventGhostObjects.Count > 1) { Log.Info("A computer object was unable to be matched to " + whichComputer.Value + " please ensure that " + calledObject.Name + " contains a property called Computer with a value mathing the name of the appropriate computer object."); Log.Info(computer.Name + " with an address of: " + computer.Address + ":" + OSAEObjectPropertyManager.GetObjectPropertyValue(computer.Name, "EventGhost Port") + " is being used to transmit the package."); } } } //logging.AddToLog(address, true); //logging.AddToLog(objectName, true); //logging.AddToLog(combinedString, true); //get the server address indicated in the address for the object passed to the method string ipAddress = computer.Address; //check to make sure computer object has address, if not assume local host if (ipAddress.Equals("", StringComparison.Ordinal)) { ipAddress = "Localhost"; } OSAEObjectProperty portAddress = OSAEObjectPropertyManager.GetObjectPropertyValue(computer.Name, "Port"); //if no value for port use default value of 33333 Log.Debug("The port being used is: " + portAddress.Value); int port = 0; //Log.Debug("The port being used is: " + portAddress.Value); if ((portAddress.Value).Equals("", StringComparison.Ordinal)) { port = 33333; } else { port = Int32.Parse(portAddress.Value); Log.Debug("The port being used is: " + portAddress.Value); } //logging.AddToLog(port, true); //logging.AddToLog(ipAddress, true); IPAddress serverAddr = IPAddress.Parse(ipAddress); IPEndPoint endPoint = new IPEndPoint(serverAddr, port); Log.Debug("The ipEndPoint is:" + ipAddress + ":" + port); //send the updpacket UdpClient udp = new UdpClient(); byte[] sendBytes = Encoding.ASCII.GetBytes(combinedString); udp.Send(sendBytes, sendBytes.Length, endPoint); ////if not value for port use default value of 33333 //int port = 0; //if ((portAddress.Value).Equals("",StringComparison.Ordinal)) // port = 33333; //else // port = Int32.Parse(portAddress.Value); ////logging.AddToLog(port, true); ////logging.AddToLog(ipAddress, true); //IPAddress serverAddr = IPAddress.Parse(ipAddress); //IPEndPoint endPoint = new IPEndPoint(serverAddr, port); ////send the updpacket //UdpClient udp = new UdpClient(); //byte[] sendBytes = Encoding.ASCII.GetBytes(combinedString); //udp.Send(sendBytes, sendBytes.Length, endPoint); }