Example #1
0
        IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IStorageAccount.BeginSetProperties(AccountPropertyNames propertyNames, IAccountCondition conditions, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("StorageAccount.SetProperties", callback, state);

            asyncIteratorContext.Begin(this.SetPropertiesImpl(propertyNames, conditions, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Example #2
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);
        }
Example #3
0
        private IEnumerator <IAsyncResult> GetPropertiesImpl(AccountPropertyNames propertyNames, IAccountCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { propertyNames, condition, this.Timeout };
            verboseDebug.Log("StorageAccount.GetPropertiesImpl({0},{1},{2})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    StorageStampHelpers.CheckAccountName(this._account.Name);
                    Account account = this.LoadAccount(dbContext);
                    this._account   = account;
                    if (account.SecondaryReadEnabled)
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        this._accountServiceMetadata.SecondaryReadEnabled = new bool?(true);
                    }
                    if (propertyNames.ServiceMetadataPropertyNames.HasFlag((AccountServiceMetadataPropertyNames)((long)32768)))
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        if (account.BlobServiceSettings == null)
                        {
                            this._accountServiceMetadata.BlobAnalyticsSettings = new AnalyticsSettings();
                        }
                        else
                        {
                            this._accountServiceMetadata.BlobAnalyticsSettings = ServiceSettingsSerializer.DeSerialize(account.BlobServiceSettings);
                        }
                        this._accountServiceMetadata.BlobGeoReplicationStats = this.LoadGeoReplicationStats(dbContext);
                    }
                    if (propertyNames.ServiceMetadataPropertyNames.HasFlag((AccountServiceMetadataPropertyNames)((long)65536)))
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        if (account.QueueServiceSettings == null)
                        {
                            this._accountServiceMetadata.QueueAnalyticsSettings = new AnalyticsSettings();
                        }
                        else
                        {
                            this._accountServiceMetadata.QueueAnalyticsSettings = ServiceSettingsSerializer.DeSerialize(account.QueueServiceSettings);
                        }
                        this._accountServiceMetadata.QueueGeoReplicationStats = this.LoadGeoReplicationStats(dbContext);
                    }
                    if (propertyNames.ServiceMetadataPropertyNames.HasFlag((AccountServiceMetadataPropertyNames)((long)131072)))
                    {
                        if (this._accountServiceMetadata == null)
                        {
                            this._accountServiceMetadata = new AccountServiceMetadata();
                        }
                        if (account.TableServiceSettings == null)
                        {
                            this._accountServiceMetadata.TableAnalyticsSettings = new AnalyticsSettings();
                        }
                        else
                        {
                            this._accountServiceMetadata.TableAnalyticsSettings = ServiceSettingsSerializer.DeSerialize(account.TableServiceSettings);
                        }
                        this._accountServiceMetadata.TableGeoReplicationStats = this.LoadGeoReplicationStats(dbContext);
                    }
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageAccount.GetPropertiesImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }