Exemple #1
0
 public ServicesService(
     INeutrinoClient neutrinoClient,
     IOptions <ApplicationParameters> applicationParameters)
 {
     _neutrinoClient        = neutrinoClient;
     _applicationParameters = applicationParameters.Value;
 }
Exemple #2
0
        public static bool is_resolved()
        {
            if (ApplicationParameters.get_merged_assembly_name() == ApplicationParameters.default_merged_assembly_name)
            {
                return(true);
            }

            string log4net_file       = "log4net.dll";
            bool   log4net_dll_exists = false;

            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, log4net_file)))
            {
                log4net_dll_exists = true;
            }

            if (!log4net_dll_exists)
            {
                //try to resolve it anywhere
                try
                {
                    DefaultAssemblyLoader.load_assembly(log4net_file);
                    log4net_dll_exists = true;
                }
                catch (Exception)
                {
                    //the file doesn't exist
                }
            }

            return(log4net_dll_exists);
        }
        public static void configure()
        {
            //ILoggerRepository log_repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
            //log_repository.Threshold = Level.Info;

            //BasicConfigurator.Configure(log_repository, set_up_console_appender());
            //BasicConfigurator.Configure(log_repository,set_up_rolling_file_appender());

            //todo: merge assembly is the default now.

            string assembly_name = ApplicationParameters.log4net_configuration_assembly;
            Stream xml_config_stream;

            try
            {
                xml_config_stream = Assembly.Load(ApplicationParameters.get_merged_assembly_name()).GetManifestResourceStream(ApplicationParameters.log4net_configuration_resource);

                if (xml_config_stream == null)
                {
                    throw new NullReferenceException("Failed to load xml configuration for log4net, consider that assemblies was not merged");
                }
            }
            catch (Exception)
            {
                used_merged       = false;
                xml_config_stream = Assembly.Load(assembly_name).GetManifestResourceStream(ApplicationParameters.log4net_configuration_resource);
            }

            XmlConfigurator.Configure(xml_config_stream);

            the_logger.DebugFormat("Configured {0} from assembly {1}", ApplicationParameters.log4net_configuration_resource, used_merged ? ApplicationParameters.get_merged_assembly_name() : assembly_name);
        }
