private static LinksToHtmlModel CreateApisEuHtmlMode(String docNumber, String toPar, String domain, int limit) { LinksToHtmlModel result = null; var apisDomain = WebApisHelper.MapNormalDomainToApisForEuAct(domain); var apisResponse = WebApisRequest.GetEuDocLinks(domain: apisDomain, limit: limit, celex: docNumber, toPar: toPar); if (apisResponse != null) { result = LinksToHtmlModel.Create( links: apisResponse.Links, totalCount: apisResponse.Full_Count, limit: limit, allLinksUrl: apisResponse.All_Url, sourceName: "Apis Web"); } return(result); }
private HttpResponseMessage SearchByClassifierId(string classifierId, string domain, int langId, int siteLangId, int limitPerSource) { ChangeLangCulture(langId); List <int> l = new List <int>(); string baseUrl = HttpContext.Current.Request.Url.AbsoluteUri; baseUrl = baseUrl.Substring(0, baseUrl.IndexOf("/api")); ClassificationService.ClassificatorTreeModel ci = null; if (!String.IsNullOrEmpty(classifierId)) { ci = ClassifiersProvider.Service.GetTreeByGuid(classifierId); } StringBuilder result = new StringBuilder(); if (ci == null) // Eurovoc term is not found { string title = Resources.Resources.UI_SearchByTerm; result.Append("<html><head><title>" + title.Replace("<br/>", " ") + "</title>"); result.Append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); result.Append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + baseUrl + "/Content/Styles/docapi.css\"></link>"); result.Append("</head><body>"); result.Append("<div id=\"DivTopTop\"></div>"); result.Append("<div id=\"DivTopGray\"><img src=\"" + baseUrl + "/Content/Images/EUCasesLogo.jpg\" alt=\"\"/></div>"); result.Append("<div id=\"DivHeader\"><p>" + title + "<hr/>" + Resources.Resources.UI_EurovocTermNotFound + "</p></div>"); result.Append("</body></html>"); } else { string term = ci.LanguageVariantsWithHints[langId.ToString()].Title; string title = Resources.Resources.UI_SearchByTerm + " \"" + term + "\"<br/>"; string searchQuery = "classificators:(" + classifierId.Replace("-", "") + ")"; switch (domain.ToLower()) { case "natcl": title += " " + Resources.Resources.UI_inNatCL; searchQuery += " props:(dtjudgment) props:(noteudoc)"; break; case "natl": title += " " + Resources.Resources.UI_inNatL; searchQuery += " props:(dtact) props:(noteudoc)"; break; case "eucl": title += " " + Resources.Resources.UI_inEUCL; searchQuery += " props:(dtjudgment) props:(eudoc)"; break; case "eul": title += " " + Resources.Resources.UI_inEUL; searchQuery += " props:(dtact) props:(eudoc)"; break; } int[] wsRes = null; //SearchBox sb = new SearchBox(langId); //sb.SearchText = term; int[] langPref = new int[] { langId, 4 }; string searchWrapperUrl = null; if (ConfigurationManager.AppSettings["SolutionVersion"] == "product") { searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath"]; } else { searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath_cc"]; } SearchResult sr = new SearchResult(SearchSources.Search, HttpContext.Current.Application["SearchWrapper"], searchWrapperUrl, HttpContext.Current.Application["FilterDocsStruct"], HttpContext.Current.Application["FilterDocsClassifiers"], HttpContext.Current.Application["ClassifiersMap"], HttpContext.Current.Application["ResultsGroupper"], HttpRuntime.AppDomainAppPath, langId, 0, 0 ); //sr.SearchBoxFilters = sb; sr.SearchFTQuery(searchQuery, ref wsRes, langPref); // wsRes = wsRes.Take(limitPerSource).ToArray(); var linksToHtmlModels = new List <LinksToHtmlModel>(); if (!String.IsNullOrEmpty(domain) && langId == 1 && // for documents which are in bulgarian domain.IsIn(StringComparison.InvariantCultureIgnoreCase, "natl", "natcl", "all")) { // only if the document is in bulgarian language var bgTitle = String.Empty; if (ci.LanguageVariantsWithHints.ContainsKey("1")) { bgTitle = ci.LanguageVariantsWithHints["1"]?.Title; } if (!string.IsNullOrEmpty(bgTitle)) { var webApisDomain = WebApisHelper.MapNormalDomainToApisDomain(domain); try { var apisSearchResponse = WebApisRequest.SearchByText(domain: webApisDomain, text: bgTitle, limit: limitPerSource); if (apisSearchResponse != null) { // var apisSearchResponse = WebApisRequest.TestData(); var htmlModel = LinksToHtmlModel.Create(apisSearchResponse.Links, apisSearchResponse.Full_Count, limitPerSource, apisSearchResponse.All_Url, "Apis Web"); linksToHtmlModels.Add(htmlModel); } } catch { } } } var docList = EurocasesDocumentLink.FromDocLinks(Doc.GetDocListByIds(wsRes.Take(limitPerSource).ToArray(), domain), baseUrl); if (docList.Any()) { var allUrl = EuroCasesHelper.BuildAllUrlForSearchByXmlId(baseUrl: baseUrl, xmlId: ci.XmlId, domain: domain, langId: langId, uiLangId: siteLangId); var linsksToHtmlMode = LinksToHtmlModel.Create(docList, wsRes.Length, limitPerSource, allUrl, "EuroCases"); linksToHtmlModels.Insert(0, linsksToHtmlMode); } result.Append(DocLinks2Html(linksToHtmlModels, title, String.Empty, limitPerSource, baseUrl, true)); } var response = this.Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(result.ToString(), Encoding.UTF8, "text/html"); return(response); }