Esempio n. 1
0
 public static Client Connect()
 {
     var uri = new MyCouchUriBuilder(Settings.Get("Adagi.Database.Host"));
     uri.SetBasicCredentials(Settings.Get("Adagi.Database.Username"), Settings.Get("Adagi.Database.Password"));
     uri.SetDbName(Settings.Get("Adagi.Database.Name"));
     return new Client(uri.Build());
 }
 public void ConfigureDB()
 {
     dbName = "todos";
     var settings = System.Environment.GetEnvironmentVariable("VCAP_SERVICES");
     if (settings == null)
     {
         Console.WriteLine("VCAP_SERVICES environment variable not set.");
     }
     var parsed = JObject.Parse(settings);
     if (parsed["cloudantNoSQLDB"] != null && parsed["cloudantNoSQLDB"][0] != null)
     {
         user = parsed["cloudantNoSQLDB"][0]["credentials"]["username"].ToString();
         password = parsed["cloudantNoSQLDB"][0]["credentials"]["password"].ToString();
         cloudantURL = parsed["cloudantNoSQLDB"][0]["credentials"]["url"].ToString();
         var uriBuilder = new MyCouchUriBuilder(cloudantURL).SetBasicCredentials(user, password);
         uri = uriBuilder.Build();
         db = new MyCouchServerClient(uriBuilder.Build());
     }
 }