-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathPopulateNewIndexAction.cs
More file actions
60 lines (51 loc) · 1.58 KB
/
PopulateNewIndexAction.cs
File metadata and controls
60 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using JetBrains.Annotations;
using SIM.Extensions;
using SIM.Instances;
using Sitecore.Diagnostics.Base;
using System;
using System.Collections.Generic;
namespace SIM.Pipelines.InstallSearchIndexes
{
public class PopulateNewIndexAction : InstallSearchIndexesProcessor
{
protected override void Process([NotNull] InstallSearchIndexesArgs args)
{
Assert.ArgumentNotNull(args, nameof(args));
foreach (var index in args._AvailableSearchIndexesDictionary)
{
string newCorePath = args.SolrFolder.EnsureEnd(@"\") + index.Value;
PopulateNewIndex(index.Key, args.Instance, args.Headers, args.AuthCookies);
}
}
private void PopulateNewIndex(string coreID, Instance instance, IDictionary<string, string> headers, string authCookie)
{
var popUrl = instance.GetUrl(@"/sitecore/admin/PopulateManagedSchema.aspx?indexes=" + coreID);
try
{
int sitecoreVersion;
int.TryParse(instance.Product.ShortVersion, out sitecoreVersion);
if (sitecoreVersion >= 91)
{
if (headers == null)
{
return;
}
var result = WebRequestHelper.DownloadString(popUrl, headers: headers).Trim();
}
else if (sitecoreVersion == 90)
{
string instanceUri = instance.GetUrl();
if (string.IsNullOrEmpty(authCookie))
{
return;
}
var result = WebRequestHelper.DownloadString(popUrl, cookies: authCookie).Trim();
}
}
catch (Exception ex)
{
return;
}
}
}
}