/// <summary>
        /// Reads the settings provided from stream 
        /// </summary> 
        /// <param name="xmlReader"></param> 
        /// <returns></returns> 
        public static AnalyticsSettings DeserializeAnalyticsSettings(XmlReader xmlReader)
        {
            // Read the root and check if it is empty or invalid xmlReader.Read();
            xmlReader.ReadStartElement(SettingsSerializerHelper.RootPropertiesElementName);

            AnalyticsSettings settings = new AnalyticsSettings();

            while (true)
            {
                if (xmlReader.IsStartElement(SettingsSerializerHelper.LoggingElementName))
                {
                    DeserializeLoggingElement(xmlReader, settings);
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.MetricsElementName))
                {
                    DeserializeMetricsElement(xmlReader, settings);
                }
                else
                {
                    break;
                }
            }

            xmlReader.ReadEndElement();

            return settings;
        }
        /// <summary> 
        /// Write the settings provided to stream 
        /// </summary> 
        /// <param name="inputStream"></param> 
        /// <returns></returns> 
        public static void SerializeAnalyticsSettings(XmlWriter xmlWriter, AnalyticsSettings settings)
        {
            xmlWriter.WriteStartDocument();
            xmlWriter.WriteStartElement(SettingsSerializerHelper.RootPropertiesElementName);

            //LOGGING STARTS HERE
            xmlWriter.WriteStartElement(SettingsSerializerHelper.LoggingElementName);

            xmlWriter.WriteStartElement(SettingsSerializerHelper.VersionElementName);
            xmlWriter.WriteValue(settings.LogVersion);
            xmlWriter.WriteEndElement();

            bool isReadEnabled = (settings.LogType & LoggingLevel.Read) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeReadElementName);
            xmlWriter.WriteValue(isReadEnabled);
            xmlWriter.WriteEndElement();

            bool isWriteEnabled = (settings.LogType & LoggingLevel.Write) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeWriteElementName);
            xmlWriter.WriteValue(isWriteEnabled);
            xmlWriter.WriteEndElement();

            bool isDeleteEnabled = (settings.LogType & LoggingLevel.Delete) != LoggingLevel.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.ApiTypeDeleteElementName);
            xmlWriter.WriteValue(isDeleteEnabled);
            xmlWriter.WriteEndElement();

            SerializeRetentionPolicy(xmlWriter, settings.IsLogRetentionPolicyEnabled, settings.LogRetentionInDays);
            xmlWriter.WriteEndElement(); // logging element

            //METRICS STARTS HERE
            xmlWriter.WriteStartElement(SettingsSerializerHelper.MetricsElementName);

            xmlWriter.WriteStartElement(SettingsSerializerHelper.VersionElementName);
            xmlWriter.WriteValue(settings.MetricsVersion);
            xmlWriter.WriteEndElement();

            bool isServiceSummaryEnabled = (settings.MetricsType & MetricsType.ServiceSummary) != MetricsType.None;
            xmlWriter.WriteStartElement(SettingsSerializerHelper.MetricsEnabledElementName);
            xmlWriter.WriteValue(isServiceSummaryEnabled);
            xmlWriter.WriteEndElement();

            if (isServiceSummaryEnabled)
            {
                bool isApiSummaryEnabled = (settings.MetricsType & MetricsType.ApiSummary) != MetricsType.None;
                xmlWriter.WriteStartElement(SettingsSerializerHelper.IncludeApiSummaryElementName);
                xmlWriter.WriteValue(isApiSummaryEnabled);
                xmlWriter.WriteEndElement();
            }

            SerializeRetentionPolicy(
                xmlWriter,
                settings.IsMetricsRetentionPolicyEnabled,
                settings.MetricsRetentionInDays);
            xmlWriter.WriteEndElement();
            // metrics
            xmlWriter.WriteEndElement();
            // root element
            xmlWriter.WriteEndDocument();
        }
