Beispiel #1
0
        /// <summary>
        /// Adds exception to message and changes messageType to Error.
        /// </summary>
        /// <param name="ex"></param>
        public void AddError(Exception ex)
        {
            string error = "<error><number>" + ex.HResult + "</number><severity>99</severity><state>1</state><procedure>ListenerReciveSubscriptions</procedure><linenb></linenb><message>" + ex.Message + "</message></error>";

            Error       = new NotificationMessageError(error);
            MessageType = NotificationMessageType.Error;
        }
Beispiel #2
0
 public NotificationMessage(string title, string message, NotificationMessageType type, object data=null)
 {
     this.Title   = title;
       this.Message = message;
       this.Type    = type;
       this.Data    = data;
 }
Beispiel #3
0
 public NotificationMessageData(string message, NotificationMessageType type = NotificationMessageType.Error)
 {
     Title     = "Plc Visualizer";
     Message   = message;
     Type      = type;
     Timestamp = DateTime.Now;
     AutoFade  = true;
 }
 /// <param name="messageTime"/>
 /// <param name="messageType"/>
 /// <param name="messageText"/>
 /// <param name="shortMessageText">Короткий вариант сообщения до 20 символов.</param>
 /// <param name="source">Окно/Класс в котором возникло сообщение.</param>
 public NotificationMessage(DateTime messageTime, NotificationMessageType messageType, string messageText, string shortMessageText, string source)
 {
     this.MessageTime      = messageTime;
     this.MessageText      = messageText;
     this.MessageType      = messageType;
     this.ShortMessageText = shortMessageText;
     this.Source           = source;
 }
 public virtual INotificationHandler Create(NotificationMessageType type)
 {
     return(type switch
     {
         NotificationMessageType.Email => container.Resolve <MailNotificationHandler>(),
         NotificationMessageType.Sms => container.Resolve <SmsNotificationHandler>(),
         _ => throw new Exception($"{type} not implemented")
     });
Beispiel #6
0
 public NewVersionNotificationMessage(
 string title,
 string message,
 NotificationMessageType type,
 IEnumerable<VersionDescription> new_versions)
     : base(title, message, type)
 {
     this.VersionDescriptions = new_versions;
 }
Beispiel #7
0
 public NewVersionNotificationMessage(
     string title,
     string message,
     NotificationMessageType type,
     IEnumerable <VersionDescription> new_versions)
     : base(title, message, type)
 {
     this.VersionDescriptions = new_versions;
 }
Beispiel #8
0
        public async Task <bool> NotificationRegistrationAsync(Ekreta.Mobile.Core.Models.Profile profile)
        {
            try
            {
                if (!this._pushNotificationPlatformSpecificService.IsPushNotificationEnabledByDevice())
                {
                    throw new DisabledPushByDeviceException().SetErrorCode <DisabledPushByDeviceException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDataService.cs", 123);
                }
                string platform = this._pushNotificationHandler.Platform.ToString();
                NotificationMessageType notificationType = NotificationMessageType.All;
                string handle = this._pushNotificationHandler.Token;
                NotificationMessageSource notificationSource = NotificationMessageSource.Kreta;
                TokenData tokenData = this._secureStore.GetTokenData(profile.Id);
                if (tokenData.ExpiresAt <= DateTime.Now)
                {
                    tokenData = await((IAuthDataService)Mvx.get_IoCProvider().Resolve <IAuthDataService>()).RefreshToken(profile);
                }
                if (tokenData == null)
                {
                    return(false);
                }
                profile.TokenInfo = (TokenInfo)JsonConvert.DeserializeObject <TokenInfo>(TokenDecoder.Decode(tokenData.AccessToken));
                PushSettings pushSettings = await this._globalMobileApi.NotificationRegistrationAsync(profile.TokenInfo.InstituteCode, profile.TokenInfo.InstituteUserId, profile.TokenInfo.TutelaryId, platform, handle, profile.TokenInfo.Role, notificationSource, (int)notificationType, profile.Id);

                if (pushSettings != null)
                {
                    pushSettings.NotificationTypes = notificationType;
                    pushSettings.FirstTimePushRun  = true;
                    pushSettings.UpdateEugyintezes = true;
                    pushSettings.Token             = handle;
                    profile.PushSettings           = pushSettings;
                }
                else if (profile.PushSettings != null)
                {
                    profile.PushSettings.FirstTimePushRun = true;
                }
                else
                {
                    profile.PushSettings = new PushSettings()
                    {
                        FirstTimePushRun = true
                    }
                };
                this.AddOrUpdate(profile);
                return(pushSettings != null);
            }
            catch (DisabledPushByDeviceException ex)
            {
                ex.SetErrorCode <DisabledPushByDeviceException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDataService.cs", 180);
                throw;
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, "ProfileDataService.NotificationRegistrationAsync", "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDataService.cs", 75);
                return(false);
            }
        }
