Exemple #1
0
        public static void ShowToast(string appId, RedgateNotification notification)
        {
            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            if (!string.IsNullOrWhiteSpace(notification.ImagePath))
            {
                toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

                String      imagePath     = "file:///" + notification.ImagePath;
                XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
                imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;
            }

            var stringElements = toastXml.GetElementsByTagName("text");

            stringElements[0].AppendChild(toastXml.CreateTextNode(notification.Title));
            stringElements[1].AppendChild(toastXml.CreateTextNode(notification.Message));

            var toast = new ToastNotification(toastXml);

            var events = new ToastEvents();

            toast.Activated += events.ToastActivated;
            toast.Dismissed += events.ToastDismissed;
            toast.Failed    += events.ToastFailed;

            // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut!
            ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
        }
Exemple #2
0
        public Task Consume(ConsumeContext <DatabaseRegistered> context)
        {
            var dbDetails = context.Message;

            var notification = new RedgateNotification
            {
                Title     = "Database Registry",
                Message   = $"{dbDetails.Database.Server}-{dbDetails.Database.Database} has been registered",
                ImagePath = Path.GetFullPath("img/search.png")
            };

            CommonHelper.SaveNotification(notification);

            CommonHelper.ShowToast(AppId, notification);

            return(Task.CompletedTask);
        }
        public Task Consume(ConsumeContext <SchemaChanged> context)
        {
            var dbDetails         = context.Message;
            var connectionDetails = dbDetails.Database.ConnectionDetails;
            var notification      = new RedgateNotification
            {
                Title     = "Schema change",
                Message   = $"{connectionDetails.Database} now has {dbDetails.Database.Tables.Count} tables",
                ImagePath = Path.GetFullPath("img/search.png")
            };

            CommonHelper.SaveNotification(notification);

            CommonHelper.ShowToast(AppId, notification);

            return(Task.CompletedTask);
        }
Exemple #4
0
        public static void SaveNotification(RedgateNotification notification)
        {
            {
                var subPath = $@"C:\dev\Stores\notifications";

                if (!Directory.Exists(subPath))
                {
                    Directory.CreateDirectory(subPath);
                }

                var filename = $"{DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss")}.txt";

                var serilisedNotification = JsonConvert.SerializeObject(notification);

                var path = Path.Combine(subPath, filename);

                File.WriteAllText(path, serilisedNotification);
            }
        }