public Task <CommunicationResponse> Handle(SendNotificationRequest Request, CancellationToken cancellationToken)
 {
     try
     {
         var Notification = new NotificationQueue()
         {
             Message     = Request.Message,
             Subject     = Request.Subject,
             DeviceID    = Request.DeviceID,
             Status      = 0,
             CreatedBy   = 1,
             CreatedDate = DateTime.UtcNow
         };
         _MessageRepository.Add(Notification);
         return(Task.FromResult(new CommunicationResponse {
             ErrorCode = 101, ReturnMsg = "Message sent."
         }));
     }
     catch (Exception ex)
     {
         return(Task.FromResult(new CommunicationResponse {
             ErrorCode = 99, ReturnMsg = "Message not sent."
         }));
     }
 }
Ejemplo n.º 2
0
        public void NotificationQueue_Default_Constructor()
        {
            // Arrange
            // Act
            var queue = new NotificationQueue();

            // Assert
            queue.Id.Should().Be(0);
            queue.Key.Should().BeEmpty();
            queue.Status.Should().Be(NotificationStatus.Pending);
            queue.Priority.Should().Be(NotificationPriorities.Normal);
            queue.Encoding.Should().Be(NotificationEncodings.Utf8);
            queue.SendOn.Should().Be(new DateTime());
            queue.Subject.Should().BeNull();
            queue.BodyType.Should().Be(NotificationBodyTypes.Html);
            queue.Body.Should().BeNull();
            queue.Bcc.Should().BeNull();
            queue.Cc.Should().BeNull();
            queue.Tag.Should().BeNull();
            queue.ProjectId.Should().BeNull();
            queue.Project.Should().BeNull();
            queue.ToAgencyId.Should().BeNull();
            queue.ToAgency.Should().BeNull();
            queue.TemplateId.Should().BeNull();
            queue.Template.Should().BeNull();
            queue.ChesMessageId.Should().BeNull();
            queue.ChesTransactionId.Should().BeNull();
            queue.Responses.Should().BeEmpty();
        }
Ejemplo n.º 3
0
        public void NotificationQueue_Constructor_01()
        {
            // Arrange
            var date     = DateTime.UtcNow;
            var template = new NotificationTemplate("template", "subject", "body")
            {
                BodyType = NotificationBodyTypes.Text,
                Priority = NotificationPriorities.Low,
                Encoding = NotificationEncodings.Base64,
                Tag      = "tag"
            };
            var project = EntityHelper.CreateProject(1, 1);

            // Act
            var queue = new NotificationQueue(template, project, "to", "subject", "body");

            // Assert
            queue.Id.Should().Be(0);
            queue.Key.Should().NotBeEmpty();
            queue.TemplateId.Should().Be(template.Id);
            queue.Template.Should().Be(template);
            queue.Subject.Should().Be("subject");
            queue.Body.Should().Be("body");
            queue.BodyType.Should().Be(template.BodyType);
            queue.Priority.Should().Be(template.Priority);
            queue.Encoding.Should().Be(template.Encoding);
            queue.Tag.Should().Be(template.Tag);
            queue.ProjectId.Should().Be(project.Id);
            queue.Project.Should().Be(project);
            queue.To.Should().Be("to");
            queue.SendOn.Should().BeOnOrAfter(date);
        }
Ejemplo n.º 4
0
 public void AddNotificationQueue(NotificationContainer noti)
 {
     lock (NotificationQueue)
     {
         NotificationQueue.Add(noti);
     }
 }
Ejemplo n.º 5
0
 public void ClearNotificationQueue()
 {
     lock (NotificationQueue)
     {
         NotificationQueue.Clear();
     }
 }
Ejemplo n.º 6
0
    private void DelayedNotifications()
    {
        remainingSeconds = ConvertMinutesToSeconds(minutes, seconds);

        float timeToLastMinute = remainingSeconds - 60;

        Game.DelayedEvents.AddDelayedAction(delegate
        {
            NotificationQueue.PushNotification("Il reste une minute.");
        }, timeToLastMinute);


        float timeToLastFiveMinutes = remainingSeconds - 300;

        if (timeToLastFiveMinutes > 0)
        {
            Game.DelayedEvents.AddDelayedAction(delegate
            {
                NotificationQueue.PushNotification("Il reste 5 minutes.");
            }, timeToLastFiveMinutes);
        }


        float timetoLastTenMinutes = remainingSeconds - 600;

        if (timetoLastTenMinutes > 0)
        {
            Game.DelayedEvents.AddDelayedAction(delegate
            {
                NotificationQueue.PushNotification("Il reste 10 minutes.");
            }, timetoLastTenMinutes);
        }
    }
