Exemplo n.º 1
0
        internal BucketStatistics GetFullStatistics()
        {
            BucketStatistics ret = new BucketStatistics();

            ret.Name    = _Bucket.Name;
            ret.GUID    = _Bucket.GUID;
            ret.Objects = 0;
            ret.Bytes   = 0;

            string    countQuery = "SELECT COUNT(*) AS numobjects, SUM(contentlength) AS totalbytes FROM objects WHERE bucketguid = '" + _Bucket.GUID + "'";
            DataTable result     = _ORM.Query(countQuery);

            if (result != null && result.Rows.Count == 1)
            {
                if (result.Rows[0].Table.Columns.Contains("numobjects") &&
                    result.Rows[0]["NumObjects"] != DBNull.Value &&
                    result.Rows[0]["NumObjects"] != null)
                {
                    ret.Objects = Convert.ToInt64(result.Rows[0]["numobjects"]);
                }

                if (result.Rows[0].Table.Columns.Contains("totalbytes") &&
                    result.Rows[0]["TotalBytes"] != DBNull.Value &&
                    result.Rows[0]["TotalBytes"] != null)
                {
                    ret.Bytes = Convert.ToInt64(result.Rows[0]["totalbytes"]);
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        internal BucketStatistics GetStatistics(List <Obj> objects)
        {
            BucketStatistics ret = new BucketStatistics();

            ret.Name    = _Bucket.Name;
            ret.GUID    = _Bucket.GUID;
            ret.Objects = 0;
            ret.Bytes   = 0;

            if (objects != null && objects.Count > 0)
            {
                ret.Objects = objects.Count;
                ret.Bytes   = objects.Sum(o => o.ContentLength);
            }

            return(ret);
        }