예제 #1
0
        public UMSContext GetConnection(string databaseId)
        {
            //HttpClient client = new HttpClient();
            //client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);

            //HttpResponseMessage response = client.GetAsync(ConfigurationManager.AppSettings["UMS_URL"] + "/api/User/GetUserDetailsByID?userId=" + userId).Result;
            //if (response.IsSuccessStatusCode)
            //{
            //    var responseResult = response.Content.ReadAsStringAsync().Result;
            //    if (responseResult != "\"Content not found id = " + userId + "\"" && responseResult != "Content not found id = " + userId)
            //    {
            //        return true;
            //    }
            //}
            //throw new Exception("Invalid userId");

            var db = (from c in _masterDbContext.Clients
                      where c.DBName == databaseId
                      select new DBCredentials
            {
                ClientID = c.ClientID,
                DBName = c.DBName,
                DBPassword = c.DBPassword,
                DBServer = c.DBServer,
                DBUserId = c.DBUserId
            }).FirstOrDefault();

            if (db != null)
            {
                _clientDbContext = new UMSContext(ConnectionTools.GetClientConnection(db));
            }
            return(_clientDbContext);
        }
예제 #2
0
 public BaseRepository()
 {
     if (Convert.ToBoolean(ConfigurationManager.AppSettings["IsNon_PCRDB"]) == true)
     {
         _masterDbContext = new UMSContext(ConnectionTools.GetMasterConnection());
     }
     else
     {
         _masterDbContext = new UMSContext(ConnectionTools.GetMasterDbConnection());
     }
 }
예제 #3
0
        /// <summary>
        /// Constructor for public access, creates a connection without an existing PCR-ID
        /// </summary>
        /// <param name="databaseId">DatabaseId to connect to</param>
        public BaseRepository(string databaseId)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["IsNon_PCRDB"]) == true)
            {
                _masterDbContext = new UMSContext(ConnectionTools.GetMasterConnection());

                GetConnection(databaseId);
            }
            else
            {
                _connectionInfo  = ConnectionTools.GetOnboardingDbConnection(databaseId);
                _masterDbContext = new UMSContext(_connectionInfo.MasterDBConnection);
                _clientDbContext = new UMSContext(_connectionInfo.ClientDBConnection);
            }
        }