示例#3
0
        public void GetAnalyticsSettingsTest()
        {
            CloudTableClient  tableClient       = new CloudTableClient(_credentials.TableBaseAddress, _credentials.StorageCredentials);
            AnalyticsSettings analyticsSettings = tableClient.GetServiceSettings();

            Assert.IsNotNull(analyticsSettings);
        }
示例#4
0
        public void UpdateAnalyticsSettingsTest()
        {
            /*initialize settings for update*/
            AnalyticsSettings analyticsSettings = new AnalyticsSettings();

            analyticsSettings.IsLogRetentionPolicyEnabled     = true;
            analyticsSettings.IsMetricsRetentionPolicyEnabled = true;

            //one day
            analyticsSettings.LogRetentionInDays = _oneDay.Days;
            analyticsSettings.LogType            = LoggingLevel.Write | LoggingLevel.Read | LoggingLevel.Delete;
            analyticsSettings.LogVersion         = AnalyticsSettings.Version;

            //one day
            analyticsSettings.MetricsRetentionInDays = _oneDay.Days;
            analyticsSettings.MetricsType            = MetricsType.All;
            analyticsSettings.MetricsVersion         = AnalyticsSettings.Version;

            CloudTableClient tableClient = new CloudTableClient(_credentials.TableBaseAddress, _credentials.StorageCredentials);

            tableClient.SetServiceSettings(analyticsSettings);
            AnalyticsSettings serviceSettings = tableClient.GetServiceSettings();

            Assert.IsNotNull(serviceSettings);
            Assert.AreEqual(analyticsSettings, serviceSettings);
        }
示例#5
0
 public AnalyticsRegistry(IAppSettings _AppSettings, AnalyticsOperationRepository analyticsOperationRepository, AnalyticsModuleRepository analyticsModuleRepository, ModuleOperationRepository modulesOperationsRepository)
 {
     _analyticsSettings            = _AppSettings.AnalyticsSettings;
     _analyticsOperationRepository = analyticsOperationRepository;
     _analyticsModuleRepository    = analyticsModuleRepository;
     _modulesOperationsRepository  = modulesOperationsRepository;
 }
示例#6
0
        public Task StartAsync(CancellationToken stoppingToken)
        {
            AnalyticsSettings analyticsSettings = _services.GetRequiredService <IAppSettings>().AnalyticsSettings;

            _timer = new Timer(DoWork, null, TimeSpan.Zero,
                               TimeSpan.FromMilliseconds(5000));

            return(Task.CompletedTask);
        }
 override public void EnableService(bool enabled)
 {
     if (AnalyticsSettings.enabled != enabled)
     {
         AnalyticsSettings.SetEnabledServiceWindow(enabled);
         EditorAnalytics.SendEventServiceInfo(new AnalyticsServiceState()
         {
             analytics = enabled
         });
     }
 }
示例#8
0
        public static byte[] Serialize(AnalyticsSettings settings)
        {
            if (settings == null)
            {
                return(null);
            }
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            MemoryStream    memoryStream    = new MemoryStream();

            binaryFormatter.Serialize(memoryStream, settings);
            return(memoryStream.ToArray());
        }
        protected override void InternalEnableService(bool enable)
        {
            if (AnalyticsSettings.enabled != enable)
            {
                AnalyticsSettings.SetEnabledServiceWindow(enable);
                EditorAnalytics.SendEventServiceInfo(new AnalyticsServiceState()
                {
                    analytics = enable
                });
                if (!enable && PurchasingService.instance.IsServiceEnabled())
                {
                    PurchasingService.instance.EnableService(false);
                }
            }

            base.InternalEnableService(enable);
        }
