public static void AddSite( // the incoming queue [QueueTrigger(SiteMonitRConfiguration.QUEUE_NAME_NEW_SITE)] string url, // the list of all sites [Table(SiteMonitRConfiguration.TABLE_NAME_SITES)] IQueryable <SiteRecord> listOfSiteRecords, // the table into which sites should be saved [Table(SiteMonitRConfiguration.TABLE_NAME_SITES)] CloudTable table ) { var cleansedUrl = SiteMonitRConfiguration.CleanUrlForRowKey(url); var siteRecord = new SiteRecord(); siteRecord.RowKey = SiteMonitRConfiguration.GetPartitionKey(); siteRecord.PartitionKey = cleansedUrl; siteRecord.Uri = url; if (!listOfSiteRecords.ToList().Any(entity => entity.PartitionKey == siteRecord.PartitionKey)) { table.Execute(TableOperation.InsertOrReplace(siteRecord)); } }
public static void DeleteSite( // the incoming queue [QueueInput(SiteMonitRConfiguration.QUEUE_NAME_DELETE_SITE)] string url, // the site list table from which data should be deleted [Table(SiteMonitRConfiguration.TABLE_NAME_SITES)] IDictionary <Tuple <string, string>, SiteRecord> siteRecords, // the site log table from which data should be deleted [Table(SiteMonitRConfiguration.TABLE_NAME_SITE_LOGS)] IDictionary <Tuple <string, string>, SiteResult> siteResults ) { var cleansedUrl = SiteMonitRConfiguration.CleanUrlForRowKey(url); var key = new Tuple <string, string>( SiteMonitRConfiguration.GetPartitionKey(), cleansedUrl); // delete the site record if (siteRecords.ContainsKey(key)) { siteRecords.Remove(key); } // delete all the site's logs foreach (var siteResult in siteResults) { if (siteResult.Key.Item1 == cleansedUrl) { siteResults.Remove(siteResult.Key); } } }
public static void AddSite( // the incoming queue [QueueInput(SiteMonitRConfiguration.QUEUE_NAME_NEW_SITE)] string url, // the table into which sites should be saved [Table(SiteMonitRConfiguration.TABLE_NAME_SITES)] IDictionary <Tuple <string, string>, SiteRecord> siteRecords ) { var cleansedUrl = SiteMonitRConfiguration.CleanUrlForRowKey(url); var key = new Tuple <string, string>( SiteMonitRConfiguration.GetPartitionKey(), cleansedUrl); if (!siteRecords.ContainsKey(key)) { siteRecords.Add(key, new SiteRecord { Uri = url }); } }
public SiteRecordTableEntity() { this.PartitionKey = SiteMonitRConfiguration.GetPartitionKey(); }