當前位置: 首頁>>代碼示例>>C#>>正文


C# BlobListingDetails.HasFlag方法代碼示例

本文整理匯總了C#中BlobListingDetails.HasFlag方法的典型用法代碼示例。如果您正苦於以下問題:C# BlobListingDetails.HasFlag方法的具體用法?C# BlobListingDetails.HasFlag怎麽用?C# BlobListingDetails.HasFlag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BlobListingDetails的用法示例。


在下文中一共展示了BlobListingDetails.HasFlag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ListLogs

        /// <summary>
        /// Returns an enumerable collection of log blobs containing Analytics log records. The blobs are retrieved lazily.
        /// </summary>
        /// <param name="service">A <see cref="StorageService"/> enumeration value.</param>
        /// <param name="startTime">A <see cref="DateTimeOffset"/> object representing the start of the time range for which logs should be retrieved.</param>
        /// <param name="endTime">A <see cref="DateTimeOffset"/> object representing the end of the time range for which logs should be retrieved.</param>
        /// <param name="operations">A <see cref="LoggingOperations"/> enumeration value that indicates the types of logging operations on which to filter the log blobs.</param>
        /// <param name="details">A <see cref="BlobListingDetails"/> enumeration value that indicates whether or not blob metadata should be returned. Only <c>None</c> and <c>Metadata</c> are valid values. </param>
        /// <param name="options">A <see cref="BlobRequestOptions"/> object that specifies additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
        /// <returns>An enumerable collection of objects that implement <see cref="ICloudBlob"/> and are retrieved lazily.</returns>
        /// <remarks>Note that specifying a logging operation type for the <paramref name="operations"/> parameter will return any Analytics log blob that contains the specified logging operation,
        /// even if that log blob also includes other types of logging operations. Also note that the only currently supported values for the <paramref name="details"/> 
        /// parameter are <c>None</c> and <c>Metadata</c>.</remarks>
        public IEnumerable<ICloudBlob> ListLogs(StorageService service, DateTimeOffset startTime, DateTimeOffset? endTime, LoggingOperations operations, BlobListingDetails details, BlobRequestOptions options, OperationContext operationContext)
        {
            CloudBlobDirectory logDirectory = this.GetLogDirectory(service);
            BlobListingDetails metadataDetails = details;
            DateTimeOffset utcStartTime = startTime.ToUniversalTime();
            DateTimeOffset dateCounter = new DateTimeOffset(utcStartTime.Ticks - (utcStartTime.Ticks % TimeSpan.TicksPerHour), utcStartTime.Offset);
            DateTimeOffset? utcEndTime = null;
            string endPrefix = null;

            // Ensure that the date range is correct.
            if (endTime.HasValue)
            {
                utcEndTime = endTime.Value.ToUniversalTime();
                endPrefix = logDirectory.Prefix + utcEndTime.Value.ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture);
                if (utcStartTime > utcEndTime.Value)
                {
                    string errorString = string.Format(CultureInfo.InvariantCulture, SR.StartTimeExceedsEndTime, startTime, endTime.Value);
                    throw new ArgumentException(errorString);
                }
            }

            // Currently only support the ability to retrieve metadata on logs.
            if (details.HasFlag(BlobListingDetails.Copy) || details.HasFlag(BlobListingDetails.Snapshots) || details.HasFlag(BlobListingDetails.UncommittedBlobs))
            {
                throw new ArgumentException(SR.InvalidListingDetails);
            }

            // At least one LogType must be specified.
            if (operations == LoggingOperations.None)
            {
                throw new ArgumentException(SR.InvalidLoggingLevel);
            }

            // If metadata or a specific LogType is specified, metadata should be retrieved.
            if (details.HasFlag(BlobListingDetails.Metadata) || !operations.HasFlag(LoggingOperations.All))
            {
                metadataDetails = BlobListingDetails.Metadata;
            }

            // Check logs using an hour-based prefix until we reach a day boundary.
            while (dateCounter.Hour > 0)
            {
                string currentPrefix = logDirectory.Prefix + dateCounter.ToString("yyyy/MM/dd/HH", CultureInfo.InvariantCulture);
                IEnumerable<IListBlobItem> currentLogs = logDirectory.Container.ListBlobs(currentPrefix, true, metadataDetails, options, operationContext);

                foreach (ICloudBlob log in currentLogs)
                {
                    if (!utcEndTime.HasValue || string.Compare(log.Parent.Prefix, endPrefix) <= 0)
                    {
                        if (IsCorrectLogType(log, operations))
                        {
                            yield return log;
                        }
                    }
                    else
                    {
                        yield break;
                    }
                }

                dateCounter = dateCounter.AddHours(1);
                if (dateCounter > DateTimeOffset.UtcNow.AddHours(1))
                {
                    yield break;
                }
            }

            // Check logs using a day-based prefix until we reach a month boundary.
            while (dateCounter.Day > 1)
            {
                string currentPrefix = logDirectory.Prefix + dateCounter.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture);
                IEnumerable<IListBlobItem> currentLogs = logDirectory.Container.ListBlobs(currentPrefix, true, metadataDetails, options, operationContext);

                foreach (ICloudBlob log in currentLogs)
                {
                    if (!utcEndTime.HasValue || string.Compare(log.Parent.Prefix, endPrefix) <= 0)
                    {
                        if (IsCorrectLogType(log, operations))
                        {
                            yield return log;
                        }
                    }
                    else
                    {
                        yield break;
                    }
//.........這裏部分代碼省略.........
開發者ID:jianghaolu,項目名稱:azure-storage-net,代碼行數:101,代碼來源:CloudAnalyticsClient.cs


注:本文中的BlobListingDetails.HasFlag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。