Beispiel #9
0
 public NoItemException(
     string instituteCode,
     int instituteUserId,
     int itemId,
     NotificationMessageType type)
     : base(string.Format("No Item present for instituteCode: {0}, instituteUserId: {1},", (object)instituteCode, (object)instituteUserId) + string.Format("itemId: {0}, Type: {1}", (object)itemId, (object)type.ToString()))
 {
     this.InstituteCode   = instituteCode;
     this.InstituteUserId = instituteUserId;
     this.ItemId          = itemId;
     this.Type            = type;
 }
Beispiel #10
0
        public static void ShowMessage(this Controller controller, NotificationMessageType messageType,
                                       string message, bool showAfterRedirect = false)
        {
            var messageTypeKey = messageType.ToString();

            if (showAfterRedirect)
            {
                controller.TempData[messageTypeKey] = message;
            }
            else
            {
                controller.ViewData[messageTypeKey] = message;
            }
        }
Beispiel #11
0
        public NotificationMessage(NotificationMessageType type, string fromAddress, string fromName, string subject)
        {
            this.Type = type;

            if (fromAddress.IsNotNullOrEmpty())
            {
                this.AddFrom(fromAddress, fromName);
            }

            if (subject.IsNotNullOrEmpty())
            {
                this.AddSubject(subject);
            }
        }
        public void ShowMessageNotification(string messageTitle, string Message, NotificationMessageType _type, Dispatcher dispatcher = null)
        {
            // if the dispatcher passed null assume the calling thread is owned by mainWindow Dispatcher
            Dispatcher __ = dispatcher != null
                ? dispatcher
                : MainWindow.MainWindowAccessor.Dispatcher;

            __.Invoke((Action) delegate
            {
                var messageNoti = new NotificationMessage();
                messageNoti.SetMessageText(messageTitle, Message, _type);
                NotificationContainerWindow notificationWindow = new NotificationContainerWindow(messageNoti);
                notificationWindow.NotificationType            = NotificationType.Message;
                notificationWindow.Show();
            });
        }
Beispiel #13
0
        private void SetMessage(NotificationMessageType type, string message)
        {
            if (!Enum.IsDefined(typeof(NotificationMessageType), type))
            {
                this.Type = NotificationMessageType.UNKNOWN;
            }
            else
            {
                this.Type = type;
            }

            if (string.IsNullOrEmpty(message))
            {
                this.Message = string.Empty;
            }
            else
            {
                this.Message = message;
            }
        }
Beispiel #14
0
        public async Task <bool> NotificationUpdateAsync(
            Ekreta.Mobile.Core.Models.Profile profile,
            NotificationMessageType notificationType,
            string token)
        {
            try
            {
                PushSettings pushSettings = await this._globalMobileApi.NotificationUpdateAsync(profile.PushSettings.RegistrationId, (int)notificationType, NotificationMessageSource.Kreta, token);

                profile.PushSettings.NotificationTypes = notificationType;
                profile.PushSettings.Token             = token;
                this.AddOrUpdate(profile);
                return(true);
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, nameof(NotificationUpdateAsync), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDataService.cs", 206);
                return(false);
            }
        }
Beispiel #15
0
        public void QueueNotification(
            string message,
            string navigation,
            NotificationMessageType type,
            IEnumerable <string> targets,
            bool force = false,
            bool save  = true)
        {
            _notificationQueue.Enqueue(ct => SaveAndSendNotifications(MessageFactory, targets, ct, force, save));
            _signal.Release();

            NotificationMessage MessageFactory(string target) =>
            new NotificationMessage
            {
                UserInformationId = target,
                Message           = message,
                Navigation        = navigation,
                Type  = type,
                Force = force,
            };
        }
