public DatabaseManager(ConfigurationXml configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException();
            }

            _Configuration = configuration;

            try { LOG.Info("Loading XML-File from '" + Path.GetFullPath(_Configuration.DatabaseFilename) + "'"); }
            catch { LOG.Error("Unable to detect fullpath of XML-File: "); }
            try { LOG.Info("Loading TXT-File from '" + Path.GetFullPath(_Configuration.TransferFilename) + "'"); }
            catch { LOG.Error("Unable to detect fullpath of TXT-File: "); }

            _Database    = DatabaseXml.Load(_Configuration.DatabaseFilename);
            _FtpManager  = new FtpManager(_Configuration.FtpUser, _Configuration.FtpPassword, _Configuration.FtpPath);
            _FileManager = new FileManager(_Configuration.TransferFilename, new FileManager.StringDelegate(ehFileManager_OnNewExerciseDetected));
        }
Exemple #2
0
        public static DatabaseXml Load(string filename)
        {
            DatabaseXml instance = null;

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(DatabaseXml));
                using (TextReader reader = new StreamReader(filename, System.Text.Encoding.Unicode))
                {
                    instance = serializer.Deserialize(reader) as DatabaseXml;
                    reader.Close();
                }
            }
            catch
            {
                instance = new DatabaseXml();
            }

            instance._Filename = filename;
            return(instance);
        }