-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
65 lines (51 loc) · 1.72 KB
/
Program.cs
File metadata and controls
65 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using Azure;
using Azure.Data.Tables;
using System.Text.Json;
var connectionString = @"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1";
var tableName = "progresstable";
try
{
var tableClient = new TableClient(connectionString, tableName);
var progress1 = new Progress("meublob_" + DateTime.Now.ToString())
{
FinishDate = DateTime.UtcNow.AddMinutes(10)
};
await tableClient.AddEntityAsync(progress1);
var createdEntity = await tableClient.GetEntityAsync<Progress>(progress1.PartitionKey, progress1.RowKey);
Console.WriteLine(JsonSerializer.Serialize(createdEntity, new JsonSerializerOptions { WriteIndented = true }));
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
public enum Status
{
Processing = 0,
Failed = 1,
Finished = 2
}
public class Progress : ITableEntity
{
public DateTime StartDate { get; set; }
public DateTime FinishDate { get; set; }
public string BlobPath { get; set; }
public int ItemsCount { get; set; }
public int FailedItems { get; set; }
public Status Status { get; set; }
public string PartitionKey { get; set; }
public string RowKey { get; set; }
public DateTimeOffset? Timestamp { get; set; }
public ETag ETag { get; set; }
public Progress()
{
}
public Progress(string blobPath)
{
RowKey = Guid.NewGuid().ToString();
PartitionKey = nameof(Progress);
StartDate = DateTime.UtcNow;
BlobPath = blobPath;
}
}