public NotificationEventArgs(string title, string content, NotificationTypes notificationType, Action callback)
 {
     Title            = title;
     Content          = content;
     NotificationType = notificationType;
     Callback         = callback;
 }
Ejemplo n.º 2
0
        public async Task <bool> ScheduleNotificationAsync(DateTime dateTime, NotificationTypes notificationType,
                                                           string entity, string entityId)
        {
            try
            {
                Logger.Debug("Attempting to schedule native notification");

                if ((await NativeNotificationService.ScheduleNotificationAsync(
                         dateTime,
                         notificationType,
                         entity,
                         entityId)) == false)
                {
                    throw new Exception("Native exception could not be scheduled");
                }

                Logger.Debug("Native notification service claims to have completed successfully.");

                SalesAppNotification notification = new SalesAppNotification
                {
                    NotificationStatus = NotificationStatus.Scheduled,
                    Entity             = entity,
                    EntityId           = entityId,
                    NotificationType   = notificationType,
                    NotificiationTime  = dateTime
                };

                return((await SaveAsync(notification)).SavedModel.Id != default(Guid));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Main Application Logic
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // Do some really complex work here..
            // when you get done.. let the user know via a notification..

            // Ex:

            NotificationTypes notification = GetNotificationType();

            switch (notification)
            {
            case NotificationTypes.Sms:
                SendSms();
                break;

            case NotificationTypes.Email:
                SendEmail();
                break;

            case NotificationTypes.Console:
                SendConsole();
                break;
            }

            Console.ReadLine();
        }
        /// <summary>
        /// The GetNotificationTemplate method
        /// </summary>
        /// <param name="eventTypeId">The eventTypeId parameter</param>
        /// <param name="notifyType">The notifyType parameter</param>
        /// <returns>The AuthNet.PoC.EventModel.Entities.NotificationTemplate type object</returns>        
        public NotificationTemplate GetNotificationTemplate(int eventTypeId, NotificationTypes notifyType)
        {
            NotificationTemplate notification = new NotificationTemplate();
            string notificationstring = notifyType.ToString();
            string name = string.Empty;
            string sqlquery = "SELECT * from EventType where EventTypeId = " + eventTypeId;
            using (IDataReader reader = ExecuteInlineQueryReader(sqlquery))
            {
                while (reader.Read())
                {
                    name = reader[1].ToString();
                    break;
                }
            }

            sqlquery = "SELECT * from NotificationTemplate where EventType = '" + name + "' AND NotificationType = '" + notificationstring + "'";

            using (IDataReader reader = ExecuteInlineQueryReader(sqlquery))
            {
                while (reader.Read())
                {
                    notification.ID = int.Parse(reader[0].ToString());
                    notification.EventTypeID = eventTypeId;
                    notification.NotificationType = notifyType;
                    notification.GroupName = reader[3].ToString();
                    notification.TemplateName = reader[4].ToString();
                    break;
                }
            }

            return notification;
        }
 internal void RaiseToastNotification(string title, string content, NotificationTypes notificationType, Action callback)
 {
     if (ToastNotification != null)
     {
         ToastNotification(this, new NotificationEventArgs(title, content, notificationType, callback));
     }
 }
        public static NotificationResult Send(NotificationTypes channel, IEnumerable <string> to, string message, string title)
        {
            try
            {
                // select operation
                switch (channel)
                {
                case NotificationTypes.CALL:
                    return(SendCall(to, message));

                case NotificationTypes.SMS:
                    return(SendSms(to, message));

                case NotificationTypes.EMAIL:
                    return(SendEmail(to, message, title));

                default:
                    return(new NotificationResult(false, "Operação não suportada: " + channel));
                }
            }
            catch (Exception e)
            {
                return(new NotificationResult(false, "NotificationResult.Send [" + channel + "] " + e.Message));
            }
        }
Ejemplo n.º 7
0
 public Notification(string subject, string message, string details, NotificationTypes notificationType)
 {
     this.Subject          = subject;
     this.Message          = message;
     this.Details          = details;
     this.NotificationType = notificationType;
 }
 public Notification(string t, NotificationTypes notificationtype, string remarks, string id)
 {
     Title            = t;
     NotificationType = notificationtype;
     Remarks          = remarks;
     UserId           = id;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the notifier.
 /// </summary>
 /// <param name="notifyOptions"><see cref="NotificationTypes"/> that can be processed by the notifier.</param>
 public NotifierBase(NotificationTypes notifyOptions)
 {
     m_notifyOptions = notifyOptions;
     m_notifyTimeout = 30;
     m_persistSettings = true;
     m_settingsCategory = this.GetType().Name;
 }
Ejemplo n.º 10
0
        private async Task <Result <SlimNotificationOptions> > TryGetDefaultOptions(NotificationTypes type, ApiCallerTypes userType)
        {
            var receiver = userType.ToReceiverType();
            var options  = await _context.DefaultNotificationOptions.SingleOrDefaultAsync(o => o.Type == type);

            if (options is null)
            {
                return(Result.Failure <SlimNotificationOptions>($"Cannot find notification options for the type '{type}'"));
            }

            var emailTemplateId = userType switch
            {
                ApiCallerTypes.Agent => options.AgentEmailTemplateId,
                ApiCallerTypes.Admin => options.AdminEmailTemplateId,
                ApiCallerTypes.PropertyOwner => options.PropertyOwnerEmailTemplateId,
                _ => throw new NotImplementedException("No email templates are defined for the specified API caller type")
            };

            return(options.EnabledReceivers.HasFlag(receiver)
                ? new SlimNotificationOptions(enabledProtocols: options.EnabledProtocols,
                                              isMandatory: options.IsMandatory,
                                              enabledReceivers: options.EnabledReceivers,
                                              emailTemplateId: emailTemplateId)
                : Result.Failure <SlimNotificationOptions>($"Cannot find notification options for the type '{type}' and the receiver '{receiver}'"));
        }
Ejemplo n.º 11
0
 public SqlDependencyEx(
     string connectionString,
     string databaseName,
     string tableName,
     string schemaName = "dbo",
     NotificationTypes listenerType =
     NotificationTypes.Insert | NotificationTypes.Update | NotificationTypes.Delete,
     bool receiveDetails     = true,
     int identity            = 1,
     List <string> fieldList = null)
 {
     this.ConnectionString = connectionString;
     this.DatabaseName     = databaseName;
     this.TableName        = tableName;
     this.SchemaName       = schemaName;
     this.NotificaionTypes = listenerType;
     this.DetailsIncluded  = receiveDetails;
     this.Identity         = identity;
     if (fieldList != null)
     {
         this.FieldList = new List <string>();
         foreach (var field in fieldList)
         {
             this.FieldList.Add(string.Format("''{0}''", field));
         }
     }
 }
Ejemplo n.º 12
0
        public async Task <Result> Send(DataWithCompanyInfo messageData, NotificationTypes notificationType)
        {
            return(await GetRecipients(notificationType)
                   .Bind(GetNotificationOptions)
                   .Bind(BuildSettings)
                   .Tap(AddNotifications));


            async Task <Result <Dictionary <int, string> > > GetRecipients(NotificationTypes notificationType)
            {
                var roles = await _context.AdministratorRoles.ToListAsync();

                var roleIds = roles.Where(r => r.NotificationTypes?.Contains(notificationType) ?? false)
                              .Select(r => r.Id)
                              .ToList();

                var recipients = new Dictionary <int, string>();

                foreach (var roleId in roleIds)
                {
                    var addedRecipients = await _context.Administrators.Where(a => a.AdministratorRoleIds.Contains(roleId))
                                          .ToDictionaryAsync(a => a.Id, a => a.Email);

                    recipients = recipients.Union(addedRecipients)
                                 .ToDictionary(r => r.Key, r => r.Value);
                }

                return(recipients);
            }

            async Task <Result <List <RecipientWithNotificationOptions> > > GetNotificationOptions(Dictionary <int, string> recipients)
            => await _notificationOptionsService.GetNotificationOptions(recipients, notificationType);
        private async void OnSendNotification(NotificationTypes notificationType)
        {
            switch (notificationType)
            {
            case NotificationTypes.Email:
                await _pebble.NotificationMailAsync(Sender, Subject, Body);

                break;

            case NotificationTypes.SMS:
                await _pebble.NotificationSmsAsync(Sender, Body);

                break;

            case NotificationTypes.Facebook:
                await _pebble.NotificationFacebookAsync(Sender, Body);

                break;

            case NotificationTypes.Twitter:
                await _pebble.NotificationTwitterAsync(Sender, Body);

                break;
            }
        }
Ejemplo n.º 14
0
        public bool RaiseToastNotification(string title, string content, NotificationTypes notificationType, Action callback)
        {
            bool notificationRaised = false;

            // Disabling resize handles temporarily prevents mouse capture by the non-client area around the main keyboard
            this.mainWindowManipulationService.DisableResize();
            callback += () => this.mainWindowManipulationService.SetResizeState();

            if (ToastNotification != null)
            {
                ToastNotification(this, new NotificationEventArgs(title, content, notificationType, callback));
                notificationRaised = true;
            }
            else
            {
                if (notificationType == NotificationTypes.Error)
                {
                    pendingErrorToastNotificationContent.AppendLine(content);
                }

                //Error raised before the ToastNotification is initialised. Call callback delegate to ensure everything continues.
                callback();
            }

            return(notificationRaised);
        }
Ejemplo n.º 15
0
 public NotificationEventArgs(string title, string content, NotificationTypes notificationType, Action callback)
 {
     Title = title;
     Content = content;
     NotificationType = notificationType;
     Callback = callback;
 }
Ejemplo n.º 16
0
 protected void SetNotification(string message, NotificationTypes type, string title = "")
 {
     TempData["Notification"] = new AlertNotificationModel()
     {
         Message = message,
         Title   = title,
         Type    = type
     };
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Process a notification.
        /// </summary>
        /// <param name="subject">Subject matter for the notification.</param>
        /// <param name="message">Brief message for the notification.</param>
        /// <param name="details">Detailed message for the notification.</param>
        /// <param name="notificationType">One of the <see cref="NotificationTypes"/> values.</param>
        /// <returns>true if notification is processed successfully; otherwise false.</returns>
        public bool Notify(string subject, string message, string details, NotificationTypes notificationType)
        {
            if (!Enabled || (m_notifyThread != null && m_notifyThread.IsAlive))
            {
                return(false);
            }

            // Start notification thread with appropriate parameters.
            m_notifyThread = new Thread(NotifyInternal);
            if ((notificationType & NotificationTypes.Alarm) == NotificationTypes.Alarm &&
                (m_notifyOptions & NotificationTypes.Alarm) == NotificationTypes.Alarm)
            {
                // Alarm notifications are supported.
                m_notifyThread.Start(new object[] { new Action <string, string, string>(NotifyAlarm), subject, message, details });
            }
            else if ((notificationType & NotificationTypes.Warning) == NotificationTypes.Warning &&
                     (m_notifyOptions & NotificationTypes.Warning) == NotificationTypes.Warning)
            {
                // Warning notifications are supported.
                m_notifyThread.Start(new object[] { new Action <string, string, string>(NotifyWarning), subject, message, details });
            }
            else if ((notificationType & NotificationTypes.Information) == NotificationTypes.Information &&
                     (m_notifyOptions & NotificationTypes.Information) == NotificationTypes.Information)
            {
                // Information notifications are supported.
                m_notifyThread.Start(new object[] { new Action <string, string, string>(NotifyInformation), subject, message, details });
            }
            else if ((notificationType & NotificationTypes.Heartbeat) == NotificationTypes.Heartbeat &&
                     (m_notifyOptions & NotificationTypes.Heartbeat) == NotificationTypes.Heartbeat)
            {
                // Heartbeat notifications are supported.
                m_notifyThread.Start(new object[] { new Action <string, string, string>(NotifyHeartbeat), subject, message, details });
            }
            else
            {
                // Specified notification type is not supported.
                return(false);
            }

            if (m_notifyTimeout < 1)
            {
                // Wait indefinetely on the refresh.
                m_notifyThread.Join(Timeout.Infinite);
            }
            else
            {
                // Wait for the specified time on refresh.
                if (!m_notifyThread.Join(m_notifyTimeout * 1000))
                {
                    m_notifyThread.Abort();

                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 18
0
 private static string GetLevel(NotificationTypes type)
 {
     return(type switch
     {
         NotificationTypes.Information => Notification.Information,
         NotificationTypes.Warning => Notification.Warning,
         NotificationTypes.Error => Notification.Error,
         _ => throw new ArgumentException(nameof(type)),
     });
Ejemplo n.º 19
0
 /// <summary>
 /// Create a client registration for a certain event type.
 /// </summary>
 /// <param name="clientUri"></param>
 /// <param name="eventType"></param>
 /// <param name="userName"></param>
 /// <param name="prox"></param>
 public void RegisterClient(Uri clientUri, NotificationTypes eventType, string userName, IClientNotification prox)
 {           
     var reg = new Registration() { RegistrationUri = clientUri, EventType = eventType.ToString(), UserName = userName, clientProxy=prox  };
     var key = reg.CreateKey();
     if (!Registrations.ContainsKey(key))
         Registrations.Add(key, new List<Registration> { reg });
     else if (Registrations[key].Find(rg => (rg.RegistrationUri.AbsolutePath == reg.RegistrationUri.AbsolutePath)) == null)
            Registrations[key].Add(reg);            
 }
Ejemplo n.º 20
0
 public Notification(string message, NotificationTypes notificationType, DateTime startDate, DateTime dueDate, string createdBy)
 {
     Message = message;
     NotificationType = notificationType;
     StartDate = startDate;
     if (Util.IsNotNullDate(dueDate))
         DueDate = dueDate;
     CreatedBy = createdBy;
 }
 /// <summary>
 /// Constructor with automatique Guid
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="databaseName"></param>
 /// <param name="schemaName"></param>
 /// <param name="listenerType"></param>
 /// <param name="receiveDetails"></param>
 public SqlTableDependency(
     string connectionString,
     string schemaName = "dbo",
     NotificationTypes listenerType =
     NotificationTypes.Insert | NotificationTypes.Update | NotificationTypes.Delete,
     bool receiveDetails = true)
     : base(connectionString, schemaName, listenerType, receiveDetails)
 {
 }
Ejemplo n.º 22
0
        public void ShowNotification(NotificationTypes notificationType, string message)
        {
            panNotification.CssClass   = string.Format("notification {0} canhide", notificationType).ToLower();
            litNotificationHeader.Text = notificationType.ToString().ToUpper() + ":";
            litMessage.Text            = message;
            panNotification.Style.Add("display", "block");

            this.Visible = true;
        }
Ejemplo n.º 23
0
 public Notification(string title, string time, NotificationTypes type, string description, string link, string sitelink)
 {
     this.title       = title;
     this.time        = time;
     this.type        = type;
     this.description = description;
     this.link        = link;
     this.sitelink    = sitelink;
 }
Ejemplo n.º 24
0
 private static NotificationTypes[] GetMembers(NotificationTypes value)
 {
     return
         (Enum.GetValues(typeof(NotificationTypes))
          .Cast <int>()
          .Where(enumValue => enumValue != 0 && (enumValue & (int)value) == enumValue)
          .Cast <NotificationTypes>()
          .ToArray());
 }
Ejemplo n.º 25
0
 private NotificationsHelperBase GetHelper(NotificationTypes notificationType)
 {
     switch (notificationType)
     {
     case NotificationTypes.ProspectReminder:
         return(new ProspectsReminderNotificationsHelper(AppContext));
     }
     throw new Exception("Notification helper for notification type '" + notificationType.ToString() + "' has not been implemented");
 }
Ejemplo n.º 26
0
        public async Task SetAllOverdueNotificationsViewed(NotificationTypes notificationTypes)
        {
            List <SalesAppNotification> overdueNotifications = await GetAllOverdueNotificationsAsync(notificationTypes);

            foreach (var overdueNotification in overdueNotifications)
            {
                await SetSingleNotificationViewed(overdueNotification);
            }
        }
Ejemplo n.º 27
0
        private void SendFriendsNotification(string messageText, NotificationTypes notificationType)
        {
            var extraParams = new ExtraParams();

            extraParams.AddNew(ExtraParamsList.save_to_history, "1");
            extraParams.AddNew(ExtraParamsList.dialog_id, dialogId);
            extraParams.AddNew(ExtraParamsList.notification_type, ((int)notificationType).ToString());

            quickbloxClient.ChatXmppClient.SendMessage(otherUserJid, messageText, extraParams, dialogId, null);
        }
Ejemplo n.º 28
0
        private static NotificationContent GetContent(string title, string message, NotificationTypes notificationType)
        {
            var content = new NotificationContent();

            content.Title   = title;
            content.Message = message;
            content.Type    = (NotificationType)notificationType;

            return(content);
        }
Ejemplo n.º 29
0
        private static IList <LotView> GetLotViewsFromNotifications(LotQuery query, NotificationTypes notificationType, bool unReadOnly, string orderBy, bool desc, int pageIndex, int pageSize, out int recordCount)
        {
            IList <LotView> list = new List <LotView>();

            foreach (NotificationswithLot lot in notificationWithLotGateway.GetNotificationswithLotsBy(query, notificationType, unReadOnly, orderBy, desc, pageIndex, pageSize, out recordCount))
            {
                list.Add(GetLotViewByLotID(lot.LotID));
            }
            return(list);
        }
Ejemplo n.º 30
0
        public void Convert_ReturnsColor(NotificationTypes type, byte r, byte g, byte b)
        {
            var sut = new NotificationColorConverter();

            var actual = sut.Convert(type, null, null, null) as SolidColorBrush;

            actual.Color.R.Should().Be(r);
            actual.Color.G.Should().Be(g);
            actual.Color.B.Should().Be(b);
        }
 /// <summary>
 /// Constructor with automatique Guid
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="databaseName"></param>
 /// <param name="schemaName"></param>
 /// <param name="listenerType"></param>
 /// <param name="receiveDetails"></param>
 protected ExtendedSqlDependency(
     string connectionString,
     string schemaName = "dbo",
     NotificationTypes listenerType =
     NotificationTypes.Insert | NotificationTypes.Update | NotificationTypes.Delete,
     bool receiveDetails = true)
     : this(connectionString, Guid.Empty, schemaName, listenerType, receiveDetails)
 {
     this.Identity = Guid.NewGuid();
 }
Ejemplo n.º 32
0
        private Task SendDetailedBookingNotification(AccommodationBookingInfo bookingInfo, string recipient, SlimAgentContext agent,
                                                     NotificationTypes notificationType)
        {
            var details          = bookingInfo.BookingDetails;
            var notificationData = CreateNotificationData(bookingInfo, details);

            return(_notificationService.Send(agent: agent,
                                             messageData: notificationData,
                                             notificationType: notificationType,
                                             email: recipient));
        }
 public SqlDependencyEx(SqlDependencyExOptions opts,
                        NotificationTypes listenerType = NotificationTypes.Insert | NotificationTypes.Update | NotificationTypes.Delete,
                        bool receiveDetails            = true,
                        int identity = 1)
 {
     ConnectionOptions            = opts;
     ConnectionOptions.SchemaName = opts.SchemaName ?? "dbo";
     Notifications   = listenerType;
     DetailsIncluded = receiveDetails;
     Identity        = identity;
 }
Ejemplo n.º 34
0
 private IHandler GetHandler(NotificationTypes type)
 {
     if (type == NotificationTypes.EMAIL)
     {
         return(new EmailHandler());
     }
     else
     {
         return(new TextHandler());
     }
 }
        /// <summary>
        /// Register a one-way channel information
        /// </summary>
        /// <param name="clientUri"></param>
        /// <param name="notificationType"></param>
        public void Register(string clientUri, NotificationTypes notificationType)
        {
            string userName = "******";

            if ((OperationContext.Current != null) &&
                (OperationContext.Current.ServiceSecurityContext != null) &&
                (OperationContext.Current.ServiceSecurityContext.PrimaryIdentity != null))
            {
                userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;               
            }
            MemoryRepository.Current.RegisterClient(new Uri(clientUri), notificationType, userName, null);
         }
Ejemplo n.º 36
0
 public CascadeLevel(int orderNumber, NotificationTypes notificationTypes, Workplace responsible = null, int headLevel = 0, TimeSpan?delay = null)
 {
     Responsible       = responsible;
     HeadLevel         = headLevel;
     TriggeredAt       = null;
     OrderNumber       = orderNumber;
     NotificationTypes = notificationTypes;
     if (delay.HasValue)
     {
         DelayTicks = delay.Value.Ticks;
     }
 }
Ejemplo n.º 37
0
        public static void Inform(string message, NotificationTypes notifType=NotificationTypes.Notice, bool isModal=false)
        {
            printMsg(notifType.ToString(), message);

            if(isModal)
                MessageBox.Show(message, notifType.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);

            if(notifType == NotificationTypes.FATAL) {
                MessageBox.Show(message + "\nL'application va maintenant s'arrêter de fonctionner.", "Erreur critique", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Process.GetCurrentProcess().Kill();
            }
        }
Ejemplo n.º 38
0
 public Notification GetNotification(string notificationId, NotificationTypes notificationType)
 {
     switch (notificationType)
     {
         case NotificationTypes.FeedNotification:
             return NotificationsCollection.Collection.FindOneByIdAs<FeedNotification>(new ObjectId(notificationId));
         case NotificationTypes.TimetableNotification:
             return NotificationsCollection.Collection.FindOneByIdAs<TimetableNotification>(new ObjectId(notificationId));
         case NotificationTypes.MonitoredWebsitesNotification:
             return NotificationsCollection.Collection.FindOneByIdAs<MonitoredWebsiteNotification>(new ObjectId(notificationId));
     }
     return null;
 }
        /// <summary>
        /// Register a duplex callback channel
        /// </summary>
        /// <param name="notificationType"></param>
        public void RegisterCallback(NotificationTypes notificationType)
        {
            string userName = "******";

            if ((OperationContext.Current != null) &&
                (OperationContext.Current.ServiceSecurityContext != null) &&
                (OperationContext.Current.ServiceSecurityContext.PrimaryIdentity != null))
            {
                userName = OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name;
            }

          //  var dchf = new DuplexChannelFactory<IClientNotification>(OperationContext.Current.InstanceContext);
           // IClientNotification prox = dchf.CreateChannel();
            IClientNotification prox = OperationContext.Current.GetCallbackChannel<IClientNotification>();
            MemoryRepository.Current.RegisterClient(null , notificationType, userName, prox);
        }
 private async void OnSendNotification( NotificationTypes notificationType )
 {
     switch ( notificationType )
     {
         case NotificationTypes.Email:
             await _pebble.NotificationMailAsync( Sender, Subject, Body );
             break;
         case NotificationTypes.SMS:
             await _pebble.NotificationSmsAsync( Sender, Body );
             break;
         case NotificationTypes.Facebook:
             await _pebble.NotificationFacebookAsync( Sender, Body );
             break;
         case NotificationTypes.Twitter:
             await _pebble.NotificationTwitterAsync( Sender, Body );
             break;
     }
 }
Ejemplo n.º 41
0
 public SqlDependencyEx(
     string connectionString,
     string databaseName,
     string tableName, string schemaName = "dbo",
     NotificationTypes listenerType = NotificationTypes.Insert | NotificationTypes.Update | NotificationTypes.Delete,
     bool receiveDetails = true,
     int identity = 1,
     string identityName = "",
     ModalityTypes modality = ModalityTypes.Full)
 {
     ConnectionString = connectionString;
     DatabaseName = databaseName;
     TableName = tableName;
     SchemaName = schemaName;
     NotificaionTypes = listenerType;
     DetailsIncluded = receiveDetails;
     Identity = identity;
     IdentityName = identityName;
     ModalityType = modality;
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Initializes a new instance of the notifier.
 /// </summary>
 /// <param name="notifyOptions"><see cref="NotificationTypes"/> that can be processed by the notifier.</param>
 public NotifierBase(NotificationTypes notifyOptions)
 {
     m_notifyOptions = notifyOptions;
     m_notifyTimeout = 30;
     PersistSettings = true;
 }
 /// <summary>
 /// This method returns Notification Template for specified eventID and Notification Type
 /// </summary>
 /// <param name="eventID">The eventID</param>
 /// <param name="notifyType">The Notification Type</param>
 /// <returns>The Notification Template</returns>        
 public override NotificationTemplate GetNotificationTemplate(int eventID, NotificationTypes notifyType)
 {
     return Business.GetNotificationTemplateV2(eventID, notifyType);
 }
 /// <summary>
 /// This method returns notification template for specified eventID and notification Type
 /// </summary>
 /// <param name="eventID">The eventID parameter</param>
 /// <param name="notifyType">The notification Type parameter</param>
 /// <returns>The Notification Template type object</returns>        
 public virtual NotificationTemplate GetNotificationTemplate(int eventID, NotificationTypes notifyType)
 {
     return this.Business.GetNotificationTemplate(eventID, notifyType);
 }
Ejemplo n.º 45
0
 internal void RaiseToastNotification(string title, string content, NotificationTypes notificationType, Action callback)
 {
     if (ToastNotification != null)
     {
         ToastNotification(this, new NotificationEventArgs(title, content, notificationType, callback));
     }
 }
Ejemplo n.º 46
0
 public IDisposable ShowNotification( Guid pluginId, string title, string content, int duration, NotificationTypes notificationType, Action<object, EventArgs> imageClickAction )
 {
     return ShowCustomBaloon( pluginId, GetDefaultContent( title, content ), duration, imageClickAction, notificationType );
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Creates a notification by directly providing a UIElement. MAKE SURE THE UIELEMENT HAS BEEN CREATED BY THE APPLICATION'S MAIN THREAD.
 /// </summary>
 /// <param name="pluginId"></param>
 /// <param name="content"></param>
 /// <param name="duration"></param>
 /// <param name="notificationType"></param>
 /// <param name="imageClickAction"></param>
 /// <returns></returns>
 public IDisposable ShowNotification( Guid pluginId, UIElement content, int duration, NotificationTypes notificationType, Action<object, EventArgs> imageClickAction )
 {
     return ShowCustomBaloon( pluginId, content, duration, imageClickAction, notificationType );
 }
Ejemplo n.º 48
0
        private void createSubscription(int subscriberId, int eventId, NotificationTypes nType)
        {

            EventType selectedEvent = new EventType() { ID = eventId };
            NotificationEndpoint notificationEP;
            Subscription subscription = new Subscription() { SubscriberID = subscriberId, EventType = selectedEvent };
            string emailEP;
            string smsEP;
            string webhookEP;

            if (nType == NotificationTypes.Email)
            {
                emailEP = txtBoxEmail.Text.Trim();
                bool emailCheck = IsValidEmail(emailEP);
                if (!emailCheck)
                {
                    MessageBox.Show("Invalid EmailID");
                }
                else
                {
                    if (string.Compare(emailEP, "") != 0)
                    {
                        notificationEP = new EmailNotificationSetting() { NotificationType = nType, EmailAddress = emailEP };
                        subscription.NotificationEndpoint = notificationEP;
                        SubscriptionBusiness.Subscribe(subscription);
                    }
                }
            }
            if (nType == NotificationTypes.SMS)
            {
                smsEP = txtBoxSMS.Text.Trim();
                bool phoneCheck = isValidPhoneNumber(smsEP);
                if (!phoneCheck)
                {
                    MessageBox.Show("Invalid Phone Number");
                }
                else
                {
                    if (string.Compare(smsEP, "") != 0)
                    {
                        notificationEP = new SmsNotificationSetting() { NotificationType = nType, PhoneNumber = smsEP };
                        subscription.NotificationEndpoint = notificationEP;
                        SubscriptionBusiness.Subscribe(subscription);
                    }
                }

            }
            if (nType == NotificationTypes.Webhook)
            {
                webhookEP = txtBoxWebhook.Text.Trim();
                bool webhookCheck = Uri.IsWellFormedUriString(webhookEP, UriKind.RelativeOrAbsolute);
                bool webhookhttp = IsValidUrl(webhookEP);
                if (!webhookCheck || webhookhttp == false)
                {
                    MessageBox.Show("Invalid URL");
                }
                else
                {
                    if (string.Compare(webhookEP, "") != 0)
                    {
                        notificationEP = new WebhookNotificationSetting() { NotificationType = nType, Url = webhookEP };
                        subscription.NotificationEndpoint = notificationEP;
                        SubscriptionBusiness.Subscribe(subscription);
                    }
                }

            }
        }
 /// <summary>
 /// The GetNotificationTemplateV2 method
 /// </summary>
 /// <param name="eventTypeId">The eventTypeId parameter</param>
 /// <param name="notifyType">The notifyType parameter</param>
 /// <returns>returns true or false respectively</returns>        
 public NotificationTemplate GetNotificationTemplateV2(int eventTypeId, NotificationTypes notifyType)
 {
     return this.notificationTemplateDAL.GetNotificationTemplate(eventTypeId, notifyType);
 }
 /// <summary>
 /// The SubscriptionExistsV2 method
 /// </summary>
 /// <param name="merchantId">The merchantId parameter</param>
 /// <param name="eventTypeId">The eventTypeId parameter</param>
 /// <param name="ntype">The ntype parameter</param>
 /// <returns>returns true or false respectively</returns>        
 public bool SubscriptionExistsV2(int merchantId, int eventTypeId, NotificationTypes ntype)
 {
     return this.subscriptionDAL.SubscriptionExists(merchantId, eventTypeId, ntype);
 }
Ejemplo n.º 51
0
        /// <summary>
        /// Get a particular registration
        /// </summary>
        /// <param name="eventType"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public Registration[] GetRegistrations(NotificationTypes eventType, string userName)
        {
            if (string.IsNullOrEmpty(userName))
                userName = "******";

            var q = from reglst in Registrations.Values
                    from reg in reglst
                    where ((reg.EventType == eventType.ToString()) && (reg.UserName == userName))
                    select reg;

            return q.ToArray();

        }
Ejemplo n.º 52
0
 /// <summary>
 /// Clear all registrations for an event type
 /// </summary>
 /// <param name="eventType"></param>
 public void ClearRegistrations(NotificationTypes? eventType)
 {
     if (eventType == null)
         Registrations = new Dictionary<string, List<Registration>>();
     else if (Registrations.ContainsKey(eventType.ToString()))
     {
         Registrations[eventType.ToString()] = new List<Registration>();
     }
 }
Ejemplo n.º 53
0
 public Notification GetNotification(string notificationId, NotificationTypes notificationType)
 {
     return dal.GetNotification(notificationId, notificationType);
 }
Ejemplo n.º 54
0
 public IDisposable ShowNotification( Guid pluginId, string title, string content, int duration, NotificationTypes notificationType )
 {
     return ShowCustomBaloon( pluginId, GetDefaultContent( title, content ), duration, null, notificationType );
 }
 /// <summary>
 /// This method tells whether subscription exists or not
 /// </summary>
 /// <param name="merchantId">The merchantId parameter</param>
 /// <param name="eventId">The eventId parameter</param>
 /// <param name="ntype">The Notification Type parameter</param>
 /// <returns>The status of existence of subscription</returns>        
 public virtual bool SubscriptionExists(int merchantId, int eventId, NotificationTypes ntype)
 {
     return this.Business.SubscriptionExists(merchantId, eventId, ntype);
 }
Ejemplo n.º 56
0
 /// <summary>
 /// Create a client registration for a certain event type.
 /// </summary>
 /// <param name="clientUri"></param>
 /// <param name="eventType"></param>
 public void UnRegisterClient(Uri clientUri, NotificationTypes eventType)
 {
     var reg = new Registration() { RegistrationUri = clientUri, EventType = eventType.ToString() };
      var key = reg.CreateKey();
      if (Registrations.ContainsKey(key))
          Registrations.Remove(key);
 }
 /// <summary>
 /// This method tells whether Subscription Exists or not
 /// </summary>
 /// <param name="merchantId">The merchantId</param>
 /// <param name="eventId">The eventId</param>
 /// <param name="ntype">The Notification Type</param>
 /// <returns>The status of subscription existence</returns>        
 public override bool SubscriptionExists(int merchantId, int eventId, NotificationTypes ntype)
 {
     return Business.SubscriptionExistsV2(merchantId, eventId, ntype);
 }
Ejemplo n.º 58
0
        /// <summary>
        /// Get all the client registrations
        /// </summary>
        /// <param name="eventType"></param>
        /// <returns></returns>
        public Registration[] GetAllRegistrations(NotificationTypes eventType)
        {
            var q = from reglst in Registrations.Values
                     from reg in reglst
                     where reg.EventType == eventType.ToString()
                     select reg;

            return q.ToArray();
        }
Ejemplo n.º 59
0
        /// <summary>
        /// Process a notification.
        /// </summary>
        /// <param name="subject">Subject matter for the notification.</param>
        /// <param name="message">Brief message for the notification.</param>
        /// <param name="details">Detailed message for the notification.</param>
        /// <param name="notificationType">One of the <see cref="NotificationTypes"/> values.</param>
        /// <returns>true if notification is processed successfully; otherwise false.</returns>
        public bool Notify(string subject, string message, string details, NotificationTypes notificationType)
        {
            if (!Enabled || (m_notifyThread != null && m_notifyThread.IsAlive))
                return false;

            // Start notification thread with appropriate parameters.
            m_notifyThread = new Thread(NotifyInternal);
            if ((notificationType & NotificationTypes.Alarm) == NotificationTypes.Alarm &&
                (m_notifyOptions & NotificationTypes.Alarm) == NotificationTypes.Alarm)
                // Alarm notifications are supported.
                m_notifyThread.Start(new object[] { new Action<string, string, string>(NotifyAlarm) , subject, message, details});
            else if ((notificationType & NotificationTypes.Warning) == NotificationTypes.Warning && 
                     (m_notifyOptions & NotificationTypes.Warning) == NotificationTypes.Warning)
                // Warning notifications are supported.
                m_notifyThread.Start(new object[] { new Action<string, string, string>(NotifyWarning), subject, message, details });
            else if ((notificationType & NotificationTypes.Information) == NotificationTypes.Information && 
                     (m_notifyOptions & NotificationTypes.Information) == NotificationTypes.Information)
                // Information notifications are supported.
                m_notifyThread.Start(new object[] { new Action<string, string, string>(NotifyInformation), subject, message, details });
            else if ((notificationType & NotificationTypes.Heartbeat) == NotificationTypes.Heartbeat && 
                     (m_notifyOptions & NotificationTypes.Heartbeat) == NotificationTypes.Heartbeat)
                // Heartbeat notifications are supported.
                m_notifyThread.Start(new object[] { new Action<string, string, string>(NotifyHeartbeat), subject, message, details });
            else
                // Specified notification type is not supported.
                return false;

            if (m_notifyTimeout < 1)
            {
                // Wait indefinetely on the refresh.
                m_notifyThread.Join(Timeout.Infinite);
            }
            else
            {
                // Wait for the specified time on refresh.
                if (!m_notifyThread.Join(m_notifyTimeout * 1000))
                {
                    m_notifyThread.Abort();

                    return false;
                }
            }

            return true;
        }
Ejemplo n.º 60
0
        /// <summary>
        /// Loads saved notifier settings from the config file if the <see cref="Adapter.PersistSettings"/> property is set to true.
        /// </summary>
        /// <exception cref="ConfigurationErrorsException"><see cref="Adapter.SettingsCategory"/> has a value of null or empty string.</exception>
        public override void LoadSettings()
        {
            base.LoadSettings();

            if (PersistSettings)
            {
                // Load settings from the specified category.
                ConfigurationFile config = ConfigurationFile.Current;
                CategorizedSettingsElementCollection settings = config.Settings[SettingsCategory];
                settings.Add("Enabled", Enabled, "True if this notifier is enabled; otherwise False.");
                settings.Add("NotifyTimeout", m_notifyTimeout, "Number of seconds to wait for notification processing to complete.");
                settings.Add("NotifyOptions", m_notifyOptions, "Types of notifications (Information; Warning; Alarm; Heartbeat) to be processed by this notifier.");
                Enabled = settings["Enabled"].ValueAs(Enabled);
                NotifyTimeout = settings["NotifyTimeout"].ValueAs(m_notifyTimeout);
                NotifyOptions = settings["NotifyOptions"].ValueAs(m_notifyOptions);
            }
        }