Example #1
0
        protected void Notify(string message, string icon, int time, bool requireClose, NotifyActionItem[] actions)
        {
            var index = Enumerable.Range(0, 10).First(i => Items.All(n => n.Index != i));

            if (time == 0)
            {
                requireClose = true;
            }
            time += 800;
            var notificationItem = new NotificationItem()
            {
                AnimatedX    = 0,
                Icon         = StyleProvider.GetImage(icon),
                Message      = message,
                TimeLeft     = time,
                Time         = time,
                Index        = index,
                RequireClose = requireClose,
                Actions      = actions
            };

            EditorApplication.delayCall +=
                () => {
                Items.Add(notificationItem);
            };

            Signal <IDebugWindowEvents>(_ => _.RegisterInspectedItem(notificationItem, notificationItem.Message, true));
            //Add notification item to the queue
        }
Example #2
0
        private async Task OnNotificationQueueReceived(NotificationItem ni)
        {
            _logger.LogInformation($"{Name}: Notification Queue Received with a type of {ni.Type} and id of {ni.ItemId}, starting processing...");
            await NotificationBroadcastLogic.ProcessNotificationItem(ni, Guid.NewGuid().ToString(), "");

            _logger.LogInformation($"{Name}: Finished processing of Notification with type of {ni.Type} and id of {ni.ItemId}.");
        }
        protected void Notify(string message, string icon, int time, bool requireClose, NotifyActionItem[] actions)
        {
            var index = Enumerable.Range(0, 10).First(i => Items.All(n => n.Index != i));
            if (time == 0) requireClose = true;
            time += 800;
            var notificationItem = new NotificationItem()
            {
                AnimatedX = 0,
                Icon = StyleProvider.GetImage(icon),
                Message = message,
                TimeLeft = time,
                Time = time,
                Index = index,
                RequireClose = requireClose,
                Actions = actions
            };

            EditorApplication.delayCall +=
                () => {
                          Items.Add(notificationItem);
                };

            Signal<IDebugWindowEvents>(_ => _.RegisterInspectedItem(notificationItem, notificationItem.Message, true));
            //Add notification item to the queue
        }
