public Location(double lat, double lng) { ParamsValidator.ThrowIfInfinity(lat, lng); Lat = lat; Lng = lng; }
/// <summary> /// Can be run with arguments: -pass/to/xml, url, method, -parralel_sends_count (optional) /// </summary> /// <param name="args"></param> static int Main(string[] args) { if (args.Length > 4 || args.Length < 3) { Console.WriteLine("Wrong number of params. " + "Should be supplied 3 or 4 params: " + "1. xml file path, " + "2. request url, " + "3. action url, " + "4. parralel request count (optional)"); Console.WriteLine(@"Usage example: text.xml https://somedomain.info:443/SomeService.svc Name.Space/SomeServise/ActionMethod 1"); return(1); } var parser = new ArgumentParser(); var cmdParams = parser.ParseArguments(args); var validator = new ParamsValidator(); validator.Validate(cmdParams); var soapEnvelope = File.ReadAllText(cmdParams.XmlFilePath); var client = new SoapWebClient(); var tasks = new List <Task <SoapResult> >(); // todo define size for (var x = 0; x < cmdParams.ParralelThreadsCount; x++) { tasks.Add(new Task <SoapResult>(() => client.GetResponseSoap(cmdParams.EndpointUrl, cmdParams.ActionUrl, soapEnvelope))); } tasks.ForEach(x => x.Start()); Task.WaitAll(tasks.ToArray()); foreach (var task in tasks) { if (string.IsNullOrWhiteSpace(task.Result.Data)) { continue; } if (!task.Result.IsSucces && task.Result.Error != null) { Console.WriteLine($"Error: {task.Result.Error.Description}"); } var xml = XDocument.Parse(task.Result.Data ?? task.Result.Error.ResponseData); Console.WriteLine(xml.ToString()); Console.WriteLine("__________________________________________________________\n"); } Console.ReadKey(); return(0); }
public async Task <Measurement> GetMeasurmentByLocationIdAsync(int locationId, bool includeWind = false, IndexQueryType type = IndexQueryType.AirlyCAQI) { ParamsValidator.ThrowIfNegativeNumber(locationId); return(await Api.Request <Measurement>(end : "measurements/location", "GET", new { locationId, includeWind, type = ResolveIndexType(type) })); }
public async Task <Measurement> GetMeasurmentNearestAsync(double lat, double lng, double maxDistance = 3, IndexQueryType type = IndexQueryType.AirlyCAQI) { return(await Api.Request <Measurement>("measurements/nearest", "GET", new { lat, lng, maxDistanceKM = ParamsValidator.InfinityToDouble(maxDistance), indexType = ResolveIndexType(type) })); }
public async Task <Measurement> GetMeasurmentByInstallationAsync(int id, bool includeWind = false, IndexQueryType type = IndexQueryType.AirlyCAQI) { ParamsValidator.ThrowIfNegativeNumber(id); return(await Api.Request <Measurement>("measurements/installation", "GET", new { installationId = id, includeWind, indexType = ResolveIndexType(type) })); }
public async Task <List <Installation> > GetInstallationsNearestAsync(double lat, double lng, double maxDistance = 3, int maxResults = 1) { return(await Api.Request <List <Installation> >("installations/nearest", "GET", new { lat, lng, maxDistanceKM = ParamsValidator.InfinityToDouble(maxDistance), maxResults })); }
public async Task <Installation> GetInstallationByIdAsync(int id) { ParamsValidator.ThrowIfNegativeNumber(id); return(await Api.Request <Installation>($"installations/{id}", method : null, options : null)); }