コード例 #1
0
        /// <summary>
        /// The ButtonSave_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonSave_Click(object sender, EventArgs args)
        {
            var roles = (from DataRowView view in clbRoles.CheckedItems select(Role) view["OBJECT"]).ToList();

            foreach (var remNotification in CurrentSituation.Notifications)
            {
                CurrentSituation.RemoveNotification(remNotification);
            }

            var newNotification = new NewNotification();

            foreach (var role in roles)
            {
                newNotification.Roles.Add(role);
            }

            var notification = MainForm.CurrentSystem.CreateNotification(newNotification);

            if (notification == null)
            {
                return;
            }

            CurrentSituation.AddNotification(notification);
        }
コード例 #2
0
        private void UpdateQuizzNotification(NewNotification entity)
        {
            var editor = new NewNotificationEditor(entity);

            editor.AddNewFrom(_currentUser.Id);

            _uow.NewNotifications.Update(entity);
        }
コード例 #3
0
        /// <summary>
        /// The ButtonAdd_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonAdd_Click(object sender, EventArgs args)
        {
            var roles = (from DataRowView view in clbRoles.CheckedItems select(Role) view["OBJECT"]).ToList();

            var newNotification = new NewNotification();

            foreach (var role in roles)
            {
                newNotification.Roles.Add(role);
            }

            MainForm.CurrentSystem.CreateNotification(newNotification);
        }
コード例 #4
0
ファイル: NotificationForm.cs プロジェクト: neontsun/Mercury
        /// <summary>
        /// Строит уведомления
        /// </summary>
        public void LoadNotification()
        {
            this.list = (this.Owner as Main).notificationCollection;

            this.Controls.Clear();

            foreach (var item in list)
            {
                var control = NewNotification.CreateNewNotification(this, GetNotificationCount(),
                                                                    GetFontForNotification(), item, GetLocationForNotification());

                this.Controls.Add(control);
            }
            UpdateNotificationCount();
        }
コード例 #5
0
        public void ExecuteNotification(string sender, IEnumerable <string> messages)
        {
            if (string.IsNullOrWhiteSpace(sender))
            {
                return;
            }

            foreach (var message in messages)
            {
                if (string.IsNullOrEmpty(message))
                {
                    continue;
                }

                Notifications.Insert(0, new NotificationItem(sender, message));
                NewNotification?.Invoke(this, new EventArgs <string, string>(sender, message));
            }
        }
コード例 #6
0
 public NewNotificationEditor(NotificationTypeEnum type, int FromId, int ToId)
 {
     _entity = new NewNotification
     {
         PostedDate        = DateTime.UtcNow,
         NotificationType  = type,
         IsNew             = true,
         ToUserId          = ToId,
         FromUserId        = FromId,
         OldFromUser       = "",
         NewFromUser       = FromId.ToString(),
         QuizzId           = 1,
         QuizzCommentId    = 1,
         QuestionId        = 1,
         AssignmentGroupId = 1,
         AssignmentId      = 1,
     };
 }
コード例 #7
0
        public CustomerService()
        {
            SqlDependency.Start(ConfigurationManager.ConnectionStrings["NotificationCenterContext"].ConnectionString);

            var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NotificationCenterContext"].ConnectionString);

            var command = new SqlCommand
            {
                Connection   = connection,
                CommandType  = CommandType.Text,
                CommandText  = "SELECT * FROM [dbo].[Notifications]",
                Notification = null
            };

            command.Connection.Open();

            SqlDependency dependency = new SqlDependency(command);

            dependency.OnChange += (sender, args) => { NewNotification?.Invoke(); };
            command.ExecuteReader();
        }
コード例 #8
0
        /// <summary>
        /// The ButtonAdd_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonAdd_Click(object sender, EventArgs args)
        {
            var newNotification = new NewNotification();

            foreach (ListViewItem roleItem in lvRoles.Items)
            {
                if (!roleItem.Checked)
                {
                    continue;
                }

                var role = roleItem.Tag as Role;
                if (role == null)
                {
                    continue;
                }

                newNotification.Roles.Add(role);
            }

            foreach (ListViewItem userItem in lvUsers.Items)
            {
                if (!userItem.Checked)
                {
                    continue;
                }

                var user = userItem.Tag as User;
                if (user == null)
                {
                    continue;
                }

                newNotification.Users.Add(user);
            }

            SelectedSituation.AddNotification(newNotification);
        }