Beispiel #16
0
        private Notify NewDocumentNotifyObject(string endpoint, string flow, CommonTransactionStatusCode status,
                                               string description, string[] documentIds)
        {
            if (CollectionUtils.IsNullOrEmpty(documentIds))
            {
                throw new ArgumentNullException("Document ids cannot be null or empty");
            }
            Notify notify = NewNotifyObject(endpoint, flow);

            notify.messages = new NotificationMessageType[documentIds.Length];
            for (int i = 0; i < documentIds.Length; ++i)
            {
                NotificationMessageType notification = new NotificationMessageType();
                notification.messageCategory = NotificationMessageCategoryType.Document;
                notification.messageName     = string.Format("{0} Document", flow);
                notification.objectId        = documentIds[i];
                notification.status          = (TransactionStatusCode)
                                               Enum.Parse(typeof(TransactionStatusCode), status.ToString(), true);
                notification.statusDetail = description;
                notify.messages[i]        = notification;
            }
            return(notify);
        }
        public bool IsPushMessageDownloaded(Ekreta.Mobile.Core.Models.PushNotification.PushMessage pushMessage)
        {
            NotificationMessageType notificationType = pushMessage.NotificationType;
            int    itemId = pushMessage.ItemId;
            object obj;

            switch (notificationType)
            {
            case NotificationMessageType.Evaluation:
                obj = (object)this._evaluationDataService.GetEvaluations(this._profileDataService.GetActiveProfile()).Where <Evaluation>((Func <Evaluation, bool>)(x => x.EvaluationId == itemId)).FirstOrDefault <Evaluation>();
                break;

            case NotificationMessageType.Absence:
                obj = (object)this._absenceDataService.Get(itemId);
                break;

            case NotificationMessageType.Note:
                obj = (object)this._noteDataService.Get(this._profileDataService.GetActiveProfile(), itemId);
                break;

            case NotificationMessageType.Message:
                obj = (object)this._uzenetDataService.GetPostaladaElem(itemId);
                break;

            case NotificationMessageType.Homework:
                obj = (object)this._lessonDataService.GetByTeacherHomeworkId(itemId);
                break;

            case NotificationMessageType.Exam:
                obj = (object)this._examDataService.GetByUid(itemId);
                break;

            default:
                return(false);
            }
            return(obj != null);
        }
Beispiel #18
0
        /// <summary>
        /// Public constructor for creating instance from Message string. Message string should be Xml with proper structure.
        /// </summary>
        /// <param name="xmlMessage"> Message string containing all neccesary information. </param>
        public NotificationMessage(string xmlMessage)
        {
            if (string.IsNullOrWhiteSpace(xmlMessage))
            {
                MessageString = "";
                MessageType   = NotificationMessageType.Empty;
                return;
            }
            MessageString            = xmlMessage;
            Message                  = XDocument.Parse(xmlMessage);
            base.MainServiceName     = Message.Element("notification").Attribute("servicename").Value;
            base.SubscriberString    = Message.Element("notification").Attribute("subscriberstring").Value;
            ValidTill                = DateTime.Parse(Message.Element("notification").Attribute("validtill").Value);
            base.ValidFor            = Convert.ToInt32((ValidTill - DateTime.Now).TotalSeconds);
            base.ProcedureSchemaName = Message.Element("notification").Element("schema").Attribute("name").Value;
            base.ProcedureName       = Message.Element("notification").Element("schema").Element("procedure").Attribute("name").Value;
            if (Message.Element("notification").Element("error") != null)
            {
                Error = new NotificationMessageError(Message.Element("notification").Element("error"));
            }
            if (Message.Element("notification").Element("inserted") != null)
            {
                Inserted = new NotificationData(Message.Element("notification").Element("inserted"));
            }
            if (Message.Element("notification").Element("deleted") != null)
            {
                Deleted = new NotificationData(Message.Element("notification").Element("deleted"));
            }

            if (Inserted != null)
            {
                MessageType = NotificationMessageType.InsertedData;
            }
            if (Deleted != null)
            {
                MessageType = NotificationMessageType.DeletedData;
            }
            if (Inserted != null && Deleted != null)
            {
                MessageType = NotificationMessageType.InsertedAndDeletedData;
            }
            if (Message.Element("notification").Element("unsubscribed") != null)
            {
                MessageType = NotificationMessageType.Unsubscribed;
            }
            if (Error != null)
            {
                MessageType = NotificationMessageType.Error;
            }

            SqlCommand ProcedureCmd = new SqlCommand(base.ProcedureSchemaName + "." + base.ProcedureName);

            foreach (XElement parameter in Message.Element("notification").Element("schema").Element("procedure").Elements("parameter"))
            {
                string    parameterName  = parameter.Element("name").Value;
                SqlDbType parameterType  = (SqlDbType)Enum.Parse(typeof(SqlDbType), parameter.Element("type").Value);
                string    parameterValue = parameter.Element("value").Value;
                ProcedureCmd.Parameters.Add(AccessDB.CreateSqlParameter(parameterName, parameterType, parameterValue));
            }
            base.ProcedureParameters = ProcedureCmd.Parameters;
        }
 public void StartReceiving(ReceiverCallback callback, SubscriptionClient subscriptionClient, NotificationMessageType msgType = NotificationMessageType.All)
 {
     StartReceiving(callback, subscriptionClient, new TimeSpan(5000));
 }
Beispiel #20
0
        private static bool NotificationReceived(NotificationMessage message, NotificationMessageType type)
        {
            Console.WriteLine(@"Received Message - {0}, Type={1}", message.Body, type);

            return(true);
        }
