Ejemplo n.º 1
0
        private void OnGo()
        {
            // Go:Click
            _btnGo.Click += (o, e) =>
            {
                try
                {
                    // reset message type
                    MessageType = MessageType.None;

                    // log every Go button click - !
                    // Log.LogUse(_btnGo.Text == "Map it!" ? 1 : 27, _comboDatabases.Text);

                    // check .NET path
                    if (!CheckNetDirectory())
                    {
                        return;
                    }

                    // check repository
                    if (!CheckRepository())
                    {
                        return;
                    }

                    // Finished, Stopped -> Idle
                    if (ProcessState == ProcessState.Finished || ProcessState == ProcessState.Stopped)
                    {
                        SetIdle();
                        return;
                    }

                    // Processing -> Stopped
                    if (ProcessState.IsProcessing())
                    {
                        if (_mapping != null && _mapping.Thread != null)
                        {
                            SetStopped();
                            return;
                        }
                    }

                    // validate
                    if (!ValidateGo())
                    {
                        return;
                    }

                    // create connection builder
                    _start.SetConnBuilder(_comboDatabases.Text);
                    var connBuilder = new SqlConnectionStringBuilder(_start.ConnBuilder.ToString());

                    // set processing and start mapping (on other thread)
                    SetProcessingTryConnection();
                    _mapping = new MappingHandler(this, CurrentGuid, connBuilder, _ctrMapper.Text);
                }
                catch (System.Exception ex)
                {
                    SetException(ex);
                }
            };

            // Go:MouseEnter
            _btnGo.MouseEnter += (o, e) =>
            {
                try
                {
                    if (_processState == ProcessState.Idle || _processState.IsProcessing())
                    {
                        _btnGo.BackColor = Color.Green;
                    }
                }
                catch { }  // do nothing
            };

            // Go:MouseLeave
            _btnGo.MouseLeave += (o, e) =>
            {
                try
                {
                    if (_processState == ProcessState.Idle || _processState.IsProcessing())
                    {
                        _SetGoDefault();
                    }
                }
                catch { }  // do nothing
            };
        }