示例#10
0
 private void PreserveUnchangedAnalyticsSettings(AnalyticsSettings newSettings, AnalyticsSettings oldSettings)
 {
     if (newSettings != null && oldSettings != null)
     {
         if (!newSettings.MinuteMetricsElementRead)
         {
             newSettings.MinuteMetricsType    = oldSettings.MinuteMetricsType;
             newSettings.MinuteMetricsVersion = oldSettings.MinuteMetricsVersion;
             newSettings.IsMinuteMetricsRetentionPolicyEnabled = oldSettings.IsMinuteMetricsRetentionPolicyEnabled;
             newSettings.MinuteMetricsRetentionInDays          = oldSettings.MinuteMetricsRetentionInDays;
         }
         if (!newSettings.CorsRulesElementRead)
         {
             newSettings.CorsRulesSerializedString = oldSettings.CorsRulesSerializedString;
         }
         if (!newSettings.IsAnalyticsVersionAtLeastV3)
         {
             return;
         }
         if (!newSettings.MetricsElementRead)
         {
             newSettings.MetricsType    = oldSettings.MetricsType;
             newSettings.MetricsVersion = oldSettings.MetricsVersion;
             newSettings.IsMetricsRetentionPolicyEnabled = oldSettings.IsMetricsRetentionPolicyEnabled;
             newSettings.MetricsRetentionInDays          = oldSettings.MetricsRetentionInDays;
         }
         if (!newSettings.LoggingElementRead)
         {
             newSettings.LogType = oldSettings.LogType;
             newSettings.IsLogRetentionPolicyEnabled = oldSettings.IsLogRetentionPolicyEnabled;
             newSettings.LogVersion         = oldSettings.LogVersion;
             newSettings.LogRetentionInDays = oldSettings.LogRetentionInDays;
         }
         if (!newSettings.DefaultServiceVersionElementRead)
         {
             newSettings.DefaultRESTVersion = oldSettings.DefaultRESTVersion;
         }
     }
 }
        public void UpdateAnalyticsSettingsTest()
        {
            /*initialize settings for update*/
            AnalyticsSettings analyticsSettings = new AnalyticsSettings();
            analyticsSettings.IsLogRetentionPolicyEnabled = true;
            analyticsSettings.IsMetricsRetentionPolicyEnabled = true;

            //one day
            analyticsSettings.LogRetentionInDays = _oneDay.Days;
            analyticsSettings.LogType = LoggingLevel.Write | LoggingLevel.Read | LoggingLevel.Delete;
            analyticsSettings.LogVersion = AnalyticsSettings.Version;

            //one day
            analyticsSettings.MetricsRetentionInDays = _oneDay.Days;
            analyticsSettings.MetricsType = MetricsType.All;
            analyticsSettings.MetricsVersion = AnalyticsSettings.Version;

            CloudTableClient tableClient = new CloudTableClient(_credentials.TableBaseAddress, _credentials.StorageCredentials);
            tableClient.SetServiceSettings(analyticsSettings);
            AnalyticsSettings serviceSettings = tableClient.GetServiceSettings();
            Assert.IsNotNull(serviceSettings);
            Assert.AreEqual(analyticsSettings,serviceSettings);
        }