Ejemplo n.º 7
0
            public void ProcessChoiceResults()
            {
                DisplayCurrentNodeCharacterPortrait();
                DisableMe();
                dialogueUI.DestroyInteractiveChoices();
                dialogueUI.InsertSpacer();

                if (dialogueUI.GetChoiceResultsCount(myID) > 0)
                {
                    dialogueUI.ActivateQuests(myID);
                    dialogueUI.ActivateQuestTasks(myID);
                    //dialogueUI.ActivateNewGrammar(myID);
                    dialogueUI.ActivateNewWelsh(myID);
                    dialogueUI.MarkDialogueComplete(myID);
                    dialogueUI.ActivateNewDialogue(myID);

                    notificationQueue = FindObjectOfType <NotificationQueue>();
                    notificationQueue.DisplayQueuedNotifications();
                }

                if (isVocabTest)
                {
                    dialogueUI.CurrentPlayerChoice = this;
                    dialogueUI.ProcessPlayerChoiceTest(vocabArray, testData);
                }
                else if (myNextNode != "")
                {
                    dialogueUI.DisplayDialogueNode(GetDialogueNodeData(myNextNode));
                }
                else
                {
                    dialogueUI.SetNotInUse();
                }
            }
Ejemplo n.º 8
0
 public ComparisonTracker(IMailSelector selection)
 {
     _selection = selection;
     _workTodo = new NotificationQueue<ComparisonInformation>();
     _workTodo.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_workTodo_CollectionChanged);
     Logger.LogInfo(string.Format(CultureInfo.CurrentCulture, "EMAILTRACKING: Initialised Comparison Tracker - Working Threads Available = {0}", 1));
 }
 /// <summary>
 ///  Add to the notifications queue to process later with back ground process.
 /// </summary>
 /// <param name="notification"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public async Task Handle(RegisteredPatientEvent notification, CancellationToken cancellationToken)
 {
     var notificationToAdd = new NotificationQueue(notification.CreatedOn, notification.GetType().FullName, JsonConvert.SerializeObject(notification));
     // await _notificationQueueRepository.InsertAsync(notificationToAdd);
     // dummy for now
     await Task.CompletedTask;
 }
Ejemplo n.º 10
0
 public async Task AddNotification(string body, EmailConf emailGeneral, string subject, string attachment = null)
 {
     try
     {
         var notification = new NotificationQueue
         {
             Subject          = subject,
             Body             = body,
             Attachment       = attachment,
             To               = emailGeneral.Email,
             ToName           = emailGeneral.FullName,
             From             = _settings.Value.From,
             FromName         = _settings.Value.FromName,
             ReplyTo          = _settings.Value.ReplyTo,
             ReplyToName      = _settings.Value.ReplyToName,
             Priority         = emailGeneral.Priority,
             CreatedTimestamp = DateTime.Now,
             FailCount        = 0
         };
         _notificationDbContext.NotificationQueues.Add(notification);
         await _notificationDbContext.SaveChangesAsync();
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
     }
 }
        private void CheckForNewNotifications(object sender, EventArgs e)
        {
            var world     = WarframeInfoProvider.GetWorldState();
            var newAlerts = WarframeInfoProvider.GetAlerts(world);

            var tmpAlerts = new ObservableCollection <Alert>();

            foreach (Alert alert in newAlerts)
            {
                if (!(Alerts.Any(x => x._id.oid == alert._id.oid)) && alert != null)
                {
                    NotificationQueue.Add(alert);
                }
                alert.ToNotificationString();
                tmpAlerts.Add(alert);
            }
            Alerts = tmpAlerts;

            WarframeInfoProvider.GetInvasions(world);

            var newInvasions = WarframeInfoProvider.GetInvasions(world);

            var tmpInvasions = new ObservableCollection <Invasion>();

            foreach (Invasion invasion in newInvasions)
            {
                if (!(Invasions.Any(x => x._id.oid == invasion._id.oid)) && invasion != null)
                {
                    NotificationQueue.Add(invasion);
                }
                invasion.ToNotificationString();
                tmpInvasions.Add(invasion);
            }
            Invasions = tmpInvasions;
        }
