public ActionResult Create(PresenceModel vm) { if (WebUser != null) { // Create the batch operation. var batchOperation = new TableBatchOperation(); var userActivities = JsonConvert.DeserializeObject <List <UserActivity> >(vm.Payload); var service = new CloudTableService(); foreach (var userActivity in userActivities) { userActivity.PartitionKey = WebUser.Id.ToString(); userActivity.RowKey = Guid.NewGuid().ToString("N"); userActivity.AssetId = vm.AssetId; userActivity.Name = WebUser.Name; batchOperation.Insert(userActivity); } if (userActivities.Count > 0) { service.AddBatch(batchOperation); } return(Json(true)); } return(Json(false)); }
public static async Task <IServiceCollection> AddInfrastructure(this IServiceCollection services) { var result = await CloudTableService.GetTable("test"); //DefaultEndpointsProtocol=https;AccountName=azlib;AccountKey=L00YRKyQIz6KEuOmcN2fFwGDqUVkGESIyxOT6PPsPYA5ncGYE7hklSKKgSKG4qKSzBWeXve0SDj4UtsSo1GcSw==;TableEndpoint=https://azlib.table.cosmos.azure.com:443/; return(services.AddDbContext <LibraryDbContext>(options => options.UseSqlServer(Environment.GetEnvironmentVariable("AzureSQLConnectionString")))); }
public TableDataSource(Application app, string name, Dictionary<string, object> configuration) : base(app, name, configuration) { string storageAccount = (string)configuration["storageAccount"]; if (String.IsNullOrEmpty(storageAccount)) { Runtime.Abort("No storageAccount was specified in the configuration for the '%s' data source.", name); } string accessKey = (string)configuration["accessKey"]; if (String.IsNullOrEmpty(accessKey)) { Runtime.Abort("No accessKey was specified in the configuration for the '%s' data source.", name); } _tableService = Azure.CreateTableService(storageAccount, accessKey); }
public TableDataSource(Application app, string name, Dictionary <string, object> configuration) : base(app, name, configuration) { string storageAccount = (string)configuration["storageAccount"]; if (String.IsNullOrEmpty(storageAccount)) { Runtime.Abort("No storageAccount was specified in the configuration for the '%s' data source.", name); } string accessKey = (string)configuration["accessKey"]; if (String.IsNullOrEmpty(accessKey)) { Runtime.Abort("No accessKey was specified in the configuration for the '%s' data source.", name); } _tableService = Azure.CreateTableService(storageAccount, accessKey); }
private static void Main(string[] args) { var service = new CloudTableService(); // Display Logs var logs = service.GetAllLogsForUser(2); foreach (var accessLog in logs) { Console.WriteLine(accessLog.LogTime); } // Create new Entity var newLog = new AccessLog(2, DateTime.UtcNow, AccessLogSource.GridDesktop, "HeartBeat", ""); service.AddLog(newLog); // Display Logs logs = service.GetAllLogsForUser(2); foreach (var accessLog in logs) { Console.WriteLine(accessLog.LogTime); } }