/// <summary>
        /// Called by Loupe to have the configuration editor display itself and edit the provided configuration
        /// </summary>
        public DialogResult EditConfiguration(IRepositoryContext context, IRepositoryConfiguration configuration, bool initialConfiguration)
        {
            _context = context;
            _context.Log.Verbose(ExtentionDefinition.LogCategory, "Begin editing Session Alert config", null);

            var newConfig = configuration.Common as FindByUserConfiguration ?? new FindByUserConfiguration();

            DisplayConfiguration(newConfig);

            DialogResult result = ShowDialog();
            if (result == DialogResult.OK)
            {
                //copy back our changes, but first make a clone to allow change logging
                var oldConfig = newConfig.Clone();

                newConfig.DatabaseProvider = cboProvider.Text;
                newConfig.ConnectionString = txtConnectionString.Text;
                newConfig.AutoScanSessions = chkEnableAutoScan.Checked;

                configuration.Common = newConfig; // this is redundant except in the crucial first-time initialization case!

                LogConfigurationChanges(newConfig, oldConfig);
            }
            else
            {
                _context.Log.Verbose(ExtentionDefinition.LogCategory, "Canceling FindByUser config dialog", null);
            }

            return result;
        }
Exemple #2
0
        /// <summary>
        /// Called by Loupe to have the configuration editor display itself and edit the provided configuration
        /// </summary>
        public DialogResult EditConfiguration(IRepositoryContext context, IRepositoryConfiguration configuration, bool initialConfiguration)
        {
            _context = context;
            _context.Log.Verbose(ExtentionDefinition.LogCategory, "Begin editing Session Alert config", null);

            var newConfig = configuration.Common as FindByUserConfiguration ?? new FindByUserConfiguration();

            DisplayConfiguration(newConfig);

            DialogResult result = ShowDialog();

            if (result == DialogResult.OK)
            {
                //copy back our changes, but first make a clone to allow change logging
                var oldConfig = newConfig.Clone();

                newConfig.DatabaseProvider = cboProvider.Text;
                newConfig.ConnectionString = txtConnectionString.Text;
                newConfig.AutoScanSessions = chkEnableAutoScan.Checked;

                configuration.Common = newConfig; // this is redundant except in the crucial first-time initialization case!

                LogConfigurationChanges(newConfig, oldConfig);
            }
            else
            {
                _context.Log.Verbose(ExtentionDefinition.LogCategory, "Canceling FindByUser config dialog", null);
            }

            return(result);
        }
        public static bool TryGetValue <T>(this IRepositoryConfiguration config, Type section, string key, out T value)
        {
            var configItem = new ConfigurationItem(section.Name, key);

            if (config.Contains(configItem) == true)
            {
                try
                {
                    if (ConfigurationBase.CanSupportType(typeof(T)) == true)
                    {
                        value = (T)config[configItem];
                        return(true);
                    }
                    else
                    {
                        var text = (string)config[configItem];
                        value = XmlSerializerUtility.ReadString <T>(text.Decrypt());
                        return(true);
                    }
                }
                catch
                {
                }
            }

            value = default;
            return(false);
        }
 public DocumentDbRepository(string collectionId, IRepositoryConfiguration config)
 {
     CollectionId          = collectionId;
     this.config           = config;
     DocumentCollectionUri = UriFactory.CreateDocumentCollectionUri(config.DatabaseId, collectionId);
     CreateCollectionIfNotExistAsync(collectionId).Wait();
 }
 public SessionProvider(IRepositoryConfiguration configuration)
 {
     var factory = configuration.CreateSessionFactory();
     var session = factory.GetCurrentSession();
     if (session == null || !session.IsOpen)
     {
         session = factory.OpenSession();
     }
     _session = session;
 }
Exemple #6
0
        protected BaseRepository(IRepositoryConfiguration config, ILogger <IRepository> logger)
        {
            config = config ?? throw new ArgumentNullException(nameof(config));

            logger = logger ?? throw new ArgumentNullException(nameof(logger));

            Logger = logger;

            _connectionString = config.SQL_CONNECTION_STRING;
        }
        public static void SetValue <T>(this IRepositoryConfiguration config, Type section, string key, T value)
        {
            var configItem = new ConfigurationItem(section.Name, key);

            if (ConfigurationBase.CanSupportType(typeof(T)) == true)
            {
                config[configItem] = value;
            }
            else
            {
                config[configItem] = XmlSerializerUtility.GetString(value).Encrypt();
            }
        }
