Ejemplo n.º 1
0
 private Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer GetSqlTableContainer(string tableName)
 {
     Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer = (
         from c in this.m_dbContext.TableContainers
         where (c.AccountName == this.AccountName) && (c.TableName == tableName.ToLowerInvariant())
         select c).FirstOrDefault <Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer>();
     return(tableContainer);
 }
Ejemplo n.º 2
0
 internal DbTableContainer(DbStorageAccount account, Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer container)
 {
     StorageStampHelpers.CheckContainerName(container.CasePreservedTableName, Microsoft.Cis.Services.Nephos.Common.Storage.ContainerType.TableContainer, false);
     this.StorageManager  = account.StorageManager;
     this._tableContainer = container;
     this.OperationStatus = account.OperationStatus;
     this.Account         = account;
 }
Ejemplo n.º 3
0
 internal static void CheckTableContainerCondition(Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer, IContainerCondition condition)
 {
     if (condition != null && condition.IfModifiedSinceTime.HasValue && condition.IfModifiedSinceTime.Value >= tableContainer.LastModificationTime)
     {
         throw new ConditionNotMetException(null, null, null);
     }
     if (condition != null && condition.IfNotModifiedSinceTime.HasValue && condition.IfNotModifiedSinceTime.Value < tableContainer.LastModificationTime)
     {
         throw new ConditionNotMetException(null, null, null);
     }
 }
Ejemplo n.º 4
0
 internal static Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer LoadTableContainer(DevelopmentStorageDbDataContext context, Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer)
 {
     StorageStampHelpers.CheckContainerName(tableContainer.CasePreservedTableName, Microsoft.Cis.Services.Nephos.Common.Storage.ContainerType.TableContainer, false);
     Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer1 = (
         from c in context.TableContainers
         where (c.AccountName == tableContainer.AccountName) && (c.TableName == tableContainer.TableName)
         select c).FirstOrDefault <Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer>();
     if (tableContainer1 == null)
     {
         throw new ContainerNotFoundException();
     }
     return(tableContainer1);
 }
Ejemplo n.º 5
0
        private IEnumerator <IAsyncResult> GetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan remaining) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer = this.LoadTableContainer(dbContext);
                    DbTableContainer.CheckTableContainerCondition(tableContainer, condition);
                    this._tableContainer = tableContainer;
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbTableContainer.GetPropertiesImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Ejemplo n.º 6
0
        private void SaveTableChanges()
        {
            this.FailedCommandIndex = 0;
            if (this.changeDescriptionList == null || this.changeDescriptionList.Count != 1)
            {
                throw new XStoreArgumentException("Invalid number of table commands. Only a single table command is allowed.");
            }
            ChangeDescription changeDescription = this.changeDescriptionList.FirstOrDefault <ChangeDescription>();

            this.CheckPermission(changeDescription.TableName, true, false, changeDescription.UpdateType);
            if (changeDescription.UpdateType != UpdateKind.Insert)
            {
                if (changeDescription.UpdateType != UpdateKind.Delete)
                {
                    throw new NotSupportedException("Operation is not supported!");
                }
                UtilityTable utilityTable = this.ExecuteQuery <UtilityTable>(changeDescription);
                if (utilityTable == null)
                {
                    throw new DataServiceException(404, "Resource not found.");
                }
                changeDescription.Row = utilityTable;
                Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer sqlTableContainer = this.GetSqlTableContainer(((UtilityTable)changeDescription.Row).TableName);
                this.m_dbContext.TableContainers.DeleteOnSubmit(sqlTableContainer);
                this.m_dbContext.SubmitChanges();
                return;
            }
            Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer tableContainer = new Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer()
            {
                AccountName = changeDescription.AccountName
            };
            if (string.IsNullOrEmpty(((UtilityTable)changeDescription.Row).TableName))
            {
                throw new TableServiceGeneralException(TableServiceError.PropertiesNeedValue, null);
            }
            tableContainer.TableName = ((UtilityTable)changeDescription.Row).TableName.ToLowerInvariant();
            tableContainer.CasePreservedTableName = ((UtilityTable)changeDescription.Row).TableName;
            this.m_dbContext.TableContainers.InsertOnSubmit(tableContainer);
            this.m_dbContext.SubmitChanges();
        }
Ejemplo n.º 7
0
        private IEnumerator <IAsyncResult> SetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan remaining) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.TableContainer applicationMetadata = this.LoadTableContainer(dbContext);
                    if ((propertyNames & ContainerPropertyNames.ApplicationMetadata) != ContainerPropertyNames.None)
                    {
                        StorageStampHelpers.ValidateApplicationMetadata(this.ApplicationMetadata);
                        applicationMetadata.Metadata = this.ApplicationMetadata;
                    }
                    if ((propertyNames & ContainerPropertyNames.ServiceMetadata) != ContainerPropertyNames.None)
                    {
                        applicationMetadata.ServiceMetadata = ((IContainer)this).ServiceMetadata;
                    }
                    dbContext.SubmitChanges();
                    this._tableContainer = applicationMetadata;
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbTableContainer.SetProperties"));

            yield return(asyncResult);

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