Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetaWeblogHandler" /> class.
        /// </summary>
        /// <exception cref="BlogSystemException">unable to create container</exception>
        /// <exception cref="RahulRai.Websites.Utilities.Common.Exceptions.BlogSystemException">unable to create container</exception>
        public MetaWeblogHandler()
        {
            TraceUtility.LogInformation("Metawebloghander started initializing");
            try
            {
                if (null == this.metaweblogTable)
                {
                    this.metaweblogTable = new AzureTableStorageService <TableBlogEntity>(
                        this.connectionString,
                        this.blogTableName,
                        AzureTableStorageAssist.ConvertEntityToDynamicTableEntity,
                        AzureTableStorageAssist.ConvertDynamicEntityToEntity <TableBlogEntity>);
                    this.metaweblogTable.CreateStorageObjectAndSetExecutionContext();
                    TraceUtility.LogInformation("Blog table created");
                }

                if (null == this.mediaStorageService)
                {
                    this.mediaStorageService = new BlobStorageService(this.connectionString);
                    if (FileOperationStatus.FolderCreated
                        != this.mediaStorageService.CreateContainer(
                            this.blogResourceContainerName,
                            VisibilityType.FilesVisibleToAll))
                    {
                        TraceUtility.LogWarning("Resource container could not be created");
                        throw new BlogSystemException("unable to create container");
                    }
                }

                if (null == this.azureQueueService)
                {
                    this.azureQueueService = new AzureQueueService(this.connectionString, this.queueName);
                }

                if (null != this.searchService)
                {
                    return;
                }

                this.searchService = new AzureSearchService(
                    this.searchServiceName,
                    this.searchServiceKey,
                    ApplicationConstants.SearchIndex);
                TraceUtility.LogInformation("Search service initialized");
            }
            catch (BlogSystemException)
            {
                //// This is a custom exception. Throw it again.
                throw;
            }
            catch (Exception exception)
            {
                TraceUtility.LogError(exception);
                throw new BlogSystemException("failed to initialize");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlogService" /> class.
 /// </summary>
 /// <param name="blogContext">The blog context.</param>
 /// <param name="newsletterContext">The newsletter context.</param>
 /// <param name="newSubscriberQueueContext">The new subscriber queue context.</param>
 /// <param name="pageSize">Size of the page.</param>
 /// <param name="searchRecordsSize">Size of the search records.</param>
 public BlogService(
     AzureTableStorageService <TableBlogEntity> blogContext,
     AzureTableStorageService <TableNewsletterEntity> newsletterContext,
     AzureQueueService newSubscriberQueueContext,
     int pageSize,
     int searchRecordsSize)
 {
     this.blogContext               = blogContext;
     this.newsletterContext         = newsletterContext;
     this.newSubscriberQueueContext = newSubscriberQueueContext;
     this.pageSize          = pageSize;
     this.searchRecordsSize = searchRecordsSize;
 }
        public async Task <TableResult> RetrieveEntity(string partitionKey, string rowKey)
        {
            IAzureTableStorageService tableStorageService = new AzureTableStorageService(SettingsManager.AzureWebJobsStorage(), SettingsManager.SentimentTableName());

            return(await tableStorageService.GetEntity(partitionKey, rowKey));
        }
        public async Task <TableResult> SaveSentimentResult(SentimentEntity entity)
        {
            IAzureTableStorageService tableStorageService = new AzureTableStorageService(SettingsManager.AzureWebJobsStorage(), SettingsManager.SentimentTableName());

            return(await tableStorageService.InsertEntity(entity));
        }