Launch from Desktop

This commit is contained in:
Christian Wade 2019-12-07 19:53:15 -08:00
parent 7b6526a516
commit 1f8dc324a9
4 changed files with 116 additions and 79 deletions

View File

@ -78,13 +78,16 @@ namespace AlmToolkit
private void ComparisonForm_Load(object sender, EventArgs e)
{
_comparisonInfo = new ComparisonInfo();
_comparisonInfo.AppName = Utils.AssemblyProduct;
if (_comparisonInfo == null)
{
_comparisonInfo = new ComparisonInfo();
_comparisonInfo.AppName = Utils.AssemblyProduct;
GetFromAutoCompleteSource();
GetFromAutoCompleteTarget();
//GetFromAutoCompleteSource();
//GetFromAutoCompleteTarget();
SetNotComparedState();
SetNotComparedState();
}
//hdpi
Rescale();
@ -307,19 +310,19 @@ namespace AlmToolkit
private void GetFromAutoCompleteSource()
{
string serverNameSource = ReverseArray<string>(Settings.Default.SourceServerAutoCompleteEntries.Substring(0,
Settings.Default.SourceServerAutoCompleteEntries.Length - 1).Split("|".ToCharArray()))[0]; //.Reverse().ToArray();
//_connectionInfoSource = new ConnectionInfo(serverNameSource, Settings.Default.SourceCatalog);
}
//private void GetFromAutoCompleteSource()
//{
// string serverNameSource = ReverseArray<string>(Settings.Default.SourceServerAutoCompleteEntries.Substring(0,
// Settings.Default.SourceServerAutoCompleteEntries.Length - 1).Split("|".ToCharArray()))[0]; //.Reverse().ToArray();
// _connectionInfoSource = new ConnectionInfo(serverNameSource, Settings.Default.SourceCatalog);
//}
private void GetFromAutoCompleteTarget()
{
string serverNameTarget = ReverseArray<string>(Settings.Default.TargetServerAutoCompleteEntries.Substring(0,
Settings.Default.TargetServerAutoCompleteEntries.Length - 1).Split("|".ToCharArray()))[0];
//_connectionInfoTarget = new ConnectionInfo(serverNameTarget, Settings.Default.TargetCatalog);
}
//private void GetFromAutoCompleteTarget()
//{
// string serverNameTarget = ReverseArray<string>(Settings.Default.TargetServerAutoCompleteEntries.Substring(0,
// Settings.Default.TargetServerAutoCompleteEntries.Length - 1).Split("|".ToCharArray()))[0];
// //_connectionInfoTarget = new ConnectionInfo(serverNameTarget, Settings.Default.TargetCatalog);
//}
internal static T[] ReverseArray<T>(T[] array)
{
@ -351,7 +354,7 @@ namespace AlmToolkit
Settings.Default.SourceCatalog = _comparisonInfo.ConnectionInfoSource.DatabaseName;
Settings.Default.Save();
GetFromAutoCompleteSource();
//GetFromAutoCompleteSource();
}
if (!_comparisonInfo.ConnectionInfoTarget.UseProject && !_comparisonInfo.ConnectionInfoTarget.UseDesktop && !_comparisonInfo.ConnectionInfoTarget.UseBimFile)
@ -367,7 +370,7 @@ namespace AlmToolkit
Settings.Default.TargetCatalog = _comparisonInfo.ConnectionInfoTarget.DatabaseName;
Settings.Default.Save();
GetFromAutoCompleteTarget();
//GetFromAutoCompleteTarget();
}
}
@ -724,22 +727,19 @@ namespace AlmToolkit
catch { }
}
private void SetFileNameTitle(bool unsaved)
public void LoadFromDesktop(string serverName, string databaseName)
{
_unsaved = unsaved;
_comparisonInfo = new ComparisonInfo();
_comparisonInfo.AppName = Utils.AssemblyProduct;
if (String.IsNullOrEmpty(_fileName))
{
this.Text = Utils.AssemblyProduct;
}
else
{
this.Text = Utils.AssemblyProduct + " - " + Path.GetFileName(_fileName);
if (unsaved)
{
this.Text += " *";
}
}
_comparisonInfo.ConnectionInfoSource.UseDesktop = true;
_comparisonInfo.ConnectionInfoSource.ServerName = serverName;
_comparisonInfo.ConnectionInfoSource.DatabaseName = databaseName;
//GetFromAutoCompleteSource();
//GetFromAutoCompleteTarget();
SetNotComparedState();
}
public void LoadFile(string fileName)
@ -762,6 +762,24 @@ namespace AlmToolkit
}
}
private void SetFileNameTitle(bool unsaved)
{
_unsaved = unsaved;
if (String.IsNullOrEmpty(_fileName))
{
this.Text = Utils.AssemblyProduct;
}
else
{
this.Text = Utils.AssemblyProduct + " - " + Path.GetFileName(_fileName);
if (unsaved)
{
this.Text += " *";
}
}
}
public void SaveFile(string fileName)
{
try

View File

@ -1,4 +1,5 @@
using System;
using Microsoft.AnalysisServices;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -18,28 +19,37 @@ namespace AlmToolkit
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//with args(user open file with the program)
if (args != null && args.Length > 0)
{
string fileName = args[0];
//Check file exists
if (File.Exists(fileName))
if (args.Length > 1)
//User opened from Desktop with server/db name
{
string serverName = args[0];
string databaseName = args[1];
ComparisonForm MainFrom = new ComparisonForm();
MainFrom.LoadFile(fileName);
MainFrom.LoadFromDesktop(serverName, databaseName);
Application.Run(MainFrom);
return;
}
//The file does not exist
else
//User opened file with the program
{
Application.Run(new ComparisonForm());
string fileName = args[0];
//Check file exists, if not will run without args below
if (File.Exists(fileName))
{
ComparisonForm MainFrom = new ComparisonForm();
MainFrom.LoadFile(fileName);
Application.Run(MainFrom);
return;
}
}
}
//without args
else
{
Application.Run(new ComparisonForm());
}
//Without valid args
Application.Run(new ComparisonForm());
}
}
}

