Esempio n. 1
0
        private void CacheReportGenerationTask(ReportGenerationTask task, UserConnection userConnection)
        {
            var key   = task.TaskId.ToString();
            var value = new UserReportGenerationTask(task, userConnection.CurrentUser.Id);

            _taskStore[key] = value;
        }
 /// <summary>
 /// Sends a message about completion of report generation. Sends the message to the next sender if can’t send it yourself.
 /// </summary>
 /// <param name="fileConversionTask">The remote task of file conversion.</param>
 /// <param name="reportGenerationTask">The local task of a report generation.</param>
 /// <returns>True if message about completion of report generation sent; otherwise false.</returns>
 public bool SendMessage(FileConversionTask fileConversionTask, UserReportGenerationTask reportGenerationTask)
 {
     if (SendMessageInternal(fileConversionTask, reportGenerationTask))
     {
         return(true);
     }
     return(_successor != null && _successor.SendMessage(fileConversionTask, reportGenerationTask));
 }
        private void SendNotification(
            IMsgChannel channel,
            FileConversionTask fileConversionTask,
            UserReportGenerationTask reportGenerationTask)
        {
            var simpleMessage = new SimpleMessage {
                Id   = Guid.NewGuid(),
                Body = GetNotificationBody(fileConversionTask, reportGenerationTask),
            };

            simpleMessage.Header.Sender = NotifySender;
            channel.PostMessage(simpleMessage);
        }
        /// <inheritdoc cref="ReportGenerationCompletionSender.SendMessageInternal"/>
        protected override bool SendMessageInternal(FileConversionTask fileConversionTask, UserReportGenerationTask reportGenerationTask)
        {
            var taskId        = reportGenerationTask.TaskId;
            var userId        = reportGenerationTask.UserId;
            var sysUserEntity = CreateSysUserEntity();

            if (!sysUserEntity.FetchFromDB(userId))
            {
                return(false);
            }
            SendReminding(sysUserEntity, fileConversionTask, reportGenerationTask);
            Log.Info($"The reminder about report generation completion for the task ID = {taskId} has been sent.");
            return(true);
        }
        /// <inheritdoc cref="ReportGenerationCompletionSender.SendMessageInternal"/>
        protected override bool SendMessageInternal(FileConversionTask fileConversionTask, UserReportGenerationTask reportGenerationTask)
        {
            var taskId  = reportGenerationTask.TaskId;
            var userId  = reportGenerationTask.UserId;
            var channel = MsgChannelManager.Instance.FindItemByUId(userId);

            if (channel == null)
            {
                return(false);
            }
            SendNotification(channel, fileConversionTask, reportGenerationTask);
            Log.Info($"The notification about report generation completion for the task ID = {taskId} has been sent.");
            return(true);
        }
 /// <summary>
 /// Gets the body of a notification message.
 /// </summary>
 /// <param name="fileConversionTask">The remote task of file conversion.</param>
 /// <param name="reportGenerationTask">The local task of a report generation.</param>
 /// <returns>The message body of notification by the <paramref name="fileConversionTask"/> and <paramref name="reportGenerationTask"/>.</returns>
 protected virtual object GetNotificationBody(FileConversionTask fileConversionTask, UserReportGenerationTask reportGenerationTask)
 {
     return(new {
         taskId = reportGenerationTask.TaskId,
         reportName = reportGenerationTask.ReportName,
         success = fileConversionTask.Status == TaskStatus.Successed,
         methodName = nameof(IAsyncReportGenerationController.GetReportFile),
         serviceName = nameof(PdfAsyncReportGenerationController),
     });
 }
 /// <summary>
 /// Sends a message about completion of report generation.
 /// </summary>
 /// <param name="fileConversionTask">The remote task of file conversion.</param>
 /// <param name="reportGenerationTask">The local task of a report generation.</param>
 /// <returns>True if message about completion of report generation sent; otherwise false.</returns>
 protected abstract bool SendMessageInternal(FileConversionTask fileConversionTask, UserReportGenerationTask reportGenerationTask);