HaBookTableContinuationToken.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using MessagePack;
  2. using Microsoft.WindowsAzure.Storage;
  3. using Microsoft.WindowsAzure.Storage.Table;
  4. using System;
  5. using System.ComponentModel.DataAnnotations;
  6. using TEAMModelOS.SDK.Extension.DataResult.PageToken;
  7. using TEAMModelOS.SDK.Helper.Common.ValidateHelper;
  8. namespace TEAMModelOS.SDK.Module.AzureTable.Configuration
  9. {
  10. [MessagePackObject(keyAsPropertyName: true)]
  11. public class HaBookTableContinuationToken
  12. {
  13. [Required]
  14. public string NextPartitionKey { get; set; }
  15. [Required]
  16. public string NextRowKey { get; set; }
  17. [Required]
  18. public string NextTableName { get; set; }
  19. [Required]
  20. public StorageLocation? TargetLocation { get; set; }
  21. public TableContinuationToken GetContinuationToken() {
  22. TableContinuationToken continuationToken = new TableContinuationToken
  23. {
  24. NextPartitionKey = this.NextPartitionKey,
  25. NextRowKey = this.NextRowKey,
  26. NextTableName = this.NextTableName,
  27. TargetLocation = this.TargetLocation
  28. };
  29. return ValidateHelper.ValidObj(continuationToken);
  30. }
  31. public HaBookTableContinuationToken() {
  32. }
  33. public HaBookTableContinuationToken(TableContinuationToken continuationToken) {
  34. if (null != continuationToken) {
  35. this.NextPartitionKey = continuationToken.NextPartitionKey;
  36. this.NextRowKey = continuationToken.NextRowKey;
  37. this.NextTableName = continuationToken.NextTableName;
  38. this.TargetLocation = continuationToken.TargetLocation;
  39. }
  40. }
  41. public HaBookTableContinuationToken(AzureTableToken continuationToken)
  42. {
  43. if (null != continuationToken) {
  44. this.NextPartitionKey = continuationToken.NextPartitionKey;
  45. this.NextRowKey = continuationToken.NextRowKey;
  46. this.NextTableName = continuationToken.NextTableName;
  47. int index = 0;
  48. foreach (StorageLocation item in Enum.GetValues(typeof(StorageLocation)))
  49. {
  50. if (continuationToken.TargetLocation == index)
  51. {
  52. this.TargetLocation = item;
  53. break;
  54. }
  55. index++;
  56. }
  57. }
  58. }
  59. public AzureTableToken GetAzureTableToken() {
  60. AzureTableToken continuationToken = new AzureTableToken
  61. {
  62. NextPartitionKey = this.NextPartitionKey,
  63. NextRowKey = this.NextRowKey,
  64. NextTableName = this.NextTableName
  65. };
  66. ///枚举遍历
  67. ///
  68. int index = 0;
  69. foreach (StorageLocation item in Enum.GetValues(typeof(StorageLocation))) {
  70. if (this.TargetLocation == item) {
  71. continuationToken.TargetLocation = index;
  72. break;
  73. }
  74. index++;
  75. }
  76. return ValidateHelper.ValidObj(continuationToken);
  77. }
  78. }
  79. }