示例#1
0
        private void ReportAuthError(IUnitOfWork uow, Fr8AccountDO user, InvalidTokenRuntimeException ex)
        {
            var activityTemplate = ex?.FailedActivityDTO.ActivityTemplate;

            var errorMessage = $"Activity {ex?.FailedActivityDTO.Label} was unable to authenticate with remote web-service.";

            errorMessage += $"Please re-authorize {ex?.FailedActivityDTO.Label} activity " +
                            $"by clicking on the Settings dots in the upper " +
                            $"right corner of the activity and then selecting Choose Authentication. ";

            // Try getting specific the instructions provided by the terminal.
            if (!String.IsNullOrEmpty(ex.Message))
            {
                errorMessage += "Additional instructions from the terminal: ";
                errorMessage += ex.Message;
            }

            _pusherNotifier.NotifyUser(new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericFailure,
                Subject          = "Plan Failed",
                Message          = errorMessage,
                Collapsed        = false
            }, user.Id);
        }
示例#2
0
        public async Task Share(Guid planId, string userId)
        {
            try
            {
                var planDto = CrateTemplate(planId, userId);

                var dto = new PublishPlanTemplateDTO
                {
                    Name         = planDto.Name,
                    Description  = planDto.Description,
                    ParentPlanId = planId,
                    PlanContents = planDto
                };

                var planTemplateCM = await _planTemplate.CreateOrUpdate(userId, dto);

                await _searchProvider.CreateOrUpdate(planTemplateCM);

                await _webservicesPageGenerator.Generate(planTemplateCM, userId);

                await _planTemplateDetailsGenerator.Generate(dto);

                // Notify user with directing him to PlanDirectory with related search query
                var url = CloudConfigurationManager.GetSetting("PlanDirectoryUrl") + "/plan_directory#?planSearch=" + HttpUtility.UrlEncode(dto.Name);

                _pusherNotifier.NotifyUser(new NotificationMessageDTO
                {
                    NotificationType = NotificationType.GenericSuccess,
                    Subject          = "Success",
                    Message          = $"Plan Shared. To view, click on " + url,
                    Collapsed        = false
                }, userId);
            }
            catch
            {
                _pusherNotifier.NotifyUser(new NotificationMessageDTO
                {
                    NotificationType = NotificationType.GenericSuccess,
                    Subject          = "Success",
                    Message          = $"Plan sharing failed",
                    Collapsed        = false
                }, userId);
            }
        }
        public async Task <IHttpActionResult> RunMonitoring()
        {
            //We don't need to wait for the result as the purpose of this method is just to initiate a start (as a double-check measure)
            var currentUser = _securityServices.GetCurrentUser();

            _pusher.NotifyUser(new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericInfo,
                Subject          = "Manifest Registry Monitoring",
                Message          = "Preparing to launch manifest registry monitoring...",
                Collapsed        = false
            }, currentUser);
            var resultNotification = new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericSuccess,
                Subject          = "Manifest Registry Monitoring",
                Collapsed        = true
            };
            ManifestRegistryMonitorResult result;

            try
            {
                result = await _manifestRegistryMonitor.StartMonitoringManifestRegistrySubmissions();

                resultNotification.Message = result.IsNewPlan
                    ? $"New plan with Id {result.PlanId} was created and started to monitor manifest registry"
                    : $"An existing plan with Id {result.PlanId} was used to monitor manifest registry";
            }
            catch (Exception ex)
            {
                resultNotification.NotificationType = NotificationType.GenericFailure;
                resultNotification.Message          = $"Failed to manually start manifest registry monitoring. Reason - {ex.Message}. See incidents and error logs for more details";
                Logger.GetLogger().Error("Failed to manually start manifest registry monitoring", ex);
                throw;
            }
            finally
            {
                _pusher.NotifyUser(resultNotification, currentUser);
            }
            return(Ok());
        }
示例#4
0
 private void NotifyUser(IUnitOfWork uow, string user)
 {
     if (user != null)
     {
         _pusherNotifier.NotifyUser(new NotificationMessageDTO
         {
             NotificationType = NotificationType.GenericFailure,
             Subject          = "Plan Failed",
             Message          = "You are running more Activities than your capacity right now. " +
                                $"This Account will be prevented from processing Activities for the next {Math.Ceiling(_userBanTime.TotalSeconds / 60.0f)} minutes. " +
                                "Contact [email protected] for assistance",
             Collapsed = false
         }, user);
     }
 }
示例#5
0
        public IHttpActionResult Post(NotificationMessageDTO notificationMessage)
        {
            string userId;

            if (IsThisTerminalCall())
            {
                var user = GetUserTerminalOperatesOn();
                userId = user?.Id;
            }
            else
            {
                userId = _security.GetCurrentUser();
            }

            // These notifications are evaulated as terminal event without exception
            notificationMessage.NotificationType = NotificationType.TerminalEvent;
            _pusherNotifier.NotifyUser(notificationMessage, userId);
            return(Ok());
        }
示例#6
0
        public async Task Deactivate(Guid planId)
        {
            var deactivateTasks = new List <Task>();

            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var plan = uow.PlanRepository.GetById <PlanDO>(planId);
                if (plan == null)
                {
                    throw new MissingObjectException($"Plan with Id {planId} doesn't exist");
                }
                plan.PlanState = PlanState.Inactive;
                uow.SaveChanges();

                foreach (var activity in plan.GetDescendants().OfType <ActivityDO>())
                {
                    deactivateTasks.Add(_activity.Deactivate(activity));
                }

                _pusherNotifier.NotifyUser(new NotificationMessageDTO
                {
                    NotificationType = NotificationType.ExecutionStopped,
                    Subject          = "Plan Stopped",
                    Message          = $"\"{plan.Name}\" has been stopped.",
                    Collapsed        = false
                }, plan.Fr8AccountId);
            }

            try
            {
                await Task.WhenAll(deactivateTasks);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to deactivate plan", ex);
            }

            EventManager.PlanDeactivated(planId);
        }