@@ -22,9 +22,11 @@ public FormBase(FormMain myParent)
2222 MyParent = myParent ;
2323 InitializeComponent ( ) ;
2424
25+ var configurationSettings = new ConfigurationSettings ( ) ;
26+
2527 try
2628 {
27- InitialiseConnections ( GlobalParameters . ConfigurationPath + GlobalParameters . ConfigfileName ) ;
29+ InitialiseConfiguration ( configurationSettings . ConfigurationPath + GlobalParameters . ConfigfileName ) ;
2830 }
2931 catch ( Exception )
3032 {
@@ -33,10 +35,11 @@ public FormBase(FormMain myParent)
3335
3436 }
3537
36- public static void InitialiseConnections ( string chosenFile )
38+ public static void InitialiseRootPath ( )
3739 {
40+ // This is the hardcoded base path that always needs to be accessible, it has the main file which can locate the rest of the configuration
3841 var configList = new Dictionary < string , string > ( ) ;
39- var fs = new FileStream ( chosenFile , FileMode . Open , FileAccess . Read ) ;
42+ var fs = new FileStream ( GlobalParameters . ConfigurationPath + GlobalParameters . PathfileName , FileMode . Open , FileAccess . Read ) ;
4043 var sr = new StreamReader ( fs ) ;
4144
4245 try
@@ -54,6 +57,40 @@ public static void InitialiseConnections(string chosenFile)
5457 sr . Close ( ) ;
5558 fs . Close ( ) ;
5659
60+ // These variables are used as global vairables throughout the application
61+ var configurationSettingObject = new ConfigurationSettings ( ) ;
62+
63+ configurationSettingObject . ConfigurationPath = configList [ "ConfigurationPath" ] ;
64+ configurationSettingObject . OutputPath = configList [ "OutputPath" ] ;
65+
66+ }
67+ catch ( Exception )
68+ {
69+ // richTextBoxInformation.AppendText("\r\n\r\nAn error occured while interpreting the configuration file. The original error is: '" + ex.Message + "'");
70+ }
71+ }
72+
73+ public static void InitialiseConfiguration ( string chosenFile )
74+ {
75+ try
76+ {
77+ var configList = new Dictionary < string , string > ( ) ;
78+ var fs = new FileStream ( chosenFile , FileMode . Open , FileAccess . Read ) ;
79+ var sr = new StreamReader ( fs ) ;
80+
81+ string textline ;
82+ while ( ( textline = sr . ReadLine ( ) ) != null )
83+ {
84+ if ( textline . IndexOf ( @"/*" , StringComparison . Ordinal ) == - 1 )
85+ {
86+ var line = textline . Split ( '|' ) ;
87+ configList . Add ( line [ 0 ] , line [ 1 ] ) ;
88+ }
89+ }
90+
91+ sr . Close ( ) ;
92+ fs . Close ( ) ;
93+
5794 var connectionStringOmd = configList [ "connectionStringMetadata" ] ;
5895 connectionStringOmd = connectionStringOmd . Replace ( "Provider=SQLNCLI10;" , "" ) . Replace ( "Provider=SQLNCLI11;" , "" ) . Replace ( "Provider=SQLNCLI12;" , "" ) ;
5996
@@ -129,6 +166,8 @@ public static void InitialiseConnections(string chosenFile)
129166 configurationSettingObject . PresentationDatabaseName = configList [ "PresentationDatabase" ] ;
130167
131168 configurationSettingObject . OutputPath = configList [ "OutputPath" ] ;
169+ configurationSettingObject . ConfigurationPath = configList [ "ConfigurationPath" ] ;
170+
132171 configurationSettingObject . LinkedServer = configList [ "LinkedServerName" ] ;
133172
134173
@@ -402,6 +441,13 @@ public string OutputPath
402441 set { _OutputPath = value ; }
403442 }
404443
444+ private static string _ConfigurationPath ;
445+ public string ConfigurationPath
446+ {
447+ get { return _ConfigurationPath ; }
448+ set { _ConfigurationPath = value ; }
449+ }
450+
405451 private static string _LinkedServer ;
406452 public string LinkedServer
407453 {
@@ -455,35 +501,15 @@ public string metadataRepositoryType
455501 }
456502 }
457503
458- public DataTable GetDataTable ( ref SqlConnection sqlConnection , string sql )
459- {
460- // Pass the connection to a command object
461- var sqlCommand = new SqlCommand ( sql , sqlConnection ) ;
462- var sqlDataAdapter = new SqlDataAdapter { SelectCommand = sqlCommand } ;
463-
464- var dataTable = new DataTable ( ) ;
465-
466- // Adds or refreshes rows in the DataSet to match those in the data source
467- try
468- {
469- sqlDataAdapter . Fill ( dataTable ) ;
470- }
471-
472- catch ( Exception )
473- {
474- // MessageBox.Show(@"SQL error: " + exception.Message + "\r\n\r\n The executed query was: " + sql + "\r\n\r\n The connection used was " + sqlConnection.ConnectionString, "An issue has been encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
475- return null ;
476- }
477- return dataTable ;
478-
479- }
480-
481504 public class GlobalParameters
482505 {
483506 // These variables are used as global vairables throughout the applicatoin
484507 private static string _configurationLocalPath = Application . StartupPath + @"\Configuration\" ;
485508 private static string _outputLocalPath = Application . StartupPath + @"\Output\" ;
486- private static string _fileLocalName = "Virtual_EDW_configuration.txt" ;
509+
510+ private static string _fileConfigLocalName = "TEAM_configuration.txt" ;
511+ private static string _filePathLocalName = "TEAM_Path_configuration.txt" ;
512+
487513 private static string _jsonTableMappingFileName = "TEAM_Table_Mapping.json" ;
488514 private static string _jsonAttributeMappingFileName = "TEAM_Attribute_Mapping.json" ;
489515
@@ -501,8 +527,14 @@ public static string OutputPath
501527
502528 public static string ConfigfileName
503529 {
504- get { return _fileLocalName ; }
505- set { _fileLocalName = value ; }
530+ get { return _fileConfigLocalName ; }
531+ set { _fileConfigLocalName = value ; }
532+ }
533+
534+ public static string PathfileName
535+ {
536+ get { return _filePathLocalName ; }
537+ set { _filePathLocalName = value ; }
506538 }
507539
508540 public static string jsonTableMappingFileName
@@ -517,6 +549,28 @@ public static string jsonAttributeMappingFileName
517549 }
518550 }
519551
552+ public DataTable GetDataTable ( ref SqlConnection sqlConnection , string sql )
553+ {
554+ // Pass the connection to a command object
555+ var sqlCommand = new SqlCommand ( sql , sqlConnection ) ;
556+ var sqlDataAdapter = new SqlDataAdapter { SelectCommand = sqlCommand } ;
557+
558+ var dataTable = new DataTable ( ) ;
559+
560+ // Adds or refreshes rows in the DataSet to match those in the data source
561+ try
562+ {
563+ sqlDataAdapter . Fill ( dataTable ) ;
564+ }
565+
566+ catch ( Exception )
567+ {
568+ // MessageBox.Show(@"SQL error: " + exception.Message + "\r\n\r\n The executed query was: " + sql + "\r\n\r\n The connection used was " + sqlConnection.ConnectionString, "An issue has been encountered", MessageBoxButtons.OK, MessageBoxIcon.Error);
569+ return null ;
570+ }
571+ return dataTable ;
572+
573+ }
520574 public KeyValuePair < int , int > GetVersion ( int selectedVersion , SqlConnection sqlConnection )
521575 {
522576 var currentVersion = selectedVersion ;
0 commit comments