Example #1
0
 public static TablePost TablePostData(dynamic post)
 {
     TablePost item = new TablePost(post.Type, post.id)
     {
         district = post.Path.District,
         school = post.Path.School,
         classes = post.Path.Classes,
         timestamp = post.Info.timestamp,
         user = post.Info.user,
         uid = post.Info.uid,
         message = post.Info.message
     };
     return item;
 }
Example #2
0
        private static async Task BackupPostCollection(DocumentCollection dc)
        {
            
            var ds =
                  from d in _client.CreateDocumentQuery<PostMessage>(dc.DocumentsLink)
                  where d.Type == "Post"
                  select d;

            var docNumber = 0;
            TableBatchOperation batchOperation = new TableBatchOperation();
            foreach (var d in ds)
            {              
                    TablePost c = new TablePost(d.Type, d.id)
                    {
                        district = d.Path.District,
                        school = d.Path.School,
                        classes = d.Path.Classes,
                        timestamp = d.Info.timestamp,
                        user = d.Info.user,
                        uid = d.Info.uid,
                        message = d.Info.message
                    };

                    if (docNumber < 100)
                    {
                        batchOperation.Insert(c);
                        await DeletePost(dc,d.id);                      
                        docNumber++;
                    }
                    else if (docNumber == 100)
                    {
                        await _table.ExecuteBatchAsync(batchOperation);
                        batchOperation = new TableBatchOperation();
                        docNumber = 0;
                    }
               
            }
            if (batchOperation.Count>0)
            {
                await _table.ExecuteBatchAsync(batchOperation);
            }
        }