コード例 #1
0
ファイル: AdagiDatabase.cs プロジェクト: joelalejandro/Adagi
 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());
 }
コード例 #2
0
ファイル: SearchController.cs プロジェクト: aj18/BharatMovies
        public async Task<ActionResult> Index(string q)
        {
            var uri = new MyCouchUriBuilder("https://anupamjaiswal.cloudant.com/")
             .SetBasicCredentials("anupamjaiswal", "social24x7")
             .SetDbName("campaignlink")
             .Build();
            //.SetBasicCredentials("cedsteressivarshwaskyage", "vbmqH8q0PwdKSqaN74yMlqsU")
            // var uri = new MyCouchUriBuilder("https://anupamjaiswal.cloudant.com/")
            //.SetDbName("animaldb")
            //.SetBasicCredentials("nortintastilineafterremp", "XUxnpETtOGgdJ4lnNDQcoG1Q")
            //.Build();

            using (var client = new MyCouchCloudantClient(uri))
            {


                var s = new SearchIndexIdentity("views", "SearchCampaign");


                var si = new MyCouch.Cloudant.Requests.SearchIndexRequest(s);
                si.Expression = q;
                si.Limit = 25;

                si.Counts.Add("default");
                //si.IncludeDocs = true;





                dynamic x = await client.Searches.SearchAsync(si);

                List<string> idList = new List<string>();

                foreach (var data in x.Rows)
                {
                    foreach (var data1 in data.Fields)
                    {
                        idList.Add(data1.Value);
                    }
                }
                var uniqueid = idList.Distinct().ToList();

                ViewBag.Title = q;
                ViewBag.uniqueid = uniqueid;

            }
            return View();
        }
コード例 #3
0
 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());
     }
 }