/// <summary>
        /// Gets all blocks from a specified switchboard panel.
        /// </summary>
        /// <param name="ownerElementId">The switchboard panel unique identifier (DB).</param>
        /// <returns>The requested list of <see cref="ElementAction"/>.</returns>
        public List <ElementAction> GetByElement(Int64 ownerElementId)
        {
            string               sql   = string.Empty;
            ElementAction        item  = null;
            List <ElementAction> items = new List <ElementAction>();

            Logger.LogDebug(this, "[CLASS].GetByElement({0})", ownerElementId);

            try
            {
                Connect();

                sql = @"SELECT 
                        " + ElementActionManager.SQL_FIELDS_SELECT + @" 
                    FROM 
                        " + ElementActionManager.SQL_TABLE + @" 
                    WHERE 
                        blockid = @blockid";

                SetParameter("blockid", ownerElementId);

                using (SQLiteDataReader reader = ExecuteReader(sql))
                {
                    while (reader.Read())
                    {
                        item = ElementActionManager.ReadEntityRecord(reader);
                        if (item != null)
                        {
                            items.Add(item);
                        }
                    }
                }

                return(items);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
        /// <summary>
        /// Update the specified action data.
        /// </summary>
        /// <param name="action">An instance with the updated data.</param>
        public void Update(ElementAction action)
        {
            string sql = string.Empty;

            Logger.LogDebug(this, "[CLASS].Update([{0}])", action);

            try
            {
                Connect();

                sql = @"UPDATE 
                        " + ElementActionManager.SQL_TABLE + @" 
                    SET 
                        blockid         = @blockid, 
                        type            = @type, 
                        eventtype       = @eventtype,
                        description     = @description,
                        conditionstatus = @conditionstatus, 
                        intparam1       = @intparam1, 
                        intparam2       = @intparam2 
                    WHERE 
                        id = @id";

                SetParameter("blockid", action.OwnerElementID);
                SetParameter("type", action.ActionType);
                SetParameter("eventtype", (int)action.EventType);
                SetParameter("description", action.Description);
                SetParameter("intparam1", action.IntegerParameter1);
                SetParameter("intparam2", action.IntegerParameter2);
                SetParameter("conditionstatus", action.ConditionParentStatus);
                SetParameter("id", action.ID);

                ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
        /// <summary>
        /// Adds a new panel into the current project.
        /// </summary>
        /// <param name="action">An implementation of <see cref="ElementAction"/> containing the data for new object.</param>
        public void Add(ElementAction action)
        {
            string sql = string.Empty;

            Logger.LogDebug(this, "[CLASS].Add([{0}])", action);

            try
            {
                Connect();

                // Añade el registro
                sql = @"INSERT INTO 
                        " + ElementActionManager.SQL_TABLE + @" (" + ElementActionManager.SQL_FIELDS_INSERT + @") 
                    VALUES 
                        (@blockid, @type, @eventtype, @description, @conditionstatus, @intparam1, @intparam2)";

                SetParameter("blockid", action.OwnerElementID);
                SetParameter("type", action.ActionType);
                SetParameter("eventtype", (int)action.EventType);
                SetParameter("description", action.Description);
                SetParameter("conditionstatus", action.ConditionParentStatus);
                SetParameter("intparam1", action.IntegerParameter1);
                SetParameter("intparam2", action.IntegerParameter2);

                ExecuteNonQuery(sql);

                // Obtiene el nuevo ID
                sql = @"SELECT 
                        Max(id) As id 
                    FROM 
                        " + ElementActionManager.SQL_TABLE;

                action.ID = (int)ExecuteScalar(sql, 0);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
        /// <summary>
        /// Read a category from the current reader record.
        /// </summary>
        internal static ElementAction ReadEntityRecord(SQLiteDataReader reader)
        {
            string        typeName = (reader.IsDBNull(5) ? string.Empty : reader.GetString(2));
            ElementAction record   = ElementAction.CreateActionInstance(typeName);

            if (record != null)
            {
                record.ID                    = reader.GetInt32(0);
                record.OwnerElementID        = reader.GetInt32(1);
                record.ActionType            = typeName;
                record.EventType             = (Rwm.Otc.LayoutControl.Actions.ElementAction.ExecutionEventType)(reader.IsDBNull(3) ? (int)Rwm.Otc.LayoutControl.Actions.ElementAction.ExecutionEventType.Undefined : reader.GetInt32(3));
                record.Description           = reader.IsDBNull(4) ? string.Empty : reader.GetString(4);
                record.ConditionParentStatus = reader.GetInt32(5);
                record.IntegerParameter1     = reader.GetInt32(6);
                record.IntegerParameter2     = reader.GetInt32(7);

                return(record);
            }

            throw new ArgumentException("Not supported event " + typeName);
        }