开发学院服务器云计算 保护模拟运算表并使其不受应用错误的影响 阅读

保护模拟运算表并使其不受应用错误的影响

 2010-06-21 00:00:00 来源:WEB开发网   
核心提示: BackupTableRange建立了一个会扫描指定密钥范围的查询,然后援引下列BackupToContainer,保护模拟运算表并使其不受应用错误的影响(3),我们使用 BackupEntity类来读取结果,BackupEntity保存了一个内部XElement,我们可以使用所示代码中的Rea

BackupTableRange建立了一个会扫描指定密钥范围的查询,然后援引下列BackupToContainer。我们使用 BackupEntity类来读取结果。BackupEntity保存了一个内部XElement,XElement名为EntryElement,它将接收到的一个用于实体数据的原始OData XML保存在查询响应中。为了掌握这个原始数据,我们可以使用所示代码中的ReadingEntity事件。ResolveType代表用来提供类型名称,而WCF数据服务客户会使用此类型名称。

/// <summary>
/// Create a query that will scan the assigned range and save it to a blob in the given container
/// </summary>
/// <param name="tableClient"></param>
/// <param name="container"></param>
/// <param name="tableName"></param>
/// <param name="range"></param>
/// <param name="backupId"></param>
private static void BackupTableRange(
CloudTableClient tableClient, 
CloudBlobContainer container, 
string tableName, 
PartitionKeyRange range, 
string backupId)
{
        TableServiceContext context = tableClient.GetDataServiceContext();
        context.MergeOption = MergeOption.NoTracking;
        context.ResolveType = TableBackup.ResolveType;
        context.ReadingEntity += new EventHandler<ReadingWritingEntityEventArgs>(TableBackup.OnReadingEntity);
        context.RetryPolicy = RetryPolicies.RetryExponential(5, RetryPolicies.DefaultClientBackoff);
        var query = from entity in context.CreateQuery<BackupEntity>(tableName) select entity;
        if (range.Min != null)
        {
            query = query.Where(entity => entity.PartitionKey.CompareTo(range.Min) >= 0);
        }
        if (range.Max != null)
        {
            query = query.Where(entity => entity.PartitionKey.CompareTo(range.Max) < 0);
        }
        CloudTableQuery<BackupEntity> cloudQuery = new CloudTableQuery<BackupEntity>((DataServiceQuery<BackupEntity>)query);
        BackupToContainer(container, cloudQuery, backupId, range);
}
/// <summary>
/// Entities used for backup/restore
/// </summary>
[DataServiceKey("PartitionKey", "RowKey")]
public class BackupEntity
{
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    /// <summary>
    /// Used during restore to store the entry element.
    /// </summary>
    internal XElement EntryElement { get; set; }
}
static void OnReadingEntity(object sender, ReadingWritingEntityEventArgs args)
{
     BackupEntity entity = args.Entity as BackupEntity;
     entity.EntryElement = args.Data;
}
static Type ResolveType(string entityName)
{
        return typeof(BackupEntity);
}

上一页  1 2 3 4 5 6 7  下一页

Tags:保护 模拟 运算

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接