public void FireNotification(NotificationContent notificationContent)
        {
            if (SubscriptionBrowsers.Subscriptions.Any())
            {
                if (SubscriptionBrowsers.Subscriptions.ContainsKey(notificationContent.Browser))
                {
                    var pushSubscription = SubscriptionBrowsers.Subscriptions[notificationContent.Browser].ToPushSubscription();

                    var vapidDetails = new VapidDetails(this.ApplicationMailTo, this.ApplicationPublicKey, this.ApplicationPrivateKey);

                    var data = Newtonsoft.Json.JsonConvert.SerializeObject(notificationContent);

                    var webPushClient = new WebPushClient();
                    webPushClient.SendNotification(pushSubscription, data, vapidDetails);
                }
                else
                {
                    throw new Exception("There is no subscription for this browser.");
                }
            }
            else
            {
                throw new Exception("There isn't any subscriptions");
            }
        }
        public void NotifyExtended(string title, string msg)
        {
            if (_busy)
            {
                _queue.Enqueue(new Tuple <string, string>(title, msg));
                return;
            }

            _busy = true;
            Dispatcher.Invoke(() =>
            {
                NotificationText.Text  = msg;
                NotificationTitle.Text = title;
                NotificationContainer.LayoutTransform.BeginAnimation(ScaleTransform.ScaleYProperty,
                                                                     new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200))
                {
                    EasingFunction = new QuadraticEase()
                });
                NotificationContent.BeginAnimation(OpacityProperty,
                                                   new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(150))
                {
                    EasingFunction = new QuadraticEase()
                });
                NotificationTimeGovernor.LayoutTransform.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(_notificationDuration)));
                _n.Start();
            });
        }
예제 #3
0
        public void ScheduleLocalNotification()
        {
            if (!InitCheck())
            {
                return;
            }

            var notif = new NotificationContent();

            notif.title    = title;
            notif.subtitle = subtitle;
            notif.body     = message;

            notif.userInfo = new Dictionary <string, object>();
            notif.userInfo.Add("string", "OK");
            notif.userInfo.Add("number", 3);

            if (fakeNewUpdate)
            {
                notif.userInfo.Add("newUpdate", true);
            }

            notif.categoryId = categoryId;

            // Increase badge number (iOS only)
            notif.badge = Notifications.GetAppIconBadgeNumber() + 1;

            DateTime triggerDate = DateTime.Now + new TimeSpan(delayHours, delayMinutes, delaySeconds);

            Notifications.ScheduleLocalNotification(triggerDate, notif);
        }
예제 #4
0
        public void ShowNotif(string titulo, Cita info, string tipo)
        {
            MenuItem            curItem = new MenuItem();
            NotificationContent content = new NotificationContent
            {
                Title   = titulo,
                Message = "Mañana a las " + info.Fecha.TimeOfDay + " tienes una cita con " + info.NombreCliente,
                Type    = NotificationType.Information
            };

            switch (tipo)
            {
            case "info":
                content.Type = NotificationType.Information;
                break;

            case "error":
                content.Type = NotificationType.Error;
                break;
            }

            notifManager.Show(content);

            curItem.Header = ("Cita con " + info.NombreCliente);
            curItem.SetBinding(MenuItem.CommandProperty, new Binding("ButtonInfoCita"));
            curItem.CommandParameter = info;
            Notificaciones.Items.Add(curItem);
        }
        private void _n_Tick(object sender, EventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                NotificationContainer.RenderTransform.BeginAnimation(TranslateTransform.XProperty,
                                                                     new DoubleAnimation(0, -50, TimeSpan.FromMilliseconds(250))
                {
                    EasingFunction = new QuadraticEase()
                });
                NotificationContent.BeginAnimation(OpacityProperty,
                                                   new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(200))
                {
                    EasingFunction = new QuadraticEase()
                });
            });
            _n.Stop();
            _busy = false;
            if (_queue.Count <= 0)
            {
                return;
            }
            var tuple = _queue.Dequeue();

            NotifyExtended(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4);
        }
 private void SendNotification()
 {
     Notifications.Send(NotificationContent.CreateWithText("Hey, just testing a feature!"), SendNotificationTarget.Users(FormUserList()), () =>
     {
         _console.LogD("Notifications sent!");
     }, OnError);
 }
