/// <summary> /// on new message, updates the config /// </summary> /// <param name="sender"></param> /// <param name="message"></param> public void UpdateSettings(object sender, string message) { JObject command = JObject.Parse(message); int commandID = (int)command["commandID"]; // check the commandID for a matching response if (commandID == (int)CommandEnum.GetConfigCommand) { // in case of GetConfigCommand ImageServiceConfig fromService = ImageServiceConfig.FromJSON((string)command["config"]); foreach (string handler in fromService.handlers) { model_handlers.Add(handler); } model_thumbSize = fromService.thumbSize.ToString(); model_logName = fromService.logName; model_OPD = fromService.OPD; model_source = fromService.source; } else if (commandID == (int)CommandEnum.CloseCommand) { // in case of CloseCommand update string dir = (string)command["path"]; if (model_handlers != null) { model_handlers.Remove(dir); } } }
public event EventHandler <CommandRecievedEventArgs> CommandRecieved; // The event that notifies about a new Command being recieved #endregion /// <summary> /// constructor /// </summary> /// <param name="log"></param> public DirectoryManager(ILoggingService log, ImageServiceConfig config, EventHandler <DirectoryCloseEventArgs> update) { m_logging = log; //one controller to rule them all m_controller = new ImageController(new ImageModel( ConfigurationManager.AppSettings["OutputDir"], config.thumbSize)); //enlisting our newly created handlers to command recieved and our OnDirClosed(server method) to closing //event of handlers for (int i = 0; i < config.handlers.Count(); i++) { // set the required event handlers IDirectoryHandler dH = new DirectoryHandler(m_controller, m_logging); CommandRecieved += dH.OnCommandRecieved; dH.DirectoryClose += update; // start handle directory try { dH.StartHandleDirectory(config.handlers[i]); } catch (Exception e) { m_logging.Log("directory" + config.handlers[i] + "couldn't be handeled" + "because" + e.Message, MessageTypeEnum.FAIL); } } }
// GET: Config public ActionResult Config() { //this is the configuration page control method ImageServiceConfig config = configModel.getConfig(); if (config != null) { //case we got a configuration ViewBag.config = config; ViewBag.handlers = config.handlers; while (!configModel.removed) { //waiting for handler removal and to avoid busy waiting we use delay Task.Delay(1000); } } else { //if we cannot get our configuration we show blank results config = new ImageServiceConfig(null, 0, "not available", "not available", "not available"); ViewBag.config = config; } return(View()); }
public ImageController(IOptionsSnapshot <ImageServiceConfig> imageServiceConfig, IOptionsSnapshot <RabbitMqConfig> rabbitMqConfig, IImageService imageService) { this._imageServiceConfig = imageServiceConfig.Value; this._rabbitMqConfig = rabbitMqConfig.Value; this._imageService = imageService; }
public ImageService( IImageRepository imageRepository, IMapper mapper, IOptions <ImageServiceConfig> options, ILogger <ImageService> logger) { _imageRepository = imageRepository; _mapper = mapper; _config = options.Value; _logger = logger; }
/// <summary> /// constructor /// </summary> /// <param name="log"></param> public ImageServer(ILoggingService log, EventLog eventLogger) { m_eventLogger = eventLogger; //taking info given in the config List <string> dest = ConfigurationManager.AppSettings["Handler"].Split(';').ToList(); int thumbSize = Int32.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]); string sourceName = ConfigurationManager.AppSettings["SourceName"]; string logName = ConfigurationManager.AppSettings["LogName"]; string outputDir = ConfigurationManager.AppSettings["OutputDir"]; // build the config object m_config = new ImageServiceConfig(dest, thumbSize, sourceName, logName, outputDir); dm = new DirectoryManager(log, m_config, this.OnDirClosed); guis = new GUIServer(9999, log, this.OnNewMessage); eventLogger.EntryWritten += WhenEntryWritten; eventLogger.EnableRaisingEvents = true; guis.Start(); }
private void initialize() { imageService = _dataService.GetService(SettingsRegistry.ServiceTitleImageSaver); ImageServiceConfig = imageService.Config; MusicTickerToImagePath = ImageServiceConfig.GetParameterValue("FilenameMusic") as string; _lastFmService = _dataService.Services.FirstOrDefault(service => service.Config.ServiceName == SettingsRegistry.ServiceTitleMusicTicker); _lastFmService.GetData((dataObject) => { CurrentTrack = dataObject as MusicTrackInfo; CurrentTrack.PropertyChanged += (o, e) => { if (e.PropertyName == MusicTrackInfo.ImagePropertyName) { if (imageService.Config.Enabled) { UI.Dispatch(() => { IsNeedSave = true; IsNeedSave = false; }); } } }; }); Config = _lastFmService.Config; Config.PropertyChanged += (o, e) => { if (e.PropertyName == ServiceConfig.EnabledPropertyName) { if (Config.Enabled) { Win.ShowMusicTicker(); } else { Win.HideMusicTicker(); } } }; AppConfig = (Application.Current as App).AppConfig; }
/// <summary> /// constructor /// </summary> /// <param name="log"></param> public ImageServer(ILoggingService log, EventLog eventLogger) { m_eventLogger = eventLogger; //taking info given in the config List <string> dest = ConfigurationManager.AppSettings["Handler"].Split(';').ToList(); int thumbSize = Int32.Parse(ConfigurationManager.AppSettings["ThumbnailSize"]); string sourceName = ConfigurationManager.AppSettings["SourceName"]; string logName = ConfigurationManager.AppSettings["LogName"]; string outputDir = ConfigurationManager.AppSettings["OutputDir"]; // build the config object m_config = new ImageServiceConfig(dest, thumbSize, sourceName, logName, outputDir); // build the DirectoryManager dm = new DirectoryManager(log, m_config, this.OnDirClosed); // build the Server serv = new Communication.Server(9900, log, m_config.handlers[0]); // set the required event handler eventLogger.EnableRaisingEvents = true; serv.Start(); // start the Server }
private void Initialize() { if (Chats == null) { Chats = new ObservableCollection <IChat>(); } imageService = _generalDataService.GetService(SettingsRegistry.ServiceTitleImageSaver); ImageServiceConfig = imageService.Config; StatusToImagePath = ImageServiceConfig.GetParameterValue("FilenameStatus") as string; ChatsView = CollectionViewSource.GetDefaultView(Chats) as ListCollectionView; ChatsView.CustomSort = new SortViewerCount(); _dataService.ChatStatusHandler = (chat) => { UI.Dispatch(() => { Chats.RemoveAll(item => item.ChatName == chat.ChatName); if (chat.Enabled == true) { Chats.Add(chat); chat.Status.PropertyChanged += (o, e) => { if (ImageServiceConfig.Enabled) { IsNeedSave = true; IsNeedSave = false; } }; } if (ChatsView.NeedsRefresh) { ChatsView.Refresh(); } }); }; AppConfig = Ubiquitous.Default.Config.AppConfig; }