Exemple #4
0
        private async Task <ApplicationParameters?> ReadOrProvisionMicrosoftIdentityApplication(
            TokenCredential tokenCredential,
            ApplicationParameters applicationParameters)
        {
            ApplicationParameters?currentApplicationParameters = null;

            if (!string.IsNullOrEmpty(applicationParameters.EffectiveClientId))
            {
                currentApplicationParameters = await MicrosoftIdentityPlatformApplicationManager.ReadApplication(tokenCredential, applicationParameters);

                if (currentApplicationParameters == null)
                {
                    Console.Write($"Couldn't find app {applicationParameters.EffectiveClientId} in tenant {applicationParameters.EffectiveTenantId}. ");
                }
            }

            if (currentApplicationParameters == null && !ProvisioningToolOptions.Unregister)
            {
                currentApplicationParameters = await MicrosoftIdentityPlatformApplicationManager.CreateNewApp(tokenCredential, applicationParameters);

                if (ProvisioningToolOptions.Json == null || ProvisioningToolOptions.Json == false)
                {
                    Console.Write($"Created app {currentApplicationParameters.ClientId}. ");
                }
            }
            return(currentApplicationParameters);
        }
        public static void configure_without_console()
        {
            //ILoggerRepository log_repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
            //log_repository.Threshold = Level.Info;

            //BasicConfigurator.Configure(log_repository, set_up_console_appender());
            //BasicConfigurator.Configure(log_repository,set_up_rolling_file_appender());

            string assembly_name = ApplicationParameters.log4net_configuration_assembly;
            Stream xml_config_stream;

            try
            {
                xml_config_stream = Assembly.Load(ApplicationParameters.get_merged_assembly_name()).GetManifestResourceStream(ApplicationParameters.log4net_configuration_resource_no_console);
            }
            catch (Exception)
            {
                used_merged       = false;
                xml_config_stream = Assembly.Load(assembly_name).GetManifestResourceStream(ApplicationParameters.log4net_configuration_resource_no_console);
            }

            XmlConfigurator.Configure(xml_config_stream);

            the_logger.DebugFormat("Configured {0} from assembly {1}", ApplicationParameters.log4net_configuration_resource_no_console, used_merged ? ApplicationParameters.get_merged_assembly_name() : assembly_name);
        }
 public AuditEventListModel(String HolderName, List <AuditEvent> AuditEvents)
 {
     this.HolderName  = HolderName;
     this.AuditEvents = AuditEvents;
     Filter           = new AuditEventListFilter();
     AppParams        = new ApplicationParameters();
 }
        public RoleListModel(string HolderName)
        {
            int result = 0;

            Filter    = new RoleListFilter();
            AppParams = new ApplicationParameters();

            int TotalItems = 0;

            this.HolderName          = HolderName;
            this.Filter.ItemsPerPage = (HttpContext.Current.Request["s"] != null && int.TryParse(HttpContext.Current.Request["s"], out result)) ? result : int.Parse(AppParams.AppUiPagingSize.Value);
            this.Filter.CurrentPage  = (HttpContext.Current.Request["p"] != null && int.TryParse(HttpContext.Current.Request["p"], out result)) ? result : 1;

            this.Filter.SortColumn   = (HttpContext.Current.Request["c"] != null && int.TryParse(HttpContext.Current.Request["c"], out result)) ? result : 1;
            this.Filter.SortOrderAsc = (HttpContext.Current.Request["o"] != null && (int.TryParse(HttpContext.Current.Request["o"], out result)) ? (result == 1 ? true : false) : true);

            this.Filter.SortColumnName = "RoleID";
            switch (this.Filter.SortColumn)
            {
            case 2: this.Filter.SortColumnName = "Name"; break;

            case 3: this.Filter.SortColumnName = "MemberCount"; break;

            case 6: this.Filter.SortColumnName = "Created"; break;

            case 7: this.Filter.SortColumnName = "Modified"; break;

            case 5: this.Filter.SortColumnName = "Settings"; break;
            }

            this.Roles      = Web.Admin.Logic.Collections.Roles.Get(Filter, out TotalItems);
            this.TotalItems = TotalItems;
        }
 public MemberListModel(String HolderName, List <Member> Members)
 {
     this.HolderName = HolderName;
     this.Members    = Members;
     Filter          = new MemberListFilter();
     AppParams       = new ApplicationParameters();
 }
        public void register_db_provider_factory()
        {
            var dataSet = (DataSet)ConfigurationManager.GetSection("system.data");

            if (dataSet != null)
            {
                var my_sql_client_row = dataSet?.Tables[0]
                                        .Rows?.Cast <DataRow>()
                                        .SingleOrDefault(row => (string)row[2] == "MySql.Data.MySqlClient");

                if (my_sql_client_row != null)
                {
                    dataSet.Tables[0].Rows.Remove(my_sql_client_row);
                }

                var factory_type = is_merged
                    ? "MySql.Data.MySqlClient.MySqlClientFactory, " + ApplicationParameters.get_merged_assembly_name()
                    : "MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data";

                dataSet.Tables[0].Rows.Add(
                    "MySQL Data Provider",
                    ".Net Framework Data Provider for MySQL",
                    "MySql.Data.MySqlClient",
                    factory_type);
            }
        }
 public DomainListModel()
 {
     Domains             = new List <Domain>();
     Filter              = new DomainListFilter();
     HolderName          = "";
     Filter.ItemsPerPage = 5;
     Filter.CurrentPage  = 1;
     AppParams           = new ApplicationParameters();
 }
 public RoleListModel()
 {
     Roles               = new List <Role>();
     Filter              = new RoleListFilter();
     HolderName          = "";
     Filter.ItemsPerPage = 5;
     Filter.CurrentPage  = 1;
     AppParams           = new ApplicationParameters();
 }
        public bool IsValid(CommandLineParameterWithValueCollection parameters)
        {
            ApplicationParameters param = new ApplicationParameters(parameters);

            return(param.GetSearchString().Count == param.GetReplaceString().Count);
            //return parameters.Exists(p => String.Compare(p.GetName(), "L", true) == 0);
            //{

            //}
        }
        private static void set_licensed_options(ChocolateyConfiguration config, ChocolateyLicense license, ConfigFileSettings configFileSettings)
        {
            config.Information.IsLicensedVersion = license.is_licensed_version();
            config.Information.LicenseType       = license.LicenseType.get_description_or_value();

            if (license.AssemblyLoaded)
            {
                Type licensedConfigBuilder = license.Assembly.GetType(ApplicationParameters.LicensedConfigurationBuilder, throwOnError: false, ignoreCase: true);

                if (licensedConfigBuilder == null)
                {
                    if (config.RegularOutput)
                    {
                        "chocolatey".Log().Warn(ChocolateyLoggers.Important,
                                                @"Unable to set licensed configuration. Please upgrade to a newer 
 licensed version (choco upgrade chocolatey.extension).");
                    }
                    return;
                }
                try
                {
                    object componentClass = Activator.CreateInstance(licensedConfigBuilder);

                    licensedConfigBuilder.InvokeMember(
                        SET_CONFIGURATION_METHOD,
                        BindingFlags.InvokeMethod,
                        null,
                        componentClass,
                        new Object[] { config, configFileSettings }
                        );
                }
                catch (Exception ex)
                {
                    var isDebug = ApplicationParameters.is_debug_mode_cli_primitive();
                    if (config.Debug)
                    {
                        isDebug = true;
                    }
                    var message = isDebug ? ex.ToString() : ex.Message;

                    if (isDebug && ex.InnerException != null)
                    {
                        message += "{0}{1}".format_with(Environment.NewLine, ex.ToString());
                    }

                    "chocolatey".Log().Error(
                        ChocolateyLoggers.Important,
                        @"Error when setting configuration for '{0}':{1} {2}".format_with(
                            licensedConfigBuilder.FullName,
                            Environment.NewLine,
                            message
                            ));
                }
            }
        }
 public PdfExportClient(
     string baseAddress,
     ILogger <NightcrawlerClient> logger,
     HttpClient httpClient,
     IOptions <ApplicationParameters> applicationParameters)
 {
     _baseAddress           = baseAddress;
     _logger                = logger;
     _httpClient            = httpClient;
     _applicationParameters = applicationParameters.Value;
 }
 public DiscoveryService(
     INeutrinoClient neutrinoClient,
     IOptions <ApplicationParameters> applicationParameters,
     IMemoryCache memoryCache,
     ILogger <DiscoveryService> logger)
 {
     _neutrinoClient        = neutrinoClient;
     _applicationParameters = applicationParameters.Value;
     _memoryCache           = memoryCache;
     _logger = logger;
 }
Exemple #16
0
 public GatewayService(
     IHttpContextAccessor httpContextAccessor,
     IOptions <ApplicationParameters> applicationParameters,
     IDiscoveryService discoveryService,
     ILoggerFactory loggerFactory,
     HttpClient httpClient)
 {
     _httpContextAccessor   = httpContextAccessor;
     _applicationParameters = applicationParameters.Value;
     _discoveryService      = discoveryService;
     _logger     = loggerFactory.CreateLogger <GatewayService>();
     _httpClient = httpClient;
 }
Exemple #17
0
 static void Main()
 {
     // Configurações padrão do visual studio
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     // Carrega parâmtros de configuração da aplicação
     // Ex: times, custos de viagem e estadia etc.
     ConfigureAntBr.LoadApplicationParameters();
     // Gera a matriz de custos total (estadia + viagem).
     ApplicationParameters.caulculateTotalCostMatrix();
     // Inicia a execução do Form.
     Application.Run(new Form1());
 }
        public void Initialize(ApplicationParameters parameters, IModuleRegistrar registrar)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (registrar == null)
            {
                throw new ArgumentNullException("registrar");
            }

            registrar.RegisterType<IFileWordsService, FileWordsService>();
        }
        public void Initialize(ApplicationParameters parameters, IModuleRegistrar registrar)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (registrar == null)
            {
                throw new ArgumentNullException("registrar");
            }

            registrar.RegisterType <IFileWordsService, FileWordsService>();
        }
