Skip to content

Commit a99ff9e

Browse files
committed
Adding automatic analyze method and overloads
1 parent 2226cb8 commit a99ff9e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

SSLLWrapper/SSLLService.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading;
23
using SSLLWrapper.Domain;
34
using SSLLWrapper.External;
45
using SSLLWrapper.Interfaces;
@@ -128,6 +129,32 @@ public Analyze Analyze(string host, Publish publish, ClearCache clearCache, From
128129
return analyzeModel;
129130
}
130131

132+
public Analyze AutomaticAnalyze(string host)
133+
{
134+
return AutomaticAnalyze(host, 300, 1000);
135+
}
136+
137+
public Analyze AutomaticAnalyze(string host, int maxWaitInterval, int sleepInterval)
138+
{
139+
return AutomaticAnalyze(host, Publish.Off, ClearCache.On, FromCache.Ignore, All.On, maxWaitInterval, sleepInterval);
140+
}
141+
142+
public Analyze AutomaticAnalyze(string host, Publish publish, ClearCache clearCache, FromCache fromCache, All all, int maxWaitInterval, int sleepInterval)
143+
{
144+
var startTime = DateTime.Now;
145+
var sleepIntervalMilliseconds = sleepInterval * 10;
146+
var analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
147+
148+
// Shouldn't have to check status header as HasErrorOccurred should be enough
149+
while (analyzeModel.HasErrorOccurred == false && analyzeModel.status != "READY" && (DateTime.Now - startTime).TotalSeconds < maxWaitInterval)
150+
{
151+
Thread.Sleep(sleepIntervalMilliseconds);
152+
analyzeModel = Analyze(host, publish, clearCache, fromCache, all);
153+
}
154+
155+
return analyzeModel;
156+
}
157+
131158
public Endpoint GetEndpointData(string host, string s)
132159
{
133160
return GetEndpointData(host, s, FromCache.Off);

0 commit comments

Comments
 (0)