Esempio n. 1
0
 public void StoreCacheDetailInTable(string cahceName, string feedName, string cacheServiceName)
 {
     try
     {
         string connStr = CloudConfigurationManager.GetSetting("StorageConnectionString");
         CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connStr);
         CloudTableClient    client         = storageAccount.CreateCloudTableClient();
         CloudTable          table          = client.GetTableReference("cs218cache");
         // table.CreateIfNotExists();
         CS218CacheTable cacheTable = new CS218CacheTable();
         cacheTable.Id               = Guid.NewGuid().ToString();
         cacheTable.CacheName        = cahceName;
         cacheTable.FeedName         = feedName;
         cacheTable.CacheServiceName = cacheServiceName;
         cacheTable.PartitionKey     = cahceName;
         cacheTable.RowKey           = feedName;
         cacheTable.CreatedDate      = DateTime.Now;
         cacheTable.LastFetchDate    = DateTime.Now;
         cacheTable.FetchCount       = 0;
         TableOperation insertOperation = TableOperation.Insert(cacheTable);
         table.Execute(insertOperation);
     }
     catch (Exception exp)
     {
         Trace.TraceError(exp.Message + Environment.NewLine + exp.StackTrace);
     }
 }
Esempio n. 2
0
        private void UpdateFeedCacheItem(string cachename, string FeedName)
        {
            string connStr = CloudConfigurationManager.GetSetting("StorageConnectionString");
            CloudStorageAccount storageAccount    = CloudStorageAccount.Parse(connStr);
            CloudTableClient    client            = storageAccount.CreateCloudTableClient();
            CloudTable          table             = client.GetTableReference("cs218cache");
            TableOperation      retrieveOperation = TableOperation.Retrieve <CS218CacheTable>(cachename, FeedName);
            TableResult         retrievedResult   = table.Execute(retrieveOperation);
            CS218CacheTable     updateEntity      = (CS218CacheTable)retrievedResult.Result;

            updateEntity.FetchCount    = updateEntity.FetchCount + 1;
            updateEntity.LastFetchDate = DateTime.Now;
            TableOperation insertOrReplaceOperation = TableOperation.InsertOrReplace(updateEntity);

            table.Execute(insertOrReplaceOperation);
        }