Beispiel #21
0
 public NotificationMessage(NotificationMessageType variableType, Object variable)
 {
     VariableType = variableType;
     Variable     = variable;
 }
Beispiel #22
0
 public NotificationMessage(NotificationMessageType variableType)
 {
     VariableType = variableType;
     Variable     = null;
 }
Beispiel #23
0
 public NotificationMessage(NotificationMessageType type)
 {
     this.Type = type;
 }
 /// <param name="messageType"/>
 /// <param name="messageText"/>
 /// <param name="shortMessageText">Короткий вариант сообщения до 20 символов.</param>
 /// <param name="source">Окно/Класс в котором возникло сообщение.</param>
 public NotificationMessage(NotificationMessageType messageType, string messageText, string shortMessageText, string source)
     : this(DateTime.Now, messageType, messageText, shortMessageText, source)
 {
 }
 /// <param name="messageType"/>
 /// <param name="messageText"/>
 /// <param name="source">Окно/Класс в котором возникло сообщение.</param>
 public NotificationMessage(NotificationMessageType messageType, string messageText, [CallerMemberName] string source = null)
     : this(DateTime.Now, messageType, messageText, messageText.Substring(0, Math.Min(messageText.Length, ShortMessageTextLength)), source)
 {
 }
Beispiel #26
0
 public void AddMessage(bool valid, NotificationMessageType type, string message, Exception ex)
 {
     this.IsValid = valid;
     this.Messages.Add(new NotificationMessage(type, message, ex));
 }
Beispiel #27
0
 public NotificationMessage(NotificationMessageType type, string message, Exception ex)
 {
     SetMessage(type, message);
     this.Exception = ex;
 }
Beispiel #28
0
 public NotificationMessage(NotificationMessageType type, string message)
 {
     SetMessage(type, message);
 }
 /// <summary>
 /// set inner context of the notification
 /// </summary>
 /// <param name="messageTitle"></param>
 /// <param name="messageText"></param>
 /// <param name="_type"></param>
 public void SetMessageText(string messageTitle, string messageText, NotificationMessageType _type)
 {
     this.MessageText.Text        = messageText;
     this.MessageTitle.Text       = messageTitle;
     this.MessageTitle.Foreground = _type == NotificationMessageType.Error ? Brushes.Red : Brushes.White;
 }
Beispiel #30
0
        public async Task SendEmailAsync(
            string messageRefId,
            string subject,
            string messageContent,
            string senderEmail,
            string recipientEmail,
            string recipientName,
            bool showSenderTitleInSubject,
            NotificationMessageType notificationMessageType
            )
        {
            try
            {
                // Set Subject
                if (showSenderTitleInSubject)
                {
                    subject = _configurationSection["SenderTitle"] + " - " + subject;
                }

                // Set up email
                var email = new MimeMessage();
                email.From.Add(MailboxAddress.Parse(senderEmail));
                email.To.Add(MailboxAddress.Parse(recipientEmail));

                email.Subject = subject;

                email.Body = new TextPart(TextFormat.Html)
                {
                    Text = messageContent
                };

                // send email
                string smtPServer       = _configuration["SMTP_SERVER"] ?? _configurationSection["SMTPServer"];
                string smtpPort         = _configuration["SMTP_PORT"] ?? _configurationSection["SMTPPort"];
                string smtpUser         = _configuration["SMTP_USER_NAME"] ?? _configurationSection["SMTPUserName"];
                string smtpUserPassword = _configuration["SMTP_USER_PASSWORD"] ?? _configurationSection["SMTPUserPassword"];

                bool enableTLS = _configurationSection["EnableTLS"].ToUpper().Contains("TRUE");

                using var smtpClient = new SmtpClient();
                await smtpClient.ConnectAsync(smtPServer, int.Parse(smtpPort), enableTLS);

                await smtpClient.AuthenticateAsync(smtpUser, smtpUserPassword);

                await smtpClient.SendAsync(email);

                await smtpClient.DisconnectAsync(true);

                //Log if allowed
                if (_configurationSection["LogMailMessages"].ToUpper().Contains((notificationMessageType + "").ToUpper()))
                {
                    await _mediator.Publish(new UpdateNotificationMessageCommand
                    {
                        MessageRefId  = messageRefId,
                        MessageStatus = NotificationMessageStatus.SENT
                    });
                }
            }
            catch (Exception e)
            {
                //Log if allowed
                if (_configurationSection["LogMailMessages"].ToUpper().Contains((notificationMessageType + "").ToUpper()))
                {
                    await _mediator.Publish(new UpdateNotificationMessageCommand
                    {
                        MessageRefId  = messageRefId,
                        MessageStatus = NotificationMessageStatus.FAILED
                    });
                }

                _logger.LogError(e.Message, e.StackTrace);
            }
        }