/// <summary>
 /// Deprecated Method for adding a new object to the DeviceCommands EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDeviceCommands(DeviceCommand deviceCommand)
 {
     base.AddObject("DeviceCommands", deviceCommand);
 }
 /// <summary>
 /// Create a new DeviceCommand object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="deviceId">Initial value of the DeviceId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static DeviceCommand CreateDeviceCommand(global::System.Int32 id, global::System.Int32 deviceId, global::System.String name)
 {
     DeviceCommand deviceCommand = new DeviceCommand();
     deviceCommand.Id = id;
     deviceCommand.DeviceId = deviceId;
     deviceCommand.Name = name;
     return deviceCommand;
 }
        internal String ExecuteDeviceCommand(DeviceCommand deviceCommand)
        {
            string result = String.Empty;

            if (!String.IsNullOrEmpty(deviceCommand.SerialCommand))
            {
                try
                {
                    SerialPortWrapper.SerialCommand serCmd = new SerialPortWrapper.SerialCommand(
                        deviceCommand.Device.SerialPort.Value, deviceCommand.SerialCommand);
                    serCmd.BaudRate = deviceCommand.Device.BaudRate.Value;
                    serCmd.Hex = deviceCommand.Device.HexMode;
                    result += SerialPortWrapper.SendSerialCommand(serCmd) + "<br/>";
                }
                catch (Exception ex)
                {
                    result += ex.Message + "<br/>";
                }
            }

            if (!String.IsNullOrEmpty(deviceCommand.URL) )
            {
                try
                {
                    WebRequest myRequest = WebRequest.Create(deviceCommand.URL);
                    myRequest.Credentials = new NetworkCredential("admin", "McAdmin");
                    WebResponse response = myRequest.GetResponse();
                }
                catch (Exception ex)
                {
                    result += ex.Message + "<br/>";
                }
            }

            if(!String.IsNullOrEmpty(deviceCommand.IRCode))
            {
                try
                {
                    result += IRWrapper.SendCode(deviceCommand.IRCode);
                }
                catch (Exception ex)
                {
                    result += ex.Message + "<br/>";
                }
            }

            return result;
        }