예제 #7
0
        protected override void SendAddtionalNotification()
        {
            string table1;

            string[]            p   = new string[] { };
            string[]            d   = new string[] { };
            NotificationContent msg = new NotificationContent();

            foreach (DataRow row in nc.GetDataTable("tbresult").Rows)
            {
                if (!p.Contains(row["userno"].ToString()))
                {
                    Array.Resize(ref p, p.Length + 1);
                    p.SetValue(row["userno"].ToString(), p.Length - 1);
                    //string userno = row["userno"].ToString();
                    msg.AddTo(GetMailAddressByEmployeeIdFromOA(row["userno"].ToString()));
                }
            }
            table1 = GetHTMLTable(nc.GetDataTable("tbresult").DefaultView.ToTable(), null, null);

            if (nc.GetDataTable("tbresult").DefaultView.ToTable().Rows.Count > 0)
            {
                table1 = "以下已点收GB 物料 ,请技术人员配合检验 <br/>" + table1;
            }
            msg.AddCc("*****@*****.**");
            msg.AddCc("*****@*****.**");
            msg.AddCc("*****@*****.**");
            msg.AddCc("*****@*****.**");
            msg.AddBcc("*****@*****.**");
            msg.subject = this.subject;
            msg.content = GetContentHead() + table1 + GetContentFooter();
            msg.AddNotify(new MailNotify());
            msg.Update();
            msg.Dispose();
        }
예제 #8
0
        public void SendNotifications(IMessageService messageService, INotifyService notifyService, TimeSpan timeSpan)
        {
            var messages      = messageService.GetNewerThan(DateTime.Now - timeSpan);
            var notifications = new List <Notification>();

            foreach (var message in messages)
            {
                var recipients = new List <string>();
                message.Receivers.ForEach(r => recipients.Add(r.Email));
                message.CC.ForEach(cc => recipients.Add(cc.Email));
                message.BCC.ForEach(bcc => recipients.Add(bcc.Email));

                var content = new NotificationContent()
                {
                    Sender  = message.Sender.Email,
                    Subject = message.Subject,
                    Body    = message.MessageBody
                };

                notifications.AddRange(recipients.Select(r => new Notification()
                {
                    Content        = JsonConvert.SerializeObject(content),
                    ContentType    = "application/json",
                    RecipientsList = new List <string> {
                        r
                    },
                    WithAttachments = message.Attachments.Any()
                }));
            }

            notifyService.SendNotifications(notifications);
            notifyService.UpdateConfig();
        }
예제 #9
0
        public void ScheduleLocalNotification(string id, TimeSpan delay, NotificationContent content, NotificationRepeat repeat)
        {
            if (repeat == NotificationRepeat.None)
            {
                ScheduleLocalNotification(id, delay, content);
                return;
            }

            if (!mIsInitialized)
            {
                Debug.Log("Please initialize first.");
                return;
            }

            // Prepare iOSNotificationContent
            var iOSContent = iOSNotificationHelper.ToIOSNotificationContent(content);

            // Prepare dateComponents
            var fireDate       = DateTime.Now + delay;
            var dateComponents = new iOSDateComponents();

            dateComponents.year   = fireDate.Year;
            dateComponents.month  = fireDate.Month;
            dateComponents.day    = fireDate.Day;
            dateComponents.hour   = fireDate.Hour;
            dateComponents.minute = fireDate.Minute;
            dateComponents.second = fireDate.Second;

            iOSNotificationNative._ScheduleRepeatLocalNotification(id, ref iOSContent, ref dateComponents, repeat);
        }
예제 #10
0
        async Task ExecuteSendPushNotificationCommand(string tag)
        {
            var id = await MobileCenter.GetInstallIdAsync();

            var content = new NotificationContent();
            var target  = new NotificationTarget();

            content.Body  = "This is a test!";
            content.Title = "push sent from mobile device";

            target.Devices = new string[] { id.ToString() };

            //if (!string.IsNullOrEmpty(tag))
            //target.Audiences = new List<string>() { tag };

            var push = new MobileCenterNotification();

            push.Content = content;
            push.Target  = target;

            push.Content.CustomData = new Dictionary <string, string>()
            {
                { "hello", "mahdi" }
            };

            var httpclient = new HttpClient();

            var jsonin = JsonConvert.SerializeObject(push);

            var res = await httpclient.PostAsync <string>("http://mobilecenterpush.azurewebsites.net/api/sendpush", push);
        }
