Beispiel #1
0
        public async Task <TableResult> InsertAsync(UserMedia entity, CancellationToken ct = default(CancellationToken))
        {
            var insertOperation = TableOperation.Insert(entity);

            ICancellableAsyncResult ar = _cloudTable.BeginExecute(insertOperation, null, null);

            ct.Register(ar.Cancel);

            return(await Task.Factory.FromAsync <TableResult>(ar, _cloudTable.EndExecute).ConfigureAwait(false));
        }
Beispiel #2
0
        public static void LogGetAsyncDataValuesException(string serviceURL, string siteCode, string variableCode, DateTime startTime, DateTime endTime, Exception e)
        {
            CloudStorageAccount csa         = GetCUAHSILogsStorageAccount();
            CloudTableClient    tableClient = csa.CreateCloudTableClient();
            CloudTable          errorTable  = tableClient.GetTableReference(DiscoveryStorageTableNames.GetValuesException);

            DynamicTableEntity er = new DynamicTableEntity(DiscoveryStorageTableNames.GetValuesException, LogHelper.DescendingRowKey(DateTime.UtcNow));

            er.Properties.Add("message", new EntityProperty(e.Message));
            if (e.InnerException != null)
            {
                er.Properties.Add("innerex", new EntityProperty(e.InnerException.ToString()));
            }

            er.Properties.Add("serviceURL", new EntityProperty(serviceURL));
            er.Properties.Add("siteCode", new EntityProperty(siteCode));
            er.Properties.Add("variableCode", new EntityProperty(variableCode));
            er.Properties.Add("startTime", new EntityProperty(startTime));
            er.Properties.Add("endTime", new EntityProperty(endTime));

            TableOperation logerror = TableOperation.Insert(er);

            errorTable.BeginExecute(logerror, null, null);
            // errorTable.BeginExecute(logerror, null, null); // store without tracking callback (fire and forget (application layer not network layer))
        }
        public static Task <TableResult> ExecuteAsync(
            this CloudTable table,
            TableOperation operation,
            CancellationToken ct = default(CancellationToken))
        {
            ICancellableAsyncResult ar = table.BeginExecute(operation, null, null);

            ct.Register(ar.Cancel);

            return(Task.Factory.FromAsync <TableResult>(ar, table.EndExecute));
        }
Beispiel #4
0
        public static Task <TableResult> ExecuteAsync(this CloudTable tbl, TableOperation operation, TableRequestOptions opt, OperationContext ctx, CancellationToken token)
        {
            ICancellableAsyncResult result = null;

            if (opt == null && ctx == null)
            {
                result = tbl.BeginExecute(operation, null, null);
            }
            else
            {
                result = tbl.BeginExecute(operation, opt, ctx, null, null);
            }

            var cancellationRegistration = token.Register(result.Cancel);

            return(Task.Factory.FromAsync(result, ar =>
            {
                cancellationRegistration.Dispose();
                return tbl.EndExecute(ar);
            }));
        }
Beispiel #5
0
        /// <summary>
        /// Persist information for tracking new session initializations, with server-generated timestamp
        /// </summary>
        /// <param name="sessionID">ID to be assigned to all subsequent requests</param>
        /// <param name="ipaddr">IP address of the user</param>
        public static void LogNewAPIUse(string sessionID)
        {
            CloudStorageAccount csa         = GetCUAHSILogsStorageAccount();
            CloudTableClient    tableClient = csa.CreateCloudTableClient();
            CloudTable          logTbl      = tableClient.GetTableReference(DiscoveryStorageTableNames.SessionStart);

            DynamicTableEntity log = new DynamicTableEntity(DiscoveryStorageTableNames.SessionStart, LogHelper.DescendingRowKey(DateTime.UtcNow));

            log.Properties.Add("sessionID", new EntityProperty(sessionID));

            TableOperation logerror = TableOperation.Insert(log);

            logTbl.BeginExecute(logerror, null, null);
        }
Beispiel #6
0
        /// <summary>
        ///     Executes table operation asynchronously.
        /// </summary>
        /// <param name="cloudTable">Cloud table.</param>
        /// <param name="tableOperation">
        ///     A <see cref="T:Microsoft.WindowsAzure.Storage.Table.TableOperation" /> object that represents the operation to perform.
        /// </param>
        /// <param name="cancellationToken">Cancellation token.</param>
        /// <returns>
        ///     A <see cref="T:Microsoft.WindowsAzure.Storage.Table.TableResult" /> containing the result of executing the operation on the table.
        /// </returns>
        public static Task <TableResult> ExecuteAsync(
            this CloudTable cloudTable,
            TableOperation tableOperation,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            ICancellableAsyncResult       asyncResult  = cloudTable.BeginExecute(tableOperation, null, null);
            CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);

            return(Task <TableResult> .Factory.FromAsync(
                       asyncResult,
                       result =>
            {
                registration.Dispose();
                return cloudTable.EndExecute(result);
            }));
        }
Beispiel #7
0
        private void InsertCity(CityRecord city)
        {
            if (city == null)
            {
                return; //not sure when this gets hit
            }
            lock (_pending)
            {
                if (_executing >= ConcurrencyMax)
                {
                    _pending.Enqueue(city);
                    return;
                }
            }

            var insert = TableOperation.InsertOrReplace(city);

            _table.BeginExecute(insert, InsertComplete, _table);
            lock (_pending)
            {
                _executing++;
            }
        }
Beispiel #8
0
 public ICancellableAsyncResult BeginExecute(TableOperation operation, AsyncCallback callback, object state)
 {
     return(_cloudTable.BeginExecute(operation, callback, state));
 }