Skip to content

Instantly share code, notes, and snippets.

View igorkulman's full-sized avatar

Igor Kulman igorkulman

View GitHub Profile
@igorkulman
igorkulman / LocalizedStrings.cs
Last active December 18, 2015 17:49
LocalizedStrings class for Windows Phone 7
public class LocalizedStrings
{
private static readonly Resources.AppResources localizedResources = new Resources.AppResources();
public Resources.AppResources LocalizedResources { get { return localizedResources; } }
}
let data =
"test.xlsx"
|> Excel.getWorksheetByIndex 1
|> Excel.getContent
data
|> Seq.iter (fun x-> printfn "%s" x)
[<DataServiceKey("PartitionKey", "RowKey")>]
type LogEntity() =
let mutable partitionKey = ""
let mutable rowKey = ""
let mutable message = ""
let mutable timestamp = DateTime.Now
let mutable severity = ""
member x.PartitionKey with get() = partitionKey and set v = partitionKey <- v
member x.RowKey with get() = rowKey and set v = rowKey <- v
member x.Message with get() = message and set v = message <- v
type Severity =
| Debug
| Information
| Error
with
member this.toString() =
match this with
| Debug -> "Debug"
| Information -> "Information"
| Error -> "Error"
[<CLIMutable>]
[<DataServiceKey("PartitionKey", "RowKey")>]
type LogEntity =
{
Message: string
Timestamp: DateTime
Severity: string
PartitionKey: string
RowKey: string
}
let getLogs (date:DateTime) = seq {
for e in client.GetDataServiceContext().CreateQuery<LogEntity>("LogEntity") do
if e.PartitionKey = date.ToString("yyyy-MM-dd") then
yield e
}
let log (severity:Severity) message =
async {
let entry = LogEntity(PartitionKey = DateTime.Now.ToString("yyyy-MM-dd"), RowKey = Guid.NewGuid().ToString(), Timestamp = DateTime.Now, Message = message, Severity = severity.ToString())
CreateEntityWithClient client "LogEntity" entry
} |> Async.Start
let log (severity:Severity) message =
let entry = LogEntity(PartitionKey = DateTime.Now.ToString("yyyy-MM-dd"), RowKey = Guid.NewGuid().ToString(), Timestamp = DateTime.Now, Message = message, Severity = string severity)
CreateEntityWithClient client "LogEntity" entry
let client = BuildTableClientWithConnStr "TableStorageConnectionString"
protected override void OnInvoke(ScheduledTask task)
{
ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
var toast = new ShellToast {Title = DateTime.Now.ToShortTimeString(), Content = "Task Running"};
toast.Show();
NotifyComplete();
}