예제 #11
0
 public Notification(
     string to,
     NotificationContent content)
 {
     To      = to;
     Content = content;
 }
예제 #12
0
        public void SendMail(NotificationContent email)
        {
            string smtpFrom      = ConfigurationManager.AppSettings["SMTP_FROM"];
            string smtpUser      = ConfigurationManager.AppSettings["SMTP_USERNAME"];
            string smtpPassword  = ConfigurationManager.AppSettings["SMTP_PASSWORD"];
            string smtpHost      = ConfigurationManager.AppSettings["SMTP_HOST"];
            int    smtpPort      = int.Parse(ConfigurationManager.AppSettings["SMTP_PORT"]);
            bool   smtpEnableSsl = bool.Parse(ConfigurationManager.AppSettings["SMTP_ENABLE_SSL"]);

            // Create an SMTP client with the specified host name and port.
            using (SmtpClient client = new SmtpClient(smtpHost, smtpPort))
            {
                // Create a network credential with your SMTP user name and password.
                client.Credentials = new NetworkCredential(smtpUser, smtpPassword);

                // Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then
                // the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL.
                client.EnableSsl = true;

                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress(smtpFrom);
                foreach (var item in email.SendTo)
                {
                    mailMessage.To.Add(item);
                }
                mailMessage.Subject = email.Subject;
                mailMessage.Body    = email.Body;

                mailMessage.IsBodyHtml = true;

                client.Send(mailMessage);
            }
        }
예제 #13
0
        internal static NotificationContent ToCrossPlatformNotificationContent(iOSNotificationContent iOSContent, out bool isRemote)
        {
            var content = new NotificationContent();

            content.title      = iOSContent.title;
            content.subtitle   = iOSContent.subtitle;
            content.body       = iOSContent.body;
            content.badge      = iOSContent.badge;
            content.categoryId = iOSContent.categoryId;

            // Decode user info JSON.
            var userInfo = Json.Deserialize(iOSContent.userInfoJson) as Dictionary <string, object>;

            isRemote = false;

            if (userInfo.ContainsKey(IOS_USERINFO_ORIGIN_KEY) && userInfo[IOS_USERINFO_ORIGIN_KEY].Equals(IOS_USERINFO_EM_KEY))
            {
                // This is a local notification created by us.
                // Extract the actual user info and assign it to the returned content.
                content.userInfo = userInfo[IOS_USERINFO_DATA_KEY] != null ? userInfo[IOS_USERINFO_DATA_KEY] as Dictionary <string, object> : new Dictionary <string, object>();
            }
            else
            {
                // This is probably a remote notification created by APNS.
                // We'll just return the original userInfo.
                isRemote         = userInfo.ContainsKey("aps");
                content.userInfo = userInfo;
            }

            return(content);
        }
예제 #14
0
        public void ScheduleLocalNotification(string id, DateTime fireDate, NotificationContent content)
        {
            fireDate = fireDate.ToLocalTime();
            TimeSpan delay = fireDate <= DateTime.Now ? TimeSpan.Zero : fireDate - DateTime.Now;

            ScheduleLocalNotification(id, delay, content);
        }
예제 #15
0
        public void 特定カテゴリ通知API呼び出しテスト()
        {
            var notificationContent = new NotificationContent();

            notificationContent.Message = "test_message";
            notificationContent.Tags    = new List <string>();
            notificationContent.Tags.Add("tag1");
            notificationContent.Tags.Add("tag3");
            var json          = JsonConvert.SerializeObject(notificationContent);
            var stringContent = new StringContent(json, Encoding.UTF8, Constant.Http.ContentType);
            var expected      = stringContent.ReadAsStringAsync().ToString();
            HttpResponseMessage httpResponseMessage = this.CreateResponseMessage(Message.Ok, System.Net.HttpStatusCode.OK);

            this.httpHandler.Setup(m => m.PostAsync(Constant.Api.NotificationUrl, It.IsAny <StringContent>())).ReturnsAsync(httpResponseMessage);
            this.pushManager = new PushManager(this.httpHandler.Object);
            var categories = new List <NotificationCategory>();

            categories.Add(new NotificationCategory("tag1", "tag1", true));
            categories.Add(new NotificationCategory("tag2", "tag2", false));
            categories.Add(new NotificationCategory("tag3", "tag3", true));
            var result = this.pushManager.SendAsync("test_message", categories);

            this.httpHandler.Verify(m => m.PostAsync(Constant.Api.NotificationUrl, It.Is <StringContent>(x => x.ReadAsStringAsync().ToString().Equals(expected))));
            Assert.AreEqual(result.Result, Message.Ok);
        }
