private static ConnectionStrings CreateConnectionStrings(int bankCode) { string feed = CreateConnectionString("Feed", bankCode); string trade = CreateConnectionString("Trade", bankCode); ConnectionStrings result = new ConnectionStrings(feed, trade); return result; }
private static ConnectionStrings CreateConnectionStrings(int bankCode, int metaAccount) { string feedConnectionString = CreateFeedConnectionString(bankCode); string tradeConnectionSTring = CreateTradeConnectionString(bankCode, metaAccount); ConnectionStrings result = new ConnectionStrings(feedConnectionString, tradeConnectionSTring); return result; }
private static ConnectionStrings CreateConnectionStrings(string address, string username, string password) { string feedConnectionString = FixAdviserLauncher.FeedConnectionString(address, username, password); string tradeConnectionSTring = FixAdviserLauncher.TradeConnectionString(address, username, password); ConnectionStrings result = new ConnectionStrings(feedConnectionString, tradeConnectionSTring); return result; }
// ************************************** // Get // ************************************** //public static string Get(string key) //{ // string value = ConfigurationManager.AppSettings[key]; // if (String.IsNullOrEmpty(value)) { throw new KeyNotFoundException(String.Format("{0} is not specified in config file", key)); } // return value; //} public static string ConnectionString(ConnectionStrings connection) { var key = String.Format("{0}", connection); string value = ConfigurationManager.ConnectionStrings[key].ConnectionString; if (String.IsNullOrEmpty(value)) { throw new KeyNotFoundException(String.Format("{0} is not specified in config file", key)); } return value; }
public Database() { var logger = ObjectFactory.GetInstance<Logger>(); logger.Trace("[Server].[Configuration].[Sections].[Database()] invoked."); const string smsToMailConnectionStringDefaultValue = ""; smsToMailConnectionStringValue = new ConnectionStrings<string>(smsToMailConnectionStringName, smsToMailConnectionStringDefaultValue); Func<KeyValuePair<string, string>> smsToMailConnectionStringEvaluator = () => new KeyValuePair<string, string>(smsToMailConnectionStringName, smsToMailConnectionStringValue.Value); smsToMailConnectionString = new Evaluator<KeyValuePair<string, string>>(smsToMailConnectionStringEvaluator); logger.Trace("[Server].[Configuration].[Sections].[Database()] finished work."); }
public RegistrationContext(DbContextOptions <RegistrationContext> options, IOptions <ConnectionStrings> connectionstrings) { _connectionStrings = connectionstrings.Value; }
public void Startup() { // // get configuration information // MessageQueueAppConfig messageQueueAppConfig = new MessageQueueAppConfig(); ConnectionStrings connectionStrings = new ConnectionStrings(); var basePath = PlatformServices.Default.Application.ApplicationBasePath; if (basePath.ToLower().Contains("inventorymanagementqa")) { CodeProject.Shared.Common.Models.AppSettings.MessageQueueAppSettings appSettings = new CodeProject.Shared.Common.Models.AppSettings.MessageQueueAppSettings(); string readContents; using (StreamReader streamReader = new StreamReader(basePath + @"\AppSettings.QA.json", Encoding.UTF8)) { readContents = streamReader.ReadToEnd(); } appSettings = CodeProject.Shared.Common.Utilities.SerializationFunction <CodeProject.Shared.Common.Models.AppSettings.MessageQueueAppSettings> .ReturnObjectFromString(readContents); messageQueueAppConfig.MessageQueueHostName = appSettings.MessageQueueAppConfig.MessageQueueHostName; messageQueueAppConfig.MessageQueueUserName = appSettings.MessageQueueAppConfig.MessageQueueUserName; messageQueueAppConfig.MessageQueuePassword = appSettings.MessageQueueAppConfig.MessageQueuePassword; messageQueueAppConfig.MessageQueueEnvironment = appSettings.MessageQueueAppConfig.MessageQueueEnvironment; messageQueueAppConfig.ExchangeName = appSettings.MessageQueueAppConfig.ExchangeName; messageQueueAppConfig.RoutingKey = appSettings.MessageQueueAppConfig.RoutingKey; messageQueueAppConfig.InboundMessageQueue = appSettings.MessageQueueAppConfig.InboundMessageQueue; messageQueueAppConfig.OutboundMessageQueues = appSettings.MessageQueueAppConfig.OutboundMessageQueues; messageQueueAppConfig.LoggingExchangeName = appSettings.MessageQueueAppConfig.LoggingExchangeName; messageQueueAppConfig.LoggingMessageQueue = appSettings.MessageQueueAppConfig.LoggingMessageQueue; messageQueueAppConfig.OriginatingQueueName = appSettings.MessageQueueAppConfig.OriginatingQueueName; messageQueueAppConfig.SendToLoggingQueue = appSettings.MessageQueueAppConfig.SendToLoggingQueue; messageQueueAppConfig.AcknowledgementMessageExchangeSuffix = appSettings.MessageQueueAppConfig.AcknowledgementMessageExchangeSuffix; messageQueueAppConfig.AcknowledgementMessageQueueSuffix = appSettings.MessageQueueAppConfig.AcknowledgementMessageQueueSuffix; messageQueueAppConfig.TriggerExchangeName = appSettings.MessageQueueAppConfig.TriggerExchangeName; messageQueueAppConfig.TriggerQueueName = appSettings.MessageQueueAppConfig.TriggerQueueName; messageQueueAppConfig.QueueImmediately = appSettings.MessageQueueAppConfig.QueueImmediately; messageQueueAppConfig.InboundSemaphoreKey = appSettings.MessageQueueAppConfig.InboundSemaphoreKey; messageQueueAppConfig.OutboundSemaphoreKey = appSettings.MessageQueueAppConfig.OutboundSemaphoreKey; messageQueueAppConfig.ProcessingIntervalSeconds = appSettings.MessageQueueAppConfig.ProcessingIntervalSeconds; messageQueueAppConfig.SendingIntervalSeconds = appSettings.MessageQueueAppConfig.SendingIntervalSeconds; messageQueueAppConfig.ReceivingIntervalSeconds = appSettings.MessageQueueAppConfig.ReceivingIntervalSeconds; messageQueueAppConfig.SignalRHubUrl = appSettings.MessageQueueAppConfig.SignalRHubUrl; messageQueueAppConfig.RunAsService = appSettings.MessageQueueAppConfig.RunAsService; connectionStrings.PrimaryDatabaseConnectionString = appSettings.ConnectionStrings.PrimaryDatabaseConnectionString; using (var sw = File.AppendText(Path)) { sw.WriteLine("HostName=" + messageQueueAppConfig.MessageQueueHostName + "*"); } } else { string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); string jsonFile = $"AppSettings.{environment}.json"; var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(jsonFile, optional: true, reloadOnChange: true); IConfigurationRoot configuration = configBuilder.Build(); configuration.GetSection("MessageQueueAppConfig").Bind(messageQueueAppConfig); configuration.GetSection("ConnectionStrings").Bind(connectionStrings); } // // set up sending queue // IMessageQueueConnection sendingQueueConnection = new MessageQueueConnection(messageQueueAppConfig); sendingQueueConnection.CreateConnection(); List <IMessageQueueConfiguration> messageQueueConfigurations = new List <IMessageQueueConfiguration>(); // // Inventory Received Transactions // IMessageQueueConfiguration inventoryReceivedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.InventoryReceived, messageQueueAppConfig, sendingQueueConnection); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.PurchaseOrderQueue); inventoryReceivedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); inventoryReceivedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(inventoryReceivedConfiguration); // // Product Creation and Updates // IMessageQueueConfiguration productUpdatedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.ProductUpdated, messageQueueAppConfig, sendingQueueConnection); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.PurchaseOrderQueue); productUpdatedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); productUpdatedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(productUpdatedConfiguration); // // Inventory Shipped Transactions // IMessageQueueConfiguration inventoryShippedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.InventoryShipped, messageQueueAppConfig, sendingQueueConnection); inventoryShippedConfiguration.AddQueue(MessageQueueEndpoints.SalesOrderQueue); inventoryShippedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); inventoryShippedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(inventoryShippedConfiguration); // // initialize Sending Messages // IInventoryManagementDataService inventoryManagementDataService = new InventoryManagementDataService(); IMessageQueueProcessing messageProcessing = new MessageProcessing(inventoryManagementDataService); _sendInventoryManagementMessages = new SendMessages(sendingQueueConnection, messageProcessing, messageQueueAppConfig, connectionStrings, messageQueueConfigurations, MessageQueueEndpoints.InventoryQueue); // // set up receiving queue // IMessageQueueConnection receivingConnection = new MessageQueueConnection(messageQueueAppConfig); receivingConnection.CreateConnection(); List <IMessageQueueConfiguration> inboundMessageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration inboundConfiguration = new MessageQueueConfiguration(messageQueueAppConfig, receivingConnection); inboundMessageQueueConfigurations.Add(inboundConfiguration); inboundConfiguration.InitializeInboundMessageQueueing(MessageQueueEndpoints.InventoryQueue); inboundConfiguration.InitializeLoggingExchange(MessageQueueExchanges.Logging, MessageQueueEndpoints.LoggingQueue); IInventoryManagementDataService inboundInventoryManagementDataService = new InventoryManagementDataService(); IMessageQueueProcessing inboundMessageProcessing = new MessageProcessing(inboundInventoryManagementDataService); _receiveInventoryManagementMessages = new ReceiveMessages(receivingConnection, inboundMessageProcessing, messageQueueAppConfig, connectionStrings, inboundMessageQueueConfigurations); // // Set Up Message Processing // IInventoryManagementDataService inventoryManagementProcessingDataService = new InventoryManagementDataService(); IMessageQueueProcessing messageProcessor = new MessageProcessing(inventoryManagementProcessingDataService); _processMessages = new ProcessMessages(messageProcessor, messageQueueAppConfig, connectionStrings); }
public ProcessResult MoveStock( int reqNumber, int reqLine, string partNumber, decimal quantity, int?fromLocationId, int?fromPalletNumber, DateTime?fromStockDate, int?toLocationId, int?toPalletNumber, DateTime?toStockDate, string state, string stockPool) { var connection = new OracleConnection(ConnectionStrings.ManagedConnectionString()); var cmd = new OracleCommand("stores_pack.move_stock", connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new OracleParameter("p_req_number", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = reqNumber }); cmd.Parameters.Add(new OracleParameter("p_req_line", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = reqLine }); cmd.Parameters.Add(new OracleParameter("p_part_number", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = partNumber }); cmd.Parameters.Add(new OracleParameter("p_qty", OracleDbType.Decimal) { Direction = ParameterDirection.Input, Value = quantity }); cmd.Parameters.Add(new OracleParameter("p_from_location_id", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = fromLocationId }); cmd.Parameters.Add(new OracleParameter("p_from_pallet_number", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = fromPalletNumber }); cmd.Parameters.Add(new OracleParameter("p_from_stock_date", OracleDbType.Date) { Direction = ParameterDirection.Input, Value = fromStockDate }); cmd.Parameters.Add(new OracleParameter("p_to_location_id", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = toLocationId }); cmd.Parameters.Add(new OracleParameter("p_to_pallet_number", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = toPalletNumber }); cmd.Parameters.Add(new OracleParameter("p_new_stock_date", OracleDbType.Date) { Direction = ParameterDirection.Input, Value = toStockDate }); cmd.Parameters.Add(new OracleParameter("p_stock_pool", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = stockPool }); cmd.Parameters.Add(new OracleParameter("p_state", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = state }); var messageParameter = new OracleParameter("p_message", OracleDbType.Varchar2) { Direction = ParameterDirection.Output, Size = 4000 }; cmd.Parameters.Add(messageParameter); var successParameter = new OracleParameter("p_success", OracleDbType.Int32) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(successParameter); connection.Open(); cmd.ExecuteNonQuery(); connection.Close(); return(new ProcessResult { Message = messageParameter.Value.ToString(), Success = int.Parse(successParameter.Value.ToString()) == 1 }); }
public SupplierRepository(ConnectionStrings connection) : base(connection) { connectionStrings = connection; }
public override void AddDatabases(IServiceCollection services, ConnectionStrings connectionStrings, string tenantsConnectionString, string identityConnectionString, string hangfireConnectionString, string defaultConnectionString) { services.AddDbContextNoSql <NoSqlContext>(connectionStrings["NoSqlConnection"]); services.AddDbContext <AppContext>(defaultConnectionString); services.AddDbContext <IdentityContext>(identityConnectionString); }
public static async Task Main(string[] args) { // // get configuration information // MessageQueueAppConfig messageQueueAppConfig = new MessageQueueAppConfig(); ConnectionStrings connectionStrings = new ConnectionStrings(); string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); string jsonFile = $"appsettings.{environment}.json"; var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile(jsonFile, optional: true, reloadOnChange: true); IConfigurationRoot configuration = configBuilder.Build(); configuration.GetSection("MessageQueueAppConfig").Bind(messageQueueAppConfig); configuration.GetSection("ConnectionStrings").Bind(connectionStrings); // // set up sending queue // IMessageQueueConnection sendingQueueConnection = new MessageQueueConnection(messageQueueAppConfig); sendingQueueConnection.CreateConnection(); List <IMessageQueueConfiguration> messageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration purchaseOrderSubmittedConfiguration = new MessageQueueConfiguration(MessageQueueExchanges.PurchaseOrderSubmitted, messageQueueAppConfig, sendingQueueConnection); purchaseOrderSubmittedConfiguration.AddQueue(MessageQueueEndpoints.InventoryQueue); purchaseOrderSubmittedConfiguration.AddQueue(MessageQueueEndpoints.LoggingQueue); purchaseOrderSubmittedConfiguration.InitializeOutboundMessageQueueing(); messageQueueConfigurations.Add(purchaseOrderSubmittedConfiguration); IPurchaseOrderManagementDataService submittedPurchaseOrderManagementDataService = new PurchaseOrderManagementDataService(); IMessageQueueProcessing messageProcessing = new MessageProcessing(submittedPurchaseOrderManagementDataService); IHostedService submittedPurchaseOrderManagementMessages = new SendMessages(sendingQueueConnection, messageProcessing, messageQueueAppConfig, connectionStrings, messageQueueConfigurations, MessageQueueEndpoints.PurchaseOrderQueue); // // set up receiving queue // IMessageQueueConnection receivingConnection = new MessageQueueConnection(messageQueueAppConfig); receivingConnection.CreateConnection(); List <IMessageQueueConfiguration> inboundMessageQueueConfigurations = new List <IMessageQueueConfiguration>(); IMessageQueueConfiguration inboundConfiguration = new MessageQueueConfiguration(messageQueueAppConfig, receivingConnection); inboundMessageQueueConfigurations.Add(inboundConfiguration); inboundConfiguration.InitializeInboundMessageQueueing(MessageQueueEndpoints.PurchaseOrderQueue); inboundConfiguration.InitializeLoggingExchange(MessageQueueExchanges.Logging, MessageQueueEndpoints.LoggingQueue); IPurchaseOrderManagementDataService inboundPurchaseOrderManagementDataService = new PurchaseOrderManagementDataService(); IMessageQueueProcessing inboundMessageProcessing = new MessageProcessing(inboundPurchaseOrderManagementDataService); IHostedService receivePurchaseOrderManagementMessages = new ReceiveMessages(receivingConnection, inboundMessageProcessing, messageQueueAppConfig, connectionStrings, inboundMessageQueueConfigurations); // // Set Up Message Processing // IPurchaseOrderManagementDataService purchaseOrderManagementProcessingDataService = new PurchaseOrderManagementDataService(); IMessageQueueProcessing messageProcessor = new MessageProcessing(purchaseOrderManagementProcessingDataService); ProcessMessages processMessages = new ProcessMessages(messageProcessor, messageQueueAppConfig, connectionStrings); var builder = new HostBuilder().ConfigureAppConfiguration((hostingContext, config) => { }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => processMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => submittedPurchaseOrderManagementMessages); }) .ConfigureServices((hostContext, services) => { services.AddTransient <IHostedService>(provider => receivePurchaseOrderManagementMessages); }) .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); }); await builder.RunConsoleAsync(); }
public RepositoryClient(ConnectionStrings connectionStrings) { _connectionStrings = connectionStrings; }
public FrameworkContext(ConnectionStrings cs) : base(cs) { }
public LabelContext(DbContextOptions <LabelContext> options, IOptions <ConnectionStrings> connectionStrings) : base(options) { _connectionStrings = connectionStrings.Value; }
public List <SQLCommandsReturnInfoClass> RunPreparedCommands() { //var sb = new StringBuilder(); var riList = new List <SQLCommandsReturnInfoClass>(); _parentNotifies?.AddToINFO($@"{StaticFunctionsClass.DateTimeNowStr()} Executing script"); Application.DoEvents(); // int i = 0; int nr = 0; FbConnection fbConn = null; FbCommand fbCmd = null; if (_drc.DatabasePath.Length > 0) { var connstr = ConnectionStrings.Instance().MakeConnectionString(_drc); try { fbConn = new FbConnection(connstr); fbConn.Open(); } catch (Exception ex) { object[] param = { ex.Message }; SEMessageBox.ShowMDIDialog(FbXpertMainForm.Instance(), "DatabaseExceptionCaption", "ErrorWhileOpeningDatabase", SEMessageBoxButtons.OK, SEMessageBoxIcon.Exclamation, null, param); } } if (fbConn.State == System.Data.ConnectionState.Open) { var startDt = DateTime.Now; bool DBRepoend = false; bool ReopenConnectionEachCommand = true; foreach (SCRIPTCommandClass command in this.Commands.Values) { var ri = new SQLCommandsReturnInfoClass(); if (ReopenConnectionEachCommand) { if (fbCmd != null && fbCmd.Transaction != null) { ri.lastSQL = "ReopenDatabase"; try { fbCmd.Transaction.Commit(); fbCmd.Transaction = null; ri.commandDone = true; } catch (Exception ex) { ri.commandDone = false; _parentNotifies?.AddToERROR(AppStaticFunctionsClass.GetFormattedError($@"Command error {fbCmd.CommandText}", ex)); if (fbCmd.Transaction != null) { fbCmd.Transaction.Rollback(); fbCmd.Transaction = null; } } } fbConn.Close(); fbConn.Open(); DBRepoend = fbConn.State == System.Data.ConnectionState.Open; } var actDt = DateTime.Now; if ((actDt.Ticks - startDt.Ticks) > 30000000000) { _parentNotifies?.AddToINFO($@"{StaticFunctionsClass.DateTimeNowStr()} ...Executing script{nr.ToString()} commands done of {Commands.Count}."); } FbConnection usedCon = IsCreateDatabaseOrConnect(command.CommandText, fbConn); if (usedCon != null) { //Create Databes oder connect if (fbConn != null) { if (fbConn.State != System.Data.ConnectionState.Closed) { fbConn.Close(); } } fbConn = usedCon; if (fbConn.State != System.Data.ConnectionState.Open) { fbConn.Open(); } continue; } if (fbCmd == null || fbCmd.Transaction == null || DBRepoend) { fbCmd = new FbCommand(command.CommandText, fbConn); fbCmd.Transaction = fbConn.BeginTransaction(); DBRepoend = false; } else { fbCmd.CommandText = command.CommandText; } var sw = new Stopwatch(); sw.Start(); ri.lastCommandType = command.CommandType; ri.lastSQL = command.CommandText; try { if (command.CommandType == SQLCommandType.commit) { fbCmd.Transaction.Commit(); fbCmd.Transaction = null; } else { fbCmd.ExecuteNonQuery(); } ri.commandDone = true; } catch (Exception ex) { ri.nErrors++; ri.lastError = ex.Message; ri.commandDone = false; _parentNotifies?.AddToERROR(AppStaticFunctionsClass.GetFormattedError($@"Command error {fbCmd.CommandText}", ex)); if (fbCmd.Transaction != null) { fbCmd.Transaction.Rollback(); fbCmd.Transaction = null; } } sw.Stop(); command.Costs = sw.ElapsedMilliseconds; _eventNotifies?.Notify.RaiseInfo($@"SQLScriptingClass.RunPreparedCommands()", Constants.CommandDone, command); ri.costs = sw.ElapsedMilliseconds; riList.Add(ri); nr++; } if (fbCmd != null && fbCmd.Transaction != null) { fbCmd.Transaction.Commit(); fbCmd.Transaction = null; } if (fbConn.State == System.Data.ConnectionState.Open) { fbConn.Close(); } } _parentNotifies?.AddToINFO($@"{StaticFunctionsClass.DateTimeNowStr()} Executing done {nr.ToString()} Commands"); Application.DoEvents(); return(riList); }
public Facade(ConnectionStrings settings) { this.settings = settings; }
public RepositorioAviso(ConnectionStrings connectionStrings) : base(connectionStrings) { }
public FooService(IOptionsMonitor <ConnectionStrings> connectionStrings) { _connectionStrings = connectionStrings.CurrentValue; }
/// <summary> /// Instantiate the class for connecting to an external data source file. /// </summary> /// <example> /// <code> /// using Argentini.Halide; /// ... /// H3Reader reader = new H3Reader("SELECT * FROM Sheet", "/uploads/sheet.xls", "", H3Reader.ConnectionStrings.XLS_OLEDB); /// </code> /// </example> /// <param name="commandText">A SQL command to execute.</param> /// <param name="filePath">Web-style relative path to the file.</param> /// <param name="password">password for the file, if any, or a blank string.</param> /// <param name="Connection_String">H3Reader.ConnectionString constant which defines the file type.</param> public H3Reader(String commandText, String filePath, String password, ConnectionStrings Connection_String) { oledb_CommandString = commandText; String cs = StringValueOf(Connection_String).Replace("{FILEPATH}", HttpContext.Current.Server.MapPath(filePath)).Replace("{PASSWORD}", password); oledb_ConnectionString = cs; try { cn_Oledb = new OleDbConnection(cs); cmd_Oledb = new OleDbCommand(commandText, cn_Oledb); cmd_Oledb.CommandTimeout = 0; cn_Oledb.Open(); dr_Oledb = cmd_Oledb.ExecuteReader(); } catch (Exception err) { _lastSqlError = err; } }
public ConnectionStringService(IOptions <ConnectionStrings> connectionStrings) { _connectionStrings = connectionStrings.Value; }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); SiteConfig siteConfig = null; Site site = null; string location = null; IDictionary <string, string> tags = null; switch (ParameterSetName) { case ParameterSet1Name: WebApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); location = WebApp.Location; tags = WebApp.Tags; var parameters = new HashSet <string>(MyInvocation.BoundParameters.Keys, StringComparer.OrdinalIgnoreCase); // Perform the AppServicePlan update before updating site or config properties if (parameters.Contains("AppServicePlan")) { WebApp.AzureStoragePath = null; // the API to update site Object doesn't have the AzureStorage Path property WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, AppServicePlan, WebApp); } if (parameters.Any(p => CmdletHelpers.SiteConfigParameters.Contains(p))) { siteConfig = new SiteConfig { DefaultDocuments = parameters.Contains("DefaultDocuments") ? DefaultDocuments : null, NetFrameworkVersion = parameters.Contains("NetFrameworkVersion") ? NetFrameworkVersion : null, PhpVersion = parameters.Contains("PhpVersion") ? PhpVersion.ToLower() == "off" ? "" : PhpVersion : null, RequestTracingEnabled = parameters.Contains("RequestTracingEnabled") ? (bool?)RequestTracingEnabled : null, HttpLoggingEnabled = parameters.Contains("HttpLoggingEnabled") ? (bool?)HttpLoggingEnabled : null, DetailedErrorLoggingEnabled = parameters.Contains("DetailedErrorLoggingEnabled") ? (bool?)DetailedErrorLoggingEnabled : null, HandlerMappings = parameters.Contains("HandlerMappings") ? HandlerMappings : null, ManagedPipelineMode = parameters.Contains("ManagedPipelineMode") ? (ManagedPipelineMode?)Enum.Parse(typeof(ManagedPipelineMode), ManagedPipelineMode) : null, WebSocketsEnabled = parameters.Contains("WebSocketsEnabled") ? (bool?)WebSocketsEnabled : null, Use32BitWorkerProcess = parameters.Contains("Use32BitWorkerProcess") ? (bool?)Use32BitWorkerProcess : null, AutoSwapSlotName = parameters.Contains("AutoSwapSlotName") ? AutoSwapSlotName : null, NumberOfWorkers = parameters.Contains("NumberOfWorkers") ? NumberOfWorkers : WebApp.SiteConfig.NumberOfWorkers, AlwaysOn = parameters.Contains("AlwaysOn") ? (bool)AlwaysOn : false }; } Hashtable appSettings = AppSettings ?? new Hashtable(); if (siteConfig == null) { siteConfig = WebApp.SiteConfig; } //According to current implementation if AppSettings parameter is provided we are overriding existing AppSettings if (WebApp.SiteConfig.AppSettings != null && AppSettings == null) { foreach (var setting in WebApp.SiteConfig.AppSettings) { appSettings[setting.Name] = setting.Value; } } if (ContainerImageName != null) { string dockerImage = CmdletHelpers.DockerImagePrefix + ContainerImageName; if (WebApp.IsXenon.GetValueOrDefault()) { siteConfig.WindowsFxVersion = dockerImage; } else if (WebApp.Reserved.GetValueOrDefault()) { siteConfig.LinuxFxVersion = dockerImage; } } if (ContainerRegistryUrl != null) { appSettings[CmdletHelpers.DocerRegistryServerUrl] = ContainerRegistryUrl; } if (ContainerRegistryUser != null) { appSettings[CmdletHelpers.DocerRegistryServerUserName] = ContainerRegistryUser; } if (ContainerRegistryPassword != null) { appSettings[CmdletHelpers.DocerRegistryServerPassword] = ContainerRegistryPassword.ConvertToString(); } if (parameters.Contains("EnableContainerContinuousDeployment")) { if (EnableContainerContinuousDeployment) { appSettings[CmdletHelpers.DockerEnableCI] = "true"; } else { appSettings.Remove(CmdletHelpers.DockerEnableCI); } } // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, appSettings.ConvertToStringDictionary(), ConnectionStrings.ConvertToConnectionStringDictionary(), AzureStoragePath.ConvertToAzureStorageAccountPathPropertyDictionary()); //update reference to WebApp object after site configuration update WebApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); if (parameters.Any(p => CmdletHelpers.SiteParameters.Contains(p))) { site = new Site { Location = location, Tags = tags, ServerFarmId = WebApp.ServerFarmId, Identity = parameters.Contains("AssignIdentity") ? AssignIdentity ? new ManagedServiceIdentity("SystemAssigned", null, null) : new ManagedServiceIdentity("None", null, null) : WebApp.Identity, HttpsOnly = parameters.Contains("HttpsOnly") ? HttpsOnly : WebApp.HttpsOnly }; WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, WebApp.ServerFarmId, new PSSite(site)); //Update WebApp object after site update WebApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, null)); } break; case ParameterSet2Name: // Web app is direct or pipeline input string servicePlanName; string rg; location = WebApp.Location; siteConfig = WebApp.SiteConfig; // Update web app configuration WebsitesClient.UpdateWebAppConfiguration( ResourceGroupName, location, Name, Slot, siteConfig, WebApp.SiteConfig == null ? null : WebApp.SiteConfig.AppSettings .ToDictionary( nvp => nvp.Name, nvp => nvp.Value, StringComparer.OrdinalIgnoreCase), WebApp.SiteConfig == null ? null : WebApp.SiteConfig.ConnectionStrings .ToDictionary( nvp => nvp.Name, nvp => new ConnStringValueTypePair { Type = nvp.Type.Value, Value = nvp.ConnectionString }, StringComparer.OrdinalIgnoreCase)); CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName); WebApp.AzureStoragePath = null; // the API to update site Object doesn't have the AzureStorage Path property WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName, WebApp); break; } WriteObject(new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot))); }
public void ConfigureServices(IServiceCollection services) { var env = services.BuildServiceProvider() .GetRequiredService <IHostingEnvironment>(); Logger.LogInformation("Registering second-line services in Startup.ConfigureServices"); services.AddSingleton <IServiceCollection>(services); /*: configuration section "logging" : */ services.AddLogging(builder => { builder.AddConsole() .AddDebug(); }); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearerConfiguration(Configuration); services.AddAuthorizationConfiguration(Configuration); /*: configuration section "responseCaching" : */ if (ShouldUseCaching(Configuration, out var redisCacheOptions)) { services.AddDistributedRedisCache(options => { options.Configuration = redisCacheOptions.Configuration; options.InstanceName = redisCacheOptions.InstanceName; }); services.AddDistributedResponseCaching(); services.AddTransient <IDistributedCacheManager, RedisDistributedCacheManager>(); } // Database... var connectionStrings = new ConnectionStrings(); Configuration.Bind("ConnectionStrings", connectionStrings); //if(env.IsDevelopment()) // services.AddDbContext<ReferenceDataDbContext>(options => { options.UseSqlite("Data Source=mydb.db"); }); //else services.AddDbContext <ReferenceDataDbContext>(options => { options.UseSqlServer(connectionStrings.CoreReadDatabase); }); services.AddUnitOfWork <ReferenceDataDbContext>(); services.AddApiVersioning(options => { options.ReportApiVersions = true; }); services.AddVersionedApiExplorer(options => { options.DefaultApiVersion = new ApiVersion(1, 0); options.AssumeDefaultVersionWhenUnspecified = true; options.GroupNameFormat = "'v'VVV"; options.SubstituteApiVersionInUrl = true; }); services.AddOData( ) .EnableApiVersioning(options => { }); services.AddODataApiExplorer(options => { options.GroupNameFormat = "'v'VVV"; options.SubstituteApiVersionInUrl = true; }); services.AddTransient <IConfigureOptions <SwaggerGenOptions>, ConfigureSwaggerOptions>(); services.AddSwaggerGen(options => { // add a custom operation filter which sets default values options.OperationFilter <SwaggerDefaultValues>(); // tell swagger that we are using a JWT token // see: https://swagger.io/docs/specification/authentication/ options.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Type = "apiKey", Name = "Authorization", Description = "JWT Authorization header using the Bearer scheme.", }); // integrate xml comments // options.IncludeXmlComments(XmlCommentsFilePath); }); services.AddPlatformComponents(options => { options.AutoGenerateEmptyCorrelationId = false; }); // Metrics services.AddMetricFromConfiguration(Configuration); services.AddHealthFromConfiguration(Configuration, builder => { if (redisCacheOptions != null) { //builder.HealthChecks // .AddRedisCheck( // "Redis connection check", // () => ConnectionMultiplexer.Connect(redisCacheOptions.Configuration), // TimeSpan.FromSeconds(90), // true); } if (!string.IsNullOrEmpty(connectionStrings.CoreReadDatabase)) { //builder.HealthChecks // .AddSqlCheck( // "Sql Database Check", // connectionStrings.CoreReadDatabase, // TimeSpan.FromSeconds(90), // true // ); } }); services.AddMvc(options => { //options.Filters.Add( // new ResponseCacheAttribute // { // Duration = 3600, // Location = ResponseCacheLocation.Any, // VaryByQueryKeys = new[] {"*"} // }); }) .SetCompatibilityVersion( CompatibilityVersion.Version_2_1 ); AddCors(services); Logger.LogInformation("Startup.ConfigureServices completed"); }
public ReferenceService(IMapper mapper, ICovidTestRepository covidTestRepository, IOptions <ConnectionStrings> connectionStrings) { _mapper = mapper; _connectionStrings = connectionStrings.Value; _covidTestRepository = covidTestRepository; }
/// <summary> /// კონსტრუქტორი /// </summary> /// <param name="connectionStrings"></param> public PatientRepository(IOptions <ConnectionStrings> connectionStrings) { _connectionStrings = connectionStrings.Value; }
public RequisitionProcessResult CheckStockAtFromLocation( string partNumber, decimal quantity, string from, int?fromLocationId, int?fromPalletNumber, DateTime?fromStockDate) { var connection = new OracleConnection(ConnectionStrings.ManagedConnectionString()); var cmd = new OracleCommand("check_stock_at_from_location", connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new OracleParameter("p_part_number", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = partNumber }); cmd.Parameters.Add(new OracleParameter("p_qty", OracleDbType.Decimal) { Direction = ParameterDirection.Input, Value = quantity }); cmd.Parameters.Add(new OracleParameter("p_from", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = from }); cmd.Parameters.Add(new OracleParameter("p_from_location_id", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = fromLocationId }); cmd.Parameters.Add(new OracleParameter("p_from_pallet_number", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = fromPalletNumber }); cmd.Parameters.Add(new OracleParameter("p_from_stock_date", OracleDbType.Date) { Direction = ParameterDirection.Input, Value = fromStockDate }); var stateParameter = new OracleParameter("p_state", OracleDbType.Varchar2) { Direction = ParameterDirection.Output, Size = 50 }; cmd.Parameters.Add(stateParameter); var messageParameter = new OracleParameter("p_message", OracleDbType.Varchar2) { Direction = ParameterDirection.Output, Size = 4000 }; cmd.Parameters.Add(messageParameter); var successParameter = new OracleParameter("p_success", OracleDbType.Int32) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(successParameter); connection.Open(); cmd.ExecuteNonQuery(); connection.Close(); return(new RequisitionProcessResult { Message = messageParameter.Value.ToString(), Success = int.Parse(successParameter.Value.ToString()) == 1, State = stateParameter.Value?.ToString() == "null" ? null : stateParameter.Value?.ToString() }); }
public ToDoListRepository(ConnectionStrings connectionStrings) { this._connectionStrings = connectionStrings; //samewith dependency injection? }
public CodeZeroDbConnectionOptions() { ConnectionStrings = new ConnectionStrings(); }
public DosTests(IntegrationTestsFixture fixture, string storageProvider = StorageProviders.InMemory, ConnectionStrings connectionStrings = null) { if (connectionStrings != null) { fixture.ConnectionStrings = connectionStrings; } _fixture = fixture; _storageProvider = storageProvider; }
public PresenceRepository(ConnectionStrings connectionStrings) { this._connectionString = connectionStrings; }
public DbConnectionOptions() { ConnectionStrings = new ConnectionStrings(); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); SiteConfig siteConfig = null; Site site = null; string location = null; switch (ParameterSetName) { case ParameterSet1Name: WebApp = WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot); location = WebApp.Location; var parameters = new HashSet <string>(MyInvocation.BoundParameters.Keys, StringComparer.OrdinalIgnoreCase); if (parameters.Any(p => CmdletHelpers.SiteConfigParameters.Contains(p))) { siteConfig = new SiteConfig { DefaultDocuments = parameters.Contains("DefaultDocuments") ? DefaultDocuments : null, NetFrameworkVersion = parameters.Contains("NetFrameworkVersion") ? NetFrameworkVersion : null, PhpVersion = parameters.Contains("PhpVersion") ? PhpVersion : null, RequestTracingEnabled = parameters.Contains("RequestTracingEnabled") ? (bool?)RequestTracingEnabled : null, HttpLoggingEnabled = parameters.Contains("HttpLoggingEnabled") ? (bool?)HttpLoggingEnabled : null, DetailedErrorLoggingEnabled = parameters.Contains("DetailedErrorLoggingEnabled") ? (bool?)DetailedErrorLoggingEnabled : null, HandlerMappings = parameters.Contains("HandlerMappings") ? HandlerMappings : null, ManagedPipelineMode = parameters.Contains("ManagedPipelineMode") ? (ManagedPipelineMode?)Enum.Parse(typeof(ManagedPipelineMode), ManagedPipelineMode) : null, WebSocketsEnabled = parameters.Contains("WebSocketsEnabled") ? (bool?)WebSocketsEnabled : null, Use32BitWorkerProcess = parameters.Contains("Use32BitWorkerProcess") ? (bool?)Use32BitWorkerProcess : null, AutoSwapSlotName = parameters.Contains("AutoSwapSlotName") ? AutoSwapSlotName : null, NumberOfWorkers = parameters.Contains("NumberOfWorkers") ? NumberOfWorkers : WebApp.SiteConfig.NumberOfWorkers }; } // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, AppSettings.ConvertToStringDictionary(), ConnectionStrings.ConvertToConnectionStringDictionary()); if (parameters.Any(p => CmdletHelpers.SiteParameters.Contains(p))) { site = new Site { Location = location, ServerFarmId = WebApp.ServerFarmId, Identity = parameters.Contains("AssignIdentity") && AssignIdentity ? new ManagedServiceIdentity("SystemAssigned", null, null) : WebApp.Identity, HttpsOnly = parameters.Contains("HttpsOnly") ? HttpsOnly : WebApp.HttpsOnly }; Dictionary <string, string> appSettings = WebApp.SiteConfig?.AppSettings?.ToDictionary(x => x.Name, x => x.Value); if (parameters.Contains("AssignIdentity")) { // Add or update the appsettings property appSettings["WEBSITE_DISABLE_MSI"] = (!AssignIdentity).ToString(); WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, WebApp.SiteConfig, appSettings, WebApp.SiteConfig.ConnectionStrings. ToDictionary(nvp => nvp.Name, nvp => new ConnStringValueTypePair { Type = nvp.Type.Value, Value = nvp.ConnectionString }, StringComparer.OrdinalIgnoreCase)); } WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, WebApp.ServerFarmId, site); } if (parameters.Contains("AppServicePlan")) { WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, AppServicePlan); } break; case ParameterSet2Name: // Web app is direct or pipeline input string servicePlanName; string rg; location = WebApp.Location; siteConfig = WebApp.SiteConfig; // Update web app configuration WebsitesClient.UpdateWebAppConfiguration( ResourceGroupName, location, Name, Slot, siteConfig, WebApp.SiteConfig == null ? null : WebApp.SiteConfig.AppSettings .ToDictionary( nvp => nvp.Name, nvp => nvp.Value, StringComparer.OrdinalIgnoreCase), WebApp.SiteConfig == null ? null : WebApp.SiteConfig.ConnectionStrings .ToDictionary( nvp => nvp.Name, nvp => new ConnStringValueTypePair { Type = nvp.Type.Value, Value = nvp.ConnectionString }, StringComparer.OrdinalIgnoreCase)); CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName); WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName); break; } WriteObject(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); }
public RepositorioUsuarioGsa(ConnectionStrings connectionStrings) : base(connectionStrings) { }
public DBOperations(IOptions <ConnectionStrings> options) { connectionStrings = options.Value; }
public WeapsyDbContext(IOptions <ConnectionStrings> settings) { ConnectionStrings = settings.Value; }
public virtual string FindConnectionString(string name) { return(ConnectionStrings.FirstOrDefault(c => c.Name == name)?.Value); }
// Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <GzipCompressionProviderOptions>(options => options.Level = System.IO.Compression.CompressionLevel.Optimal); services.AddResponseCompression(); services.AddMvc() .AddJsonOptions(x => { x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; }); services.AddAutoMapper(); services.AddAuthentication(authOptions => { authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; authOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(cfg => { cfg.RequireHttpsMetadata = false; cfg.SaveToken = true; cfg.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidIssuer = Configuration["JWTOptions:Issuer"], ValidAudience = Configuration["JWTOptions:Audience"], ValidateIssuerSigningKey = true, IssuerSigningKey = _signingKey, ValidateLifetime = true }; }); services.AddCors(); var conStrings = new ConnectionStrings(); Configuration.Bind("ConnectionStrings", conStrings); services.AddSingleton(conStrings); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "APITESTREGISTER", Version = "v1" }); c.AddSecurityDefinition("Bearer", new ApiKeyScheme() { In = "header", Description = "Inform the JWT token with Bearer", Name = "Authorization", Type = "apiKey" }); var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "APITESTREGISTER.xml"); c.IncludeXmlComments(filePath); c.OperationFilter <ExamplesOperationFilter>(); }); services.ConfigureSwaggerGen(x => { x.OperationFilter <AuthorizationHeaderParameterOperationFilter>(); x.OperationFilter <ProducesOperatioFilter>(); }); services.AddSingleton(Mapper.Configuration); services.AddScoped <IMapper>(sp => new Mapper(sp.GetRequiredService <AutoMapper.IConfigurationProvider>(), sp.GetService)); NativeInjectorBootStrapper.RegisterServices(services, Configuration); }
/// <summary> /// Instantiate the class for connecting to an external data source file. /// </summary> /// <example> /// <code> /// using Mezzocode.Halide3; /// ... /// h3Reader reader = new h3Reader("SELECT * FROM Sheet", "/uploads/sheet.xls", "", h3Reader.ConnectionStrings.XLS_OLEDB); /// </code> /// </example> /// <param name="CommandText">A SQL command to execute.</param> /// <param name="FilePath">Web-style relative path to the file.</param> /// <param name="Password">Password for the file, if any, or a blank string.</param> /// <param name="Connection_String">h3Reader.ConnectionString constant which defines the file type.</param> public h3Reader(String CommandText, String FilePath, String Password, ConnectionStrings Connection_String) { oledb_CommandString = CommandText; String cs = StringValueOf(Connection_String).Replace("{FILEPATH}", FilePath).Replace("{PASSWORD}", Password); oledb_ConnectionString = cs; try { cn_Oledb = new OleDbConnection(cs); cmd_Oledb = new OleDbCommand(CommandText, cn_Oledb); cmd_Oledb.CommandTimeout = 0; cn_Oledb.Open(); dr_Oledb = cmd_Oledb.ExecuteReader(); } catch (Exception err) { _lastSqlError = err; } }
public AuditingPolicy() { ConnectionStrings = new ConnectionStrings(); }