public int IssueCollectionTasks() { int tasksIssued = 0; //Query Collection Tasks LinqToSqlAzureHaystackDataContext context = new LinqToSqlAzureHaystackDataContext(); IQueryable <T_CollectionTask> results = from r in context.T_CollectionTasks where r.State == StateTypeEnum.Approved.ToString() select r; //Write Queue Message, Update State to "Issued" foreach (T_CollectionTask r in results) { r.State = StateTypeEnum.Issued.ToString(); r.Issued = DateTime.UtcNow; string message = CollectionsTaskHelper.T_CollectionsTaskToMessage(r); QueueTypeEnum queueName; if (r.Command == TwitterCommandEnum.Followers.ToString()) { queueName = QueueTypeEnum.CollectionsTwitterFollowers; } else if (r.Command == TwitterCommandEnum.Friends.ToString()) { queueName = QueueTypeEnum.CollectionsTwitterFriends; } else if (r.Command == TwitterCommandEnum.Profile.ToString()) { queueName = QueueTypeEnum.CollectionsTwitterProfile; } else if (r.Command == TwitterCommandEnum.Search.ToString()) { queueName = QueueTypeEnum.CollectionsTwitterSearch; } else if (r.Command == TwitterCommandEnum.Tweets.ToString()) { queueName = QueueTypeEnum.CollectionsTwitterTweets; } else { throw new Exception("Command Not Found"); } AzureClientService.AddQueueMessage(queueName, 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); }
//5-ReportCollectionTask protected void ReportCollectionTask() { Logger.Log(GetContext() + "ReportCollectionTask(): #" + _currentTask.Id); //MetaData _currentTask.Station = _station; _currentTask.Collector = _collector; _currentTask.Collected = CollectionsTaskHelper.Now(); //SaveBlob CloudBlob blob = AzureClientService.GetBlobReference(_currentTask.Project, _currentTask.BlobName); blob.Attributes.Properties.ContentMD5 = _currentTask.ResultHash; blob.Attributes.Metadata["Id"] = _currentTask.Id.ToString(); blob.Attributes.Metadata["State"] = StateTypeEnum.Collected.ToString(); blob.Attributes.Metadata["Project"] = _currentTask.Project; blob.Attributes.Metadata["Collected"] = _currentTask.Collected; blob.Attributes.Metadata["Command"] = _currentTask.Command; //blob.Attributes.Metadata["TargetId"] = _currentTask. blob.UploadText(_currentTask.ResultJson); //AddQueue string message = CollectionsTaskHelper.CollectionsTaskToMessage(_currentTask); AzureClientService.AddQueueMessage(QueueTypeEnum.ProcessingTwitter, message); AzureClientService.DeleteQueueMessage(_collectionsQueue, _currentQueueMessage); }