private void generarAlerta(string mensaje) { NotificationConfig config = new NotificationConfig(); config.Title = Core.Constantes.Generales.nickNameDeLaApp; config.Html = mensaje; config.Height = 75; config.Width = 300; config.HideDelay = 10000; config.BodyStyle = "padding:10px"; config.Icon = Icon.UserAlert; config.PinEvent = "mouseover"; SlideIn show = new SlideIn(); show.Anchor = AnchorPoint.Right; SlideOut hide = new SlideOut(); show.Anchor = AnchorPoint.Right; config.ShowFx = show; config.HideFx = hide; X.Msg.Notify(config).Show(); }
public static NotificationConfig CreateNotificationConfig( string organizationId, string notificationConfigId, string projectId, string topicName) { OrganizationName orgName = new OrganizationName(organizationId); TopicName pubsubTopic = new TopicName(projectId, topicName); SecurityCenterClient client = SecurityCenterClient.Create(); CreateNotificationConfigRequest request = new CreateNotificationConfigRequest { ParentAsOrganizationName = orgName, ConfigId = notificationConfigId, NotificationConfig = new NotificationConfig { Description = ".Net notification config", PubsubTopicAsTopicName = pubsubTopic, StreamingConfig = new NotificationConfig.Types.StreamingConfig { Filter = "state = \"ACTIVE\"" } } }; NotificationConfig response = client.CreateNotificationConfig(request); Console.WriteLine($"Notification config was created: {response}"); return(response); }
public void ValuesAreCorrectlySaved() { // Arrange var notify = new NotificationConfig { PopupEnabled = true, PopupDisplayCorner = Corner.TopLeft, PopupDisplay = "TestDisplay" }; var cfg = new Mock <IConfig>(); cfg.SetupGet(c => c.Notifications).Returns(notify); // Act var vm = new PopupNotificationSettings(cfg.Object, null) { SelectedCorner = Corner.BottomRight, SelectedDisplay = "test", Enabled = false }; vm.SaveTo(cfg.Object); // Assert Assert.AreEqual(vm.SelectedDisplay, notify.PopupDisplay); Assert.AreEqual(vm.SelectedCorner, notify.PopupDisplayCorner); Assert.AreEqual(vm.Enabled, notify.PopupEnabled); }
public async Task <ResultModel> DeleteVehicleLocation(int id) { if (id > 0) { var entity = await _context.VEHICLE_LOCATION.FirstOrDefaultAsync(x => x.VehicleId == id && x.Deleted == false); if (entity != null) { entity.Deleted = true; await _context.SaveChangesAsync(); return(new ResultModel { Result = true, Message = NotificationConfig.DeleteSuccessMessage($"{entity.VehicleId}") }); } else { return(new ResultModel { Result = false, Message = NotificationConfig.NotFoundError }); } } else { return(new ResultModel { Result = false, Message = NotificationConfig.NotFoundMessage($"{id}") }); } }
public static async Task SendMailNotification(NotificationConfig cfg, string title, string body) { await Task.Run(() => { var fromAddress = new MailAddress(cfg.GmailUsername, "Necrobot Notifier"); //var toAddress = new MailAddress(cfg.Recipients); string fromPassword = cfg.GmailPassword; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; using (var message = new MailMessage() { Subject = title, Body = body }) { message.From = fromAddress; foreach (var item in cfg.Recipients.Split(';')) { message.To.Add(item); } smtp.Send(message); } }); }
void Start() { string channelId = "channel_id_1"; string channelName = "Test Channel"; string channelDescription = "Test notification are sent througth this channel"; // with publisher manager you can get a publisher for your notification channel // you can create it with `CreatePublisher` or you can just get a previously created // publisher using its channel id with `GetPublisher`. // // you should not worry calling `CreatePublisher` multiple times since if // there is a publisher for that channel then it is returned. publisher = PublisherManager.Instance.CreatePublisher(channelId, channelName, channelDescription); // having a notification config is optional // it helps to setup some option from inspector instead of // writing it in code for each notification you need. NotificationConfig notificationConfig = GetComponent <NotificationConfig>(); // with setting notification config of a publisher if some options of a notification // is not set by `Notification` object then they are set from given config. publisher.SetNotificationConfig(notificationConfig.GetDataConfig()); }
public async Task <ResultModel> CreateExpenseSubType(ExpenseSubTypeVm expenseSubTypeVm) { try { var entity = new ExpenseSubType { ExpenseTypeId = expenseSubTypeVm.ExpenseTypeId, ExpenseSubTypeName = expenseSubTypeVm.ExpenseSubTypeName, CreatedBy = _currentUserService.UserId, CreateDate = _dateTime.Now, }; await _context.L_EXPENSE_SUB_TYPE.AddAsync(entity); await _context.SaveChangesAsync(); return(new ResultModel { Result = true, Message = NotificationConfig.InsertSuccessMessage($"{expenseSubTypeVm.ExpenseSubTypeName}"), Id = entity.ExpenseSubTypeId.ToString() }); } catch (Exception) { return(new ResultModel { Result = false, Message = NotificationConfig.InsertErrorMessage($"{expenseSubTypeVm.ExpenseSubTypeName}") }); } }
public void SavedValuesAreAppliedDuringConstruction() { // Arrange var notifi = new NotificationConfig { PopupEnabled = true, SoundEnabled = true, ToastsEnabled = true }; var cfg = new Mock <IConfig>(); cfg.SetupGet(c => c.Notifications).Returns(notifi); // Act var vm = new NotificationSettings(cfg.Object); // Assert var toast = vm.EnabledNotifications.OfType <ToastNotificationSettings>().SingleOrDefault(); Assert.IsNotNull(toast); var sound = vm.EnabledNotifications.OfType <SoundNotificationSettings>().SingleOrDefault(); Assert.IsNotNull(sound); var popup = vm.EnabledNotifications.OfType <PopupNotificationSettings>().SingleOrDefault(); Assert.IsNotNull(popup); }
public async Task <ResultModel> DeleteExpense(int id) { if (id > 0) { var entity = await _context.EXPENSE.FirstOrDefaultAsync(x => x.ExpenseId == id && x.Deleted == false); if (entity != null) { entity.Deleted = true; await _context.SaveChangesAsync(); return(new ResultModel { Result = true, Message = NotificationConfig.DeleteSuccessMessage($"{entity.BillNo}") }); } else { return(new ResultModel { Result = false, Message = NotificationConfig.NotFoundError }); } } else { return(new ResultModel { Result = false, Message = NotificationConfig.NotFoundMessage($"{id}") }); } }
public NotificationFactory(IOptions <NotificationConfig> notificationSettings, IProducer producer, INotificationService notificationService, IService <SystemSetting> systemSettingService) { _notificationSettings = notificationSettings.Value; _producer = producer; _notificationService = notificationService; _systemSettingService = systemSettingService; }
public async Task <IActionResult> GetConfig() { if (this.User.Identity == null) { return(Unauthorized()); } if (!this.User.Identity.IsAuthenticated) { return(Unauthorized()); } var admin = await userService.GetOrCreateAsync(this.User); if (admin.Role < Role.ADMIN) { return(Forbid()); } var config = new NotificationConfig() { Period = int.Parse(Environment.GetEnvironmentVariable("NOTIFICATION_PERIOD") ?? "1"), ApiKey = Environment.GetEnvironmentVariable("NOTIFICATION_API_KEY") }; return(new JsonResult(config)); }
public void SaveWritesToConfig() { // Arrange var notify = new NotificationConfig { SoundEnabled = true, SoundFileName = "file.name" }; var cfg = new Mock <IConfig>(); cfg.SetupGet(c => c.Notifications).Returns(notify); var vm = new SoundNotificationSettings(cfg.Object) { Enabled = false, SoundFile = "test" }; // Act vm.SaveTo(cfg.Object); // Assert Assert.AreEqual(false, notify.SoundEnabled); Assert.AreEqual("test", notify.SoundFileName); }
public static void Show(NotificationConfig config) { TryInitOverlayWin(); var notificationManager = new NotificationManager(); if (config.Scenario == NotificationScenario.WarningTrigger) { notificationManager.Show( new RecogTriggerViewModel(ServiceLocator.Current.GetInstance <IEventAggregator>()) { Content = new NotificationContent { Title = config.Title, Message = config.Msg, Type = GetNotificationType(config) } }, expirationTime: config.Length); } else { notificationManager.Show(new NotificationContent { Title = config.Title, Message = config.Msg, Type = GetNotificationType(config) }, expirationTime: config.Length); } }
public static NotificationConfig UpdateNotificationConfig( string organizationId, string notificationConfigId, string projectId, string topicName) { NotificationConfigName notificationConfigName = new NotificationConfigName(organizationId, notificationConfigId); TopicName pubsubTopic = new TopicName(projectId, topicName); NotificationConfig configToUpdate = new NotificationConfig { NotificationConfigName = notificationConfigName, Description = "updated description", PubsubTopicAsTopicName = pubsubTopic, StreamingConfig = new StreamingConfig { Filter = "state = \"INACTIVE\"" } }; FieldMask fieldMask = new FieldMask { Paths = { "description", "pubsub_topic", "streaming_config.filter" } }; SecurityCenterClient client = SecurityCenterClient.Create(); NotificationConfig updatedConfig = client.UpdateNotificationConfig(configToUpdate, fieldMask); Console.WriteLine($"Notification config updated: {updatedConfig}"); return(updatedConfig); }
public async Task <ResultModel> CreateVehicleLocation(VehicleLocationVm vehicleLocationVm) { try { var entity = new Domain.Entities.VehicleLocation { Latitude = vehicleLocationVm.Latitude, Longitude = vehicleLocationVm.Longitude, TripDate = vehicleLocationVm.TripDate, TripTime = vehicleLocationVm.TripTime, Speed = vehicleLocationVm.Speed, Altitude = vehicleLocationVm.Altitude, VehicleId = vehicleLocationVm.VehicleId }; await _context.VEHICLE_LOCATION.AddAsync(entity); await _context.SaveChangesAsync(); return(new ResultModel { Result = true, Message = NotificationConfig.InsertSuccessMessage($"{vehicleLocationVm.VehicleId}"), Id = entity.VehicleLocationId.ToString() }); } catch (Exception) { return(new ResultModel { Result = false, Message = NotificationConfig.InsertErrorMessage($"{vehicleLocationVm.VehicleId}") }); } }
public int SendNotification(NotificationConfig notificationConfig) { AndroidNotification notification = notificationConfig.CreateAndroidNotification(); return(AndroidNotificationCenter .SendNotification(notification, "default_channel")); }
public NotificationConfig GetNotificationConfig(List <Dictionary <string, string> > configDict) { NotificationConfig config = new NotificationConfig(); config.SNSTopic = configDict.Single(x => x["key"] == "SNSTopic")["value"]; config.SQS = configDict.Single(x => x["key"] == "SQS")["value"]; return(config); }
public async Task <bool> CreateNotificationConfigurationAsync(NotificationConfig body, CancellationToken cancellationToken = default) { var response = await GetNotificationsUrl() .PostJsonAsync(body, cancellationToken) .ConfigureAwait(false); return(response.IsSuccessStatusCode); }
public Producer(IOptions <NotificationConfig> notificationSettings) { _notificationSettings = notificationSettings.Value; _connectionFactory = new ConnectionFactory() { HostName = _notificationSettings.HostName, VirtualHost = _notificationSettings.VirtualHost, AutomaticRecoveryEnabled = true }; }
public async Task <bool> UpdateNotificationConfigurationAsync(string id, NotificationConfig body, CancellationToken cancellationToken = default) { var response = await GetNotificationsUrl() .AppendPathSegment(id) .PutJsonAsync(body, cancellationToken) .ConfigureAwait(false); return(response.IsSuccessStatusCode); }
public static void Show(NotificationConfig config) { var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(GetNotificationStr(config)); var toastNotification = new ToastNotification(xmlDoc); _toastNotifier.Show(toastNotification); }
public static NotificationConfig GetNotificationConfig(string organizationId, string configId) { SecurityCenterClient client = SecurityCenterClient.Create(); NotificationConfigName notificationConfigName = new NotificationConfigName(organizationId, configId); NotificationConfig response = client.GetNotificationConfig(notificationConfigName); Console.WriteLine($"Notification config: {response}"); return(response); }
/// <summary> /// Print some timeline item metadata information. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <param name='itemId'> /// ID of the timeline item to print metadata information for. /// </param> public static void PrintTimelineItemMetadata(MirrorService service, String itemId) { try { TimelineItem timelineItem = service.Timeline.Get(itemId).Fetch(); Console.WriteLine("Timeline item ID: " + timelineItem.Id); if (timelineItem.IsDeleted.HasValue && timelineItem.IsDeleted.Value) { Console.WriteLine("Timeline item has been deleted"); } else { Contact creator = timelineItem.Creator; if (creator != null) { Console.WriteLine("Timeline item created by " + creator.DisplayName); } Console.WriteLine("Timeline item created on " + timelineItem.Created); Console.WriteLine( "Timeline item displayed on " + timelineItem.DisplayTime); String inReplyTo = timelineItem.InReplyTo; if (!String.IsNullOrEmpty(inReplyTo)) { Console.WriteLine("Timeline item is a reply to " + inReplyTo); } String text = timelineItem.Text; if (!String.IsNullOrEmpty(text)) { Console.WriteLine("Timeline item has text: " + text); } foreach (Contact contact in timelineItem.Recipients) { Console.WriteLine("Timeline item is shared with: " + contact.Id); } NotificationConfig notification = timelineItem.Notification; if (notification != null) { Console.WriteLine( "Notification delivery time: " + notification.DeliveryTime); Console.WriteLine("Notification level: " + notification.Level); } // See mirror.timeline.attachments.get to learn how to download the // attachment's content. foreach (Attachment attachment in timelineItem.Attachments) { Console.WriteLine("Attachment ID: " + attachment.Id); Console.WriteLine(" > Content-Type: " + attachment.ContentType); } } } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } }
private static string GetNotificationStr(NotificationConfig config) { return($@"<toast duration='long'><visual> <binding template='ToastGeneric'> <text hint-maxLines='1'>{config.Title}</text> <text>{config.Msg}</text> </binding> </visual> <actions> <action content='Ok' activationType='background' arguments='dismiss'/> </actions> <audio silent='true'/></toast>"); }
private void newBanner_Click(object sender, RoutedEventArgs e) { try { NotificationConfig config = new NotificationConfig(); File.WriteAllText(Helper.NextAvailableFilename(Helper.TemplateFolder + $"\\{config.TemplateName}.notif"), CreateConfigFile.Create(config)); refresh_Click(sender, e); } catch (Exception) { Helper.Error("Error", "Unable to create new template."); } }
public static void AddNotifications(this IServiceCollection services, IConfiguration configuration) { var providerString = configuration["NotificationProviders"]; var providers = providerString.Split(','); if (providers.Contains(NotificationProvider.SmtpEmail)) { services.AddSmtpEmailSender(configuration); } NotificationConfig.InitConfigFile().Wait(); services.AddTransient <NotificationConfig>(); services.AddTransient <INotificationProvider, NotificationProvider>(); }
/// <summary> /// 弹出提示框 /// </summary> /// <param name="type"></param> /// <param name="content"></param> /// <param name="autoHide"></param> /// <param name="hideDelay"></param> /// <param name="draggable"></param> public static void NotifyMsg(ResourceManager res, MsgType type, string content, bool autoHide = false, int hideDelay = 5000, bool draggable = true) { res.RegisterIcon(Icon.Information); NotificationConfig config = new NotificationConfig(); config.ID = Guid.NewGuid().ToString(); config.Closable = true; config.BringToFront = true; config.CloseVisible = true; config.Html = content; config.AutoHide = autoHide; config.HideDelay = hideDelay; config.Draggable = draggable; config.Closable = true; switch (type) { case MsgType.Prompt: config.Icon = Icon.Information; config.Title = "提示"; break; case MsgType.Warning: config.Icon = Icon.ApplicationError; config.Title = "警告"; break; case MsgType.Error: config.Icon = Icon.Cancel; config.Title = "错误"; break; } config.Modal = false; config.Resizable = true; config.Shadow = true; NotificationAlignConfig aliginConfig = new NotificationAlignConfig(); aliginConfig.ElementAnchor = AnchorPoint.BottomRight; aliginConfig.TargetAnchor = AnchorPoint.BottomRight; aliginConfig.OffsetX = -20; aliginConfig.OffsetY = -20; config.AlignCfg = aliginConfig; Ext.Net.Notification.Show(config); }
public async Task <ResultModel> UpdateExpense(UpdateExpenseVm updateExpenseVm) { try { if (updateExpenseVm.ExpenseId > 0) { var entity = new Expense { ExpenseId = updateExpenseVm.ExpenseId, ExpenseTypeId = updateExpenseVm.ExpenseTypeId, ExpenseSubTypeId = updateExpenseVm.ExpenseSubTypeId, BillNo = updateExpenseVm.BillNo, Quantity = updateExpenseVm.Quantity, BillingDate = updateExpenseVm.BillingDate, BillingAmount = updateExpenseVm.BillingAmount, VehicleId = updateExpenseVm.VehicleId, UpdateBy = _currentUserService.UserId, UpdateDate = _dateTime.Now, }; _context.EXPENSE.Update(entity); await _context.SaveChangesAsync(); return(new ResultModel { Result = true, Message = NotificationConfig.UpdateSuccessMessage($"{updateExpenseVm.BillNo}"), Id = entity.ExpenseId.ToString() }); } else { return(new ResultModel { Result = false, Message = NotificationConfig.NotFoundMessage($"{updateExpenseVm.BillNo} ") }); } } catch (Exception) { return(new ResultModel { Result = false, Message = NotificationConfig.UpdateErrorMessage($"{updateExpenseVm.BillNo}") }); } }
// // Ext.NET UI Message Construction public static void Message(string title, string msg, string type, int hideDelay = 15000, bool isPinned = false, int width = 250, int height = 150) { NotificationConfig notificationConfig = new NotificationConfig(); notificationConfig.Title = title; notificationConfig.Html = msg; //Hiding Delay in mlseconds notificationConfig.HideDelay = hideDelay; //Height and Width notificationConfig.Width = width; notificationConfig.Height = height; //Type if (type == "success") { notificationConfig.Icon = Icon.Accept; } else if (type == "info") { notificationConfig.Icon = Icon.Information; } else if (type == "warning") { notificationConfig.Icon = Icon.AsteriskYellow; } else if (type == "error") { notificationConfig.Icon = Icon.Exclamation; } else if (type == "help") { notificationConfig.Icon = Icon.Help; } //Pinning if (isPinned) { notificationConfig.ShowPin = true; notificationConfig.Pinned = true; notificationConfig.PinEvent = "click"; } notificationConfig.BodyStyle = "background-color: #f9f9f9;"; Notification.Show(notificationConfig); }
public static void ChangeText(NotificationConfig __instance) { if (__instance.subject != null && __instance.subject is HumanAI && ((HumanAI)__instance.subject).animal != null) { HumanAI animal = (HumanAI)__instance.subject; if (__instance.id.StartsWith("growingUp")) { __instance.text = Localization.GetText("notificationTitle_willGrowUpTomorrow").Replace("%firstName%", animal.GetFullName()); } else if (__instance.id.StartsWith("dyingOldAge")) { __instance.text = Localization.GetText("notificationTitle_isApproachingEndOfLife").Replace("%firstName%", animal.GetFullName()); } } }