public bool Notify(string message) { var notifier = new NotifierFactory().GetNotifier(_notifierType); bool acknowledgement = notifier.Send(message); return(acknowledgement); }
public static void Main() { // The path to the documents directory. string dataDir = Aspose.OCR.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //Initialize an instance of OcrEngine OcrEngine ocrEngine = new OcrEngine(); //Set the Image property by loading the image from file path location or an instance of MemoryStream ocrEngine.Image = ImageStream.FromFile(dataDir + "Sampleocr.bmp"); //Get an instance of INotifier INotifier processorWord = NotifierFactory.WordNotifier(); //Write a delegate to handle the Elapsed event processorWord.Elapsed += delegate { //Display the recognized text on screen Console.WriteLine(processorWord.Text); }; // Add the word processor to the OcrEngine ocrEngine.AddNotifier(processorWord); //Process the image ocrEngine.Process(); }
public static void Run() { // ExStart:GettingNotification // The path to the documents directory. string dataDir = RunExamples.GetDataDir_OMR(); // Initialize an instance of OcrEngine OcrEngine ocrEngine = new OcrEngine(); // Set the Image property by loading the image from file path location or an instance of MemoryStream ocrEngine.Image = ImageStream.FromFile(dataDir + "Sampleocr.bmp"); // Get an instance of INotifier INotifier processorWord = NotifierFactory.WordNotifier(); //Write a delegate to handle the Elapsed event processorWord.Elapsed += delegate { // Display the recognized text on screen Console.WriteLine(processorWord.Text); }; // Add the word processor to the OcrEngine ocrEngine.AddNotifier(processorWord); // Process the image ocrEngine.Process(); // ExEnd:GettingNotification }
public static void Run() { // ExStart:UsingNotifierFactory // The path to the documents directory. string dataDir = RunExamples.GetDataDir_OCR(); // Initialize an instance of OcrEngine OcrEngine ocrEngine = new OcrEngine(); // Set the Image property by loading the image from file path location or an instance of MemoryStream ocrEngine.Image = ImageStream.FromFile(dataDir + "answers.jpg"); // Get an instance of WordNotifier, Write a delegate to handle the Elapsed event and Display the recognized text on screen INotifier processorBlock = NotifierFactory.BlockNotifier(); processorBlock.Elapsed += delegate { Console.WriteLine(processorBlock.Text); }; // Add the word processor to the OcrEngine and Process the image ocrEngine.AddNotifier(processorBlock); ocrEngine.Process(); // ExEnd:UsingNotifierFactory }
public Worker(ILogger <Worker> logger, IConfiguration config, IHostApplicationLifetime lifeTime) { _logger = logger; _config = config.Get <Config>(); _lifeTime = lifeTime; _notifiers = NotifierFactory.CreateFromConfig(config, logger).ToList(); _httpClient = new LsfHttpClientImpl(_config.BaseUrl); }
private void DoTest() { NotifierFactory factory = new NotifierFactory(); INotifier notifier = factory.CreateNotifier(); string msg = notifier.Notify(); Assert.AreEqual(msg, "Message: Something"); }
public void FactoryTest() { SimpleContainer container = new SimpleContainer(); container.RegisterInstance <string>("Something"); NotifierFactory.SetProvider(() => container.Resolve <Notifier>()); DoTest(); }
public static void Execute() { var notifications = new List <Notification> { new(NotificationType.Email, "Email A"), new(NotificationType.ConnectDirect, "File X"), new(NotificationType.Nexxera, "File Y") }; notifications.ForEach(notification => NotifierFactory.Create(notification).Send()); }
private void SendMessage() { NotifierFactory notifierFactory = new NotifierFactory(); NotifierBase notifier = notifierFactory.GetNotifier(NotificationServerOption.LegacyHTTP, GetNotificationProps()); if (devicetokenRadioBtn.Checked) { notifier.SendPushNotificationForSpecificDevice(); } else { notifier.SendPushNotificationForTopic(); } }
private void ShowJsonData() { NotifierFactory notifierFactory = new NotifierFactory(); NotifierBase notifier = notifierFactory.GetNotifier(NotificationServerOption.LegacyHTTP, GetNotificationProps()); string jsonData; if (devicetokenRadioBtn.Checked) { jsonData = notifier.CreateNotificationMessageForSpecificDevice(); } else { jsonData = notifier.CreateNotificationMessageForTopic(); } jsonDataTextBox.Text = BeautifyJsonData(jsonData); }
public void SendNotification(Notification notification, GeneralOptions options) { var notifierFactory = new NotifierFactory(this, options); var notifierType = options.Common.NotifierType; var notifier = notifierFactory.GetNotifier(notifierType); try { _logger.Info($"Sending notification using {notifierType.ToString()} notifier"); notifier.Send(notification); _logger.Info("Notification sent"); } catch (Exception exception) { _exceptionHandler.Handle(exception); } }
public static IAppBuilder UsePingOwin(this IAppBuilder appBuilder, PingOwinOptions options = null) { options = options ?? new PingOwinOptions(); var connectionString = $"Data Source={options.PathToDb}pingowin.db;Version=3;Pooling=True;Max Pool Size=100;"; var databaseSettings = new DbSettings(connectionString); var migrator = new Migrator(databaseSettings); migrator.Migrate(); var conf = new NancyOptions { Bootstrapper = new PingOwinWebBootstrapper(databaseSettings) }; appBuilder.UseNancy(conf); var pingConfiguration = new PingConfiguration { RequestTimeOut = new TimeSpan(0, 0, 0, 0, options.RequestTimeOut), WarnThreshold = options.WarnThreshold }; var notifierType = NotifierType.Konsole; var slackConfig = new SlackConfig(); var notifierFactory = new NotifierFactory(notifierType, slackConfig); var transformerFactory = new TransformerFactory(notifierType, Level.OK); var processor = IoCFactory.CreateProcessor(pingConfiguration, databaseSettings, notifierFactory, transformerFactory); var serviceRunner = new ServiceRunner(new ServiceRunnerOptions { PingIntervalInMillis = options.PingIntervalInMillis, RunBackgroundThread = options.StartService }, processor); serviceRunner.StartBackgroundThread(); return(appBuilder); }
private static IEnumerable <INotifier> GenerateNotifiers(ILogger logger, IConfiguration configuration) { logger.LogInformation("Processing notifier config."); List <INotifier> notifiers = new List <INotifier>(); IConfigurationSection section = configuration.GetSection("Notifiers"); foreach (IConfigurationSection child in section.GetChildren()) { string type = child.GetValue <string>("Type"); if (!Enum.TryParse(type, out NotifierType notifier)) { logger.LogError($"Notifier Type '{ type }' is not supported."); throw new NotImplementedException(type); } notifiers.Add(NotifierFactory.Create(notifier, logger, child)); } return(notifiers); }
public SubscriptionActor() { notifierFactory = new NotifierFactory(); }