示例#12
0
        private IEnumerator <IAsyncResult> SetPropertiesImpl(AccountPropertyNames propertyNames, IAccountCondition conditions, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream infoDebug = Logger <INormalAndDebugLogger> .Instance.InfoDebug;

            object[] objArray = new object[] { propertyNames, conditions, this.Timeout };
            infoDebug.Log("SetPropertiesImpl({0},{1},{2})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    StorageStampHelpers.CheckAccountName(this._account.Name);
                    Account value = this.LoadAccount(dbContext);
                    this._account = value;
                    AnalyticsSettings analyticsSetting      = null;
                    AnalyticsSettings blobAnalyticsSettings = null;
                    AccountServiceMetadataPropertyNames serviceMetadataPropertyNames = propertyNames.ServiceMetadataPropertyNames;
                    if (serviceMetadataPropertyNames <= AccountServiceMetadataPropertyNames.QueueAnalyticsSettings)
                    {
                        if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.BlobAnalyticsSettings)
                        {
                            blobAnalyticsSettings = this.ServiceMetadata.BlobAnalyticsSettings;
                            if (blobAnalyticsSettings != null)
                            {
                                if (value.BlobServiceSettings != null)
                                {
                                    analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.BlobServiceSettings);
                                    this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting);
                                }
                                value.BlobServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings);
                                dbContext.SubmitChanges();
                            }
                        }
                        else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.QueueAnalyticsSettings)
                        {
                            blobAnalyticsSettings = this.ServiceMetadata.QueueAnalyticsSettings;
                            if (blobAnalyticsSettings != null)
                            {
                                if (value.QueueServiceSettings != null)
                                {
                                    analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.QueueServiceSettings);
                                    this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting);
                                }
                                value.QueueServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings);
                                dbContext.SubmitChanges();
                            }
                        }
                    }
                    else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.TableAnalyticsSettings)
                    {
                        blobAnalyticsSettings = this.ServiceMetadata.TableAnalyticsSettings;
                        if (blobAnalyticsSettings != null)
                        {
                            if (value.TableServiceSettings != null)
                            {
                                analyticsSetting = ServiceSettingsSerializer.DeSerialize(value.TableServiceSettings);
                                this.PreserveUnchangedAnalyticsSettings(blobAnalyticsSettings, analyticsSetting);
                            }
                            value.TableServiceSettings = ServiceSettingsSerializer.Serialize(blobAnalyticsSettings);
                            dbContext.SubmitChanges();
                        }
                    }
                    else if (serviceMetadataPropertyNames == AccountServiceMetadataPropertyNames.SecondaryReadEnabled)
                    {
                        bool?secondaryReadEnabled = this.ServiceMetadata.SecondaryReadEnabled;
                        if (secondaryReadEnabled.HasValue)
                        {
                            value.SecondaryReadEnabled = secondaryReadEnabled.Value;
                            dbContext.SubmitChanges();
                        }
                    }
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.SetPropertiesImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
示例#13
0
 public AliveSignalSenderHostedService(IAppSettings appSettings, IServiceProvider services)
 {
     _services          = services;
     _analyticsSettings = appSettings.AnalyticsSettings;
 }
 /// <summary>
 /// Set blob analytics settings
 ///</summary>
 /// <param name="client"></param>
 /// <param name="settings"></param>
 public static void SetServiceSettings(this CloudTableClient client, AnalyticsSettings settings)
 {
     SetSettings(client.BaseUri, client.Credentials, settings, true /* useSharedKeyLite */);
 }
        /// <summary> 
        /// Reads the metrics element and fills in the values in Analyticssettings instance
        /// </summary> 
        /// <param name="xmlReader"></param> 
        /// <param name="settings"></param> 
        private static void DeserializeMetricsElement(XmlReader xmlReader, AnalyticsSettings settings)
        {
            bool includeAPIs = false;

            // read the next element - it should be metrics.
            xmlReader.ReadStartElement(SettingsSerializerHelper.MetricsElementName);

            while (true)
            {
                if (xmlReader.IsStartElement(SettingsSerializerHelper.VersionElementName))
                {
                    settings.MetricsVersion = xmlReader.ReadElementString(SettingsSerializerHelper.VersionElementName);
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.MetricsEnabledElementName))
                {
                    if (DeserializeBooleanElementValue(
                        xmlReader,
                        SettingsSerializerHelper.MetricsEnabledElementName))
                    {
                        // only if metrics is enabled will we read include API
                        settings.MetricsType = settings.MetricsType | MetricsType.ServiceSummary;
                    }
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.IncludeApiSummaryElementName))
                {
                    if (DeserializeBooleanElementValue(
                        xmlReader,
                        SettingsSerializerHelper.IncludeApiSummaryElementName))
                    {
                        includeAPIs = true;
                    }
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.RetentionPolicyElementName))
                {
                    // read retention policy for metrics
                    bool isRetentionEnabled = false;
                    int retentionDays = 0;
                    DeserializeRetentionPolicy(xmlReader, ref isRetentionEnabled, ref retentionDays);
                    settings.IsMetricsRetentionPolicyEnabled = isRetentionEnabled;
                    settings.MetricsRetentionInDays = retentionDays;
                }
                else
                {
                    break;
                }
            }

            if ((settings.MetricsType & MetricsType.ServiceSummary) != MetricsType.None)
            {
                // If Metrics is enabled, IncludeAPIs must be included.
                if (includeAPIs)
                {
                    settings.MetricsType = settings.MetricsType | MetricsType.ApiSummary;
                }
            }

            xmlReader.ReadEndElement();// end metrics element
        }
        /// <summary> 
        ///  Reads the logging element and fills in the values in Analyticssettings instance 
        /// </summary> 
        /// <param name="xmlReader"></param> 
        /// <param name="settings"></param> 
        private static void DeserializeLoggingElement(XmlReader xmlReader, AnalyticsSettings settings)
        {
            // Read logging element
            xmlReader.ReadStartElement(SettingsSerializerHelper.LoggingElementName);

            while (true)
            {
                if (xmlReader.IsStartElement(SettingsSerializerHelper.VersionElementName))
                {
                    settings.LogVersion = xmlReader.ReadElementString(SettingsSerializerHelper.VersionElementName);
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.ApiTypeReadElementName))
                {
                    if (DeserializeBooleanElementValue(
                        xmlReader,
                        SettingsSerializerHelper.ApiTypeReadElementName))
                    {
                        settings.LogType = settings.LogType | LoggingLevel.Read;
                    }
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.ApiTypeWriteElementName))
                {
                    if (DeserializeBooleanElementValue(
                        xmlReader,
                        SettingsSerializerHelper.ApiTypeWriteElementName))
                    {
                        settings.LogType = settings.LogType | LoggingLevel.Write;
                    }
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.ApiTypeDeleteElementName))
                {
                    if (DeserializeBooleanElementValue(
                        xmlReader,
                        SettingsSerializerHelper.ApiTypeDeleteElementName))
                    {
                        settings.LogType = settings.LogType | LoggingLevel.Delete;
                    }
                }
                else if (xmlReader.IsStartElement(SettingsSerializerHelper.RetentionPolicyElementName))
                {
                    // read retention policy for logging
                    bool isRetentionEnabled = false;
                    int retentionDays = 0;
                    DeserializeRetentionPolicy(xmlReader, ref isRetentionEnabled, ref retentionDays);
                    settings.IsLogRetentionPolicyEnabled = isRetentionEnabled;
                    settings.LogRetentionInDays = retentionDays;
                }
                else
                {
                    break;
                }
            }

            xmlReader.ReadEndElement();// end Logging element
        }
