Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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"))));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
            }
        }