public void OnMessage(String message) { if (message.Equals(Infrastructure.Enums.ResultMessgeEnum.Success.ToString()) || message.Contains(Infrastructure.Enums.ResultMessgeEnum.Success.ToString())) { } else if (message.Equals(Infrastructure.Enums.ResultMessgeEnum.Fail.ToString())) { } else if (message != null) { try { ImageServiceAppConfigItem initialConfig = ImageServiceAppConfigItem.FromJSON(message); Console.WriteLine(initialConfig.OutputFolder); this.OutputDirectory = initialConfig.OutputFolder; Console.WriteLine(initialConfig.LogName); this.LogName = initialConfig.LogName; Console.WriteLine(initialConfig.SourceName); this.SourceName = initialConfig.SourceName; Console.WriteLine(initialConfig.ThumbnailSize); this.ThumbnailSize = initialConfig.ThumbnailSize; string[] folders = initialConfig.Handlers.Split(';'); this.handlers = new List <string>(); foreach (String folder in folders) { //if (!this.handlers.Contains(folder)) //{ this.handlers.Add(folder); //} } } catch (Exception) { } } }
/// <summary> /// detemines what to do when got a meesage (either got feedback for the operation or got the /// primary settings of the app config). /// </summary> /// <param name="message">The message.</param> public void GotMeesage(string message) { Console.WriteLine("in settings view model, got: " + message); if (message.Equals(Infrastructure.Enums.ResultMessgeEnum.Success.ToString()) || message.Contains(Infrastructure.Enums.ResultMessgeEnum.Success.ToString())) { if (this.handlerToClose != null) { Console.WriteLine("in settings model, got: " + message + ". removing handler now"); //stop = true; App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { this.handlers.Remove(this.handlerToClose); }); NotifyPropertyChanged("Handlers"); } } else if (message.Equals(Infrastructure.Enums.ResultMessgeEnum.Fail.ToString())) { } else if (this.configSet == false && message != null) { ImageServiceAppConfigItem initialConfig = ImageServiceAppConfigItem.FromJSON(message); if (initialConfig != null && !this.configSet) { mut.WaitOne(); this.configSet = true; Console.WriteLine(initialConfig.OutputFolder); this.OutputDirectory = initialConfig.OutputFolder; Console.WriteLine(initialConfig.LogName); this.LogName = initialConfig.LogName; Console.WriteLine(initialConfig.SourceName); this.SourceName = initialConfig.SourceName; Console.WriteLine(initialConfig.ThumbnailSize); this.ThumbnailSize = initialConfig.ThumbnailSize; App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { string[] folders = initialConfig.Handlers.Split(';'); foreach (String folder in folders) { this.handlers.Add(folder); } }); mut.ReleaseMutex(); } } else { try { Console.WriteLine("in settings model - got remove handler command, " + "command is: " + message); HandlerToClose h = HandlerToClose.FromJSON(message); if (handlers.Contains(h.Path)) { App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { this.handlers.Remove(h.Path); }); //NotifyPropertyChanged("Handlers"); } } catch (Exception) { } } }