/// <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> /// Get an action by its ID. /// </summary> /// <param name="itemId">Action unique identifier (DB)..</param> /// <returns>The requested action or <c>null</c> if the identifier doesn't exists in project.</returns> public ElementAction GetByID(Int64 itemId) { string sql = string.Empty; Logger.LogDebug(this, "[CLASS].GetByID({0})", itemId); try { Connect(); sql = @"SELECT " + ElementActionManager.SQL_FIELDS_SELECT + @" FROM " + ElementActionManager.SQL_TABLE + @" WHERE id = @id"; SetParameter("id", itemId); using (SQLiteDataReader reader = ExecuteReader(sql)) { if (reader.Read()) { return(ElementActionManager.ReadEntityRecord(reader)); } } return(null); } catch (Exception ex) { Logger.LogError(this, ex); throw; } finally { Disconnect(); } }