This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Sample | |
{ | |
public class SubLedger | |
{ | |
public string Subledger { get; set; } | |
public string SubledgerType { get; set; } | |
public string SubledgerJobType { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlogPost | |
{ | |
public string Subject { get; set; } | |
public string Content { get; set; } | |
public DayOfWeek PostDat { get; set; } | |
} | |
public enum DayOfWeek | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ManualResetEvent resetEvent = new ManualResetEvent(false); | |
while(Run) | |
{ | |
// ... | |
resetEvent.WaitOne(10000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(Run) | |
{ | |
// ... | |
Thread.Sleep(10000); | |
} | |
OnStop() | |
{ | |
Run = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while(true) | |
{ | |
// do something | |
Thread.Sleep(10000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string GetErrorFromBlob(string blobId) | |
{ | |
var container = CloudStorageAccount.Parse(this.connectionString).CreateCloudBlobClient().GetContainerReference("elmaherrors"); | |
var blob = container.GetBlobReference(blobId); | |
return blob.DownloadText(); | |
} | |
public override ErrorLogEntry GetError(string id) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string SerializeErrorToBlob(ErrorEntity error) | |
{ | |
string id = Guid.NewGuid().ToString(); | |
string xml = ErrorXml.EncodeString(error.GetOriginalError()); | |
var container = CloudStorageAccount.Parse(this.connectionString).CreateCloudBlobClient().GetContainerReference("elmaherrors"); | |
var blob = container.GetBlobReference(id); | |
blob.UploadText(xml); | |
return id; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override string Log(Error error) | |
{ | |
var entity = new ErrorEntity(error); | |
var context = CloudStorageAccount.Parse(connectionString).CreateCloudTableClient().GetDataServiceContext(); | |
entity.BlobId = SerializeErrorToBlob(entity); | |
context.AddObject("elmaherrors", entity); | |
context.SaveChangesWithRetries(); | |
return entity.RowKey; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ErrorEntity : TableServiceEntity | |
{ | |
public string BlobId { get; set; } | |
private Error OriginalError { get; set; } | |
public ErrorEntity() { } | |
public ErrorEntity(Error error) : base(...) | |
{ | |
this.OriginalError = error; | |
} |