Exemplo n.º 1
0
        /// <summary>
        /// Add connection to config
        /// </summary>
        /// <param name="connection"></param>
        private bool AddConnectionToConfig(IConnectionSettings connection)
        {
            bool result = true;

            try
            {
                XDocument xmlDoc = XDocument.Load(FileAndFolderConstants.ConnectionSettingsConfigFile);

                xmlDoc.Element("Connections").Add(connection.ToXml());

                xmlDoc.Save(FileAndFolderConstants.ConnectionSettingsConfigFile);
            }
            catch (Exception ex)
            {
                // Extended properties
                Dictionary <string, object> extProps = new Dictionary <string, object>();
                extProps.Add("Connection", connection);
                // FtpLog-Exception
                //this.unityContainer.Resolve<ILoggingService>(ServiceNames.LoggingService).Write(ex, LoggingCategories.ConnectionManagementModule, 1, 1000, System.Diagnostics.TraceEventType.Error, "ConnectionManager :: Failed to add a connection", extProps);
                // TODO: Show-Exeption
                System.Diagnostics.Debug.WriteLine(ex);

                result = false;
            }

            return(result);
        }