public void TestMultiTransformation() { ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), Tags = "test--5", PublicId = "test--5-1" }; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = "test--5-2"; uploadParams.Transformation = new Transformation().Width(100).Height(300); m_cloudinary.Upload(uploadParams); MultiParams multi = new MultiParams("test--5"); MultiResult result = m_cloudinary.Multi(multi); Assert.True(result.Uri.AbsoluteUri.EndsWith(".gif")); multi.Transformation = new Transformation().Width(100); result = m_cloudinary.Multi(multi); Assert.True(result.Uri.AbsoluteUri.Contains("w_100")); multi.Transformation = new Transformation().Width(111); multi.Format = "pdf"; result = m_cloudinary.Multi(multi); Assert.True(result.Uri.AbsoluteUri.Contains("w_111")); Assert.True(result.Uri.AbsoluteUri.EndsWith(".pdf")); }
public async Task <MultiResult> MultiAsync(MultiParams parameters) { using (var response = await Api.CallAsync(HttpMethod.Post, Api.ApiUrlImgUpV.Action("multi").BuildUrl(), parameters.ToParamsDictionary(), null, null)) { return(await MultiResult.Parse(response)); } }
public async Task <IActionResult> SalesStatistics(SalesPeriod salePeriod) { try { MultiResult <List <string>, List <decimal>, List <int> > result = new MultiResult <List <string>, List <decimal>, List <int> >(); switch (salePeriod) { case SalesPeriod.Daily: result = await GetDaily(CoreFunc.GetCustomAttributeTypedArgument(this.ControllerContext)); break; case SalesPeriod.Monthly: result = await GetMonthly(CoreFunc.GetCustomAttributeTypedArgument(this.ControllerContext)); break; case SalesPeriod.Yearly: result = await GetYearly(CoreFunc.GetCustomAttributeTypedArgument(this.ControllerContext)); break; default: break; } ; return(Ok(result)); } catch (Exception ex) { CoreFunc.Error(ref ErrorsList, _LoggingService.LogException(Request.Path, ex, User)); return(StatusCode(417, ErrorsList)); } }
private MultiResult ExecuteSequential(IEnumerable <IOperation> operations, CancellationToken cancellationToken) { var result = new MultiResult(); var operationsDone = 0; var operationArray = operations.ToArray(); var operationCount = operationArray.Length; foreach (var operation in operationArray) { SetProgress(operationsDone / (double)operationCount); // ReSharper disable once AccessToModifiedClosure var operationResult = Execute(operation, f => f / operationCount + (double)operationsDone / operationCount, cancellationToken); result.Results.Add(operationResult); if (operationResult.HasError && ErrorBehavior > SequenceErrorBehavior.Ignore) { Log?.WriteError(operationResult.ErrorDescription); } mProgressInfos[operation] = new ProgressInfo { DisplayName = operation.DisplayName, IsInitializing = false, IsCompleted = true, IsAborted = operation.IsAborted, IsIdle = true, Progress = operation.Progress }; SetProgress((operationsDone + operation.Progress) / operationCount); operationsDone++; if (operation.WasCancelled || (ErrorBehavior == SequenceErrorBehavior.Abort && operationResult.HasError)) { for (var i = operationsDone; i < operationCount; i++) { mProgressInfos[operationArray[i]] = new ProgressInfo { DisplayName = operationArray[i].DisplayName, IsInitializing = false, IsCompleted = true, IsAborted = true, IsIdle = true, Progress = operationArray[i].Progress }; } break; } } return(result); }
private void AssertMultiResult(MultiResult result, string transformation, string fileFormat) { if (!string.IsNullOrEmpty(transformation)) { Assert.True(result.Uri.AbsoluteUri.Contains(transformation)); } if (!string.IsNullOrEmpty(fileFormat)) { Assert.True(result.Uri.AbsoluteUri.EndsWith($".{fileFormat}")); } }
protected sealed override IResult Execute(CancellationToken cancellationToken) { var result = new MultiResult(); mProgressInfos.Clear(); foreach (var operation in mGraph.GetKnownElements()) { mProgressInfos.Add(operation, new ProgressInfo { DisplayName = operation.DisplayName, IsInitializing = true, IsCompleted = false, IsAborted = false, IsIdle = false, Progress = 0 }); } SetProgress(0); var partitions = mGraph.GetPartitionsByDependencyDepth().ToArray(); foreach (var partition in partitions) { MultiResult partitionResult; switch (SchedulingMode) { case OperationSequenceSchedulingMode.Sequential: partitionResult = ExecuteSequential(partition, cancellationToken); break; case OperationSequenceSchedulingMode.Parallel: partitionResult = ExecuteParallel(partition, cancellationToken); break; default: return(Result.Success); } result.Results.AddRange(partitionResult.Results); } lock (mLock) { mRunningOperations?.Clear(); } return(result); }
/// <summary> /// Allows multi transformation /// </summary> /// <param name="parameters">Parameters of operation</param> /// <returns>Result of operation</returns> public MultiResult Multi(MultiParams parameters) { UrlBuilder urlBuilder = new UrlBuilder( m_api.ApiUrlImgUpV. Action("multi"). BuildUrl()); using (HttpWebResponse response = m_api.Call( HttpMethod.POST, urlBuilder.ToString(), parameters.ToParamsDictionary(), null)) { MultiResult result = MultiResult.Parse(response); return(result); } }
public void TestMultiTransformation() { var publicId1 = GetUniquePublicId(StorageType.multi); var publicId2 = GetUniquePublicId(StorageType.multi); var tag = GetMethodTag(); ImageUploadParams uploadParams = new ImageUploadParams() { File = new FileDescription(m_testImagePath), Tags = $"{tag},{m_apiTag}", PublicId = publicId1 }; m_cloudinary.Upload(uploadParams); uploadParams.PublicId = publicId2; uploadParams.Transformation = m_simpleTransformation; m_cloudinary.Upload(uploadParams); MultiParams multi = new MultiParams(tag); MultiResult result = m_cloudinary.Multi(multi); AddCreatedPublicId(StorageType.multi, result.PublicId); Assert.True(result.Uri.AbsoluteUri.EndsWith($".{FILE_FORMAT_GIF}")); multi.Transformation = m_resizeTransformation; result = m_cloudinary.Multi(multi); AddCreatedPublicId(StorageType.multi, result.PublicId); Assert.IsTrue(result.Uri.AbsoluteUri.Contains(TRANSFORM_W_512)); multi.Transformation = m_simpleTransformationAngle; multi.Format = FILE_FORMAT_PDF; result = m_cloudinary.Multi(multi); AddCreatedPublicId(StorageType.multi, result.PublicId); Assert.True(result.Uri.AbsoluteUri.Contains(TRANSFORM_A_45)); Assert.True(result.Uri.AbsoluteUri.EndsWith($".{FILE_FORMAT_PDF}")); }
private static MultiResult GeneralSearch(Elastic.Apm.Api.ITransaction apmtran, string query, int page = 1, int pageSize = 10, bool showBeta = false, string order = null) { MultiResult res = new MultiResult() { Query = query }; if (string.IsNullOrEmpty(query)) { return(res); } if (!Lib.Searching.Tools.ValidateQuery(query)) { res.Smlouvy = new Searching.SmlouvaSearchResult(); res.Smlouvy.Q = query; res.Smlouvy.IsValid = false; return(res); } var totalsw = new Devmasters.DT.StopWatchEx(); totalsw.Start(); ParallelOptions po = new ParallelOptions(); //po.MaxDegreeOfParallelism = 20; po.MaxDegreeOfParallelism = System.Diagnostics.Debugger.IsAttached ? 1 : po.MaxDegreeOfParallelism; Parallel.Invoke(po, () => { Elastic.Apm.Api.ISpan sp = null; try { apmtran.CaptureSpan("Smlouvy", "search", () => { res.Smlouvy = HlidacStatu.Lib.Data.Smlouva.Search.SimpleSearch(query, 1, pageSize, order, anyAggregation: new Nest.AggregationContainerDescriptor <HlidacStatu.Lib.Data.Smlouva>().Sum("sumKc", m => m.Field(f => f.CalculatedPriceWithVATinCZK)) ); }); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Smlouvy query" + query, e); } finally { sp?.End(); } }, () => { try { Devmasters.DT.StopWatchEx sw = new Devmasters.DT.StopWatchEx(); sw.Start(); res.Firmy = Firma.Search.SimpleSearch(query, 0, 50); sw.Stop(); res.Firmy.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Firmy query" + query, e); } }, () => { try { res.VZ = VZ.VerejnaZakazka.Searching.SimpleSearch(query, null, 1, pageSize, order); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Verejne zakazky query" + query, e); } }, () => { try { Devmasters.DT.StopWatchEx sw = new Devmasters.DT.StopWatchEx(); sw.Start(); res.Osoby = Osoba.Search.SimpleSearch(query, 1, 10, Osoba.Search.OrderResult.Relevance); sw.Stop(); res.Osoby.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Osoba query" + query, e); } }, () => { try { var iqu = new Searching.InsolvenceSearchResult { Q = query, PageSize = pageSize, Order = order }; res.Insolvence = iqu; //if (showBeta) res.Insolvence = Insolvence.Insolvence.SimpleSearch(new Searching.InsolvenceSearchResult { Q = query, PageSize = pageSize, Order = order }); } catch (System.Exception e) { Util.Consts.Logger.Error("MultiResult GeneralSearch for insolvence query" + query, e); } }, () => { try { var dotaceService = new Dotace.DotaceService(); var iqu = new Searching.DotaceSearchResult { Q = query, PageSize = pageSize, Order = order }; res.Dotace = dotaceService.SimpleSearch( new Searching.DotaceSearchResult { Q = query, PageSize = pageSize, Order = order }, anyAggregation: new Nest.AggregationContainerDescriptor <Lib.Data.Dotace.Dotace>().Sum("souhrn", s => s.Field(f => f.DotaceCelkem)) ); } catch (System.Exception e) { Util.Consts.Logger.Error("MultiResult GeneralSearch for insolvence query" + query, e); } }, () => { try { apmtran.CaptureSpan("Dataset GeneralSearch", "search", () => { res.Datasets = Lib.Data.Search.DatasetMultiResult.GeneralSearch(query, null, 1, 5); if (res.Datasets.Exceptions.Count > 0) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for DatasetMulti query " + query, res.Datasets.GetExceptions()); } }); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for DatasetMulti query " + query, e); } finally { } } ); //TODO too slow, temporarily disabled totalsw.Stop(); res.TotalSearchTime = totalsw.Elapsed; return(res); }
public static MultiResult GeneralSearch(string query, int page = 1, int pageSize = 10) { MultiResult res = new MultiResult() { Query = query }; if (string.IsNullOrEmpty(query)) { return(res); } ParallelOptions po = new ParallelOptions(); po.MaxDegreeOfParallelism = System.Diagnostics.Debugger.IsAttached ? 1 : po.MaxDegreeOfParallelism; Parallel.Invoke(po, () => { try { res.Datasets = Lib.Data.Search.DatasetMultiResult.GeneralSearch(query, null, 1, 5); if (res.Datasets.Exceptions.Count > 0) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for DatasetMulti query " + query, res.Datasets.GetExceptions()); } } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for DatasetMulti query " + query, e); } }, () => { try { res.Smlouvy = HlidacStatu.Lib.ES.SearchTools.SimpleSearch(query, 1, 20, ES.SearchTools.OrderResult.Relevance, anyAggregation: new Nest.AggregationContainerDescriptor <HlidacStatu.Lib.Data.Smlouva>().Sum("sumKc", m => m.Field(f => f.CalculatedPriceWithVATinCZK)) ); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Smlouvy query" + query, e); } }, () => { try { Devmasters.Core.StopWatchEx sw = new Devmasters.Core.StopWatchEx(); sw.Start(); res.Firmy = new GeneralResult <string>(Firma.Search.FindAllIco(query, 1000)); sw.Stop(); res.Firmy.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Firmy query" + query, e); } }, () => { try { res.VZ = VZ.VerejnaZakazka.Searching.SimpleSearch(query, null, 1, 20, (int)ES.VerejnaZakazkaSearchData.VZOrderResult.Relevance); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Verejne zakazky query" + query, e); } }, () => { try { Devmasters.Core.StopWatchEx sw = new Devmasters.Core.StopWatchEx(); sw.Start(); if (!string.IsNullOrEmpty(query) && query.Length > 2) { res.Osoby = new GeneralResult <Osoba>( HlidacStatu.Lib.Data.Osoba.GetPolitikByNameFtx(query, 100) .OrderBy(m => m.Prijmeni) .ThenBy(m => m.Jmeno) ); } else { res.Osoby = new GeneralResult <Osoba>(new Osoba[] { }); } sw.Stop(); res.Osoby.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Osoba query" + query, e); } }, () => { try { Devmasters.Core.StopWatchEx sw = new Devmasters.Core.StopWatchEx(); sw.Start(); var buRes = HlidacStatu.Lib.Data.TransparentniUcty.BankovniUcty.SearchPolozkyRaw(query, null, 20); if (buRes != null && buRes.IsValid) { res.Transakce = new GeneralResult <TransparentniUcty.BankovniPolozka>( buRes.Total, buRes.Hits.Select(m => m.Source), buRes.IsValid ); } else { res.Transakce = new GeneralResult <TransparentniUcty.BankovniPolozka>(new TransparentniUcty.BankovniPolozka[] { }); } sw.Stop(); res.Transakce.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for bankovni ucty query" + query, e); } } ); if (res.HasFirmy && (res.Osoby == null || res.Osoby.Total < 5)) { if (res.Osoby == null) { res.Osoby = new GeneralResult <Osoba>(new Osoba[] { }); } res.Osoby = new GeneralResult <Osoba>(res.Osoby.Result .Concat(Osoba.GetPolitikByQueryFromFirmy(query, (int)(10 - (res.Osoby?.Total ?? 0)), res.Firmy.Result) ) ); res.OsobaFtx = true; } return(res); }
public MultiResult Post([FromBody] MultiRequest mr, string profile = null) { MultiResult result = new MultiResult(Request); try { if (mr == null) { throw new Exception("The body is missing or not formatted correctly. Maybe just a comma is missing between two attributes."); } //Apply profile from URI if (!string.IsNullOrEmpty(profile)) { if (mr.connection == null) { mr.connection = new ConnectionParams { Profile = profile } } ; else if (string.IsNullOrEmpty(mr.connection.Profile)) { mr.connection.Profile = profile; } } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); var cp = SAPB1.getEffectiveConnectionParams(mr?.connection, ref result.connection); //START Transaction with using and pass the same transaction object to each request processor using (var t = DIConnection.startTransaction(cp)) { //Must be used with using !!! MReqResult reqResult = null; try { result.totalJobsRequested = mr.requests.Count; for (int i = 0; i < mr.requests.Count; i++) { result.index = i; MReqJob mrJob = mr.requests[i]; reqResult = new MReqResult(); if (!string.IsNullOrEmpty(mrJob.boName) || mrJob.boReq != null) { //result.reqJob = mrJob; bool post = false; bool delete = false; bool put = false; bool getReq = false; if (string.IsNullOrEmpty(mrJob.reqType)) { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} has no reqType property (GET, PUT, DELETE, POST)"); } else { switch (mrJob.reqType) { case "GET": getReq = true; break; case "POST": post = true; break; case "PUT": put = true; break; case "DELETE": delete = true; break; default: { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} reqType {mrJob.reqType} is invalid. Use GET, PUT, DELETE, POST"); } } } if (mrJob.boReq == null) { if (getReq || delete) { mrJob.boReq = new BORequest { connection = new ConnectionParams { Profile = profile } }; } else { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} no boReq object defined for PUT, POST"); } } if (string.IsNullOrEmpty(mrJob.boName)) { throw new SQLBrokerError("Multi-request BO job has no boName property"); } if (string.IsNullOrEmpty(mrJob.boId)) { if (getReq || put || delete) { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} reqType {mrJob.reqType} requires non-empty boId property."); } } else { if (post) { throw new SQLBrokerError($"Multi-Request BO job {mrJob.boName} reqType {mrJob.reqType} doesn't allow boId property. Delete boId from your request."); } } reqResult.boResult = new BOResult(Request); reqResult.boResult.connection = new NoPwdConnectionParams(cp); reqResult.boResult.jobNumber = i; SAPB1.BOJob(t, q: mrJob.boReq, name: mrJob.boName, id: mrJob.boId, post: post, delete: delete, put: put, result: reqResult.boResult); } if (mrJob.sqlReq != null) { throw new SQLBrokerError($"Multi-Request SQL is not supported currently. Stay tuned, however."); //var sqlResult = SAPB1.SQLQuery(value, false, new SQLResult(Request)); } result.results.Add(reqResult); } t.Commit(); sw.Stop(); result.execMillis = (int)sw.Elapsed.TotalMilliseconds; return(result); } catch (Exception) { result.errorResult = reqResult; //ROLLBACK Transaction, if not rolled back alreadt t.Rollback(); throw; } } //COMMIT the transacyion if no errors occured } catch (Exception e) { if (e is SQLBrokerError) { SQLBrokerError brokerError = e as SQLBrokerError; if (result.errorResult == null) { result.errorResult = new MReqResult(); } result.errorResult.boResult = brokerError.boResult; result.errorResult.sqlResult = brokerError.sqlResult; } return(result.setResponseStatus(HttpStatusCode.BadRequest, e)); } }
private MultiResult ExecuteParallel(IEnumerable <IOperation> operations, CancellationToken cancellationToken) { var tasks = new List <Task>(); var result = new MultiResult(); var operationsDone = 0; var operationArray = operations.ToArray(); var operationCount = operationArray.Length; foreach (var operation in operationArray) { // ReSharper disable once MethodSupportsCancellation tasks.Add(Task.Run(() => { if (cancellationToken.IsCancellationRequested) { mProgressInfos[operation] = new ProgressInfo { DisplayName = operation.DisplayName, IsInitializing = false, IsCompleted = true, IsAborted = true, IsIdle = true, Progress = operation.Progress }; return; } // ReSharper disable once AccessToModifiedClosure var operationResult = Execute(operation, c => operationsDone / (double)operationCount, cancellationToken); result.Results.Add(operationResult); if (operationResult.HasError && !operation.WasCancelled && ErrorBehavior > SequenceErrorBehavior.Ignore) { Log?.WriteError(operationResult.ErrorDescription); } mProgressInfos[operation] = new ProgressInfo { DisplayName = operation.DisplayName, IsInitializing = false, IsCompleted = true, IsAborted = operation.IsAborted, IsIdle = true, Progress = operation.Progress }; operationsDone++; if (operation.WasCancelled || operationResult.HasError && ErrorBehavior == SequenceErrorBehavior.Abort) { foreach (var remainingOperation in operationArray.Where(x => x.WasCancelled || x.IsRunning)) { remainingOperation.Cancel(); } } })); } Task.WaitAll(tasks.ToArray(), cancellationToken); if (cancellationToken.IsCancellationRequested) { foreach (var operation in operationArray.Where(x => x.WasCancelled || x.IsRunning)) { mProgressInfos[operation] = new ProgressInfo { DisplayName = operation.DisplayName, IsInitializing = false, IsCompleted = true, IsAborted = true, IsIdle = true, Progress = operation.Progress }; } } return(result); }
private static MultiResult GeneralSearch(Elastic.Apm.Api.ITransaction apmtran, string query, int page = 1, int pageSize = 10, bool showBeta = false) { MultiResult res = new MultiResult() { Query = query }; if (string.IsNullOrEmpty(query)) { return(res); } if (!Lib.Searching.Tools.ValidateQuery(query)) { res.Smlouvy = new Searching.SmlouvaSearchResult(); res.Smlouvy.Q = query; res.Smlouvy.IsValid = false; return(res); } var totalsw = new Devmasters.Core.StopWatchEx(); totalsw.Start(); ParallelOptions po = new ParallelOptions(); //po.MaxDegreeOfParallelism = 20; po.MaxDegreeOfParallelism = System.Diagnostics.Debugger.IsAttached ? 1 : po.MaxDegreeOfParallelism; Parallel.Invoke(po, () => { Elastic.Apm.Api.ISpan sp = null; try { apmtran.CaptureSpan("Smlouvy", "search", () => { res.Smlouvy = HlidacStatu.Lib.Data.Smlouva.Search.SimpleSearch(query, 1, 20, Smlouva.Search.OrderResult.Relevance, anyAggregation: new Nest.AggregationContainerDescriptor <HlidacStatu.Lib.Data.Smlouva>().Sum("sumKc", m => m.Field(f => f.CalculatedPriceWithVATinCZK)) ); }); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Smlouvy query" + query, e); } finally { sp?.End(); } }, () => { try { Devmasters.Core.StopWatchEx sw = new Devmasters.Core.StopWatchEx(); sw.Start(); res.Firmy = new GeneralResult <string>(Firma.Search.FindAllIco(query, 50)); sw.Stop(); res.Firmy.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Firmy query" + query, e); } }, () => { try { res.VZ = VZ.VerejnaZakazka.Searching.SimpleSearch(query, null, 1, 5, (int)Lib.Searching.VerejnaZakazkaSearchData.VZOrderResult.Relevance); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Verejne zakazky query" + query, e); } }, () => { try { Devmasters.Core.StopWatchEx sw = new Devmasters.Core.StopWatchEx(); sw.Start(); if (!string.IsNullOrEmpty(query) && query.Length > 2) { res.Osoby = new GeneralResult <Osoba>( HlidacStatu.Lib.Data.Osoba.GetPolitikByNameFtx(query, 100) .OrderBy(m => m.Prijmeni) .ThenBy(m => m.Jmeno) ); } else { res.Osoby = new GeneralResult <Osoba>(new Osoba[] { }); } sw.Stop(); res.Osoby.ElapsedTime = sw.Elapsed; } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for Osoba query" + query, e); } }, () => { try { var iqu = new Searching.InsolvenceSearchResult { Q = query, PageSize = 5 }; res.Insolvence = iqu; //if (showBeta) res.Insolvence = Insolvence.Insolvence.SimpleSearch(new Searching.InsolvenceSearchResult { Q = query, PageSize = 5 }); } catch (System.Exception e) { Util.Consts.Logger.Error("MultiResult GeneralSearch for insolvence query" + query, e); } }, () => { try { if (showBeta) { var dotaceService = new Dotace.DotaceService(); var iqu = new Searching.DotaceSearchResult { Q = query, PageSize = 5 }; res.Dotace = iqu; //if (showBeta) res.Dotace = dotaceService.SimpleSearch(new Searching.DotaceSearchResult { Q = query, PageSize = 5 }); } } catch (System.Exception e) { Util.Consts.Logger.Error("MultiResult GeneralSearch for insolvence query" + query, e); } }, () => { Elastic.Apm.Api.ISpan sp = null; try { apmtran.CaptureSpan("Dataset GeneralSearch", "search", () => { res.Datasets = Lib.Data.Search.DatasetMultiResult.GeneralSearch(query, null, 1, 5); if (res.Datasets.Exceptions.Count > 0) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for DatasetMulti query " + query, res.Datasets.GetExceptions()); } }); } catch (System.Exception e) { HlidacStatu.Util.Consts.Logger.Error("MultiResult GeneralSearch for DatasetMulti query " + query, e); } finally { } } ); //TODO too slow, temporarily disabled if (false && res.HasFirmy && (res.Osoby == null || res.Osoby.Total < 5)) { var sw = new Devmasters.Core.StopWatchEx(); sw.Start(); if (res.Osoby == null) { res.Osoby = new GeneralResult <Osoba>(new Osoba[] { }); } res.Osoby = new GeneralResult <Osoba>(res.Osoby.Result .Concat(Osoba.GetPolitikByQueryFromFirmy(query, (int)(10 - (res.Osoby?.Total ?? 0)), res.Firmy.Result) ) ); res.OsobaFtx = true; sw.Stop(); res.AddOsobyTime = sw.Elapsed; } totalsw.Stop(); res.TotalSearchTime = totalsw.Elapsed; return(res); }