private void Execute(Operation operation) { IList <MobilePhoneEntryObject> recipients = GetRecipients(operation); if (recipients.Count == 0) { Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.NoRecipientsErrorMessage); return; } string format = _settings.GetSetting(SettingKeys.MessageFormat).GetValue <string>(); string text = operation.ToString(format); text = ReplaceUmlauts(text); text = text.Truncate(SmsMessageMaxLength, true, true); string userName = _settings.GetSetting(SettingKeys.UserName).GetValue <string>(); string password = _settings.GetSetting(SettingKeys.Password).GetValue <string>(); try { _provider.Send(userName, password, recipients.Select(r => r.PhoneNumber), text); } catch (Exception ex) { Logger.Instance.LogException(this, ex); Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SendSmsErrorMessage); } }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } string key = operation.ToString(_settings.GetSetting("Divera", "key").GetValue <string>()); TimeSpan delay = DateTime.Now - operation.Timestamp; Content content = new Content() { type = operation.ToString(_settings.GetSetting("Divera", "type").GetValue <string>()), text = operation.ToString(_settings.GetSetting("Divera", "text").GetValue <string>()), address = operation.Einsatzort.ToString(), lat = (float?)operation.Einsatzort.GeoLatitude, lng = (float?)operation.Einsatzort.GeoLongitude, ric = string.Join(",", operation.Loops), vehicle = string.Join(",", GetEMKList(operation)), delay = delay.Seconds }; HttpStatusCode result = 0; if (!SendNotification(content, key, ref result)) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorSendingNotification, result); } }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); string settingString = _settings.GetSetting("DisplayWakeUpJob", "DisplayConfiguration").GetValue <string>(); _configurations.AddRange(DisplayConfiguration.ParseSettingString(settingString)); if (_configurations.Count == 0) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.NoConfigurationsFoundError); return(false); } _autoSleepAfterMinutes = _settings.GetSetting("DisplayWakeUpJob", "TurnOffTimeout").GetValue <int>(); if (_autoSleepAfterMinutes > 0) { _autoSleepTimerThread = new Thread(AutoSleepTimerThread); _autoSleepTimerThread.Name = "Auto-sleep timer thread"; _autoSleepTimerThread.Priority = ThreadPriority.BelowNormal; _autoSleepTimerThread.IsBackground = true; _autoSleepTimerThread.Start(); } _ignoreErrorInResponse = _settings.GetSetting("DisplayWakeUpJob", "IgnoreErrorInResponse").GetValue <bool>(); return(true); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _loopsFilePath = _settings.GetSetting("OperationLoopFetcherJob", "LoopsFilePath").GetValue <string>(); _maxEntryAge = TimeSpan.FromSeconds(_settings.GetSetting("OperationLoopFetcherJob", "MaxEntryAge").GetValue <int>()); _entryDateTimeFormat = _settings.GetSetting("OperationLoopFetcherJob", "EntryDateTimeFormat").GetValue <string>(); return(true); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _addressing = serviceProvider.GetService <IAddressingServiceInternal>(); _userName = _settings.GetSetting("SMSJob", "UserName").GetValue <string>(); _password = _settings.GetSetting("SMSJob", "Password").GetValue <string>(); _provider = ExportedTypeLibrary.Import <ISmsProvider>(_settings.GetSetting("SMSJob", "Provider").GetValue <string>()); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="FaxConfiguration"/> class. /// </summary> /// <param name="serviceProvider"></param> public FaxConfiguration(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); this.FaxPath = _settings.GetSetting("FaxAlarmSource", "FaxPath").GetValue <string>(); this.ArchivePath = _settings.GetSetting("FaxAlarmSource", "ArchivePath").GetValue <string>(); this.AnalysisPath = _settings.GetSetting("FaxAlarmSource", "AnalysisPath").GetValue <string>(); this.AlarmFaxParserAlias = _settings.GetSetting("FaxAlarmSource", "AlarmfaxParser").GetValue <string>(); this.OCRSoftwarePath = _settings.GetSetting("FaxAlarmSource", "OCR.Path").GetValue <string>(); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _provider = ExportedTypeLibrary.Import <IGeoCoder>(_settings.GetSetting("Geocoding", "Provider").GetValue <string>()); if (_provider.ApiKeyRequired) { string apikey = _settings.GetSetting("Geocoding", "ApiKey").GetValue <string>(); _provider.ApiKey = apikey; } return(true); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _provider = ExportedTypeLibrary.Import<IGeoCoder>(_settings.GetSetting(SettingKeysJob.Provider).GetValue<string>()); if (_provider.IsApiKeyRequired) { _provider.ApiKey = _settings.GetSetting(SettingKeysJob.ApiKey).GetValue<string>(); } return true; }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _provider = ExportedTypeLibrary.Import <IGeoCoder>(_settings.GetSetting(SettingKeysJob.Provider).GetValue <string>()); if (_provider.IsApiKeyRequired) { _provider.ApiKey = _settings.GetSetting(SettingKeysJob.ApiKey).GetValue <string>(); } return(true); }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } string header = _settings.GetSetting(SettingKeysJob.Header).GetValue <string>(); string expression = _settings.GetSetting(SettingKeysJob.MessageContent).GetValue <string>(); string message = operation.ToString(expression); Task.Factory.StartNew(() => SendToProwl(operation, message, header)); Task.Factory.StartNew(() => SendToNotifyMyAndroid(operation, message, header)); }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } IList <MobilePhoneEntryObject> recipients = GetRecipients(operation); if (recipients.Count == 0) { Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.NoRecipientsErrorMessage); return; } string format = _settings.GetSetting("SMSJob", "MessageFormat").GetValue <string>(); string text = operation.ToString(format); text = text.Replace("Ö", "Oe").Replace("Ä", "Ae").Replace("Ü", "Ue").Replace("ö", "oe").Replace("ä", "ae").Replace("ü", "ue").Replace("ß", "ss"); // Truncate the string if it is too long text = text.Truncate(160, true, true); // Invoke the provider-send asynchronous because it is a web request and may take a while _provider.Send(_userName, _password, recipients.Select(r => r.PhoneNumber), text); }
private static Configuration LoadConfiguration(ISettingsServiceInternal settings) { Configuration configuration = new Configuration(); configuration.EnabledAlarmSources = new ReadOnlyCollection <string>(settings.GetSetting(SettingKeys.AlarmSourcesConfigurationKey).GetValue <ExportConfiguration>().GetEnabledExports()); return(configuration); }
private IEnumerable <string> GetLoopsSinceNow() { string loopsFilePath = _settings.GetSetting(SettingKeys.LoopsFilePath).GetValue <string>(); if (File.Exists(loopsFilePath)) { TimeSpan maxEntryAge = TimeSpan.FromSeconds(_settings.GetSetting(SettingKeys.MaxEntryAge).GetValue <int>()); string entryDateTimeFormat = _settings.GetSetting(SettingKeys.EntryDateTimeFormat).GetValue <string>(); string[] lines = File.ReadAllLines(loopsFilePath); // Read lines in reverse to save some time (most recent entries are appended). for (int i = lines.Length - 1; i >= 0; i--) { string line = lines[i]; string[] tokens = line.Split(';'); if (tokens.Length != 2) { continue; } string loop = tokens[0]; string timestampRaw = tokens[1]; if (string.IsNullOrWhiteSpace(loop)) { continue; } DateTime timestamp = DateTime.Now; if (!DateTime.TryParseExact(timestampRaw, entryDateTimeFormat, CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal | DateTimeStyles.AllowWhiteSpaces, out timestamp)) { continue; } if ((DateTime.Now - timestamp) > maxEntryAge) { // Speed optimization: As soon as we encounter an old entry, exit the whole process immediately. // We assume that the newest entries are last in the file, so we can easily break. break; } yield return(loop); } } }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _addressing = serviceProvider.GetService <IAddressingServiceInternal>(); _expression = _settings.GetSetting("PushJob", "MessageContent").GetValue <string>(); return(true); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _addressing = serviceProvider.GetService<IAddressingServiceInternal>(); _expression = _settings.GetSetting("PushJob", "MessageContent").GetValue<string>(); return true; }
void IAlarmSource.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); int outputPort = _settings.GetSetting(NetworkSettingKeys.OutputPort).GetValue <int>(); _server = new AlarmServer(this, outputPort); }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } string body = operation.ToString(_settings.GetSetting("eAlarm", "text").GetValue <string>()); string header = operation.ToString(_settings.GetSetting("eAlarm", "header").GetValue <string>()); string location = operation.Einsatzort.ToString(); bool encryption = _settings.GetSetting("eAlarm", "Encryption").GetValue <bool>(); string encryptionKey = _settings.GetSetting("eAlarm", "EncryptionKey").GetValue <string>(); if (encryption) { body = Helper.Encrypt(body, encryptionKey); header = Helper.Encrypt(header, encryptionKey); location = Helper.Encrypt(location, encryptionKey); } string[] to = GetRecipients(operation).Where(pushEntryObject => pushEntryObject.Consumer == "eAlarm").Select(pushEntryObject => pushEntryObject.RecipientApiKey).ToArray(); Content content = new Content() { registration_ids = to, data = new Content.Data() { awf_title = header, awf_message = body, awf_location = location } }; string message = new JavaScriptSerializer().Serialize(content); HttpStatusCode result = 0; if (SendGCMNotification("AIzaSyA5hhPTlYxJsEDniEoW8OgfxWyiUBEPiS0", message, ref result)) { Logger.Instance.LogFormat(LogType.Info, this, "Succesfully sent eAlarm notification"); } else { Logger.Instance.LogFormat(LogType.Error, this, "Error while sending eAlarm notification Errorcode: '{0}'", (int)result); } }
private void InitializeProvider() { var providerName = _settings.GetSetting(SettingKeysJob.Provider).GetValue <string>(); _provider = ExportedTypeLibrary.Import <IGeoCoder>(providerName); Logger.Instance.LogFormat(LogType.Debug, this, Properties.Resources.UsingProviderTrace, providerName); if (_provider.IsApiKeyRequired) { _provider.ApiKey = _settings.GetSetting(SettingKeysJob.ApiKey).GetValue <string>(); if (string.IsNullOrEmpty(_provider.ApiKey)) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.NoKeyForGeocodingService, providerName); } } }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _addressing = serviceProvider.GetService <IAddressingServiceInternal>(); _provider = ExportedTypeLibrary.Import <ISmsProvider>(_settings.GetSetting(SettingKeys.Provider).GetValue <string>()); return(true); }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } string body = operation.ToString(_settings.GetSetting("eAlarm", "text").GetValue <string>()); string header = operation.ToString(_settings.GetSetting("eAlarm", "header").GetValue <string>()); string location = operation.Einsatzort.ToString(); bool encryption = _settings.GetSetting("eAlarm", "Encryption").GetValue <bool>(); if (encryption) { string encryptionKey = _settings.GetSetting("eAlarm", "EncryptionKey").GetValue <string>(); body = Helper.Encrypt(body, encryptionKey); header = Helper.Encrypt(header, encryptionKey); location = Helper.Encrypt(location, encryptionKey); } string[] to = GetRecipients(operation).Where(pushEntryObject => pushEntryObject.Consumer == "eAlarm").Select(pushEntryObject => pushEntryObject.RecipientApiKey).ToArray(); Content content = new Content() { registration_ids = to, data = new Content.Data() { awf_title = header, awf_message = body, awf_location = location } }; string message = new JavaScriptSerializer().Serialize(content); HttpStatusCode result = 0; if (!SendGcmNotification(ApiKey, message, ref result)) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorSendingNotification, result); } }
private bool ShouldStoreOperation(Operation operation) { bool settingEnabled = _settingsService.GetSetting(SettingKeys.IgnoreOperationsWithSameOperationNumber).GetValue <bool>(); if (settingEnabled) { return(!_operationService.ExistsOperation(operation.OperationNumber)); } return(true); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _provider = ExportedTypeLibrary.Import<IGeoCoder>(_settings.GetSetting("Geocoding", "Provider").GetValue<string>()); if (_provider.ApiKeyRequired) { string apikey = _settings.GetSetting("Geocoding", "ApiKey").GetValue<string>(); _provider.ApiKey = apikey; } return true; }
void IAlarmSource.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); string smsParserAlias = _settings.GetSetting(SmsSettingKeys.SmsParser).GetValue <string>(); _parser = ExportedTypeLibrary.Import <IParser>(smsParserAlias); if (_parser == null) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SmsParserNotFoundError, smsParserAlias); _parser = new DefaultSMSParser(); } }
void IAlarmSource.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); string smsParserAlias = _settings.GetSetting("SmsAlarmSource", "SMSParser").GetValue<string>(); _parser = ExportedTypeLibrary.Import<IParser>(smsParserAlias); if (_parser == null) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SmsParserNotFoundError, smsParserAlias); _parser = new DefaultSMSParser(); } }
/// <summary> /// Initializes a new instance of the <see cref="FaxConfiguration"/> class. /// </summary> /// <param name="serviceProvider"></param> public FaxConfiguration(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); this.FaxPath = _settings.GetSetting("FaxAlarmSource", "FaxPath").GetValue<string>(); this.ArchivePath = _settings.GetSetting("FaxAlarmSource", "ArchivePath").GetValue<string>(); this.AnalysisPath = _settings.GetSetting("FaxAlarmSource", "AnalysisPath").GetValue<string>(); this.AlarmFaxParserAlias = _settings.GetSetting("FaxAlarmSource", "AlarmfaxParser").GetValue<string>(); this.OCRSoftware = _settings.GetSetting("FaxAlarmSource", "OCR.Software").GetValue<string>(); this.OCRSoftwarePath = _settings.GetSetting("FaxAlarmSource", "OCR.Path").GetValue<string>(); this.RoutineInterval = _settings.GetSetting("FaxAlarmSource", "Routine.Interval").GetValue<int>(); this.TestFaxKeywords = new ReadOnlyCollection<string>(_settings.GetSetting("FaxAlarmSource", "TestFaxKeywords").GetValue<string>().Split(new[] { '\n', ';' }, StringSplitOptions.RemoveEmptyEntries)); }
/// <summary> /// Initializes a new instance of the <see cref="FaxConfiguration"/> class. /// </summary> /// <param name="serviceProvider"></param> public FaxConfiguration(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); this.FaxPath = _settings.GetSetting("FaxAlarmSource", "FaxPath").GetValue <string>(); this.ArchivePath = _settings.GetSetting("FaxAlarmSource", "ArchivePath").GetValue <string>(); this.AnalysisPath = _settings.GetSetting("FaxAlarmSource", "AnalysisPath").GetValue <string>(); this.AlarmFaxParserAlias = _settings.GetSetting("FaxAlarmSource", "AlarmfaxParser").GetValue <string>(); this.OCRSoftware = _settings.GetSetting("FaxAlarmSource", "OCR.Software").GetValue <string>(); this.OCRSoftwarePath = _settings.GetSetting("FaxAlarmSource", "OCR.Path").GetValue <string>(); this.RoutineInterval = _settings.GetSetting("FaxAlarmSource", "Routine.Interval").GetValue <int>(); this.TestFaxKeywords = new ReadOnlyCollection <string>(_settings.GetSetting("FaxAlarmSource", "TestFaxKeywords").GetValue <string>().Split(new[] { '\n', ';' }, StringSplitOptions.RemoveEmptyEntries)); }
private string GetTemplateFile() { string templateFile = _settings.GetSetting(SettingKeysJob.TemplateFile).GetValue <string>(); if (!Path.IsPathRooted(templateFile)) { templateFile = Path.Combine(Utilities.GetWorkingDirectory(), templateFile); } if (!File.Exists(templateFile)) { Logger.Instance.LogFormat(LogType.Error, this, Resources.OperationPrintTemplateNotFoundError, templateFile); return(null); } return(templateFile); }
private Encoding GetEncodingFromSettings() { try { int codepage = _settings.GetSetting("MailAlarmSource", "CodePage").GetValue <int>(); if (codepage != 0) { return(Encoding.GetEncoding(codepage)); } } catch (Exception) { } return(null); }
public void Execute(IJobContext context, Operation operation) { if (context.Phase == JobPhase.OnOperationSurfaced) { string[] programs = _settings.GetSetting(SettingKeys.ExternalTool).GetStringArray(); foreach (string program in programs) { try { Task.Factory.StartNew(() => ProgramStarter.StartProgramTask(program, this)); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, CreatingProgramFailed, program); Logger.Instance.LogException(this, ex); } } } }
internal void PushIncomingAlarm(string alarmText) { if (_parser == null) { return; } string message = ""; using (XmlReader reader = XmlReader.Create(new StringReader(alarmText))) { reader.ReadToFollowing("message"); message = reader.ReadElementContentAsString(); } message = _settings.GetSetting(SettingKeys.ReplaceDictionary).GetValue <ReplaceDictionary>().ReplaceInString(message); if (!_serviceProvider.GetService <IAlarmFilter>().QueryAcceptSource(message)) { return; } Operation operation = null; try { operation = _parser.Parse(new[] { message }); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SmsParserError); Logger.Instance.LogException(this, ex); } if (operation == null) { return; } OnNewAlarm(new AlarmSourceEventArgs(operation)); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _addressing = serviceProvider.GetService<IAddressingServiceInternal>(); string smtpHostName = _settings.GetSetting("MailingJob", "HostName").GetValue<string>(); string userName = _settings.GetSetting("MailingJob", "UserName").GetValue<string>(); string userPassword = _settings.GetSetting("MailingJob", "Password").GetValue<string>(); int smtpPort = _settings.GetSetting("MailingJob", "Port").GetValue<int>(); bool smtpAuthenticate = _settings.GetSetting("MailingJob", "Authenticate").GetValue<bool>(); bool useSsl = _settings.GetSetting("MailingJob", "UseSsl").GetValue<bool>(); _senderEmail = Helpers.ParseAddress(_settings.GetSetting("MailingJob", "SenderAddress").GetValue<string>()); if (_senderEmail == null) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.NoSenderAddressMessage); return false; } _smptClient = new SmtpClient(smtpHostName, smtpPort); _smptClient.EnableSsl = useSsl; if (smtpAuthenticate) { _smptClient.Credentials = new NetworkCredential(userName, userPassword); } _mailBodyFormat = _settings.GetSetting("MailingJob", "EMailBody").GetValue<string>(); _mailSubject = _settings.GetSetting("MailingJob", "EMailSubject").GetValue<string>(); if (string.IsNullOrWhiteSpace(_mailSubject)) { _mailSubject = _settings.GetSetting("Shared", "FD.Name").GetValue<string>() + " - Neuer Alarm"; } _attachImage = _settings.GetSetting("MailingJob", "AttachImage").GetValue<bool>(); return true; }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _loopsFilePath = _settings.GetSetting("OperationLoopFetcherJob", "LoopsFilePath").GetValue<string>(); _maxEntryAge = TimeSpan.FromSeconds(_settings.GetSetting("OperationLoopFetcherJob", "MaxEntryAge").GetValue<int>()); _entryDateTimeFormat = _settings.GetSetting("OperationLoopFetcherJob", "EntryDateTimeFormat").GetValue<string>(); return true; }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); string settingString = _settings.GetSetting("DisplayWakeUpJob", "DisplayConfiguration").GetValue<string>(); _configurations.AddRange(DisplayConfiguration.ParseSettingString(settingString)); if (_configurations.Count == 0) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.NoConfigurationsFoundError); return false; } _autoSleepAfterMinutes = _settings.GetSetting("DisplayWakeUpJob", "TurnOffTimeout").GetValue<int>(); if (_autoSleepAfterMinutes > 0) { _autoSleepTimerThread = new Thread(AutoSleepTimerThread); _autoSleepTimerThread.Name = "Auto-sleep timer thread"; _autoSleepTimerThread.Priority = ThreadPriority.BelowNormal; _autoSleepTimerThread.IsBackground = true; _autoSleepTimerThread.Start(); } _ignoreErrorInResponse = _settings.GetSetting("DisplayWakeUpJob", "IgnoreErrorInResponse").GetValue<bool>(); return true; }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); _addressing = serviceProvider.GetService <IAddressingServiceInternal>(); string smtpHostName = _settings.GetSetting("MailingJob", "HostName").GetValue <string>(); string userName = _settings.GetSetting("MailingJob", "UserName").GetValue <string>(); string userPassword = _settings.GetSetting("MailingJob", "Password").GetValue <string>(); int smtpPort = _settings.GetSetting("MailingJob", "Port").GetValue <int>(); bool smtpAuthenticate = _settings.GetSetting("MailingJob", "Authenticate").GetValue <bool>(); bool useSsl = _settings.GetSetting("MailingJob", "UseSsl").GetValue <bool>(); _senderEmail = Helpers.ParseAddress(_settings.GetSetting("MailingJob", "SenderAddress").GetValue <string>()); if (_senderEmail == null) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.NoSenderAddressMessage); return(false); } _smptClient = new SmtpClient(smtpHostName, smtpPort); _smptClient.EnableSsl = useSsl; if (smtpAuthenticate) { _smptClient.Credentials = new NetworkCredential(userName, userPassword); } _mailBodyFormat = _settings.GetSetting("MailingJob", "EMailBody").GetValue <string>(); _mailSubject = _settings.GetSetting("MailingJob", "EMailSubject").GetValue <string>(); if (string.IsNullOrWhiteSpace(_mailSubject)) { _mailSubject = _settings.GetSetting("Shared", "FD.Name").GetValue <string>() + " - Neuer Alarm"; } _attachImage = _settings.GetSetting("MailingJob", "AttachImage").GetValue <bool>(); return(true); }
/// <summary> /// Initializes a new instance of the <see cref="MailConfiguration"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> public MailConfiguration(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService <ISettingsServiceInternal>(); ServerName = _settings.GetSetting("MailAlarmSource", "ServerName").GetValue <string>(); Port = (ushort)_settings.GetSetting("MailAlarmSource", "Port").GetValue <int>(); UserName = _settings.GetSetting("MailAlarmSource", "UserName").GetValue <string>(); Password = _settings.GetSetting("MailAlarmSource", "Password").GetValue <string>(); PollInterval = _settings.GetSetting("MailAlarmSource", "PollInterval").GetValue <int>(); SSL = _settings.GetSetting("MailAlarmSource", "SSL").GetValue <bool>(); MailSubject = _settings.GetSetting("MailAlarmSource", "MailSubject").GetValue <string>(); MailSender = _settings.GetSetting("MailAlarmSource", "MailSender").GetValue <string>(); AnalyseAttachment = _settings.GetSetting("MailAlarmSource", "AnalyseAttachment").GetValue <bool>(); AttachmentName = _settings.GetSetting("MailAlarmSource", "AttachmentName").GetValue <string>(); ParserAlias = _settings.GetSetting("MailAlarmSource", "MailParser").GetValue <string>(); }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _addressing = serviceProvider.GetService<IAddressingServiceInternal>(); _provider = ExportedTypeLibrary.Import<ISmsProvider>(_settings.GetSetting(SettingKeys.Provider).GetValue<string>()); return true; }
bool IJob.Initialize(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); _addressing = serviceProvider.GetService<IAddressingServiceInternal>(); _userName = _settings.GetSetting("SMSJob", "UserName").GetValue<string>(); _password = _settings.GetSetting("SMSJob", "Password").GetValue<string>(); _provider = ExportedTypeLibrary.Import<ISmsProvider>(_settings.GetSetting("SMSJob", "Provider").GetValue<string>()); return true; }
private static Configuration LoadConfiguration(ISettingsServiceInternal settings) { Configuration configuration = new Configuration(); configuration.EnabledAlarmSources = new ReadOnlyCollection<string>(settings.GetSetting(SettingKeys.AlarmSourcesConfigurationKey).GetValue<ExportConfiguration>().GetEnabledExports()); return configuration; }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } string header = operation.ToString(_settings.GetSetting("Alarmiator", "header").GetValue <string>()); string body = operation.ToString(_settings.GetSetting("Alarmiator", "text").GetValue <string>()).Replace("|", "\n"); string location = operation.Einsatzort.ToString(); string longitude = operation.Einsatzort.GeoLongitudeString; string latitude = operation.Einsatzort.GeoLatitudeString; string timestamp = operation.Timestamp.ToString("s"); string key = operation.Keywords.ToString(); string operationId = operation.OperationGuid.ToString(); string operationAlert = "EINSATZ " + _settings.GetSetting("Shared", "FD.Name").GetValue <string>(); string sound = "Alarm.mp3"; string operationTimestamp = operation.TimestampIncome.ToString("s"); var content = new Content() { notification = new Content.Notification() { alert = operationAlert, title = operationAlert, body = key + "\nEinsatzort: " + location, sound = sound }, data = new Content.Data() { opid = operationId, opkeyword = header, opdesc = body, oplat = latitude, oplon = longitude, optimestamp = timestamp, optimestampIncoming = operationTimestamp, content_available = "1" } }; //Send to Alarmiator content.registration_ids = GetRecipients(operation) .Where(pushEntryObject => pushEntryObject.Consumer == "Alarmiator") .Select(pushEntryObject => pushEntryObject.RecipientApiKey) .ToArray(); Logger.Instance.LogFormat(LogType.Debug, this, Properties.Resources.DebugSendMessage, $"Receiver count: {content.registration_ids.Length}"); HttpStatusCode result = 0; if (!SendNotification(content, ref result)) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorSendingNotification, result); } else { Logger.Instance.LogFormat(LogType.Debug, this, Properties.Resources.DebugSendMessage, "Push to ALARMIATOR successfully sent!"); } }
/// <summary> /// Initializes a new instance of the <see cref="MailConfiguration"/> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> public MailConfiguration(IServiceProvider serviceProvider) { _settings = serviceProvider.GetService<ISettingsServiceInternal>(); ServerName = _settings.GetSetting("MailAlarmSource", "ServerName").GetValue<string>(); Port = (ushort)_settings.GetSetting("MailAlarmSource", "Port").GetValue<int>(); UserName = _settings.GetSetting("MailAlarmSource", "UserName").GetValue<string>(); Password = _settings.GetSetting("MailAlarmSource", "Password").GetValue<string>(); PollInterval = _settings.GetSetting("MailAlarmSource", "PollInterval").GetValue<int>(); SSL = _settings.GetSetting("MailAlarmSource", "SSL").GetValue<bool>(); MailSubject = _settings.GetSetting("MailAlarmSource", "MailSubject").GetValue<string>(); MailSender = _settings.GetSetting("MailAlarmSource", "MailSender").GetValue<string>(); AnalyseAttachment = _settings.GetSetting("MailAlarmSource", "AnalyseAttachment").GetValue<bool>(); AttachmentName = _settings.GetSetting("MailAlarmSource", "AttachmentName").GetValue<string>(); ParserAlias = _settings.GetSetting("MailAlarmSource", "MailParser").GetValue<string>(); }
private IEnumerable <string> RetrieveEnabledJobs() { return(_settingsService.GetSetting(SettingKeys.JobsConfigurationKey).GetValue <ExportConfiguration>().GetEnabledExports()); }
void IJob.Execute(IJobContext context, Operation operation) { if (context.Phase != JobPhase.AfterOperationStored) { return; } string body = operation.ToString(_settings.GetSetting("eAlarm", "text").GetValue <string>()); string header = operation.ToString(_settings.GetSetting("eAlarm", "header").GetValue <string>()); string location = operation.Einsatzort.ToString(); string latlng = operation.Einsatzort.GeoLatLng; string timestamp = operation.Timestamp.ToString("s"); string key = operation.OperationGuid.ToString(); bool encryption = _settings.GetSetting("eAlarm", "Encryption").GetValue <bool>(); if (encryption) { string encryptionKey = _settings.GetSetting("eAlarm", "EncryptionKey").GetValue <string>(); body = Helper.Encrypt(body, encryptionKey); header = Helper.Encrypt(header, encryptionKey); location = Helper.Encrypt(location, encryptionKey); latlng = Helper.Encrypt(latlng, encryptionKey); timestamp = Helper.Encrypt(timestamp, encryptionKey); key = Helper.Encrypt(key, encryptionKey); } Content content = new Content() { data = new Content.Data() { awf_key = key, awf_title = header, awf_message = body, awf_location = location, awf_latlng = latlng, awf_timestamp = timestamp } }; //Send to eAlarm content.registration_ids = GetRecipients(operation) .Where(pushEntryObject => pushEntryObject.Consumer == "eAlarm") .Select(pushEntryObject => pushEntryObject.RecipientApiKey) .ToArray(); HttpStatusCode result = 0; if (!SendNotification(CloudMessagingService.GCM, content, ref result)) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorSendingNotification, result); } //Send to fAlarm content.registration_ids = GetRecipients(operation) .Where(pushEntryObject => pushEntryObject.Consumer == "fAlarm") .Select(pushEntryObject => pushEntryObject.RecipientApiKey) .ToArray(); result = 0; if (!SendNotification(CloudMessagingService.FCM, content, ref result)) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.ErrorSendingNotification, result); } }