// update a modified document public async Task<Document> UpdateDocument(DocumentCollection coll, DBRecord record) { var updateDone = false; Document doc = null; while (!updateDone) { try { Console.WriteLine("updating document for: " + record.id + " on: " + DateTime.Now.ToString()); Trace.TraceInformation("worker role: updating document for: " + record.id + " on: " + DateTime.Now.ToString()); doc =await client.UpsertDocumentAsync(coll.SelfLink, record); updateDone = true; } catch (DocumentClientException documentClientException) { var statusCode = (int)documentClientException.StatusCode; if (statusCode == 429 || statusCode == 503) { Thread.Sleep(documentClientException.RetryAfter); } else { Console.WriteLine("ERROR: updating document: " + document.id); Trace.TraceInformation("worker role ERROR: updating document: " + document.id); updateDone = true; } } catch (AggregateException aggregateException) { if (aggregateException.InnerException.GetType() == typeof(DocumentClientException)) { var docExcep = aggregateException.InnerException as DocumentClientException; var statusCode = (int)docExcep.StatusCode; if (statusCode == 429 || statusCode == 503) Thread.Sleep(docExcep.RetryAfter); else { Console.WriteLine("ERROR: updating document: " + document.id); Trace.TraceInformation("worker role ERROR: updating document: " + document.id); updateDone = true; } } } } return doc; }
internal DatabaseConnect(string county, List<AlteredRecord> list) { List<ListObject> List = new List<ListObject>(); foreach (AlteredRecord ar in list) { ListObject lo = new ListObject(); lo.Address = ar.Address; lo.Description = ar.Description; lo.NotFullMP = ar.NotFullMP; lo.PostCode = ar.PostCode; lo.Price = ar.Price; lo.SoldOn = ar.SoldOn; List.Add(lo); } document = new DBRecord(); document.id = county; document.records = List; }