예제 #1
0
 public static void ClearDB(int seriesID)
 {
     DBActor actors = new DBActor(seriesID);
     Clear(actors, new SQLCondition(actors, cSeriesID, seriesID, SQLConditionType.Equal));
     
     // clear the cache so that we dont accidently get invalid entries
     ClearAll();
 }
예제 #2
0
        public static List<DBActor> GetAll(int seriesID)
        {
            lock (_cache)
            {
                if (_cache == null || !_cache.ContainsKey(seriesID))
                {
                    try
                    {
                        // make sure the table is created
                        DBActor actor = new DBActor();

                        // retrieve all fields in the table
                        String sqlQuery = "select * from " + cTableName;
                        if (seriesID > 0)
                        {
                            sqlQuery += " where " + cSeriesID + " = " + seriesID.ToString();                            
                        }
                        sqlQuery += " order by " + cIndex;

                        SQLiteResultSet results = DBTVSeries.Execute(sqlQuery);
                        if (results.Rows.Count > 0)
                        {
                            List<DBActor> actors = new List<DBActor>(results.Rows.Count);

                            for (int index = 0; index < results.Rows.Count; index++)
                            {
                                actors.Add(new DBActor());
                                actors[index].Read(ref results, index);
                            }

                            if (_cache == null) 
                                _cache = new Dictionary<int, List<DBActor>>();
                            
                            _cache.Add(seriesID, actors);
                        }
                        MPTVSeriesLog.Write("Found " + results.Rows.Count + " Actors from Database", MPTVSeriesLog.LogLevel.Debug);

                    }
                    catch (Exception ex)
                    {
                        MPTVSeriesLog.Write("Error in DBActors.GetAll (" + ex.Message + ")");
                    }
                }

                List<DBActor> seriesActors = null;
                if (_cache != null && _cache.TryGetValue(seriesID, out seriesActors))
                    return seriesActors;
                
                return new List<DBActor>();
            }
        }        
예제 #3
0
 public static void Clear(int Index)
 {
     DBActor actor = new DBActor(Index);
     Clear(actor, new SQLCondition(actor, cIndex, Index, SQLConditionType.Equal));
     _cache.Remove(Index);
 }