Example #4
0
        public async Task <ActionResult <NotificationItem> > PostNotificationItem(NotificationItem notificationItem)
        {
            _context.NotificationItems.Add(notificationItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNotificationItem", new { id = notificationItem.NotificationItemId }, notificationItem));
        }
Example #5
0
    /*
     *
     *
     * //Success
     * {
     * "status": "1",
     * "result": {
     *  "notilists": [
     *      {
     *          "read_unread": 0,
     *          "_id": "5d847e080b7e9099351ed570",
     *          "sent_by_user": "******",
     *          "received_by_user": "******",
     *          "message": "asd sent you a friend request",
     *          "created_at": "2019-01-08T10:43:39.726Z",
     *          "updated_at": "2019-01-08T10:43:39.727Z"
     *      },
     *      {
     *          "read_unread": 0,
     *          "_id": "5d847e450b7e9099351ed57b",
     *          "sent_by_user": "******",
     *          "received_by_user": "******",
     *          "message": "asd sent you a friend request",
     *          "created_at": "2019-01-08T10:43:39.726Z",
     *          "updated_at": "2019-01-08T10:43:39.727Z"
     *      }
     *  ]
     * },
     * "message": "All notification lists fetched."
     * }
     *
     *
     *
     *
     *
     */
    public void GetNotifications()
    {
        Web.Create()
        .SetUrl("http://52.66.82.72:2095/notificationLists", Web.RequestType.POST, Web.ResponseType.TEXT)
        .AddHeader("access_token", Database.GetString(Database.Key.ACCESS_TOKEN))
        .AddHeader("Content-Type", "application/x-www-form-urlencoded")
        .SetOnSuccessDelegate((Web _web, Response _response) =>
        {
            JSONNode node          = JSONNode.Parse(_response.GetText());
            notificationCount.text = "" + node["result"]["notilists"].Count;

            for (int i = 0; i < node["result"]["notilists"].Count; i++)
            {
                NotificationItem newItem = Instantiate(notificationItem);
                newItem.transform.SetParent(notificationParent);
                newItem.transform.localScale = Vector3.one;
                newItem.Set(node["result"]["notilists"][i]["message"].Value);
            }
            Debug.Log(_response.GetText());
            _web.Close();
        })
        .SetOnFailureDelegate((Web _web, Response _response) =>
        {
            Debug.Log(_response.GetText());
            _web.Close();
        })
        .Connect();
    }
Example #6
0
        public async Task <IActionResult> PutNotificationItem(int id, NotificationItem notificationItem)
        {
            if (id != notificationItem.NotificationItemId)
            {
                return(BadRequest());
            }

            _context.Entry(notificationItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NotificationItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public bool Validate()
        {
            bool isValid = false;

            if (ValidationContract == null || ValidationContract.Contract == null)
            {
                isValid = false;
            }
            else if (ValidationContract.Contract.Valid)
            {
                isValid = true;
            }
            else if (!ValidationContract.Contract.Valid)
            {
                var listNotification = new List <INotificationItem>();
                var notification     = new Notification(listNotification);

                foreach (var item in ValidationContract.Contract.Notifications)
                {
                    var newNotification = new NotificationItem()
                    {
                        Message     = item.Message,
                        Description = item.Property
                    };

                    notification.Notifications.Add(newNotification);
                }

                Notification = notification;
            }

            return(isValid);
        }
Example #8
0
        public DepartmentGroup GetGroupForEvent(ProcessedNotification notification)
        {
            //NotificationItem dynamicData = (NotificationItem)JsonConvert.DeserializeObject(data);
            NotificationItem dynamicData = ObjectSerialization.Deserialize <NotificationItem>(notification.Data);

            if (notification.Type == EventTypes.UnitStatusChanged)
            {
                var unitEvent = _unitsService.GetUnitStateById(dynamicData.StateId);
                return(_departmentGroupsService.GetGroupById(unitEvent.Unit.StationGroupId.GetValueOrDefault()));
            }
            else if (notification.Type == EventTypes.PersonnelStatusChanged)
            {
                var userStaffing = _userStateService.GetUserStateById(dynamicData.StateId);
                var group        = _departmentGroupsService.GetGroupForUser(userStaffing.UserId, notification.DepartmentId);
                return(group);
            }
            else if (notification.Type == EventTypes.PersonnelStatusChanged)
            {
                var actionLog = _actionLogsService.GetActionlogById(dynamicData.StateId);
                var group     = _departmentGroupsService.GetGroupForUser(actionLog.UserId, notification.DepartmentId);
                return(group);
            }
            else if (notification.Type == EventTypes.UserAssignedToGroup)
            {
                return(_departmentGroupsService.GetGroupById(dynamicData.GroupId));
            }

            return(null);
        }
Example #9
0
        public async Task <string> notificationDidOpen([FromBody] NotificationItem item)
        {
            Console.WriteLine("NotificationDidOpen: " + item.ToString());
            var result = await produce("NotificationDidOpen", item.ToString());

            return(result);
        }
Example #10
0
        public NotificationsResponse CreateNotificationsResponse(List <CampaignEN> pNotifications)
        {
            NotificationsResponse response = new NotificationsResponse();
            NotificationMessages  messages = new NotificationMessages();

            messages.userNotifications = new List <NotificationItem>();

            try
            {
                foreach (var item in pNotifications)
                {
                    NotificationItem notif = new NotificationItem();
                    notif.trackingID     = item.NotificationID;
                    notif.notificationID = item.CampaignID;
                    notif.title          = item.NotificationTitle;
                    notif.message        = item.NotificationMessage;
                    notif.seen           = item.Read;

                    messages.userNotifications.Add(notif);
                }

                response.notifications = messages;
                response.count         = messages.userNotifications.Count;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
            }

            return(response);
        }
Example #11
0
 /// <summary>
 /// Register a notification item.
 /// </summary>
 /// <param name="key">key for the item to regster.</param>
 /// <param name="notification">notification item.</param>
 internal void RegisterNotification(string key, NotificationItem notification)
 {
     model.RegisterNotification(key, notification);
     if (model.HasNotifications)
     {
         Show();
     }
 }
 public void Post(NotificationItem item, [FromServices] NotificationService notificationService)
 {
     if (!IsConnected())
     {
         hubConnection = notificationService.Connection;
     }
     hubConnection.SendAsync("SendMessage", item.User, item.Message);
 }
        public void EnqueueNotification(NotificationItem notificationQueue)
        {
            string serializedObject = String.Empty;

            serializedObject = ObjectSerialization.Serialize(notificationQueue);

            SendMessage(ServiceBusConfig.NotificaitonBroadcastQueueName, serializedObject);
        }
 public void Send(NotificationItem notificationItem)
 {
     Console.WriteLine("Sms Notification");
     Console.WriteLine($"\t\tId: {notificationItem.Id}");
     Console.WriteLine($"\t\tTitle: {notificationItem.Title}");
     Console.WriteLine($"\t\tSent Date: {notificationItem.SentDate}");
     Console.WriteLine($"\t\tContent: {notificationItem.Content}");
     Console.WriteLine(" ");
 }
Example #15
0
        public static void Show(string Title, string Content)
        {
            NotificationItem notification = new NotificationItem();

            notification.Title   = Title;
            notification.Content = Content;

            notificationManager.Show(notification);
        }
        public async Task <Tuple <bool, string> > ProcessQueueMessage(Message message, CancellationToken token)
        {
            bool   success = true;
            string result  = "";

            if (message != null)
            {
                try
                {
                    var body = message.GetBody <string>();

                    if (!String.IsNullOrWhiteSpace(body))
                    {
                        NotificationItem ni = null;
                        try
                        {
                            ni = ObjectSerialization.Deserialize <NotificationItem>(body);
                        }
                        catch (Exception ex)
                        {
                            success = false;
                            result  = "Unable to parse message body Exception: " + ex.ToString();
                            //message.DeadLetter();
                            await _client.DeadLetterAsync(message.SystemProperties.LockToken);
                        }

                        await ProcessNotificationItem(ni, message.MessageId, body);
                    }
                    else
                    {
                        success = false;
                        result  = "Message body is null or empty";
                    }

                    try
                    {
                        //message.Complete();
                        await _client.CompleteAsync(message.SystemProperties.LockToken);
                    }
                    catch (MessageLockLostException)
                    {
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    result  = ex.ToString();

                    Logging.LogException(ex);
                    //message.Abandon();
                    await _client.AbandonAsync(message.SystemProperties.LockToken);
                }
            }

            return(new Tuple <bool, string>(success, result));
        }
        public NotificationDetailPage(NotificationItem notification)
        {
            InitializeComponent();

            this.ViewModel = new NotificationDetailPageViewModel(notification)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;
        }
Example #18
0
        public async Task <int> InsertTodo(NotificationItem contact)
        {
            await SyncAsync(true);

            await azureSyncTableTodo.InsertAsync(contact);

            await SyncAsync();

            return(1);
        }
Example #19
0
        public Task <NotificationItem> AddNotification(string content)
        {
            var item = new NotificationItem
            {
                DateTime = DateTime.UtcNow,
                Content  = content
            };

            FakeContent.Add(item);
            return(Task.FromResult(item));
        }
 public void Process(NotificationItem item)
 {
     if (Config.SystemBehaviorConfig.IsAzure)
     {
         ProcessQueueMessage(_client.Receive());
     }
     else
     {
         ProcessNotificationItem(item, Guid.NewGuid().ToString(), "");
     }
 }
Example #21
0
            public void Handle(UnitAddedEvent message)
            {
                var nqi = new NotificationItem();

                nqi.Type         = (int)EventTypes.UnitAdded;
                nqi.DepartmentId = message.DepartmentId;
                nqi.UnitId       = message.Unit.UnitId;
                nqi.Value        = message.Unit.UnitId.ToString();

                _outboundQueueProvider.EnqueueNotification(nqi);
            }
Example #22
0
            public void Handle(CalendarEventUpdatedEvent message)
            {
                var nqi = new NotificationItem();

                nqi.Type         = (int)EventTypes.CalendarEventUpdated;
                nqi.DepartmentId = message.DepartmentId;
                nqi.ItemId       = message.Item.CalendarItemId;
                nqi.Value        = message.Item.CalendarItemId.ToString();

                _outboundQueueProvider.EnqueueNotification(nqi);
            }
Example #23
0
            public void Handle(ResourceOrderAddedEvent message)
            {
                var nqi = new NotificationItem();

                nqi.Type         = (int)EventTypes.ResourceOrderAdded;
                nqi.DepartmentId = message.Order.DepartmentId;
                nqi.ItemId       = message.Order.ResourceOrderId;
                nqi.Value        = message.Order.ResourceOrderId.ToString();

                _outboundQueueProvider.EnqueueNotification(nqi);
            }
Example #24
0
 public Task <int> SaveNotificationItemAsync(NotificationItem item)
 {
     if (item.Id != -1)
     {
         return(_database.UpdateAsync(item));
     }
     else
     {
         return(_database.InsertAsync(item));
     }
 }
Example #25
0
        public static void Notify(string message, string title = "UIC Add-in") => ThreadService.RunOnUiThread(() => {
            Log.Verbose("Showing notification: {id} {message}", id, message);

            var notification = new NotificationItem($"{id++}", false, $"{title} {message}", NotificationType.Information);

            NotificationManager.AddNotification(notification);
            FrameworkApplication.AddNotification(new Notification {
                Message  = message,
                ImageUrl = "",
                Title    = title
            });
        });
        private async void SelectItem(NotificationItem notif)
        {
            if (this.IsBusy)
            {
                return;
            }
            this.IsBusy = true;

            await this.NavigationService.NavigateTo(typeof(NotificationDetailPage), new object[] { notif });

            this.IsBusy = false;
        }
Example #27
0
 public static Notification Create(NotificationItem item)
 {
     return(new Notification
     {
         Id = item.Id,
         Acknowledged = item.Acknowledged,
         CreatedAt = item.CreatedAt.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"),
         Key = item.Key,
         Level = GetLevel(item.NotificationType),
         Parameters = item.Parameters.ToList(),
     });
 }
        public static Tuple <bool, string> ProcessQueueMessage(BrokeredMessage message)
        {
            bool   success = true;
            string result  = "";

            if (message != null)
            {
                try
                {
                    var body = message.GetBody <string>();

                    if (!String.IsNullOrWhiteSpace(body))
                    {
                        NotificationItem ni = null;
                        try
                        {
                            ni = ObjectSerialization.Deserialize <NotificationItem>(body);
                        }
                        catch (Exception ex)
                        {
                            success = false;
                            result  = "Unable to parse message body Exception: " + ex.ToString();
                            message.DeadLetter();
                        }

                        ProcessNotificationItem(ni, message.MessageId, body);
                    }
                    else
                    {
                        success = false;
                        result  = "Message body is null or empty";
                    }

                    try
                    {
                        message.Complete();
                    }
                    catch (MessageLockLostException)
                    {
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    result  = ex.ToString();

                    Logging.LogException(ex);
                    message.Abandon();
                }
            }

            return(new Tuple <bool, string>(success, result));
        }
Example #29
0
    public void Update()
    {
        if (!DOTween.IsTweening(notification.transform) && notificationQueue.Count > 0)
        {
            NotificationItem item = notificationQueue[0];
            notificationQueue.RemoveAt(0);
            notification.transform.Find("Title").GetComponent <Text>().text  = item.title;
            notification.transform.Find("Text").GetComponent <Text>().text   = item.text;
            notification.transform.Find("Img").GetComponent <Image>().sprite = item.image;

            notification.transform.DOMoveY(Screen.height - 85, 0.5f, false).SetEase(Ease.InOutQuad).OnComplete(PauseCallback);
        }
    }
Example #30
0
        private static string StripEmbed(NotificationItem item)
        {
            const int MAX_TEXT_LENGTH = 120;
            var       text            = item.Embed.Description;

            text = text.Replace("**", null);
            text = text.Length > MAX_TEXT_LENGTH
                ? text.Substring(0, Math.Min(text.Length, MAX_TEXT_LENGTH))
                : text;

            // TODO: Construct text message instead of using embed description and url for google maps link
            return($"{item.City}\n{text}\n{item.Embed.Url}");
        }
        public RespondentViewModel()
        {
            SendResponseCommand = new MvxCommand(() =>
            {
                NotificationItem notify = new NotificationItem()
                {
                    SenderId = selectedName, SenderMessage = "your message goes here", RespondentId = user, MessageType = "response"
                };
                Mvx.Resolve <INotification>().InsertTodo(notify);

                Mvx.Resolve <ILocation>().GetCurrentAddress();
            });
        }
    public static void Notify(string text)
    {
        if (notificationCenter == null)
        {
            return;
        }

        NotificationItem item = new NotificationItem();
        item.notification = new GUIContent(text);
        item.area = notificationCenter.defaultArea;
        item.newPosition = new Vector2(item.area.x, item.area.y);
        item.time = 0;
        item.duration = notificationCenter.notificationDuration;

        Vector2 size = notificationCenter.notificationStyle.CalcSize(item.notification);
        item.area.width = size.x + 20;
        item.area.x -= item.area.width + 5;
        item.area.height = notificationCenter.notificationStyle.normal.background.height;

        notificationCenter.notificationItems.Insert(0, item);
        notificationCenter.ReArrangeItems();
    }
        private void AppendToast(NotificationItem notification)
        {
            //root layout
            var layoutGrid = new Grid();
            var toastItem = new ToastItem(layoutGrid, DateTime.Now, notification);
            layoutGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
            //layoutGrid.Height = 70;
            layoutGrid.Margin = new Thickness(0, 0, 0, 2); //2 - a margin between toasts
            layoutGrid.Background = notification.Brush;
            layoutGrid.Projection = new PlaneProjection();
            layoutGrid.RenderTransformOrigin = new Point(0.5, 0.5);
            layoutGrid.RenderTransform = new CompositeTransform { TranslateX = -800 };
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });


            Button closeButton = null;
            if (notification.ShowCloseButton)
            {
                layoutGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40.0) });
                //close button
                closeButton = new Button();
                SetColumn(closeButton, 1);
                closeButton.Tag = toastItem;
                closeButton.Width = 66;
                closeButton.Height = 90;
                closeButton.Content = "\u2716"; //X symbol
                closeButton.BorderThickness = new Thickness(0);
                closeButton.FontSize = 32;
                closeButton.Padding = new Thickness(0);
                closeButton.Opacity = 0.4;
                closeButton.Margin = new Thickness(-12, -15, -8, -8); //TODO: fix it
                closeButton.HorizontalAlignment = HorizontalAlignment.Right;
                closeButton.Tap += CloseButton_OnTap;
                layoutGrid.Children.Add(closeButton);
            }

            //toast content
            var contentGrid = new Grid();
            contentGrid.Tag = toastItem;
            contentGrid.Children.Add(notification.Content);
            layoutGrid.Children.Add(contentGrid);
            contentGrid.Tap += ContentGrid_OnTap;

            toastItem.FinalizingActions += () => contentGrid.Tap -= ContentGrid_OnTap;

            if (closeButton != null)
            {
                toastItem.FinalizingActions += () => closeButton.Tap -= CloseButton_OnTap;
            }

            //appear animation
            var animation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(0.2)), To = 0 };
            var storyboard = new Storyboard();
            storyboard.Children.Add(animation);
            Storyboard.SetTarget(animation, layoutGrid);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
            storyboard.Begin();

            _activeItemsControl.Items.Add(layoutGrid);
            _toastItems.Add(toastItem);
        }
 public ToastItem(FrameworkElement element, DateTime started, NotificationItem notification)
 {
     Element = element;
     Started = started;
     NotificationItem = notification;
 }
        private void AppendToast(NotificationItem notification)
        {
            //root layout
            var layoutGrid = new Grid();
            var toastItem = new ToastItem(layoutGrid, DateTime.Now, notification);
            layoutGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
            layoutGrid.Height = 65;
            layoutGrid.Margin = new Thickness(0, 0, 0, 4);
            layoutGrid.Background = new SolidColorBrush(notification.Color);
            layoutGrid.Projection = new PlaneProjection();
            layoutGrid.RenderTransformOrigin = new Point(0.5, 0.5);
            layoutGrid.RenderTransform = new CompositeTransform { TranslateX = -800 };
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
            layoutGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(65.0) });

            //close button
            var closeButton = new Button();
            Grid.SetColumn(closeButton, 1);
            closeButton.Tag = toastItem;
            closeButton.Width = 80;
            closeButton.Height = 90;
            closeButton.Content = "\u2716";
            closeButton.BorderThickness = new Thickness(0);
            closeButton.FontSize = 32;
            closeButton.Padding = new Thickness(0);
            closeButton.Opacity = 0.4;
            closeButton.Margin = new Thickness(-6, -12, -10, -8);
            closeButton.FontSize = 32;
            closeButton.HorizontalAlignment = HorizontalAlignment.Right;
            closeButton.Tap += closeButton_OnTap;
            layoutGrid.Children.Add(closeButton);

            //toast content
            var contentGrid = new Grid();
            contentGrid.Tag = toastItem;
            contentGrid.Background = new SolidColorBrush(Color.FromArgb(1, 255, 255, 255));

            contentGrid.Children.Add(notification.Content);
            layoutGrid.Children.Add(contentGrid);
            contentGrid.Tap += contentGrid_OnTap;

            toastItem.FinalizingActions += () => contentGrid.Tap -= contentGrid_OnTap;
            toastItem.FinalizingActions += () => closeButton.Tap -= closeButton_OnTap;

            //appear animation
            var animation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(0.2)), To = 0 };
            var storyboard = new Storyboard();
            storyboard.Children.Add(animation);
            Storyboard.SetTarget(animation, layoutGrid);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
            storyboard.Begin();

            ActiveToastList.Items.Add(layoutGrid);
            _toastItems.Add(toastItem);
        }