Ejemplo n.º 12
0
        void Update()
        {
            rectTransform.position = Camera.main.WorldToScreenPoint(Node.Position);
            TimeRemaining         -= Time.deltaTime;
            if (TimeRemaining < 0)
            {
                clientManager.RemoveFromOrderList(gameObject);
                Node.Order = null;
                NotificationQueue.PushNotification("Vous avez manquer une livraison !");
                Destroy(gameObject);
            }
            else if (TimeRemaining <= clientManager.TimeRemainingWarning)
            {
                objectiveWarningObject.GetComponent <Image>().enabled = true;
                countdownObject.GetComponent <Text>().color           = Color.white;
            }

            if (Node.pizza.Count > 0)
            {
                Node.pizza[0].Destroy();
                PizzaAmount--;
            }

            countdownObject.GetComponent <Text>().text  = Convert.ToString((int)TimeRemaining);
            pizzaCountObject.GetComponent <Text>().text = Convert.ToString(PizzaAmount);
        }
Ejemplo n.º 13
0
        /* publish function publishes a Notification Event */
        public void Publish()
        {
            int i = 0;

            while (true)
            {
                /* Generate the test / publish message as per interval config */
                Thread.Sleep(NotificationInterval);
                if (OnPublish != null)
                {
                    MessageEvent notificationObj = new MessageEvent(DateTime.Now, "New message arrived from");
                    Random       random          = new Random();
                    var          msg             = new NotificationQueue {
                        Id = random.Next(), ChannelMessage = ((MessageSubscriber)OnPublish.Target).SubscriberName + " " + ((MessageSubscriber)OnPublish.Target).SubscriberCategory + " " + this.PublisherName + " at " + DateTime.Now.ToString()
                    }; allNotification.Add(msg);
                    allNotification.Add(msg);
                    OnPublish(this, notificationObj);
                }
                Thread.Yield();
                i++;
                if (i == 10) /* for test set count and return */
                {
                    break;
                }
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Notifies the specified data.
 /// </summary>
 /// <param name="data">The data.</param>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 public virtual async Task NotifyAsync(T data)
 {
     if (Subscribed)
     {
         OnNotify?.Invoke(data);
         await NotificationQueue.AddAsync(data);
     }
 }
 /// <summary>
 /// SendEmailCommand
 /// </summary>
 /// <param name="emailAddress"></param>
 /// <param name="subject"></param>
 /// <param name="message"></param>
 public SendEmailCommand(NotificationQueue notificationQueue, string emailAddress, string subject, string message, AppointmentNotification appointmentNotification = null)
 {
     Notification            = notificationQueue;
     EmailAddress            = emailAddress;
     Subject                 = subject;
     Message                 = message;
     AppointmentNotification = appointmentNotification;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Notifies the specified data.
 /// </summary>
 /// <param name="data">The data.</param>
 public virtual void Notify(T data)
 {
     if (Subscribed)
     {
         OnNotify?.Invoke(data);
         NotificationQueue.Add(data);
     }
 }
Ejemplo n.º 17
0
        public void AddIdentityToNotifiticationQueue(long identityId)
        {
            var cooldownKey = new EntityIdCooldownKey(identityId);
            var delay       = Config.NotifyDelaySeconds * 1000L;

            CooldownManagerNotificationQueue.StartCooldown(cooldownKey, NOTIFICATION_COOLDOWN_COMMAND, delay);

            NotificationQueue.Add(cooldownKey);
        }
Ejemplo n.º 18
0
 public void UnlockNotificationStatus()
 {
     status = NotificationStatus.Unlocked;
     if (isNotificationsQueued)
     {
         for (int i = 0; i < notificationQueue.Count; i++)
         {
             NotificationQueue nq = notificationQueue.Dequeue();
             NotifyAllControllers(nq.Notification, nq.param);
         }
     }
 }
Ejemplo n.º 19
0
    public void Lose()
    {
        if (gameEnded)
        {
            return;
        }
        gameEnded = true;

        NotificationQueue.PushNotification(new Notification()
        {
            text = "You lost", onHide = ReturnToLevelSelect
        });
    }
Ejemplo n.º 20
0
        /// <summary>
        /// Instantiate a new <see cref="SubscriptionProcessor"/> class.
        /// </summary>
        /// <param name="servers">Discord servers dictionary</param>
        /// <param name="config">Configuration file</param>
        /// <param name="whm">Webhook controller class</param>
        public SubscriptionProcessor(Dictionary <ulong, DiscordClient> servers, WhConfig config, WebhookController whm)
        {
            _logger.Trace($"SubscriptionProcessor::SubscriptionProcessor");

            _servers  = servers;
            _whConfig = config;
            _whm      = whm;
            _queue    = new NotificationQueue();

            Manager = new SubscriptionManager(_whConfig);

            ProcessQueue();
        }
Ejemplo n.º 21
0
        public VSTalkCore(IWindowsManager windowsManager, IEnvironmentManager environmentManager, IModelContext modelContext)
        {
            WindowsManager     = windowsManager;
            EnvironmentManager = environmentManager;
            ModelContext       = modelContext;

            NotificationQueue = new NotificationQueue();

            Connector          = new ClientConnector(this);
            ControlsRepository = new ControlRepository(this);

            LoadConnections();
        }
Ejemplo n.º 22
0
        public MainViewModel()
        {
            MessengerInstance.Register <ChangeViewMessage>(this, ReceiveChangeViewMessage);

            SetInitialViewCommand      = new RelayCommand(ExecuteSetInitialViewCommand);
            OnPreviewMouseLeftButtonUp = new RelayCommand(ExecuteOnPreviewMouseLeftButtonUp);

            ViewTabs.Add(CreateItem(ViewManager.AdminTitle, ViewManager.AdminId, "Lock"));
            ViewTabs.Add(CreateItem(ViewManager.HomeTitle, ViewManager.HomeId, "Home"));
            ViewTabs.Add(CreateItem(ViewManager.LiveChartTitle, ViewManager.LiveChartId, "film"));

            NotificationQueue.Enqueue("Welcome to Material Desgin !!");
        }
Ejemplo n.º 23
0
        public SubscriptionProcessor(DiscordClient client, WhConfig config, WebhookManager whm)//, EmbedBuilder embedBuilder)
        {
            _logger.Trace($"SubscriptionProcessor::SubscriptionProcessor");

            _client   = client;
            _whConfig = config;
            _whm      = whm;
            //_embedBuilder = embedBuilder;
            _queue = new NotificationQueue();

            Manager = new SubscriptionManager(_whConfig);

            ProcessQueue();
        }
Ejemplo n.º 24
0
        public void AddEMailLog(MailMessage mail, NotificationQueue queue)
        {
            var log = new EmailLog();

            log.From         = mail.From.Address;
            log.To           = string.Join(';', mail.To.Select(t => t.Address).ToArray());
            log.CC           = string.Join(';', mail.CC.Select(t => t.Address).ToArray());
            log.BCC          = string.Join(';', mail.Bcc.Select(t => t.Address).ToArray());
            log.MessageBody  = mail.Body;
            log.SentDateTime = DateTime.Now;
            log.Subject      = mail.Subject;
            log.Description  = queue.Description;
            log.MessageId    = queue.MessageId;
            Add(log);
        }
Ejemplo n.º 25
0
    void CommandCompleted(Node node)
    {
        NotificationQueue.PushNotification("Vous avez complété une commande !");

        Objectives currentObjectives = Game.Map.cash;
        int        income            = currentObjectives.OrderBaseReward + (currentObjectives.RewardPerPizza * node.pizza.Count);

        currentObjectives.IncomeCash(income);


        for (int i = 0; i < node.pizza.Count; i++)
        {
            Destroy(node.pizza[i].gameObject);
        }
    }
Ejemplo n.º 26
0
        public async Task <long> CreateAsync(Supply supply)
        {
            if (supply == null)
            {
                throw new ArgumentNullException(nameof(supply));
            }
            this.unitOfWork.Supplies.Add(supply);

            var notification = new NotificationQueue(supply, Enums.OperationType.Create);

            this.unitOfWork.NotificationQueues.Add(notification);

            await this.unitOfWork.CommitAsync();

            return(supply.Id);
        }
        public async Task <CommunicationResponse> Handle(SendNotificationRequest Request, CancellationToken cancellationToken)
        {
            try
            {
                var Notification = new NotificationQueue()
                {
                    Message      = Request.Message,
                    Subject      = Request.Subject,
                    DeviceID     = Request.DeviceID,
                    TickerText   = Request.TickerText,
                    ContentTitle = Request.ContentTitle,
                    Status       = 0,
                    CreatedBy    = 1,
                    CreatedDate  = DateTime.UtcNow
                };
                _MessageRepository.Add(Notification);
                Notification.InQueueMessage();
                _MessageRepository.Update(Notification);
                IQueryable Result = await _MessageConfiguration.GetAPIConfigurationAsync(1, 2);

                foreach (CommunicationProviderList Provider in Result)
                {
                    string Response = await _MessageService.SendNotificationAsync(Notification.DeviceID, Notification.TickerText, Notification.ContentTitle, Notification.Message, Provider.SendURL, Provider.RequestFormat, Provider.SenderID, Provider.MethodType, Provider.ContentType);

                    CopyClass.CopyObject(Provider, ref _GetDataForParsingAPI);
                    _GenerateResponse = _WebApiParseResponse.ParseResponseViaRegex(Response, _GetDataForParsingAPI);
                    if (_GenerateResponse.Status == enTransactionStatus.Success)
                    {
                        Notification.SentMessage();
                        _MessageRepository.Update(Notification);
                        return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.NotificationSuccessMessage }));
                    }
                    else
                    {
                        continue;
                    }
                }
                Notification.FailMessage();
                _MessageRepository.Update(Notification);
                return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.NotificationFailMessage }));
            }
            catch (Exception ex)
            {
                return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.InternalError, ReturnMsg = EnResponseMessage.NotificationExceptionMessage }));
            }
        }
