Esempio n. 1
0
        private Configuration()
        {
            try
            {
                log.Info("Loading configuration.");
                string NetworkSettingsFilePath = GetNetworkSettingsFilePath();

                if (string.IsNullOrEmpty(NetworkSettingsFilePath))
                {
                    CreateNewNetworkSettingsFile();
                    NetworkSettingsFilePath = GetNetworkSettingsFilePath();
                }

                NetworkSettingCollection = NetWorkSettingCollection.Deserialize(NetworkSettingsFilePath);
                foreach (NetWorkSetting networkSetting in NetworkSettingCollection.NetWorkSettings)
                {
                    string username, password;
                    CredentialManager.GetCredential(networkSetting.CredentialKey, out username, out password);
                    networkSetting.Username = username;
                    networkSetting.Password = password;
                    // Get model passwords that were auto-saved in creential manager
                    GetModelPasswords(networkSetting.CredentialKey, networkSetting.DataMartList);
                }


                if (!Directory.Exists(PackagesFolderPath))
                {
                    Directory.CreateDirectory(PackagesFolderPath);
                }

                //copy the base plugin dependencies to the root packages folder, this is where the app domains set their base directory
                //doing this at startup regardless of if the assemblies exist so that the most current are always there.
                CopyToPluginBase("ICSharpCode.SharpZipLib.dll", AppDomain.CurrentDomain.BaseDirectory, PackagesFolderPath);
                CopyToPluginBase("log4net.dll", AppDomain.CurrentDomain.BaseDirectory, PackagesFolderPath);
                CopyToPluginBase("Lpp.Dns.DataMart.Client.DomainManger.dll", AppDomain.CurrentDomain.BaseDirectory, PackagesFolderPath);
                CopyToPluginBase("Lpp.Dns.DataMart.Model.Interface.dll", AppDomain.CurrentDomain.BaseDirectory, PackagesFolderPath);
                CopyToPluginBase("Lpp.Dns.DataMart.Client.exe", AppDomain.CurrentDomain.BaseDirectory, PackagesFolderPath);

                //delete previous dependencies from the package folder so that there is no conflict with versions in adapter packages
                DeleteFromPluginBase("Npgsql.dll", PackagesFolderPath);
                DeleteFromPluginBase("MySql.Data.dll", PackagesFolderPath);
                DeleteFromPluginBase("Oracle.ManagedDataAccess.dll", PackagesFolderPath);
            }
            catch (ArgumentException ex)
            {
                log.Debug(ex.Message, ex);
                throw new NetworkSettingsFileNotFound("No Network configured. Add new Network from File > Network Settings", ex);
            }
            catch (BadImageFormatException ex)
            {
                log.Error(ex.Message, ex);
                // Credential manager is built for a different architecture. This is a build error and should not occur.
                // The system can still run but username and password cannot be saved.
            }
            catch (Exception ex)
            {
                log.Error("Cannot fully instantiate Configuration singleton instance.", ex);
                throw;
            }
        }
Esempio n. 2
0
 private static void GetModelPasswords(NetWorkSettingCollection networks)
 {
     foreach (var network in networks.NetWorkSettings)
     {
         GetModelPasswords(((NetWorkSetting)network).CredentialKey, ((NetWorkSetting)network).DataMartList);
     }
 }
Esempio n. 3
0
 private static void SaveModelPasswords(NetWorkSettingCollection networks)
 {
     foreach (var network in networks.NetWorkSettings)
     {
         if (((NetWorkSetting)network).DataMartList != null)
         {
             // Get model passwords that were auto-saved in creential manager
             foreach (var dataMart in ((NetWorkSetting)network).DataMartList)
             {
                 if (dataMart.ModelList != null)
                 {
                     foreach (var model in dataMart.ModelList)
                     {
                         if (model.Properties != null)
                         {
                             foreach (var property in model.Properties)
                             {
                                 if (property.Name.ToLower() == "password")
                                 {
                                     CredentialManager.SaveCredential(((NetWorkSetting)network).CredentialKey + "_" + dataMart.DataMartName + "_" + model.ProcessorId, model.ModelName, property.Value);
                                     property.Value = string.Empty;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
        public static void CreateNewNetworkSettingsFile()
        {
            NetWorkSettingCollection nwc = new NetWorkSettingCollection();

            CreateNetworkSettingsFile(nwc.Serialize);
        }