Exemple #8
0
        /// <summary>
        /// Called by Gibraltar to have the configuration editor display itself and edit the provided configuration
        /// </summary>
        public DialogResult EditConfiguration(IRepositoryContext context, IRepositoryConfiguration configuration, bool initialConfiguration)
        {
            context.Log.Verbose(LogCategory, "Begin editing Session Export config", null);

            _configuration = configuration.Common as ExportAddInConfiguration ?? new ExportAddInConfiguration();

            DisplayConfiguration(context);

            DialogResult result = ShowDialog();

            if (result == DialogResult.OK)
            {
                //copy back our changes, but first make a clone to allow change logging
                var oldConfig = _configuration.Clone();

                _configuration.SessionExportPath       = txtExportPath.Text;
                _configuration.Environment             = NormalizeEnvironmentList(txtEnvironment.Text);
                _configuration.AutoExportSessions      = chkEnableAutoExport.Checked;
                _configuration.UseUniqueFilenames      = chkEnsureUniqueFilenames.Checked;
                _configuration.MetricsToExport         = txtMetricsToExport.Text;
                _configuration.EnableLogMessageExport  = chkEnableLogMessageExport.Checked;
                _configuration.IncludeSessionSummary   = chkIncludeSessionSummary.Checked;
                _configuration.IncludeExceptionDetails = chkIncludeExceptionDetails.Checked;

                // Store selected format, but guard against parse errors
                var format = LogMessageFormat.Default; // Initialize in case TryParse fails
                if (!Enum.TryParse(cboMessageFormatter.Text, true, out format))
                {
                    context.Log.Error(LogCategory, "Could not parse Log Message Formatter", "Selected value: {0}", cboMessageFormatter.Text);
                }
                _configuration.LogMessageFormat = format;

                // Store selected severity, but guard against parse errors
                var severity = LogMessageSeverity.Verbose; // Initialize in case TryParse fails
                if (!Enum.TryParse(cboMinimumSeverity.Text, true, out severity))
                {
                    context.Log.Error(LogCategory, "Could not parse Log Message Severity", "Selected value: {0}", cboMinimumSeverity.Text);
                }
                _configuration.MinimumSeverity = severity;

                configuration.Common = _configuration;

                LogConfigurationChanges(context, oldConfig);
            }
            else
            {
                context.Log.Verbose(LogCategory, "Canceling Session Export config dialog", null);
            }

            return(result);
        }
 public FsChangeSyncService(
     IRepositoryConfiguration config,
     ISynchronisationEngineFactory synchronisationEngineFactory,
     ILogger logger)
 {
     _logger = logger;
     SynchronisationEngine = synchronisationEngineFactory.Create(config);
     InnerState = new Dictionary<string, IFileStateInfo>();
     ServiceName = config.RepositoryName;
     _ignoreList = new List<string>(config.IgnoreList);
     FileSystemWatcher = CreateFSWatcherOnPath(config.FileSystemPath);
     SubscribeEvents(FileSystemWatcher);
     //OnStateChanged();
 }
        /// <summary>
        /// Called by Loupe to have the configuration editor display itself and edit the provided configuration
        /// </summary>
        /// <param name="context">The Repository Context provides a connection to the hosting environment.</param><param name="configuration">The current configuration.</param><param name="initialConfiguration">Indicates if the configuration has ever completed in the current environment.</param>
        /// <returns>
        /// DialogResult.OK if the configuration is complete and should be accepted as the new configuration.  Any other result to cancel.  If this
        ///             is the initial configuration and it is not OK the Extension will not be enabled.
        /// </returns>
        public DialogResult EditConfiguration(IRepositoryContext context, IRepositoryConfiguration configuration, bool initialConfiguration)
        {
            m_Configuration = configuration.Common as SampleAddInConfiguration ?? new SampleAddInConfiguration();

            DisplayConfiguration();

            DialogResult result = ShowDialog();
            if (result == DialogResult.OK)
            {
                //copy back our changes.
                m_Configuration.AutoExportSessions = chkEnableAutoExport.Checked;
                m_Configuration.SessionExportPath = txtSessionExportPath.Text;
                configuration.Common = m_Configuration;
            }

            return result;
        }
        /// <summary>
        /// Called by Gibraltar to have the configuration editor display itself and edit the provided configuration
        /// </summary>
        public DialogResult EditConfiguration(IRepositoryContext context, IRepositoryConfiguration configuration, bool initialConfiguration)
        {
            context.Log.Verbose(LogCategory, "Begin editing Session Export config", null);

            _configuration = configuration.Common as ExportAddInConfiguration ?? new ExportAddInConfiguration();

            DisplayConfiguration(context);

            DialogResult result = ShowDialog();
            if (result == DialogResult.OK)
            {
                //copy back our changes, but first make a clone to allow change logging
                var oldConfig = _configuration.Clone();

                _configuration.SessionExportPath = txtExportPath.Text;
                _configuration.Environment = NormalizeEnvironmentList(txtEnvironment.Text);
                _configuration.AutoExportSessions = chkEnableAutoExport.Checked;
                _configuration.UseUniqueFilenames = chkEnsureUniqueFilenames.Checked;
                _configuration.MetricsToExport = txtMetricsToExport.Text;
                _configuration.EnableLogMessageExport = chkEnableLogMessageExport.Checked;
                _configuration.IncludeSessionSummary = chkIncludeSessionSummary.Checked;
                _configuration.IncludeExceptionDetails = chkIncludeExceptionDetails.Checked;

                // Store selected format, but guard against parse errors
                var format = LogMessageFormat.Default; // Initialize in case TryParse fails
                if (!Enum.TryParse(cboMessageFormatter.Text, true, out format))
                    context.Log.Error(LogCategory, "Could not parse Log Message Formatter", "Selected value: {0}", cboMessageFormatter.Text);
                _configuration.LogMessageFormat = format;

                // Store selected severity, but guard against parse errors
                var severity = LogMessageSeverity.Verbose; // Initialize in case TryParse fails
                if (!Enum.TryParse(cboMinimumSeverity.Text, true, out severity))
                    context.Log.Error(LogCategory, "Could not parse Log Message Severity", "Selected value: {0}", cboMinimumSeverity.Text);
                _configuration.MinimumSeverity = severity;

                configuration.Common = _configuration;

                LogConfigurationChanges(context, oldConfig);
            }
            else
            {
                context.Log.Verbose(LogCategory, "Canceling Session Export config dialog", null);
            }

            return result;
        }
        public IRepositoryConfiguration GetRepository(string repositoryName)
        {
            if (!HasRepository)
            {
                throw new Exception("There are no repositories configured.");
            }

            if (String.IsNullOrEmpty(repositoryName))
            {
                repositoryName = ((ISharpRepositoryConfiguration)this).DefaultRepository;
            }

            IRepositoryConfiguration repositoryConfiguration = null;

            if (String.IsNullOrEmpty(repositoryName))
            {
                // return the first one
                foreach (RepositoryElement element in Repositories)
                {
                    repositoryConfiguration = element;
                    break;
                }

                return(repositoryConfiguration);
            }

            // find the repository element by name
            // NOTE: i've intentionally left it as this loop instead of using LINQ because the .Cast<> slows down performance and I think this is just as readable
            foreach (RepositoryElement element in Repositories)
            {
                if (element.Name == repositoryName)
                {
                    repositoryConfiguration = element;
                    break;
                }
            }

            // if this is null then throw an error
            if (repositoryConfiguration == null)
            {
                throw new Exception(String.Format("There is no repository configured with the name '{0}'", repositoryName));
            }

            return(repositoryConfiguration);
        }
