|
1 | 1 | using System;
|
| 2 | +using System.Threading; |
2 | 3 | using SSLLWrapper.Domain;
|
3 | 4 | using SSLLWrapper.External;
|
4 | 5 | using SSLLWrapper.Interfaces;
|
@@ -124,6 +125,35 @@ public Analyze Analyze(string host, Publish publish, ClearCache clearCache, From
|
124 | 125 | return analyzeModel;
|
125 | 126 | }
|
126 | 127 |
|
| 128 | + public Analyze AutomaticAnalyze(string host) |
| 129 | + { |
| 130 | + return AutomaticAnalyze(host, 300, 15); |
| 131 | + } |
| 132 | + |
| 133 | + public Analyze AutomaticAnalyze(string host, int maxWaitInterval, int sleepInterval) |
| 134 | + { |
| 135 | + return AutomaticAnalyze(host, Publish.Off, ClearCache.On, FromCache.Ignore, All.On, maxWaitInterval, sleepInterval); |
| 136 | + } |
| 137 | + |
| 138 | + public Analyze AutomaticAnalyze(string host, Publish publish, ClearCache clearCache, FromCache fromCache, All all, int maxWaitInterval, int sleepInterval) |
| 139 | + { |
| 140 | + var startTime = DateTime.Now; |
| 141 | + var sleepIntervalMilliseconds = sleepInterval * 1000; |
| 142 | + var analyzeModel = Analyze(host, publish, clearCache, fromCache, all); |
| 143 | + |
| 144 | + // Ignoring cache settings after first request to prevent loop |
| 145 | + clearCache = ClearCache.Ignore; |
| 146 | + |
| 147 | + // Shouldn't have to check status header as HasErrorOccurred should be enough |
| 148 | + while (analyzeModel.HasErrorOccurred == false && analyzeModel.status != "READY" && (DateTime.Now - startTime).TotalSeconds < maxWaitInterval) |
| 149 | + { |
| 150 | + Thread.Sleep(sleepIntervalMilliseconds); |
| 151 | + analyzeModel = Analyze(host, publish, clearCache, fromCache, all); |
| 152 | + } |
| 153 | + |
| 154 | + return analyzeModel; |
| 155 | + } |
| 156 | + |
127 | 157 | public Endpoint GetEndpointData(string host, string s)
|
128 | 158 | {
|
129 | 159 | return GetEndpointData(host, s, FromCache.Off);
|
|
0 commit comments