private void RefreshPowerBIInstances()
        {
            _powerBIInstances = new List <PowerBIInstance>()
            {
                _pbiLoadingInstance
            };
            SelectedPowerBIInstance = _pbiLoadingInstance;

            Task.Run(() => {
                // display the "loading..." message
                _powerBIInstances.Clear();
                _powerBIInstances.Add(_pbiLoadingInstance);
                NotifyOfPropertyChange(() => PowerBIDesignerInstances);
                NotifyOfPropertyChange(() => PowerBIInstanceDetected);

                // look for local workspace instances
                _powerBIInstances = PowerBIHelper.GetLocalInstances(false);

                if (_powerBIInstances.Count == 0)
                {
                    // Add the none found 'fake' instance
                    _powerBIInstances.Add(_pbiNoneInstance);
                }

                if (PowerBIInstanceDetected)
                {
                    if (SelectedPowerBIInstance == null || SelectedPowerBIInstance?.Port == -1)
                    {
                        SelectedPowerBIInstance = _powerBIInstances[0];
                    }
                }
                else
                {
                    if (PowerBIModeSelected)
                    {
                        ServerModeSelected = true;
                    }
                    SelectedPowerBIInstance = _pbiNoneInstance;
                }
                // update bound properties
                NotifyOfPropertyChange(() => PowerBIInstanceDetected);
                NotifyOfPropertyChange(() => PowerBIDesignerInstances);
                NotifyOfPropertyChange(() => SelectedPowerBIInstance);
            }).ContinueWith(t => {
                // we should only come here if we got an exception
                Log.Error(t.Exception, "Error getting PowerBI/SSDT instances: {message}", t.Exception.Message);
                _eventAggregator.PublishOnUIThread(new OutputMessage(MessageType.Error, $"Error getting PowerBI/SSDT instances: {t.Exception.Message}"));
            }, TaskContinuationOptions.OnlyOnFaulted);
        }
Exemplo n.º 2
0
        private void Connections_Load(object sender, EventArgs e)
        {
            //Settings.Default.SourceServerAutoCompleteEntries = "localhost|";
            //Settings.Default.TargetServerAutoCompleteEntries = "localhost|";
            //Settings.Default.SourceCatalog = "";
            //Settings.Default.TargetCatalog = "";
            //Settings.Default.Save();


            //this.Width = Convert.ToInt32(this.Width * 1.3);
            this.Height = Convert.ToInt32(grpSource.Height * 2.6);

            if (_dpiScaleFactor > 1)
            {
                //DPI
                float dpiScaleFactorFudged = _dpiScaleFactor * Utils.PrimaryFudgeFactor;
                float fudgeFactorWidth     = 0.95f;

                this.Scale(new SizeF(dpiScaleFactorFudged * (_dpiScaleFactor > 1.7 ? 1 : Utils.SecondaryFudgeFactor), dpiScaleFactorFudged * Utils.SecondaryFudgeFactor));
                this.Width = Convert.ToInt32(this.Width * dpiScaleFactorFudged * fudgeFactorWidth);
                foreach (Control control in Utils.GetChildInControl(this)) //.OfType<Button>())
                {
                    if (control is GroupBox || control is Button)
                    {
                        control.Font = new Font(control.Font.FontFamily,
                                                control.Font.Size * dpiScaleFactorFudged * Utils.SecondaryFudgeFactor,
                                                control.Font.Style);
                    }
                    if (control is GroupBox || control.Name == "btnSwitch")
                    {
                        control.Width = Convert.ToInt32(control.Width * dpiScaleFactorFudged * fudgeFactorWidth);
                    }
                    if (control is ComboBox)
                    {
                        control.Width = Convert.ToInt32(control.Width * fudgeFactorWidth);
                    }
                    if (control is Panel)
                    {
                        control.Left = Convert.ToInt32(control.Left * dpiScaleFactorFudged);
                    }
                }
                this.btnSwitch.Left = grpSource.Right + Convert.ToInt32(12 * dpiScaleFactorFudged);
                this.grpTarget.Left = btnSwitch.Right + Convert.ToInt32(12 * dpiScaleFactorFudged);
            }

            cboSourceServer.DataSource = ComparisonControl.ReverseArray <string>(Settings.Default.SourceServerAutoCompleteEntries.Substring(0, Settings.Default.SourceServerAutoCompleteEntries.Length - 1).Split("|".ToCharArray()));
            cboTargetServer.DataSource = ComparisonControl.ReverseArray <string>(Settings.Default.TargetServerAutoCompleteEntries.Substring(0, Settings.Default.TargetServerAutoCompleteEntries.Length - 1).Split("|".ToCharArray()));

            cboSourceDatabase.Text = Settings.Default.SourceCatalog;
            cboTargetDatabase.Text = Settings.Default.TargetCatalog;

            #region Prep Desktop/SSDT instances

            cboSourceDesktop.Items.Clear();
            cboTargetDesktop.Items.Clear();

            BindingSource desktopBindingSource = new BindingSource();
            BindingSource desktopBindingTarget = new BindingSource();
            _powerBIInstances.Clear();
            try
            {
                _powerBIInstances = PowerBIHelper.GetLocalInstances();
            }
            catch { }

            if (_powerBIInstances.Count > 0)
            {
                rdoSourceDesktop.Enabled = true;
                rdoTargetDesktop.Enabled = true;

                desktopBindingSource.DataSource = _powerBIInstances;
                desktopBindingTarget.DataSource = _powerBIInstances;

                cboSourceDesktop.DataSource    = desktopBindingSource;
                cboSourceDesktop.ValueMember   = "Port";
                cboSourceDesktop.DisplayMember = "Name";

                cboTargetDesktop.DataSource    = desktopBindingTarget;
                cboTargetDesktop.ValueMember   = "Port";
                cboTargetDesktop.DisplayMember = "Name";
            }
            else
            {
                rdoSourceDesktop.Enabled = false;
                rdoTargetDesktop.Enabled = false;
            }

            #endregion

            BindSourceConnectionInfo();
            BindTargetConnectionInfo();
        }