Exemple #20
0
        public void GetReplaceString_WithLParam_WillReturnSearchStringInLowerCase()
        {
            CommandLineParameterCollection mandatoryParams = new CommandLineParameterCollection();

            mandatoryParams.Add(new CommandLineParameter("S", String.Empty, String.Empty, true));

            CommandLineParameterWithValueCollection param = new CommandLineParameterWithValueCollection();

            param.Add(new CommandLineParameterWithValue(mandatoryParams[0], "HelloWorld"));
            param.Add(new CommandLineParameterWithValue(new CommandLineParameter("L", String.Empty, String.Empty, false), string.Empty));
            ApplicationParameters values = new ApplicationParameters(param);


            Assert.AreEqual("HelloWorld", values.GetSearchString()[0]);
            Assert.AreEqual("helloworld", values.GetReplaceString()[0]);
        }
        public MemberListModel(string HolderName)
        {
            int result = 0;

            this.Filter = new MemberListFilter();
            AppParams   = new ApplicationParameters();

            int TotalItems = 0;

            this.HolderName          = HolderName;
            this.Filter.ItemsPerPage = (HttpContext.Current.Request["s"] != null && int.TryParse(HttpContext.Current.Request["s"], out result)) ? result : int.Parse(AppParams.AppUiPagingSize.Value);
            this.Filter.CurrentPage  = (HttpContext.Current.Request["p"] != null && int.TryParse(HttpContext.Current.Request["p"], out result)) ? result : 1;

            this.Filter.SortColumn     = (HttpContext.Current.Request["c"] != null && int.TryParse(HttpContext.Current.Request["c"], out result)) ? result : 1;
            this.Filter.SortOrderAsc   = (HttpContext.Current.Request["o"] != null && (int.TryParse(HttpContext.Current.Request["o"], out result)) ? (result == 1 ? true : false) : true);
            this.Filter.SortColumnName = "MemberID";
            this.Filter.Search         = (HttpContext.Current.Request["q"] != null ? HttpUtility.UrlDecode(HttpContext.Current.Request["q"]) : "");

            if (HttpContext.Current.Request["f"] != null)
            {
                if (HttpContext.Current.Request["f"] == "or")
                {
                    Filter.RoleFilterCondition = MemberListFilterRoleConditon.OR;
                }
                else if (HttpContext.Current.Request["f"] == "and")
                {
                    Filter.RoleFilterCondition = MemberListFilterRoleConditon.AND;
                }
            }

            switch (this.Filter.SortColumn)
            {
            case 2: this.Filter.SortColumnName = "Name"; break;

            case 4: this.Filter.SortColumnName = "Email"; break;

            case 5: this.Filter.SortColumnName = "LastLogin"; break;

            case 6: this.Filter.SortColumnName = "Created"; break;
            }

            this.Filter.AlphabetFilter = StringToList(HttpContext.Current.Request["a"] != null ? HttpContext.Current.Request["a"]  : "");
            this.Filter.RolesFilter    = StringToList(HttpContext.Current.Request["r"] != null ? HttpContext.Current.Request["r"] : "");

            this.Members    = Web.Admin.Logic.Collections.Members.Get(this.Filter, out TotalItems);
            this.TotalItems = TotalItems;
        }
