protected override void ProcessRecord()
 {
     try
     {
         var client = new RestClient(SearchServiceUri);
         var helper = new SearchServiceHelper(client, SearchServiceApiKey);
         helper.DeleteSearchIndex(SearchIndexName, this);
         var indexCreationJson = JsonFileHelper.ReadJsonFileToString(IndexCreationJsonFile);
         helper.CreateIndex(SearchIndexName, indexCreationJson, this);
     }
     catch (Exception e)
     {
         ThrowTerminatingError(new ErrorRecord(e, "101", ErrorCategory.CloseError, null));
     }
 }
示例#2
0
 protected override void ProcessRecord()
 {
     try
     {
         WriteVerbose($"Seeding data to search index: {SearchIndexName}");
         var client    = new RestClient(SearchServiceUri);
         var helper    = new SearchServiceHelper(client, SearchServiceApiKey);
         var documents = JsonConvert.DeserializeObject <List <Person> >(JsonFileHelper.ReadJsonFileToString(PersonDataJsonFile));
         helper.SeedData(SearchIndexName, documents, this);
     }
     catch (Exception e)
     {
         ThrowTerminatingError(new ErrorRecord(e, "102", ErrorCategory.CloseError, null));
     }
 }