View File

@ -21,7 +21,5 @@ namespace AlmToolkit
return ((AssemblyProductAttribute)attributes[0]).Product;
}
}
}
}

View File

@ -78,6 +78,8 @@ namespace BismNormalizer.TabularCompare.UI
cboSourceDatabase.Text = Settings.Default.SourceCatalog;
cboTargetDatabase.Text = Settings.Default.TargetCatalog;
#region Prep Desktop/SSDT instances
cboSourceDesktop.Items.Clear();
cboTargetDesktop.Items.Clear();
@ -105,15 +107,17 @@ namespace BismNormalizer.TabularCompare.UI
cboTargetDesktop.DataSource = desktopBindingTarget;
cboTargetDesktop.ValueMember = "Port";
cboTargetDesktop.DisplayMember = "Name";
BindSourceConnectionInfo();
BindTargetConnectionInfo();
}
else
{
rdoSourceDesktop.Enabled = false;
rdoTargetDesktop.Enabled = false;
}
#endregion
BindSourceConnectionInfo();
BindTargetConnectionInfo();
}
private bool BindSourceConnectionInfo()
@ -136,26 +140,29 @@ namespace BismNormalizer.TabularCompare.UI
}
else if (_comparisonInfo.ConnectionInfoSource.UseDesktop)
{
rdoSourceDesktop.Checked = true;
pnlSourceDataset.Enabled = false;
pnlSourceDesktop.Enabled = true;
pnlSourceFile.Enabled = false;
int portFromConnectionInfo = -1;
if (_comparisonInfo.ConnectionInfoSource.ServerName != null &&
int.TryParse(_comparisonInfo.ConnectionInfoSource.ServerName.ToUpper().Replace("localhost:".ToUpper(), ""), out portFromConnectionInfo))
if (_powerBIInstances.Count > 0)
{
for (int i = 0; i < ((BindingSource)cboSourceDesktop.DataSource).Count; i++)
rdoSourceDesktop.Checked = true;
pnlSourceDataset.Enabled = false;
pnlSourceDesktop.Enabled = true;
pnlSourceFile.Enabled = false;
int portFromConnectionInfo = -1;
if (_comparisonInfo.ConnectionInfoSource.ServerName != null &&
int.TryParse(_comparisonInfo.ConnectionInfoSource.ServerName.ToUpper().Replace("localhost:".ToUpper(), ""), out portFromConnectionInfo))
{
if (((PowerBIInstance)((BindingSource)cboSourceDesktop.DataSource)[i]).Port == portFromConnectionInfo)
for (int i = 0; i < ((BindingSource)cboSourceDesktop.DataSource).Count; i++)
{
cboSourceDesktop.SelectedIndex = i;
break;
if (((PowerBIInstance)((BindingSource)cboSourceDesktop.DataSource)[i]).Port == portFromConnectionInfo)
{
cboSourceDesktop.SelectedIndex = i;
break;
}
}
}
boundSuccessfully = true;
}
boundSuccessfully = true;
}
else if (!String.IsNullOrEmpty(_comparisonInfo.ConnectionInfoSource.ServerName) && !String.IsNullOrEmpty(_comparisonInfo.ConnectionInfoSource.DatabaseName))
{
@ -193,26 +200,30 @@ namespace BismNormalizer.TabularCompare.UI
}
else if (_comparisonInfo.ConnectionInfoTarget.UseDesktop)
{
rdoTargetDesktop.Checked = true;
pnlTargetDataset.Enabled = false;
pnlTargetDesktop.Enabled = true;
pnlTargetFile.Enabled = false;
int portFromConnectionInfo = -1;
if (_comparisonInfo.ConnectionInfoTarget.ServerName != null &&
int.TryParse(_comparisonInfo.ConnectionInfoTarget.ServerName.ToUpper().Replace("localhost:".ToUpper(), ""), out portFromConnectionInfo))
if (_powerBIInstances.Count > 0)
{
for (int i = 0; i < ((BindingSource)cboTargetDesktop.DataSource).Count; i++)
rdoTargetDesktop.Checked = true;
pnlTargetDataset.Enabled = false;
pnlTargetDesktop.Enabled = true;
pnlTargetFile.Enabled = false;
int portFromConnectionInfo = -1;
if (_comparisonInfo.ConnectionInfoTarget.ServerName != null &&
int.TryParse(_comparisonInfo.ConnectionInfoTarget.ServerName.ToUpper().Replace("localhost:".ToUpper(), ""), out portFromConnectionInfo))
{
if (((PowerBIInstance)((BindingSource)cboTargetDesktop.DataSource)[i]).Port == portFromConnectionInfo)
for (int i = 0; i < ((BindingSource)cboTargetDesktop.DataSource).Count; i++)
{
cboTargetDesktop.SelectedIndex = i;
break;
if (((PowerBIInstance)((BindingSource)cboTargetDesktop.DataSource)[i]).Port == portFromConnectionInfo)
{
cboTargetDesktop.SelectedIndex = i;
break;
}
}
}
boundSuccessfully = true;
}
boundSuccessfully = true;
}
else if (!String.IsNullOrEmpty(_comparisonInfo.ConnectionInfoTarget.ServerName) && !String.IsNullOrEmpty(_comparisonInfo.ConnectionInfoTarget.DatabaseName))
{