Exemple #22
0
        static void Main(string[] args)
        {
            ApplicationParameters applicationParameters = new ApplicationParameters();

            IMenu <ApplicationParameters> myMenu = CreateMenu();

            Console.SetCursorPosition(0, 2);

            while (true)
            {
                myMenu.Display(35);
                var mySelection = myMenu.SelectItem("Bitte einen Menüpunkt auswählen: ");


                mySelection.Execute(applicationParameters);
            }
        }
Exemple #23
0
        //private const string proxy_factory = Environment.ProxyFactoryFactoryClass;

        public NHibernateSessionFactoryBuilder(ConfigurationPropertyHolder config)
        {
            configuration_holder = config;
            func_dictionary      = new Dictionary <string, Func <IPersistenceConfigurer> >();
            func_dictionary.Add("roundhouse.databases.sqlserver.SqlServerDatabase, roundhouse.databases.sqlserver",
                                () => MsSqlConfiguration.MsSql2005.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.sqlserver2000.SqlServerDatabase, roundhouse.databases.sqlserver2000",
                                () => MsSqlConfiguration.MsSql2000.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.sqlserverce.SqlServerCEDatabase, roundhouse.databases.sqlserverce",
                                () => MsSqlCeConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.mysql.MySqlDatabase, roundhouse.databases.mysql",
                                () => MySQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.oracle.OracleDatabase, roundhouse.databases.oracle",
                                () => OracleClientConfiguration.Oracle9.ConnectionString(configuration_holder.ConnectionString)
                                .Driver("roundhouse.databases.oracle.RoundhousEOracleDriver, roundhouse.databases.oracle"));
            func_dictionary.Add("roundhouse.databases.access.AccessDatabase, roundhouse.databases.access",
                                () => JetDriverConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.sqlite.SqliteDatabase, roundhouse.databases.sqlite",
                                () => SQLiteConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.postgresql.PostgreSQLDatabase, roundhouse.databases.postgresql",
                                () => PostgreSQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.postgresql.RedshiftSQLDatabase, roundhouse.databases.postgresql",
                                () => PostgreSQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            // merged
            string merged_assembly_name = ApplicationParameters.get_merged_assembly_name();

            func_dictionary.Add("roundhouse.databases.sqlserver.SqlServerDatabase, " + merged_assembly_name,
                                () => MsSqlConfiguration.MsSql2005.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.sqlserver2000.SqlServerDatabase, " + merged_assembly_name,
                                () => MsSqlConfiguration.MsSql2000.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.sqlserverce.SqlServerCEDatabase, " + merged_assembly_name,
                                () => MsSqlCeConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.mysql.MySqlDatabase, " + merged_assembly_name,
                                () => MySQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.oracle.OracleDatabase, " + merged_assembly_name,
                                () => OracleClientConfiguration.Oracle9.ConnectionString(configuration_holder.ConnectionString)
                                .Driver("roundhouse.databases.oracle.RoundhousEOracleDriver, " + merged_assembly_name));
            func_dictionary.Add("roundhouse.databases.access.AccessDatabase, " + merged_assembly_name,
                                () => JetDriverConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.sqlite.SqliteDatabase, " + merged_assembly_name,
                                () => SQLiteConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.postgresql.PostgreSQLDatabase, " + merged_assembly_name,
                                () => PostgreSQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
            func_dictionary.Add("roundhouse.databases.postgresql.RedshiftSQLDatabase, " + merged_assembly_name,
                                () => PostgreSQLConfiguration.Standard.ConnectionString(configuration_holder.ConnectionString));
        }
        public bool IsValid(CommandLineParameterWithValueCollection parameters)
        {
            ApplicationParameters param = new ApplicationParameters(parameters);

            if (param.GetLocationOptions().IsSet(SearchReplaceLocationOptions.ReplaceAttributeName) || param.GetLocationOptions().IsSet(SearchReplaceLocationOptions.ReplaceElementName))
            {
                foreach (string str in param.GetReplaceString())
                {
                    if (!Utility.IsValidXmlName(str))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Add API permissions.
        /// </summary>
        /// <param name="applicationParameters"></param>
        /// <param name="graphServiceClient"></param>
        /// <param name="application"></param>
        /// <returns></returns>
        private async Task <IEnumerable <IGrouping <string, ResourceAndScope> >?> AddApiPermissions(
            ApplicationParameters applicationParameters,
            GraphServiceClient graphServiceClient,
            Application application)
        {
            // Case where the app calls a downstream API
            List <RequiredResourceAccess> apiRequests = new List <RequiredResourceAccess>();
            string?calledApiScopes = applicationParameters?.CalledApiScopes;
            IEnumerable <IGrouping <string, ResourceAndScope> >?scopesPerResource = null;

            if (!string.IsNullOrEmpty(calledApiScopes))
            {
                string[] scopes = calledApiScopes.Split(' ', '\t', StringSplitOptions.RemoveEmptyEntries);
                scopesPerResource = scopes.Select(s => (!s.Contains('/'))
                                                  // Microsoft Graph shortcut scopes (for instance "User.Read")
                ? new ResourceAndScope("https://graph.microsoft.com", s)
                                                  // Proper AppIdUri/scope
                : new ResourceAndScope(s.Substring(0, s.LastIndexOf('/')), s[(s.LastIndexOf('/') + 1)..])
Exemple #26
0
        public void GetReplaceString_WithPParam_ReturnListOfReplaceStringsFromFileSpecified()
        {
            string paramFile = TestHelper.CreateParameterFile(new string[] { @"/S=""Book"" /R=""SmallBook""", @"/S=""Library"" /R=""Oxford""" });



            CommandLineParameterWithValueCollection values = new CommandLineParameterWithValueCollection();

            values.Add(new CommandLineParameterWithValue(new CommandLineParameter("P", String.Empty, String.Empty, false), paramFile));

            ApplicationParameters appParams = new ApplicationParameters(values);

            Assert.AreEqual(2, appParams.GetReplaceString().Count);
            Assert.AreEqual("SmallBook", appParams.GetReplaceString()[0]);
            Assert.AreEqual("Oxford", appParams.GetReplaceString()[1]);

            TestHelper.DeleteLastParameterFile();
        }
Exemple #27
0
        public static void configure_without_console()
        {
            string assembly_name = ApplicationParameters.log4net_configuration_assembly;
            Stream xml_config_stream;

            try
            {
                xml_config_stream = Assembly.Load(ApplicationParameters.get_merged_assembly_name()).GetManifestResourceStream(ApplicationParameters.log4net_configuration_resource_no_console);
            }
            catch (Exception)
            {
                used_merged       = false;
                xml_config_stream = Assembly.Load(assembly_name).GetManifestResourceStream(ApplicationParameters.log4net_configuration_resource_no_console);
            }

            XmlConfigurator.Configure(xml_config_stream);

            the_logger.DebugFormat("Configured {0} from assembly {1}", ApplicationParameters.log4net_configuration_resource_no_console, used_merged ? ApplicationParameters.get_merged_assembly_name() : assembly_name);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="documentsService">Documents service.</param>
 /// <param name="branchService">Branch service.</param>
 /// <param name="searchService">Search service.</param>
 /// <param name="projectsService">Projects service.</param>
 /// <param name="logsService">Logs service.</param>
 /// <param name="logger">Logger service.</param>
 /// <param name="httpContextHeaders">Http context headers.</param>
 /// <param name="applicationParameters">Application parameters.</param>
 public UploaderJob(
     IDocumentsService documentsService,
     IBranchesService branchService,
     ISearchService searchService,
     IProjectsService projectsService,
     ILogsService logsService,
     ILogger <UploaderJob> logger,
     IHttpContextHeaders httpContextHeaders,
     IOptions <ApplicationParameters> applicationParameters)
 {
     _documentsService      = documentsService;
     _branchService         = branchService;
     _searchService         = searchService;
     _projectsService       = projectsService;
     _logsService           = logsService;
     _logger                = logger;
     _httpContextHeaders    = httpContextHeaders;
     _applicationParameters = applicationParameters.Value;
 }
Exemple #29
0
        /// <summary>
        /// Loads a component registry for simple injector.
        /// </summary>
        /// <param name="componentRegistry">The component registry.</param>
        /// <param name="container">The container.</param>
        private static void load_component_registry(Type componentRegistry, Container container)
        {
            if (componentRegistry == null)
            {
                "chocolatey".Log().Warn(ChocolateyLoggers.Important,
                                        @"Unable to register licensed components. This is likely related to a 
 missing or outdated licensed DLL.");
                return;
            }
            try
            {
                object componentClass = Activator.CreateInstance(componentRegistry);

                componentRegistry.InvokeMember(
                    REGISTER_COMPONENTS_METHOD,
                    BindingFlags.InvokeMethod,
                    null,
                    componentClass,
                    new Object[] { container }
                    );
            }
            catch (Exception ex)
            {
                var isDebug = ApplicationParameters.is_debug_mode_cli_primitive();
                var message = isDebug ? ex.ToString() : ex.Message;

                if (isDebug && ex.InnerException != null)
                {
                    message += "{0}{1}".format_with(Environment.NewLine, ex.InnerException.ToString());
                }

                "chocolatey".Log().Error(
                    ChocolateyLoggers.Important,
                    @"Error when registering components for '{0}':{1} {2}".format_with(
                        componentRegistry.FullName,
                        Environment.NewLine,
                        message
                        ));
            }
        }
        public void register_db_provider_factory()
        {
            var dataSet = (DataSet)ConfigurationManager.GetSection("system.data");

            var my_sql_client_row = dataSet.Tables[0]
                                    .AsEnumerable()
                                    .Where(x => x.Field <string>(2) == "Npgsql")
                                    .SingleOrDefault();

            if (my_sql_client_row != null)
            {
                dataSet.Tables[0].Rows.Remove(my_sql_client_row);
            }

            var factory_type = is_merged ? "Npgsql.NpgsqlFactory, " + ApplicationParameters.get_merged_assembly_name() : "Npgsql.NpgsqlFactory, Npgsql";

            dataSet.Tables[0].Rows.Add(
                "PostgreSQL Data Provider",
                ".Net Framework Data Provider for PostgreSQL",
                "Npgsql",
                factory_type);
        }
        public ISessionFactory build_session_factory(Action <Configuration> additional_function)
        {
            string top_namespace = configuration_holder.DatabaseType.Substring(0, configuration_holder.DatabaseType.IndexOf(','));

            top_namespace = top_namespace.Substring(0, top_namespace.LastIndexOf('.'));
            string assembly_name = configuration_holder.DatabaseType.Substring(configuration_holder.DatabaseType.IndexOf(',') + 1);

            try
            {
                string key = configuration_holder.DatabaseType.Substring(0, configuration_holder.DatabaseType.IndexOf(',')) + ", " +
                             ApplicationParameters.get_merged_assembly_name();
                return(build_session_factory(func_dictionary[key](), Assembly.GetExecutingAssembly(), top_namespace, additional_function));
                //return build_session_factory(func_dictionary[key](), DefaultAssemblyLoader.load_assembly(ApplicationParameters.get_merged_assembly_name()),
                //top_namespace, additional_function);
            }
            catch (Exception ex)
            {
                Log.bound_to(this).log_a_warning_event_containing("Had an error building session factory from merged, attempting unmerged. The error:{0}{1}", System.Environment.NewLine, ex.ToString());
                return(build_session_factory(func_dictionary[configuration_holder.DatabaseType](), DefaultAssemblyLoader.load_assembly(assembly_name),
                                             top_namespace, additional_function));
            }
        }
        public void Initialize(ApplicationParameters parameters, IModuleRegistrar registrar)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (registrar == null)
            {
                throw new ArgumentNullException("registrar");
            }

            if (!parameters.AutoApplyDbMigrations)
            {
                Database.SetInitializer<FileWordsDataflowDbContext>(null);
            }
            else
            {
                Database.SetInitializer(new FileWordsDataflowDbContextInitializer());
            }

            registrar.RegisterType<IRepository, Repository>();
        }