예제 #16
0
        protected override void SendAddtionalNotification()
        {
            Hashtable args = new Hashtable();

            args = Base.GetParameter(this.ToString(), nc.ToString());
            string mailcc;
            string managerId;
            int    day1, day2, day3, day4, day5;

            if (args == null || args.Count != 5)
            {
                day1 = 1; day2 = 2; day3 = 3; day4 = 4; day5 = 5;
            }
            else
            {
                day1 = int.Parse(args["day1"].ToString());
                day2 = day1 + int.Parse(args["day2"].ToString());
                day3 = day2 + int.Parse(args["day3"].ToString());
                day4 = day3 + int.Parse(args["day4"].ToString());
                day5 = day4 + int.Parse(args["day5"].ToString());
            }
            string[] title = new string[] { "产品", "区域", "客户代码", "客户简称", "业务", "姓名", "未逾期", "逾期款", "本月到期", "逾期" + day1 + "月",
                                            "逾期" + day2 + "月", "逾期" + day3 + "月", "逾期" + day4 + "月", "逾期" + day5 + "月", "超过" + day5 + "月", "账款合计", "本月应收", "逾期应收", "本月总应收" };
            int[]    width = new int[] { 40, 40, 70, 80, 60, 60, 80, 80, 80, 80, 80, 80, 80, 80, 80, 90, 80, 80, 80 };
            string[] p     = new string[] { };

            foreach (DataRow row in nc.GetDataTable("tblresult").Rows)
            {
                if (p.Contains(row["userno"].ToString()))
                {
                    continue;
                }
                Array.Resize(ref p, p.Length + 1);
                p.SetValue(row["userno"].ToString(), p.Length - 1);

                nc.GetDataTable("tblresult").DefaultView.RowFilter = " userno='" + row["userno"].ToString() + "'";

                NotificationContent msg = new NotificationContent();
                //msg.AddTo("*****@*****.**");
                //抄送给直属主管
                //msg.AddTo(row["userno"].ToString() + "@" + Base.GetMailAccountDomain());
                //mailcc = GetManagerIdByEmployeeIdFromOA(row["userno"].ToString());
                //if (mailcc.ToString() != "")
                //{
                //    mailcc = mailcc +  "@" + Base.GetMailAccountDomain();
                //    msg.AddCc(mailcc);
                //}
                msg.AddTo(GetMailAddressByEmployeeIdFromOA(row["userno"].ToString()));
                managerId = GetManagerIdByEmployeeIdFromOA(row["userno"].ToString());
                if (managerId != null && managerId.ToString() != "" && !managerId.ToString().Equals("C0002") && !managerId.ToString().Equals("C0616"))
                {
                    msg.AddCc(GetMailAddressByEmployeeIdFromOA(managerId));
                }
                msg.subject = this.subject;
                msg.content = GetContent(nc.GetDataTable("tblresult").DefaultView.ToTable(), title, width);
                msg.AddNotify(new MailNotify());
                msg.Update();
                msg.Dispose();
            }
        }
예제 #17
0
        void UpdatePendingNotificationList()
        {
            Notifications.GetPendingLocalNotifications(pendingNotifs =>
            {
                StringBuilder sb = new StringBuilder();
                foreach (var req in pendingNotifs)
                {
                    NotificationContent content = req.content;

                    sb.Append("ID: " + req.id.ToString() + "\n")
                    .Append("Title: " + content.title + "\n")
                    .Append("Subtitle: " + content.subtitle + "\n")
                    .Append("Body: " + content.body + "\n")
                    .Append("Badge: " + content.badge.ToString() + "\n")
                    .Append("UserInfo: " + Json.Serialize(content.userInfo) + "\n")
                    .Append("CategoryID: " + content.categoryId + "\n")
                    .Append("NextTriggerDate: " + req.nextTriggerDate.ToShortDateString() + "\n")
                    .Append("Repeat: " + req.repeat.ToString() + "\n")
                    .Append("-------------------------\n");
                }

                var listText = sb.ToString();

                // Display list of pending notifications
                if (!pendingNotificationList.text.Equals(orgNotificationListText) || !string.IsNullOrEmpty(listText))
                {
                    pendingNotificationList.text = sb.ToString();
                }
            });
        }