Exemple #13
0
        /// <summary>
        /// Called by Loupe to have the configuration editor display itself and edit the provided configuration
        /// </summary>
        /// <param name="context">The Repository Context provides a connection to the hosting environment.</param><param name="configuration">The current configuration.</param><param name="initialConfiguration">Indicates if the configuration has ever completed in the current environment.</param>
        /// <returns>
        /// DialogResult.OK if the configuration is complete and should be accepted as the new configuration.  Any other result to cancel.  If this
        ///             is the initial configuration and it is not OK the Extension will not be enabled.
        /// </returns>
        public DialogResult EditConfiguration(IRepositoryContext context, IRepositoryConfiguration configuration, bool initialConfiguration)
        {
            m_Configuration = configuration.Common as SampleAddInConfiguration ?? new SampleAddInConfiguration();

            DisplayConfiguration();

            DialogResult result = ShowDialog();

            if (result == DialogResult.OK)
            {
                //copy back our changes.
                m_Configuration.AutoExportSessions = chkEnableAutoExport.Checked;
                m_Configuration.SessionExportPath  = txtSessionExportPath.Text;
                configuration.Common = m_Configuration;
            }

            return(result);
        }
Exemple #14
0
 public static IAccountRepository GetAccountRepo(IRepositoryConfiguration config)
 {
     return(new AccountRepository(config));
 }
 public IJournal CreateJournal(IRepositoryConfiguration configuration)
 {
     return new DiskJournal(configuration, Path, SnapshotArchiver);
 }
 public FtpSynchronisationEngine(ILogger logger, IRepositoryConfiguration config)
 {
     _logger = logger;
     _config = config;
 }
 public Repository(IRepositoryConfiguration configuration)
 {
     _connectionString = configuration.ConnectionString;
 }
 public ExternalAPIProxy(IRepositoryConfiguration repositoryConfiguration)
 {
     _httpClient = new HttpClient();
     _repositoryConfiguration = repositoryConfiguration;
 }
 public InRepoConfiguration With(string alias, IRepositoryConfiguration configuration)
 {
     _configurations[alias] = configuration;
     return this;
 }
 public RepositoryAncestor(IRepositoryConfiguration configuration) : base(configuration)
 {
 }
