Ejemplo n.º 1
0
        public FrmMain()
        {
            InitializeComponent();
            
            // ******* testing - backgroundworkers
            init_backgroundWorkers();
            // ******* testing - backgroundworkers

            // Display loading splash screen while app init all vars
            //SplashScreen ss = new SplashScreen();
            ss = new SplashScreen();
            ss.Show();
            
            m_previousWindowState = (this.WindowState == FormWindowState.Minimized ? FormWindowState.Normal : this.WindowState);

            context = new DefaultExtractorContext();
            
            // get conf
            conf = context.GetConfiguration();

            // init logger
            log = new Log(bool.Parse(conf.VerboseLogEnable), txtStatusLog);
            
            // get webproxy and set webproxy
            ReloadProxy();

            // get orgSite
            bool RESTError = false;
            bool retry = true;

            // A loop that checks connection to the web, if unable to connect it allows user to jump into proxy
            // settings and retry connecting until either a connection can be established or user kills it.
            while (retry)
            {
                try
                {
                    // try to get orgsite via REST calls if this fails then close app.
                    _orgSite = DataLoader.GetOrgSite("OrgHashCode", conf.OrganisationHashCode);
                    retry = false;
                    RESTError = false;
                }
                catch (Exception ex)
                {
                    // close the splash screen
                    ss.Close();

                    RESTError = true;
                    // write debug message to log
                    log.write(ex.ToString());

                    // rename buttons to messagebox
                    MessageBoxManager.Yes = "Retry";
                    MessageBoxManager.No = "Settings";
                    MessageBoxManager.Cancel = "Quit";
                    // registers the buttons renamed
                    MessageBoxManager.Register();

                    DialogResult result = MessageBox.Show("Could not connect to HVP servers, there maybe issues with your current connection or the server maybe down please try again. \nIf you are connected to the internet via proxies please click on settings to configure your web proxies.",
                        "Error! Could not connect to HVP servers", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error);
                    
                    // unregisters the naming back to default
                    MessageBoxManager.Unregister();

                    // no == settings
                    if (result == DialogResult.No)
                    {
                        // open settings frm
                        FrmConf frmConf = new FrmConf(conf, context, this, true);
                        frmConf.ShowDialog();
                    }
                    
                    // cancel == cancel
                    if (result == DialogResult.Cancel)
                    {
                        // kill loop
                        retry = false;
                        // exit app
                        System.Environment.Exit(0);
                    }
                }
            }

            // close loading splash screen
            ss.Close();

            // if no error from REST
            if (RESTError == false)
            {
                // nibhernate factory for sqlite db connection
                _slFactory = new SQLiteDBFactory();
            
                // Clear Cache
                ClearCache = bool.Parse(conf.ClearCache);

                // start the file watcher if there are any uploads that require it.
                _watcher = new Util.FileWatcher(this);
                
                // check if there is an update when program loads up
                AutoUpdater.Start(conf.AutoUpdateLink);

                // set the timer for auto update in milliseconds
                CheckForUpdatesTimedEvent(3600000); // every 1 hour

                // get the commonAppPath, if release version then should be under user data
                _commonAppPath = CommonAppPath.GetCommonAppPath();

                // start with the modal upload form on screen first
                FrmUpload frmUpload = new FrmUpload(this, conf.OrganisationHashCode);
                frmUpload.Focus();
                frmUpload.ShowDialog();
            }

            // get the build version from the assembly
            _Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            // display the version number in the form window text
            // remove the last 2 chars from version since we dont display that to the user
            this.Text = "HVP - Variant Exporter (" + _Version.Remove(_Version.Length - 2) + ")";

            // display notes on icon hover
            notifyIcon1.Icon = this.Icon;
        }
Ejemplo n.º 2
0
 // Configuration XML settings
 private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Open configuration xml application form dialogue box
     FrmConf frmConf = new FrmConf(conf, context, this, false);
     frmConf.ShowDialog();
 }