public int IssueCollectionTasks() { int tasksIssued = 0; //Query Collection Tasks LinqToSqlDataContext context = new LinqToSqlDataContext(); IQueryable <HaystackLibrary.CollectionTask> results = from r in context.CollectionTasks where r.State == CollectionsTaskState.Approved.ToString() select r; //Write Queue Message, Update State to "Issued" foreach (HaystackLibrary.CollectionTask r in results) { r.State = CollectionsTaskState.Issued.ToString(); r.Issued = DateTime.UtcNow; string message = CollectionsTaskHelper.DatabaseTaskToMessage(r); StorageClientHelper.AddQueueMessage(QueueType.Collections, SourceType.Twitter, message); tasksIssued++; string task = string.Format("{0} {1} {2} {3} {4} {5} {6} ", r.Id.ToString(), r.State, r.Created.ToString(), r.Project, r.Source, r.Command, r.Target); Console.WriteLine(task); } //Submit Changes context.SubmitChanges(); return(tasksIssued); }
//Step 5, Inner Loop private void ReportCollectionTask() { Logger.Log("ReportCollectionTask: #" + _currentTask.Command); Logger.Log(""); //MetaData _currentTask.CollectionsStation = _collectionsStation; _currentTask.CollectorInstance = _collectorInstance; _currentTask.Collected = CollectionsTaskHelper.Now(); //SaveBlob CloudBlob blob = StorageClientHelper.GetBlobReference(_currentTask.Project, _currentTask.BlobName); blob.Attributes.Properties.ContentMD5 = _currentTask.ResultsHash; blob.Attributes.Metadata["Id"] = _currentTask.Id.ToString(); blob.Attributes.Metadata["Project"] = _currentTask.Project; blob.Attributes.Metadata["State"] = CollectionsTaskState.Collected.ToString(); blob.Attributes.Metadata["Collected"] = _currentTask.Collected; blob.UploadText(_currentTask.ResultsXml); //AddQueue string message = CollectionsTaskHelper.LocalTaskToMessage(_currentTask); StorageClientHelper.AddQueueMessage(QueueType.Processing, SourceType.Twitter, message); }