public string SyncPatient() { try { Process p = new Process(); //设置要启动的应用程序 var appSettingsJson = AppSettingsJson.GetAppSettings(); var processpath = appSettingsJson["syncpatientapppath"];//admin12345 p.StartInfo.FileName = processpath; //是否使用操作系统shell启动 p.StartInfo.UseShellExecute = false; // 接受来自调用程序的输入信息 p.StartInfo.RedirectStandardInput = true; //输出信息 p.StartInfo.RedirectStandardOutput = true; // 输出错误 p.StartInfo.RedirectStandardError = true; //不显示程序窗口 p.StartInfo.CreateNoWindow = false; //启动程序 p.Start(); p.StandardInput.AutoFlush = true; //等待程序执行完退出进程 p.WaitForExit(); p.Close(); return("同步成功"); } catch (Exception) { return("同步失败"); } }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { var appSettingsJson = AppSettingsJson.GetAppSettings(); var connectionString = appSettingsJson["ConnectionStrings:DefaultConnection"]; optionsBuilder.UseSqlServer(connectionString); }
public IActionResult Index() { var appSettingsJson = AppSettingsJson.GetAppSettings(); var connectionString = appSettingsJson["MssqlConnectionString"]; return(View()); }
public IActionResult Index(string username, string pwd, bool logout = false) { //user admin12345 if (logout || string.IsNullOrEmpty(username)) { HttpContext.Session.SetString("user", ""); } else { MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider(); byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(username + '-' + pwd)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } var appSettingsJson = AppSettingsJson.GetAppSettings(); var userpwd = appSettingsJson["userpwd"];//admin12345 if (userpwd == sBuilder.ToString()) { HttpContext.Session.SetString("user", "admin"); ViewBag.Username = "******"; } else { ViewBag.ErrorMsg = "用户名密码错误"; } } return(View()); }
public UserController() { Microsoft.Extensions.Configuration.IConfigurationRoot appSettingsJson = AppSettingsJson.GetAppSettings(); string connectionString = appSettingsJson["DefaultConnection"]; ConnectionString = connectionString; }
//连接数据库 public SqlConnection Sqlconnect() { var asp = AppSettingsJson.GetAppSettings()["ConnectionStrings"]; SqlConnection conn = new SqlConnection(asp); conn.Open(); return(conn); }
public DataAccess(string connectionStringName = "GoodBooks", string Database = "GoodBooks") { //Get connection string from appsettings var appSettingsJson = AppSettingsJson.GetAppSettings(); connString = appSettingsJson["Data:ConnectionStrings:" + connectionStringName]; //colnnect to cluster and select db _client = new MongoClient(connString); _db = _client.GetDatabase(Database); }
public QueueSender() { var appSettings = AppSettingsJson.GetAppSettings(); _settings = new QueueSettings( appSettings["SBusAzure:SBusConnectionString"], appSettings["SBusAzure:SBusQueueName"]); _queueClient = new QueueClient( _settings.ConnectionString, _settings.QueueName); }
public QueueReceiver(IProcess processData, ILogger <QueueReceiver <T> > logger) { var appSettings = AppSettingsJson.GetAppSettings(); _settings = new QueueSettings( appSettings["SBusAzure:SBusConnectionString"], appSettings["SBusAzure:SBusQueueName"]); _processData = processData; _logger = logger; _queueClient = new QueueClient( _settings.ConnectionString, _settings.QueueName); }
public ApplicationDbContext CreateDbContext(string[] args) { // To prep each database uncomment the corresponding line below. var appSettingsJson = AppSettingsJson.GetAppSettings(); var con = appSettingsJson["Finbuckle:MultiTenant:Stores:ConfigurationStore:Defaults:ConnectionString"]; var tenantInfo = new TenantInfo { ConnectionString = con }; var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>(); return(new ApplicationDbContext(tenantInfo, optionsBuilder.Options)); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { try { var appSettingsJson = AppSettingsJson.GetAppSettings(); var connectionStrings = appSettingsJson["ConnectionStrings"]; var connectionString = appSettingsJson["EPSContext"]; connectionString = "Data Source=USTLH1LT1506\\TurnpikeTest;Initial Catalog=EPSNew;Integrated Security=True"; } catch (Exception e) { Console.Write(e.StackTrace.ToString()); } }
public JobContainer(IJobExecutionContext _Context) { var config = AppSettingsJson.GetAppSettings(); SqlConnectionStringBuilder sqlConnectionStringBuilder = new SqlConnectionStringBuilder(config.GetSection("ConnectionStrings:BaseDBContext").Value); sqlConnectionStringBuilder.Password = Encryption.Decrypt(sqlConnectionStringBuilder.Password); ConnString = sqlConnectionStringBuilder.ConnectionString; stopwatch.Start(); Context = _Context; JobName = JobGroup = MethodName = MethodParams = JobMessage = ExceptionInfo = ""; JobName = Context.JobDetail.Key.Name; InitContainer(); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var appSettingsJson = AppSettingsJson.GetAppSettings(); services.AddDbContext <DataContext>(opts => opts.UseSqlServer(appSettingsJson["ConnectionString:ReceiptsDBAzure"])); services.AddScoped <IDataRepository <Receipt>, ReceiptManager>(); services.AddScoped <IDataRepository <User>, UserManager>(); services.BuildServiceProvider().GetService <DataContext>().Database.Migrate(); services.AddOpenApiDocument(config => config.Title = "API"); services.AddControllers(); services.AddApiVersioning(config => { config.DefaultApiVersion = new ApiVersion(1, 0); config.AssumeDefaultVersionWhenUnspecified = true; config.ReportApiVersions = true; }); }
public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); // Set up the databases for the sample if needed. var env = host.Services.GetService <IWebHostEnvironment>(); if (env.EnvironmentName == "Development") { var appSettingsJson = AppSettingsJson.GetAppSettings(); var con = appSettingsJson["Finbuckle:MultiTenant:Stores:ConfigurationStore:Defaults:ConnectionString"]; using (var db = new ApplicationDbContext(new TenantInfo { ConnectionString = con })) { await db.Database.MigrateAsync(); } } await host.RunAsync(); }
public IActionResult PatientDetails() { List <string> OutPut = new List <string>(); //Dictionary<string, string> dict = new Dictionary<string, string>(); // string connectionString = "Server = demosql001.cc4mi4fhf4fo.ap-southeast-2.rds.amazonaws.com; Database = WHADemo; User Id = whadevfe; Password = 4MeW3%T7JxMA; "; //string connectionString = "SELECT TOP (1000) [PersonID],[LastName],[FirstName],[Address],[City] FROM [testdatabase].[dbo].[Persons]"; //string connectionString = "Data Source=DESKTOP-SK0EJ1N;Initial Catalog=testdatabase;Integrated Security=True"; //var xxx = ConfigurationManager.ConnectionStrings["DefaultConnectString"]; //string myDb1ConnectionString = _configuration.GetConnectionString("myDb1"); var appSettingsJson = AppSettingsJson.GetAppSettings(); var connectionString = appSettingsJson["DefaultConnectString"]; //string connectionString = "dfa"; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); //SqlCommand com = new SqlCommand("select * from dbo.POBPatient where POBPatientID = 1;", conn); SqlCommand com = new SqlCommand("select * from dbo.Persons;", conn); var Returned = com.ExecuteReader(); while (Returned.Read()) { for (int i = 0; i < Returned.FieldCount; i++) { OutPut.Add(Returned.GetName(i)); // columns.Add(Returned.GetName(i)); } //OutPut.Add(Returned.GetString(3)); } conn.Close(); var column = new PatientEmpolymentHistory(); //column.ColumnNames = OutPut; return(Ok(OutPut)); }
public ApiRequest(string System, bool LoginFlag = false) { Stopwatch = new Stopwatch(); Stopwatch.Start(); _System = System; _LoginFlag = LoginFlag; try { var config = AppSettingsJson.GetAppSettings(); ConnString = config.GetSection("ConnectionStrings:BaseDBContext").Value; SqlConnectionStringBuilder sqlConnectionStringBuilder = new SqlConnectionStringBuilder(ConnString); sqlConnectionStringBuilder.Password = Encryption.Decrypt(sqlConnectionStringBuilder.Password); ConnString = sqlConnectionStringBuilder.ConnectionString; Server = config.GetSection(System + "Setting:Server").Value; LoginUrl = config.GetSection(System + "Setting:LoginUrl").Value; Uid = config.GetSection(System + "Setting:Uid").Value; Pwd = config.GetSection(System + "Setting:Pwd").Value; } catch (Exception) { } }
public UserRepository() { var appSettings = AppSettingsJson.GetAppSettings(); _connectionString = appSettings["ConnectionString"]; }