예제 #18
0
        public void ScheduleLocalNotification(string title, string message)
        {
            if (!InitCheck())
            {
                return;
            }
            Debug.Log("ScheduleLocalNotification()");
            var notif = new NotificationContent();

            notif.title    = title;
            notif.subtitle = "Subtitle";
            notif.body     = message;

            notif.userInfo = new Dictionary <string, object>();
            notif.userInfo.Add("string", "OK");
            notif.userInfo.Add("number", 3);


            // Increase badge number (iOS only)
            notif.badge = Notifications.GetAppIconBadgeNumber() + 1;

            DateTime triggerDate = DateTime.Now + new TimeSpan(0, 0, 10);

            Notifications.ScheduleLocalNotification(triggerDate, notif);

            //NativeUI.Alert("Alert", "Sending notifications");
        }
예제 #19
0
        public ProgressNotification()
        {
            IconContent.Add(new Box
            {
                RelativeSizeAxes = Axes.Both,
            });

            Content.Add(textDrawable = new OsuTextFlowContainer(t =>
            {
                t.TextSize = 16;
            })
            {
                Colour           = OsuColour.Gray(128),
                AutoSizeAxes     = Axes.Y,
                RelativeSizeAxes = Axes.X,
            });

            NotificationContent.Add(progressBar = new ProgressBar
            {
                Origin           = Anchor.BottomLeft,
                Anchor           = Anchor.BottomLeft,
                RelativeSizeAxes = Axes.X,
            });

            State = ProgressNotificationState.Queued;

            // don't close on click by default.
            Activated = () => false;
        }
예제 #20
0
        /// <summary>
        /// ハンドルされない例外発生時
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            try {
                e.Handled = true;

                // 例外情報をファイルに保存する
                string jsonCode = JsonConvert.SerializeObject(e.Exception, Formatting.Indented);
                using (FileStream fs = new FileStream(UnhandledExceptionInfoFileName, FileMode.Create)) {
                    using (StreamWriter sw = new StreamWriter(fs)) {
                        sw.WriteLine(jsonCode);
                    }
                }

                // ハンドルされない例外の発生を通知する
                NotificationManager nm = new NotificationManager();
                NotificationContent nc = new NotificationContent()
                {
                    Title   = Current.MainWindow?.Title ?? "",
                    Message = MessageText.UnhandledExceptionOccured,
                    Type    = NotificationType.Warning
                };
                nm.Show(nc, expirationTime: new TimeSpan(0, 0, 10), onClick: () => {
                    Process.Start(UnhandledExceptionInfoFileName);
                });
            }
            catch (Exception) { }
        }
예제 #21
0
    private void SendNotification(string message, string recepientId)
    {
        var messageData = new Dictionary <string, string> {
            { "open_messages_for_id", GetSocial.User.Id }
        };

        var builder = GetSocialAction.CreateBuilder("open_chat_message");

        builder.AddActionData(messageData);

        var notificationContent = NotificationContent.NotificationWithText(message)
                                  .WithTitle(GetSocial.User.DisplayName)
                                  .WithAction(builder.Build());

        var recepients = new List <string> {
            recepientId
        };

        GetSocial.User.SendNotification(recepients, notificationContent, summary =>
        {
            MNP.HidePreloader();
        }, error =>
        {
            MNP.HidePreloader();
        });
    }
