Пример #1
0
        public static string DownloadSingleResultBlob(string freeTextInput, JobSiteEnum jobSite)
        {
            // Create the blob client.
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container.
            CloudBlobContainer blobContainer = blobClient.GetContainerReference(ResultsContainerName);

            // Create the container if it doesn't already exist.
            blobContainer.CreateIfNotExists();

            if (freeTextInput != null)
            {

                // Loop over items within the container and output the length and URI.
                foreach (IListBlobItem item in blobContainer.ListBlobs(null, false))
                {
                    CloudBlockBlob blob = item as CloudBlockBlob;

                    if (blob != null && blob.Name.Equals((int)jobSite + ":" + freeTextInput))
                    {
                        return (blob.DownloadText());
                    }
                }
            }

            return null;
        }
Пример #2
0
        /// <summary>
        /// Factory for job collector. Each collector knows how to extract jobs from a specific website.
        /// </summary>
        /// <param name="jobType"></param>
        /// <returns></returns>
        public static IJobCollectable GetCollector(JobSiteEnum jobType)
        {
            IJobCollectable jobCollector;

            switch (jobType)
            {
                case JobSiteEnum.AllJobs:
                    jobCollector = new AllJobsCollector();
                    break;
                case JobSiteEnum.JobMaster:
                    jobCollector = new JobMasterCollector();
                    break;
                case JobSiteEnum.Drushim:
                    jobCollector = new DrushimCollector();
                    break;
                case JobSiteEnum.Indeed:
                    jobCollector = new IndeedCollector();
                    break;
                default:
                    jobCollector = null;
                    break;
            }

            return jobCollector;
        }
Пример #3
0
        public static void AddToResultBlob(string freeTextInput, JobSiteEnum jobSiteType, string jobResult)
        {
            // Create the blob client.
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container.
            CloudBlobContainer blobContainer = blobClient.GetContainerReference(ResultsContainerName);

            // Create the container if it doesn't already exist.
            blobContainer.CreateIfNotExists();

            // Message is unique -> "[free text input]:[job site type]"
            string resultBlockName = freeTextInput + ":" + (int)jobSiteType;

            // Upload a text blob
            CloudBlockBlob blob = blobContainer.GetBlockBlobReference(resultBlockName);
            blob.UploadTextAsync(jobResult);

            // Log a message that can be viewed in the diagnostics tables called WADLogsTable
            System.Diagnostics.Trace.WriteLine("Transferring result to 'results' blob.");
        }
Пример #4
0
        public static void InsertJobToQueue(string freeTextInput, JobSiteEnum jobSite)
        {
            string blobName = (int)jobSite + ":" + freeTextInput;

            if (isTextInputInResultsTable(blobName))
            {
                // If the input has already been calculated in the past, don't add it to the queue
                return;
            }

            // Create the queue client.
            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            // Retrieve a reference to a queue.
            CloudQueue queue = queueClient.GetQueueReference(WorkQueueName);

            // Create the queue if it doesn't already exist.
            queue.CreateIfNotExists();

            // Create a message and add it to the queue.
            CloudQueueMessage message = new CloudQueueMessage(blobName);
            queue.AddMessage(message);
        }