Ejemplo n.º 28
0
        public Task <SendNotificationResponse> Handle(SendNotificationRequest Request, CancellationToken cancellationToken)
        {
            var Notification = new NotificationQueue()
            {
                MobileNo    = Request.MobileNo,
                Message     = Request.Message,
                DeviceID    = Request.DeviceID,
                Status      = 0,
                CreatedBy   = 1,
                CreatedDate = DateTime.UtcNow
            };

            _MessageRepository.Add(Notification);
            return(Task.FromResult(new SendNotificationResponse {
                ResponseCode = 101, ResponseMessage = "Message sent."
            }));
        }
 private int UpdateQueueStatus(NotificationQueue queue, NotificationSentStatus status, String description = "")
 {
     queue.Status = status;
     if (status == NotificationSentStatus.Failed)
     {
         queue.RetryCount += 1;
     }
     queue.Description = description;
     if (status == NotificationSentStatus.Sent)
     {
         _context.NotificationQueue.Remove(queue);
     }
     else
     {
         _context.NotificationQueue.Update(queue);
     }
     return(_context.SaveChangesAsync().Result);
 }
        private Tuple <NotificationSentStatus, string> SendNotification(NotificationQueue notificationQueue)
        {
            var feature = _context.Notification
                          .Include(r => r.SMTP)
                          .Where(r => r.IsActive).ToList();
            var description = "";
            int completed   = 0;

            foreach (var item in feature)
            {
                try
                {
                    var selectedHandler = _notificationHandlers(item.NotificationType);
                    if (!item.IsActive)
                    {
                        description += $"Feature disabled :{item.NotificationId.ToString()}; ";
                        continue;
                    }
                    var template = _templateGenerator.GetTemplateHandler(new TemplateGenerateView
                    {
                        NotificationQueue = notificationQueue,
                        MessageId         = notificationQueue.MessageId,
                        NotificationType  = item.NotificationType,
                    });
                    selectedHandler.Send(template, item);
                    completed++;
                }
                catch (Exception ex)
                {
                    description = ex.ToString();
                    Log.Error(ex, "Notifier.SendNotification");
                }
            }

            if (completed == 0)
            {
                return(Tuple.Create(NotificationSentStatus.Failed, description));
            }
            //if (completed == feature.)
            //    return Tuple.Create(Models.NotificationSentStatus.Sent, description);
            return(Tuple.Create(NotificationSentStatus.Partial, description));
        }
Ejemplo n.º 31
0
        public void Notify(Notification notification, NotificationParam param = null)
        {
            switch (status)
            {
            case NotificationStatus.Locked:
                if (param != null)
                {
                    if (param.shouldQueue)
                    {
                        NotificationQueue nq = new NotificationQueue(notification, param);
                        notificationQueue.Enqueue(nq);
                    }
                }
                break;

            case NotificationStatus.Unlocked:
                NotifyAllControllers(notification, param);
                break;
            }
        }