/// <summary> /// Loads the logger's settings from the config file /// </summary> public static void LoadSettings() { settingsFile = new KeyValueStore(Path.Combine(DefaultConnectionManager.SettingsFolder, "XmppLoggerSettings.xml")); Enable = settingsFile.GetItem <bool>("Enable"); LogLevel level; LogLevel = Enum.TryParse(settingsFile.GetItem <string>("LogLevel"), out level) ? level : LogLevel.Info; Recipient = settingsFile.GetItem <string>("Recipient"); EnableDebugLogging = settingsFile.GetItem <bool>("EnableDebugLogging"); loaded = true; }
public void TestSaveAndGet_int() { int value = new Random().Next(); testFile.SaveItem(key, value); Assert.AreEqual <int>(value, testFile.GetItem <int>(key)); }
internal static void Init() { Task t = new Task(delegate { logger.Info("Initializing FileShare"); rootPath = storage.GetItem <string>("RootPath"); //load mounts List <object> myMounts = storage.GetItem <List <object> >("mounts"); myMounts = (myMounts == null) ? new List <object>() : myMounts; mounts = new List <MountInfo>(); foreach (Object item in myMounts) { mounts.Add((MountInfo)item); } if (rootPath.IsNullOrEmpty() || !Directory.Exists(rootPath)) { mountErrorOccurred = true; logger.Error("Root directory not found"); } //load permissions List <object> _permissions = storage.GetItem <List <object> >("permissions"); _permissions = (_permissions == null) ? new List <object>() : _permissions; foreach (object item in _permissions) { if (!permissions.ContainsKey((item as Permission).Path.ToLower())) { permissions.Add(((Permission)item).Path.ToLower(), (Permission)item); } } //scan local directories to make sure hashes are available fast when requested foreach (var item in mounts) { scanDirectory(item.LocalPath); } logger.Info("FileShare initialization completed"); }); t.Start(); }
/// <summary> /// Loads the ConnectionManagers settings from the specified folder /// </summary> /// <param name="settingsFolder">The folder to use for storing settings</param> public void LoadSettings(string settingsFolder) { applicationDataFolder = settingsFolder; settingsFile = new KeyValueStore(Path.Combine(settingsFolder, "Account.xml")); if (settingsFile != null) { _clusterKey = settingsFile.GetItem <string>("ClusterKey").GetBytesBase64(); //Set up XmppMessagingClient and connect var messagingClient = new XmppMessagingClient() { Username = settingsFile.GetItem <string>("XmppUsername"), Server = settingsFile.GetItem <string>("XmppServer"), Password = settingsFile.GetItem <string>("XmppPassword") }; messagingClients.Add(messagingClient); messagingClient.MessageReceived += messagingClient_MessageReceived; messagingClient.PeerDisconnected += messagingClient_PeerDisconnected; messagingClient.Connect(); var clients = settingsFile.GetItem <IEnumerable <object> >("KnownClients"); if (clients == null) { knownClientsCache = new Dictionary <string, ClientInfo>(); } else { knownClientsCache = clients .Cast <ClientInfo>() .ToDictionary(x => x.JId); } logger.Info("Sucessfully loaded settings"); } }
/// <summary> /// Loads the ConnectionManagers settings from the specified folder /// </summary> /// <param name="settingsFolder">The folder to use for storing settings</param> public void LoadSettings(string settingsFolder) { applicationDataFolder = settingsFolder; settingsFile = new KeyValueStore(Path.Combine(settingsFolder, "Account.xml")); if (settingsFile != null) { _clusterKey = settingsFile.GetItem<string>("ClusterKey").GetBytesBase64(); //Set up XmppMessagingClient and connect var messagingClient = new XmppMessagingClient() { Username = settingsFile.GetItem<string>("XmppUsername"), Server = settingsFile.GetItem<string>("XmppServer"), Password = settingsFile.GetItem<string>("XmppPassword") }; messagingClients.Add(messagingClient); messagingClient.MessageReceived += messagingClient_MessageReceived; messagingClient.PeerDisconnected += messagingClient_PeerDisconnected; messagingClient.Connect(); var clients = settingsFile.GetItem<IEnumerable<object>>("KnownClients"); if (clients == null) knownClientsCache = new Dictionary<string, ClientInfo>(); else knownClientsCache = clients .Cast<ClientInfo>() .ToDictionary(x => x.JId); logger.Info("Sucessfully loaded settings"); } }
/// <summary> /// Loads the logger's settings from the config file /// </summary> public static void LoadSettings() { settingsFile = new KeyValueStore(Path.Combine(DefaultConnectionManager.SettingsFolder, "XmppLoggerSettings.xml")); Enable = settingsFile.GetItem<bool>("Enable"); LogLevel level; LogLevel = Enum.TryParse(settingsFile.GetItem<string>("LogLevel"), out level) ? level : LogLevel.Info; Recipient = settingsFile.GetItem<string>("Recipient"); EnableDebugLogging = settingsFile.GetItem<bool>("EnableDebugLogging"); loaded = true; }
static void Main(string[] args) { //Display general Info printLogo(); Console.Title = "Wolpertinger Fileserver"; Console.WriteLine(); ConsoleHelper.WriteLine(ConsoleColor.Red, " Wolpertinger.FileServer {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString()); ConsoleHelper.WriteLine(ConsoleColor.Red, " Wolpertinger.Core {0}", Assembly.GetAssembly(typeof(DefaultConnectionManager)).GetName().Version.ToString()); Console.WriteLine(); //Set up XmlSerializer XmlSerializer.RegisterType(typeof(ClientInfo), "clientInfo"); XmlSerializer.RegisterType(typeof(DirectoryObject), "directoryObject"); XmlSerializer.RegisterType(typeof(FileObject), "fileObject"); XmlSerializer.RegisterType(typeof(Permission), "permission"); XmlSerializer.RegisterType(typeof(MountInfo), "mountInfo"); XmlSerializer.RegisterType(typeof(SnapshotInfo), "snapshotInfo"); XmlSerializer.RegisterType(typeof(RemoteMethodCall), "remoteMethodCall"); XmlSerializer.RegisterType(typeof(RemoteMethodResponse), "remoteMethodResponse"); XmlSerializer.RegisterType(typeof(RemoteError), "remoteError"); //Set up logger LoggerService.SetLogger(new CompositeLogger(new Wolpertinger.Core.ConsoleLogger(), new XmppLogger())); logger = LoggerService.GetLogger("Wolpertinger.Fileserver"); FileObject.HashingService = HashingService.GetHashingService(); AuthenticationComponent foo = new AuthenticationComponent(); if (!Directory.Exists(Path.GetDirectoryName(folder))) { Directory.CreateDirectory(Path.GetDirectoryName(folder)); } //Set up AppData directory if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } //Set up databasefolder if (!Directory.Exists(DatabaseFolder)) { Directory.CreateDirectory(DatabaseFolder); } //Initalize ConnectionManager //TODO manager.AddProfile(Profile.FileServer); //manager.AddComponent(typeof(ClientInfoProvider), typeof(XmppLoggingConfigurator), typeof(FileShare)); connectionManager = new DefaultConnectionManager(); //connectionManager.ComponentFactory = new DefaultComponentFactory(); connectionManager.LoadSettings(folder); //connectionManager.Connect(); connectionManager.AcceptIncomingConnections = true; XmppLogger.ConnectionManager = connectionManager; XmppLogger.LoadSettings(); //Load setting specific to this role connectionManager.WolpertingerUsername = settingsFile.GetItem <string>("AdminUsername"); connectionManager.WolpertingerPassword = settingsFile.GetItem <string>("AdminPassword").ToSecureString(); FileShareServerComponent.Init(); //Console.WriteLine("Account: " + connectionManager.XmppUsername + "@" + connectionManager.XmppServer); Console.ReadLine(); }