예제 #22
0
        internal static iOSNotificationContent ToIOSNotificationContent(NotificationContent content)
        {
            // Encode user info into JSON, attach our own private info for recognization.
            var dict = new Dictionary <string, object>();

            dict.Add(IOS_USERINFO_ORIGIN_KEY, IOS_USERINFO_EM_KEY);
            dict.Add(IOS_USERINFO_DATA_KEY, content.userInfo != null ? content.userInfo : new Dictionary <string, object>());

            var iOSContent = new iOSNotificationContent();

            iOSContent.title        = content.title;
            iOSContent.subtitle     = content.subtitle;
            iOSContent.body         = content.body;
            iOSContent.badge        = content.badge;
            iOSContent.userInfoJson = Json.Serialize(dict);

            // Determine the category for this notification.
            // If no valid category specified by the user, the default one is used.
            var category = EM_Settings.Notifications.GetCategoryWithId(content.categoryId);

            if (category == null)
            {
                category = EM_Settings.Notifications.DefaultCategory;
            }

            // Set the category ID.
            iOSContent.categoryId = category.id;

            // Extract sound settings from category.
            // Note that an empty sound name is seen as "using default sound" from native side.
            iOSContent.enableSound = category.sound != NotificationCategory.SoundOptions.Off;
            iOSContent.soundName   = category.sound == NotificationCategory.SoundOptions.Custom ? category.soundName : null;

            return(iOSContent);
        }
예제 #23
0
 private static void DisplayToastrNotification(NotificationContent nc)
 {
     if (!notificationsOn)
     {
         return;
     }
     notificationManager.Show(nc, areaName: "WindowArea");
 }
 public CreateNotificationCommand(NotificationCorrelationId notificationCorrelationId, Username username, NotificationTitle notificationTitle, NotificationContent notificationContent, DateTime operationDate)
 {
     NotificationCorrelationId = notificationCorrelationId;
     Username            = username;
     NotificationTitle   = notificationTitle;
     NotificationContent = notificationContent;
     OperationDate       = operationDate;
 }
        public void プッシュ通知の呼び出し先で処理が失敗すると例外が発生する()
        {
            var notificationContent = new NotificationContent();

            notificationContent.Message = "test_message";

            Assert.ThrowsAsync(typeof(Exception), () => this.notificationControllerEx.Post(notificationContent));
        }
 /// <summary>
 /// 分发事件
 /// </summary>
 /// <param name="eventKey">事件Key</param>
 /// <param name="notific">通知</param>
 public void DispatchEvent(string eventKey, NotificationContent notific)
 {
     if (!eventListeners.ContainsKey(eventKey))
     {
         return;
     }
     eventListeners[eventKey](notific);
 }
        private async void ShowToastError(string text)
        {
            var content = new NotificationContent {
                Title = "", Message = text, Type = NotificationType.Error
            };

            await _notificationManager.ShowAsync(content, "WindowArea");
        }
 public NotificationAreaMessage(string source, NotificationSource sourceType, NotificationContent contentType)
 {
     this.contentType = contentType;
     this.sourceType = sourceType;
     this.source = source;
     if (source == null)
     throw new ArgumentNullException ("Notification source can't be null.");
     InitComponent ();
 }
