Beispiel #1
0
        /// <summary>
        /// Inicia LoadFromDAtaBaseWorker para que trabaje ebn un hilo diferente
        /// </summary>
        protected bool RefreshMetadata()
        {
            if (_Metadata.CnnString == null)
            {
                MessageView.Show("Debe establecer una conexión a la bace dedatos.-");
                return(false);
            }
            //Si la metadata se abre desde un archivo, no ejecuto este método.
            if (LoadMetaDataFromXML)
            {
                if (!IsLoadedMetaDataFromXML)
                {
                    this.LoadMetaDataFromXml();
                }
                return(true);
            }


            try
            {
                if (!_Metadata.TestConnection())
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageView.Show(ex);
                return(false);
            }


            LoadFromDatabaseWorker _LoadFromDatabaseWorker = new LoadFromDatabaseWorker();

            _LoadFromDatabaseWorker.StartWorkEvent   += new StartWorkHandler(_LoadFromDAtaBaseWorker_StartWorkEvent);
            _LoadFromDatabaseWorker.FinishtWorkEvent += new FinishWorkHandler(_LoadFromDatabaseWorker_FinishtWorkEvent);
            _LoadFromDatabaseWorker.FailtWorkEvent   += new FailWorkHandler(_LoadFromDatabaseWorker_FailtWorkEvent);

            _LoadFromDatabaseWorker.SelectedObject = _SelectedObject;
            _LoadFromDatabaseWorker.Metadata       = _Metadata;

            _LoadFromDatabaseWorker.Start();

            _LoadFromDatabaseWorker.StartWorkEvent   -= new StartWorkHandler(_LoadFromDAtaBaseWorker_StartWorkEvent);
            _LoadFromDatabaseWorker.FinishtWorkEvent -= new FinishWorkHandler(_LoadFromDatabaseWorker_FinishtWorkEvent);
            return(true);
        }
Beispiel #2
0
 private void TestCnn()
 {
     try
     {
         _Metadata.TestConnection();
         _ConnectionState = true;
         OnFinishWorkEvent();
     }
     catch (Exception ex)
     {
         OnFinishWorkEvent();
         _ConnectionState = false;
         OnStartWorkEvent("Ocurrio un error al intentar conectarce a la base de datos ", ex.Message);
         ////OnFailWorkEvent(er);
     }
     finally
     {
     }
 }