- Timestamp:
- 03/16/17 07:56:01 (7 years ago)
- Location:
- branches/symbreg-factors-2650
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650
-
branches/symbreg-factors-2650/HeuristicLab.Clients.OKB/3.3/Query/QueryClient.cs
r14185 r14751 24 24 using System.IO; 25 25 using System.Linq; 26 using System.ServiceModel; 26 27 using HeuristicLab.Clients.Common; 27 28 using HeuristicLab.Common; … … 39 40 } 40 41 } 42 43 private int endpointRetries; 44 private string workingEndpoint; 41 45 42 46 #region Properties … … 68 72 } 69 73 public void RefreshAsync(Action<Exception> exceptionCallback) { 70 var call = new Func<Exception>(delegate () {74 var call = new Func<Exception>(delegate () { 71 75 try { 72 76 Refresh(); … … 76 80 return null; 77 81 }); 78 call.BeginInvoke(delegate (IAsyncResult result) {82 call.BeginInvoke(delegate (IAsyncResult result) { 79 83 Exception ex = call.EndInvoke(result); 80 84 if (ex != null) exceptionCallback(ex); … … 156 160 157 161 #region Helpers 162 private QueryServiceClient NewServiceClient() { 163 if (endpointRetries >= Properties.Settings.Default.MaxEndpointRetries) 164 return CreateClient(workingEndpoint); 165 166 var configurations = Properties.Settings.Default.EndpointConfigurationPriorities; 167 Exception exception = null; 168 169 foreach (var endpointConfigurationName in configurations) { 170 try { 171 var cl = CreateClient(endpointConfigurationName); 172 cl.Open(); 173 workingEndpoint = endpointConfigurationName; 174 return cl; 175 } catch (EndpointNotFoundException e) { 176 exception = e; 177 ++endpointRetries; 178 } 179 } 180 181 throw exception ?? new EndpointNotFoundException("No endpoint for Query service found."); 182 } 183 184 private QueryServiceClient CreateClient(string endpointConfigurationName) { 185 var cl = ClientFactory.CreateClient<QueryServiceClient, IQueryService>(endpointConfigurationName); 186 return cl; 187 } 188 158 189 private T CallQueryService<T>(Func<IQueryService, T> call) { 159 QueryServiceClient client = ClientFactory.CreateClient<QueryServiceClient, IQueryService>(); 190 QueryServiceClient client = NewServiceClient(); 191 160 192 try { 161 193 return call(client);
Note: See TracChangeset
for help on using the changeset viewer.