Exemple #21
0
 public Repository2(IRepositoryConfiguration configuration)
     : base(configuration)
 {
 }
Exemple #22
0
 public static InRepoConfiguration With(string alias, IRepositoryConfiguration configuration)
 {
     return(MasterConfiguration.With(alias, configuration));
 }
Exemple #23
0
 public DocumentDbConfigRepositoryFactory(IRepositoryConfiguration config)
     : base(config)
 {
 }
Exemple #24
0
 public CouchDbConfigRepositoryFactory(IRepositoryConfiguration config)
     : base(config)
 {
 }
Exemple #25
0
 public EarningRepository(IRepositoryConfiguration config,
                          ILogger <IRepository> logger) : base(config, logger)
 {
 }
Exemple #26
0
 public BalanceSheetRepository(IRepositoryConfiguration config,
                               ILogger <IRepository> logger) : base(config, logger)
 {
 }
 public UserController(IRepositoryConfiguration config, INamedSettingResolver resolver) : base(config, resolver)
 {
 }
 private void InitRepository(IRepositoryConfiguration repoConfig)
 {
     try
     {
         if (!Directory.Exists(repoConfig.FileSystemPath))
         {
             throw new Exception(
                 string.Format("Директория {0} не может быть найдена. Проверьте конфиг.",
                               repoConfig.FileSystemPath));
         }
         IFsChangeSyncService trigger = _fsChangeSyncServiceFactory.Create(repoConfig);
         trigger.StateChanged += InvokeChangeNotification;
         FsChangeSyncServices.Add(trigger.ServiceName, trigger);
     }
     catch (Exception ex)
     {
         _logger.Warn(string.Format("Error on repo {0} init.\n{1}",
                                     repoConfig.RepositoryName,
                                     ex));
         _messageBoxResolver.Show(string.Format("Репозиторий {0} не инициализирован, потому что ошибка: \n{1}",
                                                repoConfig.RepositoryName, ex.Message),
                                  "Ошибка инициализования", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public AzureBlobConfigRepositoryFactory(IRepositoryConfiguration config)
     : base(config)
 {
 }
 public IJournal CreateJournal(IRepositoryConfiguration configuration)
 {
     return new MemoryJournal(configuration, JournalData);
 }
Exemple #31
0
 public DatastoreManager(IRepositoryConfiguration repositoryConfiguration)
 {
     _repositoryConfiguration = repositoryConfiguration;
 }
Exemple #32
0
 public void AddRepository(IRepositoryConfiguration repositoryConfiguration)
 {
     Repositories.Add(repositoryConfiguration);
 }
 public RavenDbConfigRepositoryFactory(IRepositoryConfiguration config)
     : base(config)
 {
 }
 public RepositoryFactory(IRepositoryConfiguration config)
 {
     _config = config;
 }
 public UnderscoreRepository(IRepositoryConfiguration configuration) : base(configuration)
 {
 }
Exemple #36
0
 public RepositoryConfigurationCacheEntry(DateTimeOffset fetched, IRepositoryConfiguration repositoryConfiguration)
 {
     this.Fetched       = fetched;
     this.Configuration = repositoryConfiguration;
 }
Exemple #37
0
 public static InRepoConfiguration With(string alias, IRepositoryConfiguration configuration)
 {
     return MasterConfiguration.With(alias, configuration);
 }
Exemple #38
0
 public AsyncInitializer(IRepositoryConfiguration repositoryConfiguration) => _repositoryConfiguration = repositoryConfiguration;
 public RepositoryFactory(IRepositoryConfiguration configuration)
 {
     _configuration = configuration;
 }
 public IJournal CreateJournal(IRepositoryConfiguration configuration, string path)
 {
     return new Journal(configuration, path);
 }
Exemple #41
0
 public AccountRepository(IRepositoryConfiguration config)
 {
     AccountConnectionString = config.AccountSqlConnectionString;
 }
Exemple #42
0
 public MongoDbConfigRepositoryFactory(IRepositoryConfiguration config)
     : base(config)
 {
 }
 public EfConfigRepositoryFactory(IRepositoryConfiguration config)
     : base(config)
 {
 }
 public IJournal CreateJournal(IRepositoryConfiguration configuration)
 {
     return new SqlServerJournal(configuration, ConnectionString, RepositoryName);
 }