Esempio n. 1
0
        internal static void ServiceGarbageCollector()
        {
            //			SorentoLib.Services.Logging.LogDebug (Strings.LogError.MediaGarbageCollector);

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table(SorentoLib.Media.DatabaseTableName);
            qb.Columns ("id", "updatetimestamp");
            qb.AddWhere ("status", "=", (int)SorentoLib.Enums.MediaStatus.Temporary);
            qb.AddWhereOR ();
            qb.AddWhere ("status", "=", (int)SorentoLib.Enums.MediaStatus.PublicTemporary);

            Query query = SorentoLib.Services.Database.Connection.Query (qb.QueryString);
            if (query.Success)
            {
                while (query.NextRow ())
                {
                    if ((SNDK.Date.CurrentDateTimeToTimestamp () - query.GetInt (qb.ColumnPos ("updatetimestamp"))) > SorentoLib.Services.Config.Get<int> (Enums.ConfigKey.media_tempmaxage))
                    {
                        Delete (query.GetGuid (qb.ColumnPos ("id")));
                    }
                }
            }

            query.Dispose ();
            query = null;
            qb = null;
        }