Esempio n. 1
0
        private void GetURLSource(object htmlDataType)
        {
            tssl_Status.UpdateStatus("Conneting...");
            try
            {
                //htmlDataType = new HtmlSource(_url);
                switch((SourceCode)htmlDataType)
                {
                    case SourceCode.Database:
                        _htmlDatabase = new HtmlSource(_url);
                        _htmlDatabase.GetInfo(SourceCode.Database);
                        break;
                    case SourceCode.Record:
                        _htmlRecord = new HtmlSource(_url);
                        _htmlRecord.GetInfo(SourceCode.Record);
                        break;
                    case SourceCode.Record_Sub:
                        _htmlRecord_Sub = new HtmlSource(_url);
                        _htmlRecord_Sub.GetInfo(SourceCode.Record_Sub);
                        break;
                    case SourceCode.Annotations:
                        _htmlAnnotations = new HtmlSource(_url);
                        _htmlAnnotations.GetInfo(SourceCode.Annotations);
                        break;
                    default:
                        MessageBox.Show("Wrong input type.");
                        return;
                }
                //_getSourceCodeCompleted();   //trig event
            }
            catch (NoAnnotationsException ex)
            {
                tssl_Status.UpdateStatus("Done.");
                //throw ex;     //failed
                //throw new Exception(ex.ErrorMessage);

                //temporary solution
                _htmlAnnotations = null;
                MessageBox.Show(ex.ErrorMessage);
                return;
            }
            catch (URLNoResponseException ex)
            {
                tssl_Status.UpdateStatus("Failed.");
                MessageBox.Show(ex.Message);
                return;
            }
            tssl_Status.UpdateStatus("Done.");
        }
Esempio n. 2
0
        private void cmb_Database_SelectedIndexChanged(object sender, EventArgs e)
        {
            //check: prevent to refresh while selectedIndex doesn't change
            if (cmb_Database.SelectedIndex == prevCmbSelectedIndex[(int)SourceCode.Database])
            {
                return;
            }
            prevCmbSelectedIndex[(int)SourceCode.Database] = cmb_Database.SelectedIndex;

            cmb_Record.Items.Clear();
            cmb_Record_SubDir.Items.Clear();
            cmb_Annotations.Items.Clear();
            prevCmbSelectedIndex[1] = -1;   //reset

            string dbName = _htmlDatabase.DBList[cmb_Database.SelectedIndex];

            //get record list
            //_url = @"http://physionet.org/physiobank/database/" + dbName;
            _url = @"http://physionet.org/physiobank/database/" + dbName + "/RECORDS";
            try
            {
                _workerThread = new Thread(new ParameterizedThreadStart(GetURLSource));
                _workerThread.Start(SourceCode.Record);
                _workerThread.Join();
                /*
                _workerThread = new Thread(new ParameterizedThreadStart(GetURLSource));
                _url = @"http://physionet.org/physiobank/database/" + dbName + "/ANNOTATORS";
                _workerThread.Start(SourceCode.Annotations);
                _workerThread.Join();
                */

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            //get annotation list
            _url = @"http://physionet.org/physiobank/database/" + dbName + "/ANNOTATORS";
            try
            {
                _workerThread = new Thread(new ParameterizedThreadStart(GetURLSource));
                _workerThread.Start(SourceCode.Annotations);
                _workerThread.Join();
            }
            catch (Exception ex)
            {
                _htmlAnnotations = null;
                MessageBox.Show(ex.Message);
            }

            cmb_Record.UpdateItems(_htmlRecord.RecordList);
            if (_htmlAnnotations != null)
            {
                cmb_Annotations.UpdateItems(_htmlAnnotations.AnnotationsList);
            }
            else
            {
                cmb_Annotations.Items.Clear();
            }
        }