예제 #29
0
        /// <summary>
        /// Send noti to fcm
        /// </summary>
        /// <param name="fcmOption"></param>
        /// <param name="notiModel"></param>
        /// <returns></returns>
        public static async Task SendNotiAsync(FcmProviderOptions fcmOption, NotificationContent notiModel, string token)
        {
            try
            {
                /* request */
                WebRequest tRequest = WebRequest.Create(fcmOption.ApiUrl);
                tRequest.Method = "post";
                tRequest.Headers.Add(string.Format("Authorization: key={0}", fcmOption.LegacyServerKey));
                tRequest.ContentType = "application/json";

                /* data */
                var payload = new
                {
                    to                = token,
                    priority          = 10, // 10 is better than high priority
                    content_available = true,
                    notification      = new
                    {
                        title        = notiModel.Title,
                        body         = notiModel.Body,
                        icon         = "logo512.png",
                        click_action = fcmOption.ClientSideUrl + notiModel.ActionUrl,
                    },
                    //data = new
                    //{
                    //    dataId = notiModel.DataId,
                    //    type = notiModel.NotificationType.ToString()
                    //}
                };

                /* send to fcm */
                string postbody  = JsonConvert.SerializeObject(payload).ToString();
                Byte[] byteArray = Encoding.UTF8.GetBytes(postbody);
                tRequest.ContentLength = byteArray.Length;
                using (Stream dataStream = tRequest.GetRequestStream())
                {
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    using (WebResponse tResponse = await tRequest.GetResponseAsync())
                    {
                        using (Stream dataStreamResponse = tResponse.GetResponseStream())
                        {
                            if (dataStreamResponse != null)
                            {
                                using (StreamReader tReader = new StreamReader(dataStreamResponse))
                                {
                                    string sResponseFromServer = tReader.ReadToEnd();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void Notify(INotificationReceiver receiver, NotificationContent content)
        {
            var mail = BuildMailMessage(receiver as SmtpMailNotificationReceiver, content);
            // Because SmtpClient.Send() is not thread safe, do not make it static.
            // Create smtp client object on the fly.
            var smtpClient = MailUtility.CreateSmtpClientFromConfiguration(_smtpConfiguration);

            smtpClient.Send(mail);
        }
        public void NotifyExtended(string title, string msg, NotificationType type, uint timeMs = 4000)
        {
            if (_busy)
            {
                Dispatcher.Invoke(() =>
                {
                    if (msg != NotificationText.Text || title != NotificationTitle.Text)
                    {
                        _queue.Enqueue(new Tuple <string, string, NotificationType, uint>(title, msg, type, timeMs));
                    }
                });
                return;
            }

            _busy = true;
            Dispatcher.Invoke(() =>
            {
                NotificationText.Text  = msg;
                NotificationTitle.Text = title;
                switch (type)
                {
                case NotificationType.Normal:
                    NotificationColorBorder.Background = R.Brushes.ChatPartyBrush;    // System.Windows.Application.Current.FindResource("ChatPartyBrush") as SolidColorBrush;
                    break;

                case NotificationType.Success:
                    NotificationColorBorder.Background = R.Brushes.GreenBrush;     // System.Windows.Application.Current.FindResource("GreenBrush") as SolidColorBrush;
                    break;

                case NotificationType.Warning:
                    NotificationColorBorder.Background = R.Brushes.Tier4DungeonBrush;     // System.Windows.Application.Current.FindResource("Tier4DungeonBrush") as SolidColorBrush;
                    break;

                case NotificationType.Error:
                    NotificationColorBorder.Background = R.Brushes.HpBrush;     //System.Windows.Application.Current.FindResource("HpBrush") as SolidColorBrush;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(type), type, null);
                }
                RefreshTopmost();
                NotificationContainer.RenderTransform.BeginAnimation(TranslateTransform.XProperty,
                                                                     new DoubleAnimation(50, 0, TimeSpan.FromMilliseconds(250))
                {
                    EasingFunction = new QuadraticEase()
                });
                NotificationContent.BeginAnimation(OpacityProperty,
                                                   new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200))
                {
                    EasingFunction = new QuadraticEase()
                });

                NotificationTimeGovernor.LayoutTransform.BeginAnimation(ScaleTransform.ScaleXProperty, new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(timeMs)));
                _n.Interval = TimeSpan.FromMilliseconds(timeMs);
                _n.Start();
            });
        }
        public NotificationBubble(string source, NotificationSource sourceType, 
				    NotificationContent contentType)
            : base(WindowType.Popup)
        {
            this.contentType = contentType;
            this.sourceType = sourceType;
            this.source = source;
            if (source == null)
            throw new ArgumentNullException ("Notification source can't be null.");
            InitComponent ();
        }
예제 #33
0
 private void PushForce(NotificationContent notification)
 {
     var window = new PopupNotificationForm(notification);
     var h = window.Height;
     var x = _origin.X;
     var y = _origin.Y - h;
     window.Left = x;
     window.Top = y;
     _windows.Add(window);
     MakeRoomInStack(window);
     window.SizeChanged += OnWindowSizeChanged;
     AnimateFadeIn(window);
     window.Closed	+= OnWindowClosed;
     window.Show();
 }
예제 #34
0
        public void PushNotification(NotificationContent content)
        {
            if(content == null) throw new ArgumentNullException("content");
            if(IsDisposed) throw new ObjectDisposedException(GetType().Name);

            if(_windows.Count < MaximumVisibleNotifications)
            {
                PushForce(content);
            }
            else
            {
                _queue.Enqueue(content);
            }
        }