/// <summary> /// Updates the report generation queue. /// </summary> /// <param name="status">The status</param> /// <returns>True if successful</returns> public bool UpdateReportGenerationQueue(ReportGenerationQueueStatusDto status) { if (status.ReportGenerationQueueId == null) { throw new ArgumentNullException("ReportGenerationQueueId"); } var client = new ReportQueueStatusServiceClient(); try { var statusData = new ReportGenerationQueueStatus() { NumberOfRetries = status.NumberOfRetries, QueryText = status.QueryText, ReportGenerationQueueId = status.ReportGenerationQueueId, ReportStatus = status.ReportStatus, ExecutionLog = status.ExecutionLog }; return client.UpdateReportGenerationQueue(statusData); } finally { client.Close(); } }
public void Should_Invoke_Status_Service() { var client = new ReportQueueStatusServiceClient(); var status = new ReportGenerationQueueStatus(); status.ReportGenerationQueueId = -1; status.ReportStatus = ReportStatus.Completed; client.UpdateReportGenerationQueue(status); }
/// <summary> /// Updates the report generation queue. /// </summary> /// <param name="status">The status</param> /// <returns>True if successful</returns> public bool UpdateReportGenerationQueue(ReportGenerationQueueStatusDto status) { //throw new NotImplementedException(); moony if (status.ReportGenerationQueueId == null) { throw new ArgumentNullException("ReportGenerationQueueId"); } var queueItem = new ReportGenerationQueueStatus() { NumberOfRetries = status.NumberOfRetries, QueryText = status.QueryText, ReportGenerationQueueId = status.ReportGenerationQueueId, ReportStatus = status.ReportStatus, ExecutionLog = status.ExecutionLog }; try { using (GenerationDao generationDao = DataAccessFactory.Create<GenerationDao>()) { var savedQueueItem = generationDao .Find<ReportGenerationQueue>(queue => queue.ReportGenerationQueueId == queueItem.ReportGenerationQueueId); // Type type = Enum.GetUnderlyingType(typeof(ReportStatus)); savedQueueItem.ReportGenerationStatus = queueItem.ReportStatus ?? savedQueueItem.ReportGenerationStatus; savedQueueItem.NumberOfRetries = queueItem.NumberOfRetries ?? savedQueueItem.NumberOfRetries; savedQueueItem.QueryText = queueItem.QueryText ?? savedQueueItem.QueryText; savedQueueItem.ExecutionLog = queueItem.ExecutionLog ?? savedQueueItem.ExecutionLog; savedQueueItem.UpdatedDate = DateTime.Now; if (generationDao.CanSubmitChanges()) { generationDao.SubmitChanges(); } else { var sb = new StringBuilder(); foreach (EntityBase entity in generationDao.InvalidEntities) { foreach (string error in entity.Errors) { sb.AppendLine(error); } } throw new Exception(sb.ToString()); } } return true; } catch (Exception e) { throw new FaultException( new FaultReason(e.Message), new FaultCode(string.Format("Could not update: {0}", queueItem.ReportGenerationQueueId))); } }