Ejemplo n.º 1
0
        private void InitializeMyComponent()
        {
            /*
             * Loading settings from file if available
             */
            if (!Directory.Exists(WorkingDirectory))
                Directory.CreateDirectory(WorkingDirectory);
            this.settings = DBExtractorSettings.Load(SettingsFilePath);
            this.events = ScheduleEventList.Load(EventsFilePath);
            //else
            //    this.settings = new DBExtractorSettings(FileName);

            /*
             * Initialize SQL connection helper
             */
            this.sql = new SQLConnectionHelper();
            this.sql.ConnectionEvent += new EventHandler<SQLConnectionEventArgs>(sql_ConnectionEvent);
            this.sql.DisconnectionEvent += new EventHandler<SQLConnectionEventArgs>(sql_DisconnectionEvent);
            this.sql.ServerNamesHasBeenFetched += new EventHandler(sql_ServerNamesHasBeenFetched);
            this.sql.DatabasesHasBeenFetched += new EventHandler(sql_DatabasesHasBeenFetched);
            this.sql.TablesHasBeenFetched += new EventHandler(sql_TablesHasBeenFetched);

            /*
             * Initialize FTP helper
             */
            this.ftp = new FTPHelper();
            this.ftp.ConnectionEvent += new EventHandler<FTPConnectionEventArgs>(ftp_ConnectionEvent);

            /*
             * Service controler handler
             */
            // TODO: Service handler goes here

            /*
             * Store settings
             */
            //this.settings.Save();
        }
Ejemplo n.º 2
0
        public static DBExtractorSettings Load(string fileName)
        {
            DBExtractorSettings settings;

            if (File.Exists(fileName))
            {
                Stream fileStream = File.OpenRead(fileName);
                BinaryFormatter deserializer = new BinaryFormatter();
                settings = (DBExtractorSettings)deserializer.Deserialize(fileStream);
                settings.fileName = fileName;
                fileStream.Close();
            }
            else
            {
                settings = new DBExtractorSettings(fileName);
            }

            return settings;
        }