示例#17
0
        public IAsyncResult BeginSetTableServiceProperties(IAccountIdentifier identifier, string ownerAccountName, AnalyticsSettings settings, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("TableManager.SetTableServiceProperties", callback, state);

            asyncIteratorContext.Begin(this.SetTableServicePropertiesImpl(identifier, ownerAccountName, settings, timeout, requestContext, asyncIteratorContext));
            return(asyncIteratorContext);
        }
示例#18
0
        private IEnumerator <IAsyncResult> SetTableServicePropertiesImpl(IAccountIdentifier identifier, string ownerAccountName, AnalyticsSettings settings, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context)
        {
            Duration startingNow = Duration.StartingNow;

            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }
            if (string.IsNullOrEmpty(ownerAccountName))
            {
                throw new ArgumentException("ownerAccountName", "Cannot be null");
            }
            if (timeout <= TimeSpan.Zero)
            {
                throw new TimeoutException("Timed out in SetTableServiceProperties");
            }
            if (identifier is TableSignedAccessAccountIdentifier)
            {
                throw new NephosUnauthorizedAccessException("Signed access not supported for this request", AuthorizationFailureReason.InvalidOperationSAS);
            }
            SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters()
            {
                SupportedSasTypes  = SasType.AccountSas,
                SignedResourceType = SasResourceType.Service,
                SignedPermission   = SASPermission.Write
            };
            SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter;
            IAsyncResult asyncResult = this.authorizationManager.BeginCheckAccess(identifier, ownerAccountName, null, null, PermissionLevel.Write | PermissionLevel.Owner, sASAuthorizationParameter1, timeout, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableServicePropertiesImpl"));

            yield return(asyncResult);

            this.authorizationManager.EndCheckAccess(asyncResult);
            IStorageAccount  accountServiceMetadatum = null;
            AccountCondition accountCondition        = new AccountCondition(false, false, null, null);

            accountServiceMetadatum = this.storageManager.CreateAccountInstance(ownerAccountName);
            accountServiceMetadatum.ServiceMetadata = new AccountServiceMetadata()
            {
                TableAnalyticsSettings = settings
            };
            accountServiceMetadatum.Timeout = timeout;
            asyncResult = accountServiceMetadatum.BeginSetProperties(new AccountPropertyNames(AccountLevelPropertyNames.None, (AccountServiceMetadataPropertyNames)((long)131072)), accountCondition, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableServicePropertiesImpl"));
            yield return(asyncResult);

            accountServiceMetadatum.EndSetProperties(asyncResult);
        }
 /// <summary>
 /// Set queue analytics settings
 /// </summary>
 /// <param name="client"></param>
 /// <param name="baseUri"></param>
 /// <param name="settings"></param>
 public static void SetServiceSettings(this CloudQueueClient client, Uri baseUri, AnalyticsSettings settings)
 {
     SetSettings(baseUri, client.Credentials, settings, false /* useSharedKeyLite */);
 }
示例#20
0
 protected abstract IEnumerator <IAsyncResult> SetQueueServicePropertiesImpl(IAccountIdentifier identifier, string ownerAccountName, AnalyticsSettings settings, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context);
        /// <summary>
        /// Set analytics settings
        /// </summary>
        /// <param name="baseUri"></param>
        /// <param name="credentials"></param>
        /// <param name="settings"></param>
        /// <param name="useSharedKeyLite"></param>
        public static void SetSettings(Uri baseUri, StorageCredentials credentials, AnalyticsSettings settings, Boolean useSharedKeyLite)
        {
            UriBuilder builder = new UriBuilder(baseUri);
            builder.Query = string.Format(
                CultureInfo.InvariantCulture,
                "comp=properties&restype=service&timeout={0}",
                DefaultTimeout.TotalSeconds);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(builder.Uri);
            request.Headers.Add(VersionHeaderName, Sep2009Version);
            request.Method = "PUT";

            StorageCredentialsAccountAndKey accountAndKey = credentials as StorageCredentialsAccountAndKey;
            using (MemoryStream buffer = new MemoryStream())
            {
                XmlTextWriter writer = new XmlTextWriter(buffer, Encoding.UTF8);
                SettingsSerializerHelper.SerializeAnalyticsSettings(writer, settings);
                writer.Flush();
                buffer.Seek(0, SeekOrigin.Begin);
                request.ContentLength = buffer.Length;

                if (useSharedKeyLite)
                {
                    credentials.SignRequestLite(request);
                }
                else
                {
                    credentials.SignRequest(request);
                }

                using (Stream stream = request.GetRequestStream())
                {
                    stream.Write(buffer.GetBuffer(), 0, (int)buffer.Length);
                }

                try
                {
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        Console.WriteLine("Response Request Id = {0} Status={1}", response.Headers[RequestIdHeaderName], response.StatusCode);
                        if (HttpStatusCode.Accepted != response.StatusCode)
                        {
                            throw new Exception("Request failed with incorrect response status.");
                        }
                    }
                }
                catch (WebException e)
                {
                    Console.WriteLine(
                        "Response Request Id={0} Status={1}",
                        e.Response != null ? e.Response.Headers[RequestIdHeaderName] : "Response is null",
                        e.Status);
                    throw;
                }
            }
        }
示例#22
0
 public abstract IAsyncResult BeginSetBlobServiceProperties(IAccountIdentifier identifier, string ownerAccountName, AnalyticsSettings settings, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state);