コード例 #9
0
ファイル: General.cs プロジェクト: JuanDouglas/WSClass
        private void ThreadNotifications(object @object)
        {
            if (!(@object is NotificationThreadStart))
            {
                throw new ArgumentException("Could not start this thread");
            }
            NotificationThreadStart notificationThreadStart = (NotificationThreadStart)@object;
            NotificationsController controller = new NotificationsController();

            do
            {
                Thread.Sleep(notificationThreadStart.UpdateDelay);
                var requestThread = controller.GetNotificationsAsync(notificationThreadStart.LoginToken, notificationThreadStart.ValidKey);
                requestThread.Wait();
                Notification[] notifications = requestThread.Result;
                if (notifications != null)
                {
                    foreach (var notification in notifications)
                    {
                        NewNotification.Invoke(null, new NewNotificationArgs(notification, DateTime.Now));
                    }
                }
            } while (Thread.CurrentThread.ThreadState == ThreadState.Running);
        }
コード例 #10
0
 protected void triggerNewNotification(NotificationEventArgs e)
 {
     NewNotification?.Invoke(this, e);
 }
コード例 #11
0
 /// <summary>
 /// Fires a new notification, returning the id of the returned notification.
 /// </summary>
 /// <param name="title"></param>
 /// <param name="line"></param>
 /// <param name="type"></param>
 /// <param name="duration"></param>
 /// <param name="template"></param>
 /// <param name="forcedId"></param>
 /// <returns></returns>
 public static int N(string title, string line, NotificationType type, int duration = -1, NotificationTemplate template = NotificationTemplate.Default, int forcedId = -1)
 {
     return(NewNotification?.Invoke(title, line, type, duration, template, forcedId) ?? -1);
 }
コード例 #12
0
 public NewNotificationEditor(NewNotification entity)
 {
     _entity = entity;
 }
コード例 #13
0
        /// <summary>
        /// Отправить уведомление.
        /// </summary>
        /// <param name="notification">Данные уведомления.</param>
        public void SendNotification(AppNotification notification)
        {
            if (notification == null)
            {
                throw new ArgumentNullException(nameof(notification));
            }

            if (!_settingsService.GetNoCache(ENABLE_IN_APP_POPUPS, true) && !notification.IsImportant)
            {
                return;
            }

            Task.Run(async() =>
            {
                try
                {
                    if (!notification.NoSound && _settingsService.GetNoCache(ENABLE_IN_APP_SOUND, true))
                    {
                        await PlaySound(notification.Type);
                    }
                }
                catch (Exception)
                {
                    _settingsService.Set(ENABLE_IN_APP_SOUND, false);
                    var error = new AppNotification
                    {
                        Type        = AppNotificationType.Error,
                        NoSound     = true,
                        Title       = _locService["AppNotifications_SoundNotWorking_Title"],
                        Content     = _locService["AppNotifications_SoundNotWorking_Content"],
                        IsImportant = true
                    };
                    SendNotification(error);
                }
            });

            _presenter.ShowNotification(notification);

            Task.Run(async() =>
            {
                try
                {
                    if (!notification.NoVibration && _settingsService.GetNoCache(ENABLE_IN_APP_VIBRATION, true))
                    {
                        await StartVibration(notification.Type);
                    }
                }
                catch (Exception)
                {
                    _settingsService.Set(ENABLE_IN_APP_VIBRATION, false);
                    var error = new AppNotification
                    {
                        Type        = AppNotificationType.Error,
                        NoVibration = true,
                        Title       = _locService["AppNotifications_VibrationNotWorking_Title"],
                        Content     = _locService["AppNotifications_VibrationNotWorking_Content"],
                        IsImportant = true
                    };
                    SendNotification(error);
                }
            });

            NewNotification?.Invoke(this, notification);
        }
コード例 #14
0
 public void RaiseNewNotification(Notification notification)
 {
     NewNotification?.Invoke(this, notification);
 }